|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of the MT_MProEngNotifyHandler test class. |
|
15 * |
|
16 */ |
|
17 |
|
18 //////////////////////////////////////////////////////////////////////// |
|
19 // MT_MProEngNotifyHandler.cpp |
|
20 // |
|
21 |
|
22 // CLASS HEADER |
|
23 #include "MT_MProEngNotifyHandler.h" |
|
24 |
|
25 // EXTERNAL INCLUDES |
|
26 #include <EUnitMacros.h> |
|
27 #include <MProEngNotifyHandler.h> |
|
28 #include <MProEngProfile.h> |
|
29 #include <MProEngEngine.h> |
|
30 #include <MProEngTones.h> |
|
31 #include <MProEngProfileName.h> |
|
32 #include <MProEngToneSettings.h> |
|
33 #include <ProEngFactory.h> |
|
34 #include <Profile.hrh> |
|
35 #include <CPbkContactEngine.h> |
|
36 #include <centralrepository.h> |
|
37 #include <ProfileEngineSDKCRKeys.h> |
|
38 |
|
39 |
|
40 // INTERNAL INCLUDES |
|
41 #include "T_ProfileTestTools.h" |
|
42 |
|
43 // CONSTANTS |
|
44 namespace |
|
45 { |
|
46 const TInt KProEngUndefinedError = -999; |
|
47 } |
|
48 |
|
49 // CONSTRUCTION |
|
50 MT_MProEngNotifyHandler* MT_MProEngNotifyHandler::NewL() |
|
51 { |
|
52 MT_MProEngNotifyHandler* self = MT_MProEngNotifyHandler::NewLC(); |
|
53 CleanupStack::Pop(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 MT_MProEngNotifyHandler* MT_MProEngNotifyHandler::NewLC() |
|
59 { |
|
60 MT_MProEngNotifyHandler* self = new( ELeave ) MT_MProEngNotifyHandler(); |
|
61 CleanupStack::PushL( self ); |
|
62 |
|
63 self->ConstructL(); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 // Destructor (virtual by CBase) |
|
69 MT_MProEngNotifyHandler::~MT_MProEngNotifyHandler() |
|
70 { |
|
71 if( iProfile ) |
|
72 { |
|
73 iProfile->Release(); |
|
74 } |
|
75 if( iEngine ) |
|
76 { |
|
77 iEngine->Release(); |
|
78 } |
|
79 delete iActiveIdObserver; |
|
80 iActiveIdObserver = NULL; |
|
81 delete iActiveProfileObserver; |
|
82 iActiveProfileObserver = NULL; |
|
83 delete iProfileObserver; |
|
84 iProfileObserver = NULL; |
|
85 delete iNameArrayObserver; |
|
86 iNameArrayObserver = NULL; |
|
87 MT_CSchedulerUtility::Release(); |
|
88 iFs.Close(); |
|
89 delete iDebugObs; |
|
90 } |
|
91 |
|
92 // Default constructor |
|
93 MT_MProEngNotifyHandler::MT_MProEngNotifyHandler() |
|
94 { |
|
95 } |
|
96 |
|
97 // Second phase construct |
|
98 void MT_MProEngNotifyHandler::ConstructL() |
|
99 { |
|
100 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
101 // It generates the test case table. |
|
102 CEUnitTestSuiteClass::ConstructL(); |
|
103 User::LeaveIfError( iFs.Connect() ); |
|
104 iEngine = ProEngFactory::NewEngineL(); |
|
105 MT_CSchedulerUtility::InstanceL(); |
|
106 iDebugObs = CMyDebugObserver::NewL(); |
|
107 } |
|
108 |
|
109 // METHODS |
|
110 |
|
111 |
|
112 // Setup methods: |
|
113 // |
|
114 |
|
115 void MT_MProEngNotifyHandler::SetupCancelAllTestL() |
|
116 { |
|
117 iHandler = ProEngFactory::NewNotifyHandlerL(); |
|
118 iActiveIdObserver = MT_CProEngActiveIdObserver::NewL(); |
|
119 iActiveProfileObserver = MT_CProEngActiveProfileObserver::NewL(); |
|
120 iNameArrayObserver = MT_CProEngNameArrayObserver::NewL(); |
|
121 iProfileObserver = MT_CProEngProfileObserver::NewL(); |
|
122 iProfileId = 0; |
|
123 } |
|
124 |
|
125 void MT_MProEngNotifyHandler::SetupRequestProfileActivationNotificationsTestL() |
|
126 { |
|
127 iHandler = ProEngFactory::NewNotifyHandlerL(); |
|
128 iActiveIdObserver = MT_CProEngActiveIdObserver::NewL(); |
|
129 } |
|
130 |
|
131 void MT_MProEngNotifyHandler::SetupRequestActiveProfileNotificationsTestL( ) |
|
132 { |
|
133 iHandler = ProEngFactory::NewNotifyHandlerL(); |
|
134 iActiveProfileObserver = MT_CProEngActiveProfileObserver::NewL(); |
|
135 iProfileId = iEngine->ActiveProfileId(); |
|
136 iProfile = iEngine->ActiveProfileL(); |
|
137 } |
|
138 |
|
139 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTestL() |
|
140 { |
|
141 iHandler = ProEngFactory::NewNotifyHandlerL(); |
|
142 iProfileObserver = MT_CProEngProfileObserver::NewL(); |
|
143 iProfile = iEngine->ProfileL( iProfileId ); |
|
144 iContactEngine = CPbkContactEngine::NewL( &iFs ); |
|
145 T_ProfileTestTools::CreateContactGroupsL( 5, iContactGroups, *iContactEngine ); |
|
146 } |
|
147 |
|
148 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest0L() |
|
149 { |
|
150 iProfileId = 0; |
|
151 SetupRequestProfileNotificationsTestL(); |
|
152 } |
|
153 |
|
154 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest1L() |
|
155 { |
|
156 iProfileId = 1; |
|
157 SetupRequestProfileNotificationsTestL(); |
|
158 } |
|
159 |
|
160 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest2L() |
|
161 { |
|
162 iProfileId = 2; |
|
163 SetupRequestProfileNotificationsTestL(); |
|
164 } |
|
165 |
|
166 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest3L() |
|
167 { |
|
168 iProfileId = 3; |
|
169 SetupRequestProfileNotificationsTestL(); |
|
170 } |
|
171 |
|
172 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest4L() |
|
173 { |
|
174 iProfileId = 4; |
|
175 SetupRequestProfileNotificationsTestL(); |
|
176 } |
|
177 |
|
178 void MT_MProEngNotifyHandler::SetupRequestProfileNotificationsTest5L() |
|
179 { |
|
180 iProfileId = 5; |
|
181 SetupRequestProfileNotificationsTestL(); |
|
182 } |
|
183 |
|
184 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTestL( ) |
|
185 { |
|
186 iDebugObs->NotifyReqL(); |
|
187 iHandler = ProEngFactory::NewNotifyHandlerL(); |
|
188 iNameArrayObserver = MT_CProEngNameArrayObserver::NewL(); |
|
189 iProfile = iEngine->ProfileL( iProfileId ); |
|
190 } |
|
191 |
|
192 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest0L( ) |
|
193 { |
|
194 iProfileId = 0; |
|
195 SetupRequestProfileNameArrayNotificationsTestL(); |
|
196 } |
|
197 |
|
198 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest1L( ) |
|
199 { |
|
200 iProfileId = 1; |
|
201 SetupRequestProfileNameArrayNotificationsTestL(); |
|
202 } |
|
203 |
|
204 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest2L( ) |
|
205 { |
|
206 iProfileId = 2; |
|
207 SetupRequestProfileNameArrayNotificationsTestL(); |
|
208 } |
|
209 |
|
210 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest3L( ) |
|
211 { |
|
212 iProfileId = 3; |
|
213 SetupRequestProfileNameArrayNotificationsTestL(); |
|
214 } |
|
215 |
|
216 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest4L( ) |
|
217 { |
|
218 iProfileId = 4; |
|
219 SetupRequestProfileNameArrayNotificationsTestL(); |
|
220 } |
|
221 |
|
222 void MT_MProEngNotifyHandler::SetupRequestProfileNameArrayNotificationsTest5L( ) |
|
223 { |
|
224 iProfileId = 5; |
|
225 SetupRequestProfileNameArrayNotificationsTestL(); |
|
226 } |
|
227 |
|
228 void MT_MProEngNotifyHandler::SetupL( ) |
|
229 { |
|
230 } |
|
231 |
|
232 /// Teardown functions: |
|
233 // |
|
234 |
|
235 void MT_MProEngNotifyHandler::TeardownCommon( ) |
|
236 { |
|
237 delete iHandler; |
|
238 iHandler = NULL; |
|
239 |
|
240 if( iProfile ) |
|
241 { |
|
242 iProfile->Release(); |
|
243 iProfile = NULL; |
|
244 } |
|
245 T_ProfileTestTools::ResetRepository(); |
|
246 } |
|
247 |
|
248 void MT_MProEngNotifyHandler::TeardownRequestProfileActivationNotificationsTest( ) |
|
249 { |
|
250 iHandler->CancelProfileActivationNotifications(); |
|
251 delete iActiveIdObserver; |
|
252 iActiveIdObserver = NULL; |
|
253 |
|
254 delete iHandler; |
|
255 iHandler = NULL; |
|
256 |
|
257 T_ProfileTestTools::ResetRepository(); |
|
258 } |
|
259 |
|
260 void MT_MProEngNotifyHandler::TeardownRequestActiveProfileNotificationsTest( ) |
|
261 { |
|
262 iHandler->CancelActiveProfileNotifications(); |
|
263 delete iActiveProfileObserver; |
|
264 iActiveProfileObserver = NULL; |
|
265 TeardownCommon(); |
|
266 T_ProfileTestTools::ResetRepository(); |
|
267 } |
|
268 |
|
269 void MT_MProEngNotifyHandler::TeardownRequestProfileNotificationsTest( ) |
|
270 { |
|
271 iHandler->CancelProfileNotifications( iProfileId ); |
|
272 delete iProfileObserver; |
|
273 iProfileObserver = NULL; |
|
274 TeardownCommon(); |
|
275 TRAP_IGNORE( T_ProfileTestTools::DeleteContactGroups( |
|
276 iContactGroups, *iContactEngine ) ); |
|
277 delete iContactEngine; |
|
278 iContactGroups.Close(); |
|
279 } |
|
280 |
|
281 void MT_MProEngNotifyHandler::TeardownRequestProfileNameArrayNotificationsTest( ) |
|
282 { |
|
283 iDebugObs->Cancel(); |
|
284 iHandler->CancelProfileNameArrayNotifications(); |
|
285 delete iNameArrayObserver; |
|
286 iNameArrayObserver = NULL; |
|
287 TeardownCommon(); |
|
288 } |
|
289 |
|
290 void MT_MProEngNotifyHandler::TeardownCancelAllTest( ) |
|
291 { |
|
292 delete iActiveIdObserver; |
|
293 iActiveIdObserver = NULL; |
|
294 delete iActiveProfileObserver; |
|
295 iActiveProfileObserver = NULL; |
|
296 delete iProfileObserver; |
|
297 iProfileObserver = NULL; |
|
298 delete iNameArrayObserver; |
|
299 iNameArrayObserver = NULL; |
|
300 |
|
301 delete iHandler; |
|
302 iHandler = NULL; |
|
303 } |
|
304 |
|
305 /// Test functions |
|
306 // |
|
307 |
|
308 void MT_MProEngNotifyHandler::RequestProfileActivationNotificationsTestL( ) |
|
309 { |
|
310 TInt result( iHandler->RequestProfileActivationNotificationsL( |
|
311 *iActiveIdObserver ) ); |
|
312 EUNIT_ASSERT( result == KErrNone ); |
|
313 iActiveIdObserver->iProfileId = 0; |
|
314 iActiveIdObserver->iError = KProEngUndefinedError; |
|
315 iEngine->SetActiveProfileL( 2 ); |
|
316 MT_CSchedulerUtility::InstanceL()->Start(); |
|
317 EUNIT_ASSERT( iActiveIdObserver->iProfileId == 2 ); |
|
318 EUNIT_ASSERT( iActiveIdObserver->iError == KErrNone ); |
|
319 iHandler->CancelProfileActivationNotifications(); |
|
320 } |
|
321 |
|
322 void MT_MProEngNotifyHandler::RequestActiveProfileNotificationsTestL( ) |
|
323 { |
|
324 TInt result( iHandler->RequestActiveProfileNotificationsL( |
|
325 *iActiveProfileObserver ) ); |
|
326 EUNIT_ASSERT( result == KErrNone ); |
|
327 iActiveProfileObserver->iNotified = EFalse; |
|
328 iActiveProfileObserver->iError = KProEngUndefinedError; |
|
329 MProEngToneSettings& ts = iProfile->ToneSettings(); |
|
330 ts.SetRingingVolume( EProfileRingingVolumeLevel5 ); |
|
331 iProfile->CommitChangeL(); |
|
332 MT_CSchedulerUtility::InstanceL()->Start(); |
|
333 EUNIT_ASSERT( iActiveProfileObserver->iNotified ); |
|
334 EUNIT_ASSERT( iActiveProfileObserver->iError == KErrNone ); |
|
335 iHandler->CancelActiveProfileNotifications(); |
|
336 } |
|
337 |
|
338 void MT_MProEngNotifyHandler::RequestProfileNotificationsTestL( ) |
|
339 { |
|
340 EUNIT_PRINT( _L( "RequestProfileNotificationsTestL before req" ) ); |
|
341 TInt result( iHandler->RequestProfileNotificationsL( |
|
342 *iProfileObserver, iProfileId ) ); |
|
343 EUNIT_PRINT( _L( "RequestProfileNotificationsTestL result=%d" ), result ); |
|
344 EUNIT_PRINT( _L( "RequestProfileNotificationsTestL after req" ) ); |
|
345 #ifndef __OFFLINE_MODE |
|
346 if( iProfileId == EProfileOffLineId ) |
|
347 { |
|
348 EUNIT_ASSERT( result == KErrNotFound ); |
|
349 return; |
|
350 } |
|
351 #endif // __OFFLINE_MODE |
|
352 EUNIT_ASSERT( result == KErrNone ); |
|
353 MProEngTones& tones = iProfile->ProfileTones(); |
|
354 MProEngToneSettings& ts = iProfile->ToneSettings(); |
|
355 |
|
356 if( ( iProfileId != EProfileOffLineId ) ) |
|
357 { |
|
358 iProfileObserver->iProfileId = -1; |
|
359 iProfileObserver->iError = KProEngUndefinedError; |
|
360 |
|
361 EUNIT_PRINT( _L( "ReqNotificationsTestL rtype before set:%d" ), ts.RingingType() ); |
|
362 User::LeaveIfError( ts.SetRingingType( EProfileRingingTypeAscending ) ); |
|
363 EUNIT_PRINT( _L( "ReqNotificationsTestL rtype after set:%d" ), ts.RingingType() ); |
|
364 iProfile->CommitChangeL(); |
|
365 MT_CSchedulerUtility::InstanceL()->Start(); |
|
366 EUNIT_PRINT( _L( "ReqNotificationsTestL observer->iProfileId:%d" ), iProfileObserver->iProfileId ); |
|
367 EUNIT_PRINT( _L( "ReqNotificationsTestL iProfileId:%d" ), iProfileId ); |
|
368 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
369 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
370 } |
|
371 |
|
372 iProfileObserver->iProfileId = -1; |
|
373 iProfileObserver->iError = KProEngUndefinedError; |
|
374 |
|
375 EUNIT_PRINT( _L( "ReqNotificationsTestL keyvol before set:%d" ), ts.KeypadVolume() ); |
|
376 if( ( iProfileId == 4 ) || ( iProfileId == 5 ) ) |
|
377 { |
|
378 User::LeaveIfError( ts.SetKeypadVolume( EProfileKeypadVolumeLevel1 ) ); |
|
379 } |
|
380 else |
|
381 { |
|
382 User::LeaveIfError( ts.SetKeypadVolume( EProfileKeypadVolumeLevel2 ) ); |
|
383 } |
|
384 EUNIT_PRINT( _L( "ReqNotificationsTestL keyvol after set:%d" ), ts.KeypadVolume() ); |
|
385 iProfile->CommitChangeL(); |
|
386 MT_CSchedulerUtility::InstanceL()->Start(); |
|
387 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
388 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
389 |
|
390 iProfileObserver->iProfileId = -1; |
|
391 iProfileObserver->iError = KProEngUndefinedError; |
|
392 |
|
393 EUNIT_PRINT( _L( "ReqNotificationsTestL rvol before set:%d" ), ts.RingingVolume() ); |
|
394 User::LeaveIfError( ts.SetRingingVolume( EProfileRingingVolumeLevel5 ) ); |
|
395 EUNIT_PRINT( _L( "ReqNotificationsTestL rvol after set:%d" ), ts.RingingVolume() ); |
|
396 iProfile->CommitChangeL(); |
|
397 EUNIT_PRINT( _L( "ReqNotificationsTestL rvol after CommitChangeL" ) ); |
|
398 MT_CSchedulerUtility::InstanceL()->Start(); |
|
399 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
400 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
401 |
|
402 iProfileObserver->iProfileId = -1; |
|
403 iProfileObserver->iError = KProEngUndefinedError; |
|
404 |
|
405 EUNIT_PRINT( _L( "ReqNotificationsTestL before vibra" ) ); |
|
406 if( ( iProfileId == EProfileOutdoorId ) || ( iProfileId == EProfilePagerId ) ) |
|
407 { |
|
408 User::LeaveIfError( ts.SetVibratingAlert( EFalse ) ); |
|
409 } |
|
410 else |
|
411 { |
|
412 User::LeaveIfError( ts.SetVibratingAlert( ETrue ) ); |
|
413 } |
|
414 EUNIT_PRINT( _L( "ReqNotificationsTestL after vibra" ) ); |
|
415 iProfile->CommitChangeL(); |
|
416 EUNIT_PRINT( _L( "ReqNotificationsTestL after vibra commit" ) ); |
|
417 MT_CSchedulerUtility::InstanceL()->Start(); |
|
418 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
419 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
420 |
|
421 iProfileObserver->iProfileId = -1; |
|
422 iProfileObserver->iError = KProEngUndefinedError; |
|
423 |
|
424 EUNIT_PRINT( _L( "ReqNotificationsTestL before warn&games" ) ); |
|
425 if( ( iProfileId == EProfileSilentId ) || ( iProfileId == EProfileMeetingId ) ) |
|
426 { |
|
427 User::LeaveIfError( ts.SetWarningAndGameTones( ETrue ) ); |
|
428 } |
|
429 else |
|
430 { |
|
431 User::LeaveIfError( ts.SetWarningAndGameTones( EFalse ) ); |
|
432 } |
|
433 EUNIT_PRINT( _L( "ReqNotificationsTestL after warn&games" ) ); |
|
434 iProfile->CommitChangeL(); |
|
435 EUNIT_PRINT( _L( "ReqNotificationsTestL after warn&games commit" ) ); |
|
436 MT_CSchedulerUtility::InstanceL()->Start(); |
|
437 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
438 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
439 |
|
440 if( ( iProfileId != EProfileOffLineId ) ) |
|
441 { |
|
442 iProfileObserver->iProfileId = -1; |
|
443 iProfileObserver->iError = KProEngUndefinedError; |
|
444 |
|
445 EUNIT_PRINT( _L( "ReqNotificationsTestL before tts" ) ); |
|
446 User::LeaveIfError( ts.SetTextToSpeech( ETrue ) ); |
|
447 EUNIT_PRINT( _L( "ReqNotificationsTestL after tts" ) ); |
|
448 iProfile->CommitChangeL(); |
|
449 EUNIT_PRINT( _L( "ReqNotificationsTestL after tts commit" ) ); |
|
450 MT_CSchedulerUtility::InstanceL()->Start(); |
|
451 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
452 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
453 |
|
454 iProfileObserver->iProfileId = -1; |
|
455 iProfileObserver->iError = KProEngUndefinedError; |
|
456 |
|
457 EUNIT_PRINT( _L( "ReqNotificationsTestL before rtone1" ) ); |
|
458 User::LeaveIfError( tones.SetRingingTone1L( KProEngMTTestTone ) ); |
|
459 EUNIT_PRINT( _L( "ReqNotificationsTestL after rtone1" ) ); |
|
460 iProfile->CommitChangeL(); |
|
461 EUNIT_PRINT( _L( "ReqNotificationsTestL after rtone1 commit" ) ); |
|
462 MT_CSchedulerUtility::InstanceL()->Start(); |
|
463 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
464 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
465 |
|
466 iProfileObserver->iProfileId = -1; |
|
467 iProfileObserver->iError = KProEngUndefinedError; |
|
468 |
|
469 EUNIT_PRINT( _L( "ReqNotificationsTestL before rtone2" ) ); |
|
470 User::LeaveIfError( tones.SetRingingTone2L( KProEngMTTestTone ) ); |
|
471 EUNIT_PRINT( _L( "ReqNotificationsTestL after rtone2" ) ); |
|
472 iProfile->CommitChangeL(); |
|
473 EUNIT_PRINT( _L( "ReqNotificationsTestL after rtone2 commit" ) ); |
|
474 iProfile->CommitChangeL(); |
|
475 MT_CSchedulerUtility::InstanceL()->Start(); |
|
476 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
477 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
478 } |
|
479 |
|
480 iProfileObserver->iProfileId = -1; |
|
481 iProfileObserver->iError = KProEngUndefinedError; |
|
482 |
|
483 EUNIT_PRINT( _L( "ReqNotificationsTestL before msgtone" ) ); |
|
484 User::LeaveIfError( tones.SetMessageAlertToneL( KProEngMTTestTone ) ); |
|
485 EUNIT_PRINT( _L( "ReqNotificationsTestL after msgtone" ) ); |
|
486 iProfile->CommitChangeL(); |
|
487 EUNIT_PRINT( _L( "ReqNotificationsTestL after msgtone commit" ) ); |
|
488 MT_CSchedulerUtility::InstanceL()->Start(); |
|
489 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
490 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
491 |
|
492 if( ( iProfileId != EProfileOffLineId ) ) |
|
493 { |
|
494 iProfileObserver->iProfileId = -1; |
|
495 iProfileObserver->iError = KProEngUndefinedError; |
|
496 |
|
497 EUNIT_PRINT( _L( "ReqNotificationsTestL before email" ) ); |
|
498 User::LeaveIfError( tones.SetEmailAlertToneL( KProEngMTTestTone ) ); |
|
499 EUNIT_PRINT( _L( "ReqNotificationsTestL after email" ) ); |
|
500 iProfile->CommitChangeL(); |
|
501 EUNIT_PRINT( _L( "ReqNotificationsTestL after email commit" ) ); |
|
502 MT_CSchedulerUtility::InstanceL()->Start(); |
|
503 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
504 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
505 |
|
506 iProfileObserver->iProfileId = -1; |
|
507 iProfileObserver->iError = KProEngUndefinedError; |
|
508 |
|
509 EUNIT_PRINT( _L( "ReqNotificationsTestL before video" ) ); |
|
510 User::LeaveIfError( tones.SetVideoCallRingingToneL( KProEngMTTestTone ) ); |
|
511 EUNIT_PRINT( _L( "ReqNotificationsTestL after video" ) ); |
|
512 iProfile->CommitChangeL(); |
|
513 EUNIT_PRINT( _L( "ReqNotificationsTestL after video commit" ) ); |
|
514 MT_CSchedulerUtility::InstanceL()->Start(); |
|
515 EUNIT_ASSERT( iProfileObserver->iProfileId == iProfileId ); |
|
516 EUNIT_ASSERT( iProfileObserver->iError == KErrNone ); |
|
517 } |
|
518 |
|
519 iHandler->CancelProfileNotifications( iProfileId ); |
|
520 } |
|
521 |
|
522 void MT_MProEngNotifyHandler::RequestProfileNameArrayNotificationsTestL( ) |
|
523 { |
|
524 EUNIT_PRINT( _L( "CMyDebugObserver::ReqNameArrayNot begin" ) ); |
|
525 TInt result( iHandler->RequestProfileNameArrayNotificationsL( |
|
526 *iNameArrayObserver ) ); |
|
527 EUNIT_PRINT( _L( "RequestNameArrayNotif result=%d" ), result ); |
|
528 EUNIT_ASSERT( result == KErrNone ); |
|
529 iNameArrayObserver->iNotified = EFalse; |
|
530 iNameArrayObserver->iError = KProEngUndefinedError; |
|
531 MProEngProfileName& name = iProfile->ProfileName(); |
|
532 const TDesC& n( name.Name() ); |
|
533 const TDesC& t( KProEngMTTestName() ); |
|
534 EUNIT_PRINT( _L( "RequestNameArrayNotif KProEngMTTestName=%S" ), &t ); |
|
535 EUNIT_PRINT( _L( "RequestNameArrayNotif name before set:%S" ), &n ); |
|
536 User::LeaveIfError( name.SetNameL( KProEngMTTestName ) ); |
|
537 const TDesC& n2( name.Name() ); |
|
538 EUNIT_PRINT( _L( "RequestNameArrayNotif name after set:%S" ), &n2 ); |
|
539 iProfile->CommitChangeL(); |
|
540 MT_CSchedulerUtility::InstanceL()->Start(); |
|
541 EUNIT_ASSERT( iNameArrayObserver->iNotified ); |
|
542 EUNIT_ASSERT( iNameArrayObserver->iError == KErrNone ); |
|
543 iHandler->CancelProfileNameArrayNotifications(); |
|
544 } |
|
545 |
|
546 void MT_MProEngNotifyHandler::CancelProfileActivationNotificationsTestL( ) |
|
547 { |
|
548 __UHEAP_MARK; |
|
549 TInt result( iHandler->RequestProfileActivationNotificationsL( |
|
550 *iActiveIdObserver ) ); |
|
551 EUNIT_ASSERT( result == KErrNone ); |
|
552 iHandler->CancelProfileActivationNotifications(); |
|
553 EUNIT_ASSERT( ETrue ); |
|
554 __UHEAP_MARKEND; |
|
555 } |
|
556 |
|
557 void MT_MProEngNotifyHandler::CancelActiveProfileNotificationsTestL( ) |
|
558 { |
|
559 __UHEAP_MARK; |
|
560 TInt result( iHandler->RequestActiveProfileNotificationsL( |
|
561 *iActiveProfileObserver ) ); |
|
562 EUNIT_ASSERT( result == KErrNone ); |
|
563 iHandler->CancelActiveProfileNotifications(); |
|
564 EUNIT_ASSERT( ETrue ); |
|
565 __UHEAP_MARKEND; |
|
566 } |
|
567 |
|
568 void MT_MProEngNotifyHandler::CancelProfileNotificationsTestL( ) |
|
569 { |
|
570 TInt result( iHandler->RequestProfileNotificationsL( |
|
571 *iProfileObserver, iProfileId ) ); |
|
572 EUNIT_ASSERT( result == KErrNone ); |
|
573 iHandler->CancelProfileNotifications( iProfileId ); |
|
574 EUNIT_ASSERT( ETrue ); |
|
575 } |
|
576 |
|
577 void MT_MProEngNotifyHandler::CancelProfileNameArrayNotificationsTestL( ) |
|
578 { |
|
579 __UHEAP_MARK; |
|
580 TInt result( iHandler->RequestProfileNameArrayNotificationsL( |
|
581 *iNameArrayObserver ) ); |
|
582 EUNIT_ASSERT( result == KErrNone ); |
|
583 iHandler->CancelProfileNameArrayNotifications(); |
|
584 EUNIT_ASSERT( ETrue ); |
|
585 __UHEAP_MARKEND; |
|
586 } |
|
587 |
|
588 void MT_MProEngNotifyHandler::CancelAllTestL( ) |
|
589 { |
|
590 TInt result( iHandler->RequestProfileActivationNotificationsL( |
|
591 *iActiveIdObserver ) ); |
|
592 EUNIT_ASSERT( result == KErrNone ); |
|
593 result = iHandler->RequestActiveProfileNotificationsL( |
|
594 *iActiveProfileObserver ); |
|
595 EUNIT_ASSERT( result == KErrNone ); |
|
596 result = iHandler->RequestProfileNotificationsL( |
|
597 *iProfileObserver, iProfileId ); |
|
598 EUNIT_ASSERT( result == KErrNone ); |
|
599 result = iHandler->RequestProfileNameArrayNotificationsL( |
|
600 *iNameArrayObserver ); |
|
601 EUNIT_ASSERT( result == KErrNone ); |
|
602 iHandler->CancelAll(); |
|
603 EUNIT_ASSERT( ETrue ); |
|
604 } |
|
605 |
|
606 CMyDebugObserver::CMyDebugObserver() |
|
607 : CActive( EPriorityStandard ) |
|
608 { |
|
609 } |
|
610 |
|
611 CMyDebugObserver::~CMyDebugObserver() |
|
612 { |
|
613 delete iRep; |
|
614 } |
|
615 |
|
616 CMyDebugObserver* CMyDebugObserver::NewL() |
|
617 { |
|
618 CMyDebugObserver* self = new ( ELeave ) CMyDebugObserver(); |
|
619 CleanupStack::PushL( self ); |
|
620 self->ConstructL(); |
|
621 CleanupStack::Pop( self ); |
|
622 return self; |
|
623 } |
|
624 |
|
625 void CMyDebugObserver::RunL() |
|
626 { |
|
627 NotifyReqL(); |
|
628 EUNIT_PRINT( _L( "CMyDebugObserver::RunL: iStatus=%u" ), iStatus.Int() ); |
|
629 } |
|
630 |
|
631 TInt CMyDebugObserver::RunError( TInt aError ) |
|
632 { |
|
633 EUNIT_PRINT( _L( "CMyDebugObserver::RunError: aError=%d" ), aError ); |
|
634 return KErrNone; |
|
635 } |
|
636 |
|
637 void CMyDebugObserver::DoCancel() |
|
638 { |
|
639 EUNIT_PRINT( _L( "Docancel: errcode=%d" ), iRep->NotifyCancel( 0x00000002, 0x40FFFFFF ) ); |
|
640 } |
|
641 |
|
642 void CMyDebugObserver::NotifyReqL() |
|
643 { |
|
644 EUNIT_PRINT( _L( "CMyDebugObserver::NotifyReqL" ) ); |
|
645 User::LeaveIfError( iRep->NotifyRequest( 0x00000002, 0x40FFFFFF, iStatus ) ); |
|
646 SetActive(); |
|
647 } |
|
648 |
|
649 void CMyDebugObserver::ConstructL() |
|
650 { |
|
651 EUNIT_PRINT( _L( "CMyDebugObserver::ConstructL" ) ); |
|
652 iRep = CRepository::NewL( KCRUidProfileEngine ); |
|
653 CActiveScheduler::Add( this ); |
|
654 } |
|
655 |
|
656 // TEST TABLE |
|
657 |
|
658 EUNIT_BEGIN_TEST_TABLE( |
|
659 MT_MProEngNotifyHandler, |
|
660 "Wrapper API Notification Handler Test cases.", |
|
661 "MODULE" ) |
|
662 |
|
663 EUNIT_TEST( |
|
664 "Request profile activation notifications - test", |
|
665 "MProEngNotifyHandler", |
|
666 "RequestProfileActivationNotificationsL", |
|
667 "FUNCTIONALITY", |
|
668 SetupRequestProfileActivationNotificationsTestL, |
|
669 RequestProfileActivationNotificationsTestL, |
|
670 TeardownRequestProfileActivationNotificationsTest) |
|
671 |
|
672 EUNIT_TEST( |
|
673 "Request active profile notifications - test", |
|
674 "MProEngNotifyHandler", |
|
675 "RequestActiveProfileNotificationsL", |
|
676 "FUNCTIONALITY", |
|
677 SetupRequestActiveProfileNotificationsTestL, |
|
678 RequestActiveProfileNotificationsTestL, |
|
679 TeardownRequestActiveProfileNotificationsTest) |
|
680 |
|
681 EUNIT_TEST( |
|
682 "Request profile(0) notifications - test", |
|
683 "MProEngNotifyHandler", |
|
684 "RequestProfileNotificationsL", |
|
685 "FUNCTIONALITY", |
|
686 SetupRequestProfileNotificationsTest0L, |
|
687 RequestProfileNotificationsTestL, |
|
688 TeardownRequestProfileNotificationsTest) |
|
689 |
|
690 EUNIT_TEST( |
|
691 "Request profile(1) notifications - test", |
|
692 "MProEngNotifyHandler", |
|
693 "RequestProfileNotificationsL", |
|
694 "FUNCTIONALITY", |
|
695 SetupRequestProfileNotificationsTest1L, |
|
696 RequestProfileNotificationsTestL, |
|
697 TeardownRequestProfileNotificationsTest) |
|
698 |
|
699 EUNIT_TEST( |
|
700 "Request name array notifications 1 - test", |
|
701 "MProEngNotifyHandler", |
|
702 "RequestProfileNameArrayNotificationsL", |
|
703 "FUNCTIONALITY", |
|
704 SetupRequestProfileNameArrayNotificationsTest1L, |
|
705 RequestProfileNameArrayNotificationsTestL, |
|
706 TeardownRequestProfileNameArrayNotificationsTest) |
|
707 |
|
708 EUNIT_TEST( |
|
709 "Request profile(2) notifications - test", |
|
710 "MProEngNotifyHandler", |
|
711 "RequestProfileNotificationsL", |
|
712 "FUNCTIONALITY", |
|
713 SetupRequestProfileNotificationsTest2L, |
|
714 RequestProfileNotificationsTestL, |
|
715 TeardownRequestProfileNotificationsTest) |
|
716 |
|
717 EUNIT_TEST( |
|
718 "Request name array notifications 2 - test", |
|
719 "MProEngNotifyHandler", |
|
720 "RequestProfileNameArrayNotificationsL", |
|
721 "FUNCTIONALITY", |
|
722 SetupRequestProfileNameArrayNotificationsTest2L, |
|
723 RequestProfileNameArrayNotificationsTestL, |
|
724 TeardownRequestProfileNameArrayNotificationsTest) |
|
725 |
|
726 EUNIT_TEST( |
|
727 "Request profile(3) notifications - test", |
|
728 "MProEngNotifyHandler", |
|
729 "RequestProfileNotificationsL", |
|
730 "FUNCTIONALITY", |
|
731 SetupRequestProfileNotificationsTest3L, |
|
732 RequestProfileNotificationsTestL, |
|
733 TeardownRequestProfileNotificationsTest) |
|
734 |
|
735 EUNIT_TEST( |
|
736 "Request name array notifications 3 - test", |
|
737 "MProEngNotifyHandler", |
|
738 "RequestProfileNameArrayNotificationsL", |
|
739 "FUNCTIONALITY", |
|
740 SetupRequestProfileNameArrayNotificationsTest3L, |
|
741 RequestProfileNameArrayNotificationsTestL, |
|
742 TeardownRequestProfileNameArrayNotificationsTest) |
|
743 |
|
744 EUNIT_TEST( |
|
745 "Request profile(4) notifications - test", |
|
746 "MProEngNotifyHandler", |
|
747 "RequestProfileNotificationsL", |
|
748 "FUNCTIONALITY", |
|
749 SetupRequestProfileNotificationsTest4L, |
|
750 RequestProfileNotificationsTestL, |
|
751 TeardownRequestProfileNotificationsTest) |
|
752 |
|
753 EUNIT_TEST( |
|
754 "Request name array notifications 4 - test", |
|
755 "MProEngNotifyHandler", |
|
756 "RequestProfileNameArrayNotificationsL", |
|
757 "FUNCTIONALITY", |
|
758 SetupRequestProfileNameArrayNotificationsTest4L, |
|
759 RequestProfileNameArrayNotificationsTestL, |
|
760 TeardownRequestProfileNameArrayNotificationsTest) |
|
761 /* |
|
762 EUNIT_TEST( |
|
763 "Request profile(5) notifications - test", |
|
764 "MProEngNotifyHandler", |
|
765 "RequestProfileNotificationsL", |
|
766 "FUNCTIONALITY", |
|
767 SetupRequestProfileNotificationsTest5L, |
|
768 RequestProfileNotificationsTestL, |
|
769 TeardownRequestProfileNotificationsTest) |
|
770 */ |
|
771 EUNIT_TEST( |
|
772 "Cancel profile activation notifications - test", |
|
773 "MProEngNotifyHandler", |
|
774 "CancelProfileActivationNotifications", |
|
775 "FUNCTIONALITY", |
|
776 SetupRequestProfileActivationNotificationsTestL, |
|
777 CancelProfileActivationNotificationsTestL, |
|
778 TeardownRequestProfileActivationNotificationsTest) |
|
779 |
|
780 EUNIT_TEST( |
|
781 "Cancel active profile notifications - test", |
|
782 "MProEngNotifyHandler", |
|
783 "CancelActiveProfileNotifications", |
|
784 "FUNCTIONALITY", |
|
785 SetupRequestActiveProfileNotificationsTestL, |
|
786 CancelActiveProfileNotificationsTestL, |
|
787 TeardownRequestActiveProfileNotificationsTest) |
|
788 |
|
789 EUNIT_TEST( |
|
790 "Cancel profile notifications - test", |
|
791 "MProEngNotifyHandler", |
|
792 "CancelProfileNotifications", |
|
793 "FUNCTIONALITY", |
|
794 SetupRequestProfileNotificationsTest0L, |
|
795 CancelProfileNotificationsTestL, |
|
796 TeardownRequestProfileNotificationsTest) |
|
797 |
|
798 EUNIT_TEST( |
|
799 "Cancen profile name array notifications - test", |
|
800 "MProEngNotifyHandler", |
|
801 "CancelProfileNameArrayNotifications", |
|
802 "FUNCTIONALITY", |
|
803 SetupRequestProfileNameArrayNotificationsTest1L, |
|
804 CancelProfileNameArrayNotificationsTestL, |
|
805 TeardownRequestProfileNameArrayNotificationsTest) |
|
806 |
|
807 EUNIT_TEST( |
|
808 "Cancel all notifications - test", |
|
809 "MProEngNotifyHandler", |
|
810 "CancelAll", |
|
811 "FUNCTIONALITY", |
|
812 SetupCancelAllTestL, |
|
813 CancelAllTestL, TeardownCancelAllTest) |
|
814 |
|
815 |
|
816 EUNIT_END_TEST_TABLE |
|
817 |
|
818 // END OF FILE |
|
819 |