15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "ut_infowidgetsathandlerprivate.h" |
18 #include "ut_infowidgetsathandlerprivate.h" |
19 #define private public |
19 #define private public |
20 #include "infowidgetsathandlerprivate.h" |
20 #include "infowidgetsathandler_p.h" |
21 #include "infowidgetsathandler.h" |
21 #include "infowidgetsathandler.h" |
22 #include "infowidgetlogging.h" |
22 #include "infowidgetlogging.h" |
23 #include "qtestmains60.h" |
23 #include "qtestmains60.h" |
|
24 |
|
25 static struct ActiveObjectControl { |
|
26 enum TOperation { |
|
27 EUndefined = 0, |
|
28 ECallRunL, |
|
29 ECallDoCancel, |
|
30 EExitSequence |
|
31 } operation; |
|
32 int iStatus; |
|
33 CActive* object; |
|
34 } m_activeObjectControl; |
|
35 |
|
36 |
|
37 void CActive::SetActive(){ |
|
38 if (m_activeObjectControl.object) |
|
39 { |
|
40 switch (m_activeObjectControl.operation) { |
|
41 case ActiveObjectControl::ECallRunL: |
|
42 m_activeObjectControl.operation = ActiveObjectControl::EExitSequence; |
|
43 m_activeObjectControl.object->iStatus = |
|
44 m_activeObjectControl.iStatus; |
|
45 m_activeObjectControl.object->RunL(); |
|
46 break; |
|
47 case ActiveObjectControl::ECallDoCancel: |
|
48 m_activeObjectControl.operation = ActiveObjectControl::EExitSequence; |
|
49 m_activeObjectControl.object->iStatus = |
|
50 m_activeObjectControl.iStatus; |
|
51 m_activeObjectControl.object->DoCancel(); |
|
52 break; |
|
53 |
|
54 default: |
|
55 break; |
|
56 } |
|
57 |
|
58 // Reset, causes infinite loop otherwise |
|
59 m_activeObjectControl.operation = ActiveObjectControl::EUndefined; |
|
60 m_activeObjectControl.object = NULL; |
|
61 } |
|
62 } |
24 |
63 |
25 void SimulateLeaveL() |
64 void SimulateLeaveL() |
26 { |
65 { |
27 User::Leave(KErrGeneral); |
66 User::Leave(KErrGeneral); |
28 } |
67 } |
121 { |
160 { |
122 DPRINT << "IN"; |
161 DPRINT << "IN"; |
123 |
162 |
124 expect("RSatSession::ConnectL"); |
163 expect("RSatSession::ConnectL"); |
125 expect("RSatService::OpenL"); |
164 expect("RSatService::OpenL"); |
126 m_satHandler->connect(); |
165 m_satHandlerPrivate->connect(); |
127 |
166 |
128 expect("RSatSession::ConnectL") |
167 expect("RSatSession::ConnectL") |
129 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
168 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
130 m_satHandler->connect(); |
169 m_satHandlerPrivate->connect(); |
131 |
170 |
132 expect("RSatService::OpenL") |
171 expect("RSatService::OpenL") |
133 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
172 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
134 m_satHandler->connect(); |
173 m_satHandlerPrivate->connect(); |
135 |
174 |
136 QVERIFY(verify()); |
175 QVERIFY(verify()); |
137 |
176 |
138 DPRINT << "OUT"; |
177 DPRINT << "OUT"; |
139 } |
178 } |
160 |
199 |
161 int i = KErrGeneral; |
200 int i = KErrGeneral; |
162 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
201 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
163 expect("RSatService::GetSetupIdleModeTextL") |
202 expect("RSatService::GetSetupIdleModeTextL") |
164 .willOnce(invoke(FillData)); |
203 .willOnce(invoke(FillData)); |
165 m_satHandler->startObserving(); |
204 m_satHandlerPrivate->startObserving(); |
166 |
205 |
167 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
206 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
168 expect("RSatService::GetSetupIdleModeTextL") |
207 expect("RSatService::GetSetupIdleModeTextL") |
169 .willOnce(invoke(FillDataNoIcon)); |
208 .willOnce(invoke(FillDataNoIcon)); |
170 m_satHandler->startObserving(); |
209 m_satHandlerPrivate->startObserving(); |
171 |
210 |
172 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
211 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
173 expect("RSatService::GetSetupIdleModeTextL") |
212 expect("RSatService::GetSetupIdleModeTextL") |
174 .willOnce(invoke(FillDataSelfExplIcon)); |
213 .willOnce(invoke(FillDataSelfExplIcon)); |
175 m_satHandler->startObserving(); |
214 m_satHandlerPrivate->startObserving(); |
176 |
215 |
177 expect("RSatService::GetSetupIdleModeTextL") |
216 expect("RSatService::GetSetupIdleModeTextL") |
178 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
217 .willOnce(invokeWithoutArguments(SimulateLeaveL)); |
179 m_satHandler->startObserving(); |
218 m_satHandlerPrivate->startObserving(); |
180 |
219 |
181 QVERIFY(verify()); |
220 QVERIFY(verify()); |
182 |
221 |
183 DPRINT << "OUT"; |
222 DPRINT << "OUT"; |
184 } |
223 } |
186 /*! |
225 /*! |
187 UT_InfoWidgetSatHandlerPrivate::t_runL |
226 UT_InfoWidgetSatHandlerPrivate::t_runL |
188 */ |
227 */ |
189 void UT_InfoWidgetSatHandlerPrivate::t_runL() |
228 void UT_InfoWidgetSatHandlerPrivate::t_runL() |
190 { |
229 { |
191 DPRINT << "IN"; |
230 DPRINT; |
192 |
|
193 int i = 1; |
|
194 expect("RSatService::GetSetupIdleModeTextL") |
231 expect("RSatService::GetSetupIdleModeTextL") |
195 .willOnce(invoke(FillData)); |
232 .willOnce(invoke(FillData)); |
196 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
233 expect("RSatService::NotifySetupIdleModeTextChange").returns(KErrNone); |
197 m_satHandler->RunL(); |
234 |
198 |
235 TRequestStatus& status(m_satHandlerPrivate->iStatus); |
199 m_satHandler->iStatus = KErrGeneral; |
236 expect("RSatService::NotifySetupIdleModeTextChange").with(status); |
200 expect("RSatService::NotifySetupIdleModeTextChange").returns(i); |
237 |
201 m_satHandler->RunL(); |
238 // Test RunL sequence with iStatus == KErrNone |
202 |
239 m_activeObjectControl.operation = ActiveObjectControl::ECallRunL; |
203 QVERIFY(verify()); |
240 m_activeObjectControl.iStatus = KErrNone; |
204 |
241 m_activeObjectControl.object = m_satHandlerPrivate; |
205 DPRINT << "OUT"; |
242 m_satHandlerPrivate->startObserving(); |
|
243 |
|
244 // Test RunL sequence with iStatus == KErrGeneral |
|
245 m_activeObjectControl.operation = ActiveObjectControl::ECallRunL; |
|
246 m_activeObjectControl.iStatus = KErrGeneral; |
|
247 m_activeObjectControl.object = m_satHandlerPrivate; |
|
248 m_satHandlerPrivate->startObserving(); |
|
249 QVERIFY(verify()); |
206 } |
250 } |
207 |
251 |
208 /*! |
252 /*! |
209 UT_InfoWidgetSatHandlerPrivate::t_doCancel |
253 UT_InfoWidgetSatHandlerPrivate::t_doCancel |
210 */ |
254 */ |
211 void UT_InfoWidgetSatHandlerPrivate::t_doCancel() |
255 void UT_InfoWidgetSatHandlerPrivate::t_doCancel() |
212 { |
256 { |
213 DPRINT << "IN"; |
257 DPRINT << "IN"; |
214 |
258 |
215 m_satHandler->DoCancel(); |
259 m_activeObjectControl.operation = ActiveObjectControl::ECallDoCancel; |
|
260 m_activeObjectControl.iStatus = KErrNone; |
|
261 m_activeObjectControl.object = m_satHandlerPrivate; |
|
262 m_satHandlerPrivate->startObserving(); |
|
263 |
216 QVERIFY(verify()); |
264 QVERIFY(verify()); |
217 |
265 |
218 DPRINT << "OUT"; |
266 DPRINT << "OUT"; |
219 } |
267 } |
220 |
268 |