|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: TestVideoSettingsAccessPointEntry class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <QtTest/QtTest> |
|
20 #include <qdebug.h> |
|
21 #include <hbapplication.h> |
|
22 #include <cpitemdatahelper.h> |
|
23 |
|
24 #include "testvideosettingsaccesspointentry.h" |
|
25 #include "videosettingsgroup.h" |
|
26 #include "cmmanager_shim.h" |
|
27 #include "cmconnectionmethod_shim.h" |
|
28 |
|
29 // trick to get access to protected/private members. |
|
30 #define private public |
|
31 #include "videosettingsaccesspointentry.h" |
|
32 #undef private |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // initTestCase |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 void TestVideoSettingsAccessPointEntry::initTestCase() |
|
39 { |
|
40 mItemHelper = new CpItemDataHelper; |
|
41 mGroup = new VideoSettingsGroup(*mItemHelper); |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // cleanupTestCase |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void TestVideoSettingsAccessPointEntry::cleanupTestCase() |
|
49 { |
|
50 delete mGroup; |
|
51 mGroup = 0; |
|
52 delete mItemHelper; |
|
53 mItemHelper = 0; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // init |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void TestVideoSettingsAccessPointEntry::init() |
|
61 { |
|
62 mTestObject = new VideoSettingsAccessPointEntry(*mItemHelper, QString("test"), mGroup); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // cleanup |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void TestVideoSettingsAccessPointEntry::cleanup() |
|
70 { |
|
71 delete mTestObject; |
|
72 mTestObject = 0; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // testConstructor |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void TestVideoSettingsAccessPointEntry::testConstructor() |
|
80 { |
|
81 // verify clicked signal connection. |
|
82 ConnectionHolder connection = mItemHelper->mConnections[mTestObject]; |
|
83 QCOMPARE( connection.signal, SIGNAL(clicked()) ); |
|
84 QVERIFY( connection.receiver == mTestObject ); |
|
85 QCOMPARE( connection.method, SLOT(openSelectionDialogSlot()) ); |
|
86 |
|
87 // verify mApplSettings construction |
|
88 QVERIFY( mTestObject->mApplSettings ); |
|
89 QVERIFY( disconnect(mTestObject->mApplSettings, SIGNAL(finished(uint)), mTestObject, SLOT(accessPointDialogFinished(uint))) ); |
|
90 connect(mTestObject->mApplSettings, SIGNAL(finished(uint)), mTestObject, SLOT(accessPointDialogFinished(uint))); |
|
91 |
|
92 // verify mSelection initial values |
|
93 QVERIFY( mTestObject->mSelection.result == CmApplSettingsUi::SelectionTypeConnectionMethod ); |
|
94 QVERIFY( mTestObject->mSelection.id == 0 ); |
|
95 |
|
96 // verify CmManagerShim construction |
|
97 QVERIFY( mTestObject->mCmManager ); |
|
98 |
|
99 // verify base class 'construction' |
|
100 QCOMPARE( mTestObject->mText, QString("test") ); |
|
101 QVERIFY( mTestObject->mDescription.isNull() ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // testConstructor |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void TestVideoSettingsAccessPointEntry::testDestructor() |
|
109 { |
|
110 CmManagerShim::mDestructorCount = 0; |
|
111 cleanup(); |
|
112 QCOMPARE( CmManagerShim::mDestructorCount, 1 ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // testSetIapId |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void TestVideoSettingsAccessPointEntry::testSetIapId() |
|
120 { |
|
121 // with empty cmArray |
|
122 mTestObject->setIapId(5); |
|
123 QCOMPARE( mTestObject->mDescription, hbTrId("txt_videos_dblist_none") ); |
|
124 |
|
125 // with non-empty cmArray, but id is not found. |
|
126 mTestObject->mCmManager->mConnectionMethods[0] = new CmConnectionMethodShim(0, 4, QString("0")); |
|
127 mTestObject->mCmManager->mConnectionMethods[2] = new CmConnectionMethodShim(2, 6, QString("2")); |
|
128 mTestObject->setIapId(5); |
|
129 QCOMPARE( mTestObject->mDescription, hbTrId("txt_videos_dblist_none") ); |
|
130 |
|
131 // with non-empty cmArray, and id is found, but CmManagerShim throws at that id. |
|
132 mTestObject->mCmManager->mConnectionMethods[1] = new CmConnectionMethodShim(1, 5, QString("1")); |
|
133 CmManagerShim::mConnectionMethodThrowsAtId = 1; |
|
134 mTestObject->setIapId(5); |
|
135 QCOMPARE( mTestObject->mDescription, hbTrId("txt_videos_dblist_none") ); |
|
136 |
|
137 // with non-empty cmArray, and id is found. |
|
138 CmManagerShim::mConnectionMethodThrowsAtId = -1; |
|
139 mTestObject->setIapId(5); |
|
140 QCOMPARE( mTestObject->mDescription, QString("1") ); |
|
141 |
|
142 // with non-empty cmArray, and id is found, but CmManagerShim throws at id before. |
|
143 CmManagerShim::mConnectionMethodThrowsAtId = 0; |
|
144 mTestObject->mDescription = QString(); |
|
145 mTestObject->setIapId(5); |
|
146 QCOMPARE( mTestObject->mDescription, QString("1") ); |
|
147 |
|
148 // with non-empty cmArray, and id is found, but CmManagerShim throws at id after. |
|
149 CmManagerShim::mConnectionMethodThrowsAtId = 2; |
|
150 mTestObject->mDescription = QString(); |
|
151 mTestObject->setIapId(5); |
|
152 QCOMPARE( mTestObject->mDescription, QString("1") ); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // testCreateSettingView |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void TestVideoSettingsAccessPointEntry::testCreateSettingView() |
|
160 { |
|
161 QVERIFY(mTestObject->callCreateSettingView() == 0 ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // testOpenSelectionDialogSlot |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void TestVideoSettingsAccessPointEntry::testOpenSelectionDialogSlot() |
|
169 { |
|
170 connect(this, SIGNAL(testSignal()), mTestObject, SLOT(openSelectionDialogSlot())); |
|
171 QSet<CmApplSettingsUi::BearerTypeFilter> filter; |
|
172 filter.insert(1); |
|
173 mTestObject->mApplSettings->mListItems = QFlags<CmApplSettingsUi::SelectionDialogItems>(); |
|
174 mTestObject->mApplSettings->mBearerTypeFilter = filter; |
|
175 mTestObject->mApplSettings->mOpenCallAmount = 0; |
|
176 |
|
177 emit testSignal(); |
|
178 |
|
179 QVERIFY( mTestObject->mApplSettings->mListItems.testFlag(CmApplSettingsUi::ShowConnectionMethods) ); |
|
180 QVERIFY( mTestObject->mApplSettings->mListItems.testFlag(CmApplSettingsUi::ShowDestinations) == false); |
|
181 QCOMPARE( mTestObject->mApplSettings->mBearerTypeFilter.count(), 0); |
|
182 QVERIFY( mTestObject->mApplSettings->mSelection.result == CmApplSettingsUi::SelectionTypeConnectionMethod ); |
|
183 QCOMPARE( mTestObject->mApplSettings->mOpenCallAmount, 1 ); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // testAccessPointDialogFinished |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void TestVideoSettingsAccessPointEntry::testAccessPointDialogFinished() |
|
191 { |
|
192 // error |
|
193 mTestObject->mApplSettings->mSelection.id = 5; |
|
194 mTestObject->mSelection.id = 0; |
|
195 mTestObject->mDescription = QString(); |
|
196 mGroup->mApId = 0; |
|
197 |
|
198 mTestObject->mApplSettings->emitFinished(CmApplSettingsUi::ApplSettingsErrorCancel); |
|
199 |
|
200 QCOMPARE( mTestObject->mSelection.id, (uint)0 ); |
|
201 |
|
202 // no error |
|
203 mTestObject->mDescription = QString(); |
|
204 mTestObject->mCmManager->mConnectionMethods[5] = new CmConnectionMethodShim(5, 4, QString("5")); |
|
205 |
|
206 mTestObject->mApplSettings->emitFinished(CmApplSettingsUi::ApplSettingsErrorNone); |
|
207 |
|
208 QCOMPARE( mTestObject->mSelection.id, mTestObject->mApplSettings->mSelection.id ); |
|
209 QCOMPARE( mGroup->mApId, (uint)4 ); |
|
210 QCOMPARE( mTestObject->mDescription, QString("5") ); |
|
211 |
|
212 // no error, but CmManagerShim throws at that id. |
|
213 mTestObject->mSelection.id = 0; |
|
214 mTestObject->mDescription = QString(); |
|
215 mGroup->mApId = 0; |
|
216 CmManagerShim::mConnectionMethodThrowsAtId = 5; |
|
217 |
|
218 mTestObject->mApplSettings->emitFinished(CmApplSettingsUi::ApplSettingsErrorNone); |
|
219 |
|
220 QCOMPARE( mTestObject->mSelection.id, (uint)0 ); |
|
221 QCOMPARE( mGroup->mApId, (uint)0 ); |
|
222 QVERIFY( mTestObject->mDescription.isNull() ); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // main |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 int main(int argc, char *argv[]) |
|
230 { |
|
231 HbApplication app(argc, argv); |
|
232 |
|
233 TestVideoSettingsAccessPointEntry tc; |
|
234 |
|
235 char *pass[3]; |
|
236 pass[0] = argv[0]; |
|
237 pass[1] = "-o"; |
|
238 pass[2] = "c:\\data\\testvideosettingsaccesspointentry.txt"; |
|
239 |
|
240 return QTest::qExec(&tc, 3, pass); |
|
241 } |
|
242 |
|
243 // end of file |