26 #include <AknGlobalConfirmationQuery.h> |
26 #include <AknGlobalConfirmationQuery.h> |
27 #include <coreapplicationuisdomainpskeys.h> |
27 #include <coreapplicationuisdomainpskeys.h> |
28 |
28 |
29 // Next row is to disable warning emerging from EUnit code. |
29 // Next row is to disable warning emerging from EUnit code. |
30 #pragma warn_illtokenpasting off |
30 #pragma warn_illtokenpasting off |
31 static TInt stubStatus = KErrNone; |
31 |
32 static TRequestStatus* rstatus = NULL; |
|
33 |
|
34 |
|
35 // ======== CAknGlobalMsgQuery stub ======== |
|
36 |
|
37 |
|
38 CAknGlobalMsgQuery* CAknGlobalMsgQuery::NewL() |
|
39 { |
|
40 CAknGlobalMsgQuery* self = CAknGlobalMsgQuery::NewLC(); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 CAknGlobalMsgQuery* CAknGlobalMsgQuery::NewLC() |
|
47 { |
|
48 CAknGlobalMsgQuery* self = new (ELeave) CAknGlobalMsgQuery(); |
|
49 CleanupStack::PushL( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 CAknGlobalMsgQuery::CAknGlobalMsgQuery() |
|
54 { |
|
55 } |
|
56 |
|
57 CAknGlobalMsgQuery::~CAknGlobalMsgQuery() |
|
58 { |
|
59 CancelMsgQuery(); |
|
60 iNotify.Close(); |
|
61 } |
|
62 |
|
63 void CAknGlobalMsgQuery::ShowMsgQueryL( |
|
64 TRequestStatus& aStatus, |
|
65 const TDesC& /*aMsgText*/, |
|
66 TInt /*aSoftkeys*/, |
|
67 const TDesC& /*HeaderText*/, |
|
68 const TDesC& /*HeaderImageFile*/, |
|
69 TInt /*aImageId*/, |
|
70 TInt /*aImageMaskId*/, |
|
71 CAknQueryDialog::TTone /*aTone*/) |
|
72 { |
|
73 if ( stubStatus == KErrNone ) |
|
74 { |
|
75 aStatus = KRequestPending; |
|
76 rstatus = &aStatus; |
|
77 } |
|
78 else |
|
79 { |
|
80 User::Leave( stubStatus ); |
|
81 } |
|
82 } |
|
83 |
|
84 void CAknGlobalMsgQuery::CancelMsgQuery() |
|
85 { |
|
86 if ( rstatus ) |
|
87 { |
|
88 User::RequestComplete( rstatus, KErrCancel ); |
|
89 rstatus = NULL; |
|
90 } |
|
91 } |
|
92 |
|
93 |
|
94 // ======== CAknGlobalConfirmationQuery stub ======== |
|
95 |
|
96 CAknGlobalConfirmationQuery* CAknGlobalConfirmationQuery::NewL() |
|
97 { |
|
98 CAknGlobalConfirmationQuery* self = CAknGlobalConfirmationQuery::NewLC(); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 |
|
104 CAknGlobalConfirmationQuery* CAknGlobalConfirmationQuery::NewLC() |
|
105 { |
|
106 CAknGlobalConfirmationQuery* self = new (ELeave) CAknGlobalConfirmationQuery(); |
|
107 CleanupStack::PushL( self ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 CAknGlobalConfirmationQuery::CAknGlobalConfirmationQuery() |
|
112 { |
|
113 } |
|
114 |
|
115 |
|
116 CAknGlobalConfirmationQuery::~CAknGlobalConfirmationQuery() |
|
117 { |
|
118 CancelConfirmationQuery(); |
|
119 iNotify.Close(); |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 void CAknGlobalConfirmationQuery::ShowConfirmationQueryL( |
|
126 TRequestStatus& aStatus, |
|
127 const TDesC& /*aPrompt*/, |
|
128 TInt /*aSoftkeys*/, |
|
129 TInt /*aAnimation*/, |
|
130 const TDesC& /*aImageFile*/, |
|
131 TInt /*aImageId*/, |
|
132 TInt /*aImageMaskId*/, |
|
133 CAknQueryDialog::TTone /*aTone*/, |
|
134 TBool /*aDismissWithAllKeys*/ ) |
|
135 |
|
136 { |
|
137 if ( stubStatus == KErrNone ) |
|
138 { |
|
139 TRequestStatus* stat = &aStatus; |
|
140 User::RequestComplete( stat, EAknSoftkeyYes ); |
|
141 // rstatus = &aStatus; |
|
142 } |
|
143 else |
|
144 { |
|
145 User::Leave( stubStatus ); |
|
146 } |
|
147 |
|
148 } |
|
149 |
|
150 void CAknGlobalConfirmationQuery::CancelConfirmationQuery() |
|
151 { |
|
152 if ( rstatus ) |
|
153 { |
|
154 User::RequestComplete( rstatus, KErrCancel ); |
|
155 rstatus = NULL; |
|
156 } |
|
157 } |
|
158 |
32 |
159 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
160 |
34 |
161 |
35 |
162 UT_CMusIndicatorApi* UT_CMusIndicatorApi::NewL() |
36 UT_CMusIndicatorApi* UT_CMusIndicatorApi::NewL() |
246 EUNIT_ASSERT( iIndicatorApi ); |
117 EUNIT_ASSERT( iIndicatorApi ); |
247 } |
118 } |
248 |
119 |
249 |
120 |
250 // ---------------------------------------------------------------------------- |
121 // ---------------------------------------------------------------------------- |
251 // @TODO: Can this be tested without a dialog? |
|
252 // ---------------------------------------------------------------------------- |
|
253 // |
|
254 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_ConfirmationQueryLL() |
|
255 { |
|
256 TBool ret = iIndicatorApi->ConfirmationQueryL( |
|
257 CMusIndicatorApi::EVsRoamingActivationQuery ); |
|
258 |
|
259 EUNIT_ASSERT( ret ); |
|
260 } |
|
261 |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // Dummy test. @TODO: Can this be tested? |
122 // Dummy test. @TODO: Can this be tested? |
265 // ---------------------------------------------------------------------------- |
123 // ---------------------------------------------------------------------------- |
266 // |
124 // |
267 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_IndicateAvailabilityLL() |
125 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_IndicateAvailabilityLL() |
268 { |
126 { |
274 // Asserts that start livesharing is called only when there is no error. |
132 // Asserts that start livesharing is called only when there is no error. |
275 // ---------------------------------------------------------------------------- |
133 // ---------------------------------------------------------------------------- |
276 // |
134 // |
277 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_RunLL() |
135 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_RunLL() |
278 { |
136 { |
279 /* NOTE: EUnit reports leak for this test due AVKON resource reservation, |
137 User::LeaveIfError( RProperty::Define( |
280 * which is not released by AVKON at end of test. Resource reservation |
138 KPSUidCoreApplicationUIs, |
281 * happend in contruction of indicator(dsa) |
139 KCoreAppUIsVideoSharingIndicator, |
282 */ |
140 RProperty::EInt, |
283 TRAPD( error, RProperty::Define( |
141 0 ) ); |
284 KPSUidCoreApplicationUIs, |
|
285 KCoreAppUIsVideoSharingIndicator, |
|
286 RProperty::EInt, |
|
287 0 ) ); |
|
288 if ( error == KErrNoMemory ) User::Leave( error ); |
|
289 EUNIT_ASSERT ( error == KErrNone ); |
|
290 |
142 |
291 TRAP( error, RProperty::Set( |
143 User::LeaveIfError( RProperty::Set( |
292 KPSUidCoreApplicationUIs, |
144 KPSUidCoreApplicationUIs, |
293 KCoreAppUIsVideoSharingIndicator, |
145 KCoreAppUIsVideoSharingIndicator, |
294 ( TInt ) ECoreAppUIsVideoSharingIndicatorOn ) ); |
146 ( TInt ) ECoreAppUIsVideoSharingIndicatorOn ) ); |
295 if ( error == KErrNoMemory ) User::Leave( error ); |
|
296 EUNIT_ASSERT ( error == KErrNone ); |
|
297 |
147 |
298 iIndicatorApi->Cancel(); |
148 iIndicatorApi->Cancel(); |
299 iIndicatorApi->iStatus = KErrNotFound; |
149 iIndicatorApi->iStatus = KErrNotFound; |
300 iIndicatorApi->RunL(); |
150 iIndicatorApi->RunL(); |
301 EUNIT_ASSERT( !iStartLiveSharingLCalled ); |
151 EUNIT_ASSERT( !iStartLiveSharingLCalled ); |
302 |
152 |
303 iIndicatorApi->Cancel(); |
153 iIndicatorApi->Cancel(); |
304 iIndicatorApi->iStatus = KErrNone; |
154 iIndicatorApi->iStatus = KErrNone; |
305 iIndicatorApi->RunL(); |
155 iIndicatorApi->RunL(); |
306 EUNIT_ASSERT( iStartLiveSharingLCalled ); |
156 EUNIT_ASSERT( iStartLiveSharingLCalled ); |
307 EUNIT_ASSERT( !iIndicatorApi->iQuery ); |
157 |
308 |
158 } |
309 delete iIndicatorApi->iLiveSharingQueryTimeout; |
159 |
310 iIndicatorApi->iLiveSharingQueryTimeout = NULL; |
160 |
311 iIndicatorApi->iLiveSharingQueryTimeout = |
161 // ---------------------------------------------------------------------------- |
312 CPeriodic::NewL( CActive::EPriorityStandard ); |
162 // Asserts that DoCancel removes current activity. |
313 |
163 // ---------------------------------------------------------------------------- |
314 iIndicatorApi->RunL(); |
164 // |
315 EUNIT_ASSERT( !iIndicatorApi->iLiveSharingQueryTimeout ); |
165 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_DoCancelL() |
316 |
166 { |
317 EUNIT_ASSERT( !iIndicatorApi->IsSubscriber() ); |
|
318 |
|
319 iIndicatorApi->iObserver = NULL; |
|
320 EUNIT_ASSERT( iIndicatorApi->IsSubscriber() ); |
|
321 iIndicatorApi->Indicator( ETrue ); |
|
322 |
|
323 iIndicatorApi->Cancel(); |
167 iIndicatorApi->Cancel(); |
324 |
|
325 iIndicatorApi->RunL(); |
|
326 |
|
327 TRequestStatus& status = iIndicatorApi->iStatus; |
|
328 rstatus = &status; |
|
329 //User::RequestComplete( rstatus, KErrCancel ); |
|
330 } |
|
331 |
|
332 |
|
333 // ---------------------------------------------------------------------------- |
|
334 // Asserts that DoCancel removes current activity and deletes used resources. |
|
335 // ---------------------------------------------------------------------------- |
|
336 // |
|
337 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_DoCancelL() |
|
338 { |
|
339 iIndicatorApi->ShowLiveSharingQueryL( EFalse ); |
|
340 iIndicatorApi->Cancel(); |
|
341 EUNIT_ASSERT( !iIndicatorApi->iQuery ); |
|
342 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
168 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
343 |
169 |
344 } |
170 } |
345 |
171 |
346 |
172 |
379 iIndicatorApi->PlayToneL(); |
205 iIndicatorApi->PlayToneL(); |
380 EUNIT_ASSERT( iIndicatorApi->iSoundPlayer ); |
206 EUNIT_ASSERT( iIndicatorApi->iSoundPlayer ); |
381 } |
207 } |
382 |
208 |
383 |
209 |
384 // ---------------------------------------------------------------------------- |
|
385 // Asserts that a note text is generated. |
|
386 // ---------------------------------------------------------------------------- |
|
387 // |
|
388 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_NoteTextLCL() |
|
389 { |
|
390 HBufC* tmp = iIndicatorApi->NoteTextLC( |
|
391 CMusIndicatorApi::EVsRoamingActivationQuery ); |
|
392 EUNIT_ASSERT( tmp ); |
|
393 EUNIT_ASSERT( tmp->Length() ); |
|
394 CleanupStack::PopAndDestroy(); |
|
395 } |
|
396 |
|
397 |
|
398 // ---------------------------------------------------------------------------- |
|
399 // Asserts that method creates a query and calls CActive::SetActive. |
|
400 // ---------------------------------------------------------------------------- |
|
401 // |
|
402 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_ShowLiveSharingQueryLL() |
|
403 { |
|
404 |
|
405 iIndicatorApi->ShowLiveSharingQueryL( EFalse ); |
|
406 EUNIT_ASSERT( iIndicatorApi->iQuery ); |
|
407 EUNIT_ASSERT( iIndicatorApi->IsActive() ); |
|
408 |
|
409 iIndicatorApi->Cancel(); |
|
410 EUNIT_ASSERT( !iIndicatorApi->iQuery ); |
|
411 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
|
412 |
|
413 stubStatus = KErrNotFound; |
|
414 iIndicatorApi->ShowLiveSharingQueryL( EFalse ); |
|
415 EUNIT_ASSERT( !iIndicatorApi->iQuery ); |
|
416 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
|
417 |
|
418 |
|
419 } |
|
420 |
|
421 // ---------------------------------------------------------------------------- |
|
422 // ---------------------------------------------------------------------------- |
|
423 // |
|
424 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_LiveSharingQueryTimeoutL() |
|
425 { |
|
426 iIndicatorApi->ShowLiveSharingQueryL( EFalse ); |
|
427 EUNIT_ASSERT( iIndicatorApi->iQuery ); |
|
428 EUNIT_ASSERT( iIndicatorApi->IsActive() ); |
|
429 |
|
430 EUNIT_ASSERT( CMusIndicatorApi::LiveSharingQueryTimeout( iIndicatorApi ) == KErrNone ); |
|
431 |
|
432 EUNIT_ASSERT( !iIndicatorApi->iQuery ); |
|
433 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
|
434 |
|
435 |
|
436 } |
|
437 |
|
438 |
|
439 |
|
440 // ======== EUNIT TEST TABLE ======== |
210 // ======== EUNIT TEST TABLE ======== |
441 |
211 |
442 |
212 |
443 EUNIT_BEGIN_TEST_TABLE( |
213 EUNIT_BEGIN_TEST_TABLE( |
444 UT_CMusIndicatorApi, |
214 UT_CMusIndicatorApi, |
451 "NewL", |
221 "NewL", |
452 "FUNCTIONALITY", |
222 "FUNCTIONALITY", |
453 SetupL, UT_CMusIndicatorApi_NewLL, Teardown ) |
223 SetupL, UT_CMusIndicatorApi_NewLL, Teardown ) |
454 |
224 |
455 EUNIT_TEST( |
225 EUNIT_TEST( |
456 "ConfirmationQueryL - test ", |
|
457 "CMusIndicatorApi", |
|
458 "ConfirmationQueryL", |
|
459 "FUNCTIONALITY", |
|
460 SetupL, UT_CMusIndicatorApi_ConfirmationQueryLL, Teardown ) |
|
461 |
|
462 EUNIT_TEST( |
|
463 "IndicateAvailabilityL - test ", |
226 "IndicateAvailabilityL - test ", |
464 "CMusIndicatorApi", |
227 "CMusIndicatorApi", |
465 "IndicateAvailabilityL", |
228 "IndicateAvailabilityL", |
466 "FUNCTIONALITY", |
229 "FUNCTIONALITY", |
467 SetupL, UT_CMusIndicatorApi_IndicateAvailabilityLL, Teardown ) |
230 SetupL, UT_CMusIndicatorApi_IndicateAvailabilityLL, Teardown ) |
499 "CMusIndicatorApi", |
262 "CMusIndicatorApi", |
500 "PlayToneL", |
263 "PlayToneL", |
501 "FUNCTIONALITY", |
264 "FUNCTIONALITY", |
502 SetupL, UT_CMusIndicatorApi_PlayToneLL, Teardown ) |
265 SetupL, UT_CMusIndicatorApi_PlayToneLL, Teardown ) |
503 |
266 |
504 EUNIT_TEST( |
|
505 "NoteTextLC - test ", |
|
506 "CMusIndicatorApi", |
|
507 "NoteTextLC", |
|
508 "FUNCTIONALITY", |
|
509 SetupL, UT_CMusIndicatorApi_NoteTextLCL, Teardown ) |
|
510 |
|
511 EUNIT_TEST( |
|
512 "ShowLiveSharingQueryL - test ", |
|
513 "CMusIndicatorApi", |
|
514 "ShowLiveSharingQueryL", |
|
515 "FUNCTIONALITY", |
|
516 SetupL, UT_CMusIndicatorApi_ShowLiveSharingQueryLL, Teardown ) |
|
517 |
|
518 EUNIT_TEST( |
|
519 "LiveSharingQueryTimeout - test ", |
|
520 "CMusIndicatorApi", |
|
521 "LiveSharingQueryTimeout", |
|
522 "FUNCTIONALITY", |
|
523 SetupL, UT_CMusIndicatorApi_LiveSharingQueryTimeoutL, Teardown ) |
|
524 |
|
525 |
267 |
526 |
268 |
527 EUNIT_END_TEST_TABLE |
269 EUNIT_END_TEST_TABLE |