|
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: Implementation of the T_ProfileTestTools. |
|
15 * |
|
16 */ |
|
17 //////////////////////////////////////////////////////////////////////// |
|
18 // T_ProfileTestTools.cpp |
|
19 // |
|
20 |
|
21 // INCLUDES |
|
22 #include "T_ProfileTestTools.h" |
|
23 |
|
24 #include <F32FILE.H> |
|
25 #include <bautils.h> |
|
26 #include <CNTITEM.H> |
|
27 #include "TProfileToneSettings.h" |
|
28 #include "MProfilesNamesArray.h" |
|
29 #include "MProfileName.h" |
|
30 #include "MProfile.h" |
|
31 #include "MProfileTones.h" |
|
32 #include "MProfileExtraTones.h" |
|
33 #include <CPbkContactEngine.h> |
|
34 #include <centralrepository.h> |
|
35 #include <ProfileEngineSDKCRKeys.h> |
|
36 #include <HWRMVibraSDKCRKeys.h> |
|
37 #include "ProfileEnginePrivateCRKeys.h" |
|
38 #include <CPbkContactItem.h> |
|
39 #include <MProEngProfile.h> |
|
40 #include <MProEngProfileName.h> |
|
41 #include <MProEngProfileNameArray.h> |
|
42 #include <MProEngTones.h> |
|
43 #include <MProEngToneSettings.h> |
|
44 #include <EUnitMacros.h> |
|
45 |
|
46 TBool T_ProfileTestTools::CompareArrays( const TArray<TContactItemId>& aArray1, const TArray<TContactItemId>& aArray2 ) |
|
47 { |
|
48 TInt count = aArray1.Count(); |
|
49 if( count != aArray2.Count() ) |
|
50 { |
|
51 return EFalse; |
|
52 } |
|
53 for( TInt i = 0 ; i < count ; ++i ) |
|
54 { |
|
55 if( aArray1[i] != aArray2[i] ) return EFalse; |
|
56 } |
|
57 return ETrue; |
|
58 } |
|
59 |
|
60 TBool T_ProfileTestTools::CompareNameArrays( |
|
61 const MProEngProfileNameArray& aArray1, |
|
62 const MProfilesNamesArray& aArray2 ) |
|
63 { |
|
64 TInt count1( aArray1.MdcaCount() ); |
|
65 TInt count2( aArray2.MdcaCount() ); |
|
66 if( count1 != count2 ) |
|
67 { |
|
68 return EFalse; |
|
69 } |
|
70 for( TInt i(0); i<count1; ++i ) |
|
71 { |
|
72 if( aArray1.MdcaPoint( i ).Compare( aArray2.MdcaPoint( i ) ) != 0 ) |
|
73 { |
|
74 return EFalse; |
|
75 } |
|
76 } |
|
77 return ETrue; |
|
78 } |
|
79 |
|
80 TBool T_ProfileTestTools::CompareProfiles( MProEngProfile& ap1, MProfile& ap2 ) |
|
81 { |
|
82 EUNIT_PRINT( _L( "CompareProfiles 1" ) ); |
|
83 MProEngProfileName& pn1( ap1.ProfileName() ); |
|
84 const MProfileName& pn2( ap2.ProfileName() ); |
|
85 EUNIT_PRINT( _L( "CompareProfiles id1=%d, id2=%d" ), pn1.Id(), pn2.Id() ); |
|
86 if( pn1.Id() != pn2.Id() ) |
|
87 { |
|
88 return EFalse; |
|
89 } |
|
90 EUNIT_PRINT( _L( "CompareProfiles 2" ) ); |
|
91 if( pn1.Name().Compare( pn2.Name() ) != 0 ) |
|
92 { |
|
93 return EFalse; |
|
94 } |
|
95 EUNIT_PRINT( _L( "CompareProfiles 3" ) ); |
|
96 MProEngTones& pt1( ap1.ProfileTones() ); |
|
97 MProEngToneSettings& pts1( ap1.ToneSettings() ); |
|
98 const MProfileTones& pt2( ap2.ProfileTones() ); |
|
99 const MProfileExtraTones& pet2( ap2.ProfileExtraTones() ); |
|
100 const TProfileToneSettings& pts2( pt2.ToneSettings() ); |
|
101 |
|
102 if( pt1.RingingTone1().Compare( pt2.RingingTone1() ) != 0 ) |
|
103 { |
|
104 return EFalse; |
|
105 } |
|
106 EUNIT_PRINT( _L( "CompareProfiles 4" ) ); |
|
107 if( pt1.RingingTone2().Compare( pt2.RingingTone2() ) != 0 ) |
|
108 { |
|
109 return EFalse; |
|
110 } |
|
111 const TDesC& msgTone1( pt1.MessageAlertTone() ); |
|
112 const TDesC& msgTone2( pt2.MessageAlertTone() ); |
|
113 EUNIT_PRINT( _L( "CompareProfiles 5 msgt1=%S, msgt2=%S" ), &msgTone1, &msgTone2 ); |
|
114 if( pt1.MessageAlertTone().Compare( pt2.MessageAlertTone() ) != 0 ) |
|
115 { |
|
116 return EFalse; |
|
117 } |
|
118 EUNIT_PRINT( _L( "CompareProfiles 6" ) ); |
|
119 if( pt1.EmailAlertTone().Compare( pet2.EmailAlertTone() ) != 0 ) |
|
120 { |
|
121 return EFalse; |
|
122 } |
|
123 EUNIT_PRINT( _L( "CompareProfiles 7" ) ); |
|
124 if( pt1.VideoCallRingingTone().Compare( pet2.VideoCallRingingTone() ) != 0 ) |
|
125 { |
|
126 return EFalse; |
|
127 } |
|
128 EUNIT_PRINT( _L( "CompareProfiles 8" ) ); |
|
129 if( pts1.RingingType() != pts2.iRingingType ) |
|
130 { |
|
131 return EFalse; |
|
132 } |
|
133 EUNIT_PRINT( _L( "CompareProfiles 9" ) ); |
|
134 if( pts1.KeypadVolume() != pts2.iKeypadVolume ) |
|
135 { |
|
136 return EFalse; |
|
137 } |
|
138 EUNIT_PRINT( _L( "CompareProfiles 10" ) ); |
|
139 if( pts1.RingingVolume() != pts2.iRingingVolume ) |
|
140 { |
|
141 return EFalse; |
|
142 } |
|
143 EUNIT_PRINT( _L( "CompareProfiles 11" ) ); |
|
144 if( pts1.VibratingAlert() != pts2.iVibratingAlert ) |
|
145 { |
|
146 return EFalse; |
|
147 } |
|
148 EUNIT_PRINT( _L( "CompareProfiles 12" ) ); |
|
149 if( pts1.WarningAndGameTones() != pts2.iWarningAndGameTones ) |
|
150 { |
|
151 return EFalse; |
|
152 } |
|
153 EUNIT_PRINT( _L( "CompareProfiles 13" ) ); |
|
154 if( pts1.TextToSpeech() != pts2.iTextToSpeech ) |
|
155 { |
|
156 return EFalse; |
|
157 } |
|
158 EUNIT_PRINT( _L( "CompareProfiles 14" ) ); |
|
159 const TArray<TContactItemId> cids1( ap1.AlertForL() ); |
|
160 const TArray<TContactItemId> cids2( ap2.AlertForL() ); |
|
161 TBool result( CompareArrays( cids1, cids2 ) ); |
|
162 EUNIT_PRINT( _L( "CompareProfiles 15 result=%d" ), result ); |
|
163 return result; |
|
164 } |
|
165 |
|
166 TBool T_ProfileTestTools::CheckArray( const MProfilesNamesArray& aArray ) |
|
167 { |
|
168 TInt count = aArray.MdcaCount(); |
|
169 TInt correctCount( 5 ); |
|
170 #ifdef __OFFLINE_MODE |
|
171 ++correctCount; |
|
172 #endif |
|
173 #ifdef __DRIVE_MODE |
|
174 ++correctCount; |
|
175 #endif |
|
176 if( count != correctCount ) |
|
177 { |
|
178 return EFalse; |
|
179 } |
|
180 for( TInt i = 0 ; i < count ; ++i ) |
|
181 { |
|
182 const MProfileName* pn = aArray.ProfileName( i ); |
|
183 if( !pn ) |
|
184 { |
|
185 return EFalse; |
|
186 } |
|
187 if( pn->Name().Compare( T_ProfileTestTools::ProfileName( i ) ) != 0 || |
|
188 pn->Id() != i ) |
|
189 { |
|
190 return EFalse; |
|
191 } |
|
192 } |
|
193 return ETrue; |
|
194 } |
|
195 |
|
196 |
|
197 const TDesC& T_ProfileTestTools::ProfileName( TInt aId ) |
|
198 { |
|
199 switch( aId ) |
|
200 { |
|
201 case 2: |
|
202 { |
|
203 return KProfileMeetingName; |
|
204 } |
|
205 case 1: |
|
206 { |
|
207 return KProfileSilentName; |
|
208 } |
|
209 case 3: |
|
210 { |
|
211 return KProfileOutdoorName; |
|
212 } |
|
213 case 4: |
|
214 { |
|
215 return KProfilePagerName; |
|
216 } |
|
217 #ifdef __OFFLINE_MODE |
|
218 case 5: |
|
219 { |
|
220 return KProfileOfflineName; |
|
221 } |
|
222 #endif |
|
223 #ifdef __DRIVE_MODE |
|
224 case 6: |
|
225 { |
|
226 return KProfileDriveName; |
|
227 } |
|
228 #endif |
|
229 case 0: |
|
230 default: |
|
231 { |
|
232 return KProfileGeneralName; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 const TDesC& T_ProfileTestTools::ProfileMessageAlertTone( TInt aId ) |
|
238 { |
|
239 switch( aId ) |
|
240 { |
|
241 case 2: |
|
242 { |
|
243 return KProfileBeepTwice; |
|
244 } |
|
245 case 1: |
|
246 { |
|
247 return KProfileNoSound; |
|
248 } |
|
249 case 3: |
|
250 case 4: |
|
251 case 0: |
|
252 default: |
|
253 { |
|
254 return KProfileMessageTone; |
|
255 } |
|
256 } |
|
257 } |
|
258 |
|
259 const TDesC& T_ProfileTestTools::ProfileRingingTone( TInt aId ) |
|
260 { |
|
261 switch( aId ) |
|
262 { |
|
263 case 2: |
|
264 { |
|
265 return KProfileBeep; |
|
266 } |
|
267 case 1: |
|
268 case 3: |
|
269 case 4: |
|
270 case 0: |
|
271 default: |
|
272 { |
|
273 return KProfileNokiaTune; |
|
274 } |
|
275 } |
|
276 } |
|
277 |
|
278 const TDesC& T_ProfileTestTools::ProfileIMMessageAlertTone( TInt aId ) |
|
279 { |
|
280 switch( aId ) |
|
281 { |
|
282 case 1: |
|
283 { |
|
284 return KProfileNoSound; |
|
285 } |
|
286 case 2: |
|
287 { |
|
288 return KProfileBeepTwice; |
|
289 } |
|
290 case 3: |
|
291 case 4: |
|
292 case 0: |
|
293 default: |
|
294 { |
|
295 return KProfileIMMessageTone; |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 const TDesC& T_ProfileTestTools::ProfileEmailAlertTone( TInt aId ) |
|
301 { |
|
302 switch( aId ) |
|
303 { |
|
304 case 1: |
|
305 { |
|
306 return KProfileNoSound; |
|
307 } |
|
308 case 2: |
|
309 { |
|
310 return KProfileBeepTwice; |
|
311 } |
|
312 case 3: |
|
313 case 4: |
|
314 case 0: |
|
315 default: |
|
316 { |
|
317 return KProfileMessageTone; |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 const TDesC& T_ProfileTestTools::ProfileVideoCallRingingTone( TInt /* aId */ ) |
|
323 { |
|
324 return KProfileNokiaTune; |
|
325 } |
|
326 |
|
327 TBool T_ProfileTestTools::CheckToneSettings( TInt aId, const TProfileToneSettings& aSettings ) |
|
328 { |
|
329 switch( aId ) |
|
330 { |
|
331 case 1: |
|
332 { |
|
333 if ( aSettings.iRingingType == EProfileRingingTypeSilent && |
|
334 aSettings.iKeypadVolume == EProfileKeypadVolumeOff && |
|
335 aSettings.iRingingVolume == 1 && |
|
336 !( aSettings.iVibratingAlert ) && |
|
337 !( aSettings.iWarningAndGameTones ) ) |
|
338 { |
|
339 return ETrue; |
|
340 } |
|
341 else |
|
342 return EFalse; |
|
343 } |
|
344 case 2: |
|
345 { |
|
346 if ( aSettings.iRingingType == EProfileRingingTypeBeepOnce && |
|
347 aSettings.iKeypadVolume == EProfileKeypadVolumeOff && |
|
348 aSettings.iRingingVolume == 1 && |
|
349 !( aSettings.iVibratingAlert ) && |
|
350 !( aSettings.iWarningAndGameTones ) ) |
|
351 { |
|
352 return ETrue; |
|
353 } |
|
354 else |
|
355 return EFalse; |
|
356 } |
|
357 case 3: |
|
358 { |
|
359 if ( aSettings.iRingingType == EProfileRingingTypeRinging && |
|
360 aSettings.iKeypadVolume == EProfileKeypadVolumeLevel3 && |
|
361 aSettings.iRingingVolume == 10 && |
|
362 aSettings.iVibratingAlert && |
|
363 aSettings.iWarningAndGameTones ) |
|
364 { |
|
365 return ETrue; |
|
366 } |
|
367 else |
|
368 return EFalse; |
|
369 } |
|
370 case 4: |
|
371 { |
|
372 if ( aSettings.iRingingType == EProfileRingingTypeSilent && |
|
373 aSettings.iKeypadVolume == EProfileKeypadVolumeLevel2 && |
|
374 aSettings.iRingingVolume == 7 && |
|
375 aSettings.iVibratingAlert && |
|
376 aSettings.iWarningAndGameTones ) |
|
377 { |
|
378 return ETrue; |
|
379 } |
|
380 else |
|
381 return EFalse; |
|
382 } |
|
383 case 0: |
|
384 default: |
|
385 { |
|
386 if ( aSettings.iRingingType == EProfileRingingTypeRinging && |
|
387 aSettings.iKeypadVolume == EProfileKeypadVolumeLevel2 && |
|
388 aSettings.iRingingVolume == 7 && |
|
389 !( aSettings.iVibratingAlert ) && |
|
390 aSettings.iWarningAndGameTones ) |
|
391 { |
|
392 return ETrue; |
|
393 } |
|
394 else |
|
395 return EFalse; |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 void T_ProfileTestTools::CreateContactGroupsL( TInt aNumber, RArray<TContactItemId>& aArray, CPbkContactEngine& aContactEngine ) |
|
401 { |
|
402 for( TInt i = 0 ; i < aNumber ; ++i ) |
|
403 { |
|
404 CContactGroup* tmp = aContactEngine.CreateContactGroupL( _L( "ProfileTestGroup" ) ); |
|
405 CleanupStack::PushL( tmp ); |
|
406 User::LeaveIfError( aArray.Append( tmp->Id() ) ); |
|
407 CleanupStack::PopAndDestroy(); // tmp; |
|
408 } |
|
409 } |
|
410 |
|
411 void T_ProfileTestTools::DeleteContactGroups( RArray<TContactItemId>& aArray, CPbkContactEngine& aContactEngine ) |
|
412 { |
|
413 TInt count = aArray.Count(); |
|
414 for( TInt i = 0 ; i < count ; ++i ) |
|
415 { |
|
416 TRAP_IGNORE( aContactEngine.DeleteContactGroupL( aArray[i] ) ); |
|
417 } |
|
418 } |
|
419 |
|
420 void T_ProfileTestTools::CreateContactsL( TInt aNumber, RArray<TContactItemId>& aArray, CPbkContactEngine& aContactEngine ) |
|
421 { |
|
422 for( TInt i = 0 ; i < aNumber ; ++i ) |
|
423 { |
|
424 CPbkContactItem* tmp = aContactEngine.CreateEmptyContactL(); |
|
425 CleanupStack::PushL( tmp ); |
|
426 aContactEngine.AddNewContactL( *tmp ); |
|
427 User::LeaveIfError( aArray.Append( tmp->Id() ) ); |
|
428 CleanupStack::PopAndDestroy(); // tmp; |
|
429 } |
|
430 } |
|
431 |
|
432 void T_ProfileTestTools::DeleteContacts( RArray<TContactItemId>& aArray, CPbkContactEngine& aContactEngine ) |
|
433 { |
|
434 TInt count = aArray.Count(); |
|
435 for( TInt i = 0 ; i < count ; ++i ) |
|
436 { |
|
437 TRAP_IGNORE( aContactEngine.DeleteContactL( aArray[i] ) ); |
|
438 } |
|
439 } |
|
440 |
|
441 void T_ProfileTestTools::WriteAlertForIdsToCenrepL( TInt aProfileId, RArray<TContactItemId>& aArray ) |
|
442 { |
|
443 CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
444 CleanupStack::PushL( cenrep ); |
|
445 TBuf8< 40 > alertForBuf; // max 10 ids |
|
446 TInt count( aArray.Count() ); |
|
447 for( TInt i( 0 ) ; i < count ; ++i ) |
|
448 { |
|
449 TContactItemId id( aArray[i] ); |
|
450 TUint8 pieceOfId( ( aArray[i] >> 24 ) & 0x000000FF ); |
|
451 alertForBuf.Append( pieceOfId ); |
|
452 pieceOfId = ( aArray[i] >> 16 & 0x000000FF ); |
|
453 alertForBuf.Append( pieceOfId ); |
|
454 pieceOfId = ( aArray[i] >> 8 & 0x000000FF ); |
|
455 alertForBuf.Append( pieceOfId ); |
|
456 pieceOfId = ( aArray[i] & 0x000000FF ); |
|
457 alertForBuf.Append( pieceOfId ); |
|
458 } |
|
459 User::LeaveIfError( |
|
460 cenrep->Set( ( aProfileId << 24 ) | KProEngAlertForGroups, |
|
461 alertForBuf ) ); |
|
462 |
|
463 CleanupStack::PopAndDestroy(); // cenrep |
|
464 } |
|
465 |
|
466 void T_ProfileTestTools::DeleteAlertForIdsFromCenrep( TInt aProfileId ) |
|
467 { |
|
468 TRAP_IGNORE( |
|
469 CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
470 TBuf8< 1 > alertForBuf; |
|
471 alertForBuf.Zero(); |
|
472 |
|
473 cenrep->Set( ( aProfileId << 24 ) | KProEngAlertForGroups, |
|
474 alertForBuf ); |
|
475 |
|
476 delete cenrep; |
|
477 ); |
|
478 } |
|
479 |
|
480 void T_ProfileTestTools::ResetRepository() |
|
481 { |
|
482 TRAP_IGNORE( |
|
483 CRepository* cr = CRepository::NewL( KCRUidProfileEngine ); |
|
484 cr->Reset(); |
|
485 delete cr; |
|
486 ); |
|
487 } |
|
488 |
|
489 TBool T_ProfileTestTools::IsCenrepFeatureEnabledL( TUid aUid, TUint32 aKey ) |
|
490 { |
|
491 CRepository* cenrep = CRepository::NewLC( aUid ); |
|
492 TInt value( 0 ); |
|
493 User::LeaveIfError( cenrep->Get( aKey, value ) ); |
|
494 CleanupStack::PopAndDestroy( cenrep ); |
|
495 return value; |
|
496 } |
|
497 |
|
498 // End of File |