|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <e32property.h> |
|
18 |
|
19 #include "te_cntsyncbase.h" |
|
20 #include "te_cntsyncstress.h" |
|
21 |
|
22 #ifdef SYMBIAN_CNTMODEL_V2 |
|
23 _LIT(KContactsDBFile, "C:\\Private\\10003A73\\CONTACTS.CDB"); |
|
24 _LIT(KContactsDBFileBackup, "C:\\Private\\10003A73\\CONTACTS.BAK"); |
|
25 _LIT(KContactsSqliteDBFile, "C:\\Private\\10003A73\\SQLite__CONTACTS.CDB"); |
|
26 _LIT(KContactsSqliteDBFileBackup, "C:\\Private\\10003A73\\SQLite__CONTACTS.BAK"); |
|
27 #else |
|
28 _LIT(KContactsDBFile, "C:\\Private\\100012A5\\DBS_100065FF_CONTACTS.CDB"); |
|
29 _LIT(KContactsDBFileBackup, "C:\\Private\\100012A5\\DBS_100065FF_CONTACTS.BAK"); |
|
30 #endif // SYMBIAN_CNTMODEL_V2 |
|
31 _LIT(KContactsModelIniFile, "C:\\Private\\10003A73\\CntModel.ini"); |
|
32 _LIT(KPhbkSyncIniFile,"C:\\Private\\102030A1\\Phbksync.ini"); |
|
33 _LIT(KPhbkSyncIniFileBackup, "C:\\Private\\102030A1\\Phbksync.bak"); |
|
34 |
|
35 |
|
36 /** |
|
37 * Factory construction method. |
|
38 * @return Pointer to CPhbkRequestDoSyncSimultaneouslyTest object |
|
39 */ |
|
40 CPhbkRequestDoSyncSimultaneouslyTest* CPhbkRequestDoSyncSimultaneouslyTest::NewL() |
|
41 { |
|
42 CPhbkRequestDoSyncSimultaneouslyTest* self = new(ELeave) CPhbkRequestDoSyncSimultaneouslyTest(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 /** |
|
47 * Default constructor. Each test step initialises it's own name. |
|
48 */ |
|
49 CPhbkRequestDoSyncSimultaneouslyTest::CPhbkRequestDoSyncSimultaneouslyTest() |
|
50 { |
|
51 SetTestStepName(_L("RequestDoSyncSimultaneouslyTest")); |
|
52 } |
|
53 |
|
54 /** |
|
55 * Request two simultaneous synchronisations. |
|
56 * Two threads try to do a Synchronisation at once. |
|
57 */ |
|
58 enum TVerdict CPhbkRequestDoSyncSimultaneouslyTest::doTestStepL() |
|
59 { |
|
60 const TInt KStackSize=0x8000; |
|
61 const TInt KHeapSize=0x8000; |
|
62 const TInt KMaxHeapSize=0x80000; |
|
63 |
|
64 _LIT(KThreadName1,"Thread1"); |
|
65 _LIT(KThreadName2,"Thread2"); |
|
66 |
|
67 RThread t1; |
|
68 RThread t2; |
|
69 |
|
70 // Create the thread |
|
71 User::LeaveIfError(t1.Create(KThreadName1,DoSyncThread,KStackSize,KHeapSize,KMaxHeapSize,NULL)); |
|
72 User::LeaveIfError(t2.Create(KThreadName2,DoSyncThread,KStackSize,KHeapSize,KMaxHeapSize,NULL)); |
|
73 |
|
74 TRequestStatus reqStatus1; |
|
75 TRequestStatus reqStatus2; |
|
76 TBool req1Complete(EFalse); |
|
77 TBool req2Complete(EFalse); |
|
78 |
|
79 t1.Logon(reqStatus1); // Notify when the thread dies |
|
80 t2.Logon(reqStatus2); |
|
81 t1.Resume(); // Start the threads |
|
82 t2.Resume(); |
|
83 User::WaitForRequest(reqStatus1); // Avoid using User::WaitForAnyRequest() |
|
84 User::WaitForRequest(reqStatus2); |
|
85 |
|
86 while(req1Complete==EFalse || req2Complete==EFalse) |
|
87 { |
|
88 if (reqStatus1 != KRequestPending && req1Complete==EFalse) // Thread1 request completed |
|
89 { |
|
90 TESTCHECK(reqStatus1.Int(), KErrNone); |
|
91 req1Complete=ETrue; |
|
92 } |
|
93 |
|
94 if (reqStatus2 != KRequestPending && req2Complete==EFalse) // Thread2 request rejected |
|
95 { |
|
96 TESTCHECK(reqStatus2.Int(), KErrNone); |
|
97 req2Complete=ETrue; |
|
98 } |
|
99 } |
|
100 |
|
101 t1.Close(); |
|
102 t2.Close(); |
|
103 |
|
104 return TestStepResult(); |
|
105 } |
|
106 |
|
107 /** |
|
108 * Control passes to this function when the thread is first resumed, |
|
109 * i.e. when the thread is initially scheduled to run. |
|
110 */ |
|
111 TInt CPhbkIntegrationStressTestBase::DoSyncThread(TAny* /*aPtr*/) |
|
112 { |
|
113 CActiveScheduler* scheduler = new CActiveScheduler; |
|
114 if(!scheduler) |
|
115 return KErrNoMemory; |
|
116 CActiveScheduler::Install(scheduler); |
|
117 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
118 TRAP_IGNORE(DoSyncThreadL()); |
|
119 delete cleanup; |
|
120 delete CActiveScheduler::Current(); |
|
121 return KErrNone; |
|
122 } |
|
123 |
|
124 /** |
|
125 * |
|
126 */ |
|
127 void CPhbkIntegrationStressTestBase::DoSyncThreadL() |
|
128 { |
|
129 RPhoneBookSession session; |
|
130 User::LeaveIfError(session.Connect()); // Connect to the Phonebook Server |
|
131 TRequestStatus status; |
|
132 |
|
133 // Attempt synchronisation for each phonebook |
|
134 // Global ADN |
|
135 session.DoSynchronisation(status); |
|
136 User::WaitForRequest(status); |
|
137 __ASSERT_ALWAYS((status.Int()==KErrNone) || (status.Int()==KErrInUse), User::Invariant()); |
|
138 |
|
139 |
|
140 // Global SDN |
|
141 session.DoSynchronisation(status, KUidIccGlobalSdnPhonebook); |
|
142 User::WaitForRequest(status); |
|
143 __ASSERT_ALWAYS((status.Int()==KErrNone) || (status.Int()==KErrInUse), User::Invariant()); |
|
144 |
|
145 // Global LND |
|
146 session.DoSynchronisation(status, KUidIccGlobalLndPhonebook); |
|
147 User::WaitForRequest(status); |
|
148 __ASSERT_ALWAYS((status.Int()==KErrNone) || (status.Int()==KErrInUse), User::Invariant()); |
|
149 |
|
150 // USIM App |
|
151 session.DoSynchronisation(status, KUidUsimAppAdnPhonebook); |
|
152 User::WaitForRequest(status); |
|
153 __ASSERT_ALWAYS((status.Int()==KErrNone) || (status.Int()==KErrInUse), User::Invariant()); |
|
154 |
|
155 |
|
156 // Global FDN |
|
157 session.DoSynchronisation(status, KUidIccGlobalFdnPhonebook); |
|
158 User::WaitForRequest(status); |
|
159 __ASSERT_ALWAYS((status.Int()==KErrNone) || (status.Int()==KErrInUse), User::Invariant()); |
|
160 } |
|
161 |
|
162 /** |
|
163 * Factory construction method. |
|
164 * @return Pointer to CPhbkLaunchServerSimultaneouslyTest object |
|
165 */ |
|
166 CPhbkLaunchServerSimultaneouslyTest* CPhbkLaunchServerSimultaneouslyTest::NewL() |
|
167 { |
|
168 CPhbkLaunchServerSimultaneouslyTest* self = new(ELeave) CPhbkLaunchServerSimultaneouslyTest(); |
|
169 return self; |
|
170 } |
|
171 |
|
172 /** |
|
173 * Default constructor. Each test step initialises it's own name. |
|
174 */ |
|
175 CPhbkLaunchServerSimultaneouslyTest::CPhbkLaunchServerSimultaneouslyTest() |
|
176 { |
|
177 SetTestStepName(_L("LaunchServerSimultaneouslyTest")); |
|
178 } |
|
179 |
|
180 /** |
|
181 * Create two threads which simultaneously attempt to connect to the Phonebook Server. |
|
182 */ |
|
183 enum TVerdict CPhbkLaunchServerSimultaneouslyTest::doTestStepL() |
|
184 { |
|
185 SetSimTsyTestNumberL(9); |
|
186 |
|
187 RThread thread1; |
|
188 RThread thread2; |
|
189 // Create the threads |
|
190 User::LeaveIfError(thread1.Create(_L("Thread1"), ServerLaunchThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
191 User::LeaveIfError(thread2.Create(_L("Thread2"), ServerLaunchThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
192 thread1.Resume(); // Start the threads |
|
193 thread2.Resume(); |
|
194 User::After(5000000); |
|
195 thread1.Close(); |
|
196 thread2.Close(); |
|
197 |
|
198 return TestStepResult(); |
|
199 } |
|
200 |
|
201 |
|
202 /** |
|
203 * Phonebook Server Launch thread function. |
|
204 */ |
|
205 TInt CPhbkIntegrationStressTestBase::ServerLaunchThread(TAny* /*aAny*/) |
|
206 { |
|
207 CActiveScheduler* scheduler = new CActiveScheduler; |
|
208 if(!scheduler) |
|
209 return KErrNoMemory; |
|
210 |
|
211 CActiveScheduler::Install(scheduler); |
|
212 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
213 CContactDatabase* db =NULL; |
|
214 TRAPD(err, db = CContactDatabase::OpenL()); |
|
215 __ASSERT_DEBUG(err==KErrNone,User::Invariant()); |
|
216 TRAP(err, CheckServerThreadCountL(1)); |
|
217 __ASSERT_DEBUG(err==KErrNone,User::Invariant()); |
|
218 delete db; |
|
219 delete cleanup; |
|
220 delete CActiveScheduler::Current(); |
|
221 return KErrNone; |
|
222 } |
|
223 |
|
224 /** |
|
225 * Checks the server thread count. |
|
226 */ |
|
227 void CPhbkIntegrationStressTestBase::CheckServerThreadCountL(TInt aExpectedCount) |
|
228 { |
|
229 TFullName name; |
|
230 TInt count=0; |
|
231 _LIT(KThreadToFind,"*PhBkSyncServer*"); // PHBKSYNC_SVR_NAME |
|
232 TFindThread find(KThreadToFind); |
|
233 |
|
234 RThread candidate; |
|
235 while(find.Next(name)==KErrNone) |
|
236 { |
|
237 // If the thread still lives, increase count. |
|
238 if(candidate.Open(name)==KErrNone) |
|
239 { |
|
240 const TExitCategoryName& category = candidate.ExitCategory(); |
|
241 |
|
242 RDebug::Print(_L("[%x] CheckServerThreadCount thread: %x -----"), (TUint)RThread().Id(), (TUint)candidate.Id()); |
|
243 RDebug::Print(_L("[%x] Thread %x ExitCategory %S"), (TUint)RThread().Id(), (TUint)candidate.Id(), &category); |
|
244 RDebug::Print(_L("[%x] Thread %x ExitReason %d"), (TUint)RThread().Id(), (TUint)candidate.Id(), candidate.ExitReason()); |
|
245 RDebug::Print(_L("[%x] Thread %x ExitType %d"), (TUint)RThread().Id(), (TUint)candidate.Id(), candidate.ExitType()); |
|
246 |
|
247 // If the thread has an ExitCategory, it is dead and not worthy of counting |
|
248 if(category.Length()==0) |
|
249 { |
|
250 count++; |
|
251 } |
|
252 |
|
253 candidate.Close(); |
|
254 } |
|
255 } |
|
256 |
|
257 __ASSERT_ALWAYS(count==aExpectedCount, User::Invariant()); |
|
258 } |
|
259 |
|
260 |
|
261 /** |
|
262 * Factory construction method. |
|
263 * @return Pointer to CPhbkRequestReadSimultaneouslyTest object |
|
264 */ |
|
265 CPhbkRequestReadSimultaneouslyTest* CPhbkRequestReadSimultaneouslyTest::NewL() |
|
266 { |
|
267 CPhbkRequestReadSimultaneouslyTest* self = new(ELeave) CPhbkRequestReadSimultaneouslyTest(); |
|
268 return self; |
|
269 } |
|
270 |
|
271 /** |
|
272 * Default constructor. Each test step initialises it's own name. |
|
273 */ |
|
274 CPhbkRequestReadSimultaneouslyTest::CPhbkRequestReadSimultaneouslyTest() |
|
275 { |
|
276 SetTestStepName(_L("RequestReadSimultaneouslyTest")); |
|
277 } |
|
278 |
|
279 /** |
|
280 * Create three threads which simultaneously attempt to request Read from |
|
281 * the Phonebook Server. |
|
282 */ |
|
283 enum TVerdict CPhbkRequestReadSimultaneouslyTest::doTestStepL() |
|
284 { |
|
285 RThread thread1; |
|
286 RThread thread2; |
|
287 RThread thread3; |
|
288 // Create the threads |
|
289 User::LeaveIfError(thread1.Create(_L("ThreadA"), MultipleReadThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
290 User::LeaveIfError(thread2.Create(_L("ThreadB"), MultipleReadThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
291 User::LeaveIfError(thread3.Create(_L("ThreadC"), MultipleReadThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
292 |
|
293 TRequestStatus reqStatus1; |
|
294 TRequestStatus reqStatus2; |
|
295 TRequestStatus reqStatus3; |
|
296 |
|
297 thread1.Logon(reqStatus1); // Notify when the thread dies |
|
298 thread2.Logon(reqStatus2); |
|
299 thread3.Logon(reqStatus3); |
|
300 thread1.Resume(); // Start the thread |
|
301 thread2.Resume(); |
|
302 thread3.Resume(); |
|
303 User::WaitForRequest(reqStatus1); // Avoid using User::WaitForAnyRequest() |
|
304 User::WaitForRequest(reqStatus2); |
|
305 User::WaitForRequest(reqStatus3); |
|
306 |
|
307 TBool req1Complete(EFalse); |
|
308 TBool req2Complete(EFalse); |
|
309 TBool req3Complete(EFalse); |
|
310 |
|
311 while(req1Complete==EFalse || req2Complete==EFalse || req3Complete==EFalse) |
|
312 { |
|
313 if (reqStatus1 != KRequestPending && req1Complete==EFalse) // Thread1 request completed |
|
314 { |
|
315 TESTCHECK(reqStatus1.Int(), KErrNone); |
|
316 req1Complete=ETrue; |
|
317 } |
|
318 |
|
319 if (reqStatus2 != KRequestPending && req2Complete==EFalse) // Thread2 request rejected |
|
320 { |
|
321 TESTCHECK(reqStatus2.Int(), KErrNone); |
|
322 req2Complete=ETrue; |
|
323 } |
|
324 |
|
325 if (reqStatus3 != KRequestPending && req3Complete==EFalse) // Thread3 request rejected |
|
326 { |
|
327 TESTCHECK(reqStatus3.Int(), KErrNone); |
|
328 req3Complete=ETrue; |
|
329 } |
|
330 } |
|
331 |
|
332 // User::After(5000000); |
|
333 thread1.Close(); |
|
334 thread2.Close(); |
|
335 thread3.Close(); |
|
336 |
|
337 return TestStepResult(); |
|
338 } |
|
339 |
|
340 /** |
|
341 * Send Read request to the Phonebook server. |
|
342 */ |
|
343 TInt CPhbkIntegrationStressTestBase::MultipleReadThread(TAny* /*aAny*/) |
|
344 { |
|
345 CActiveScheduler* scheduler = new CActiveScheduler; |
|
346 if(!scheduler) |
|
347 return KErrNoMemory; |
|
348 CActiveScheduler::Install(scheduler); |
|
349 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
350 TRAP_IGNORE(MultipleReadThreadL()); |
|
351 delete cleanup; |
|
352 delete CActiveScheduler::Current(); |
|
353 return KErrNone; |
|
354 } |
|
355 |
|
356 /** |
|
357 * |
|
358 */ |
|
359 void CPhbkIntegrationStressTestBase::MultipleReadThreadL() |
|
360 { |
|
361 CPhbkIntegrationTestUtility* access = CPhbkIntegrationTestUtility::NewL(); |
|
362 CleanupStack::PushL(access); |
|
363 access->ReadContactL(KUidIccGlobalAdnPhonebook, KTest9ICCSlotsADN); |
|
364 access->ReadContactL(KUidIccGlobalSdnPhonebook, KTest9ICCSlotsSDN); |
|
365 access->ReadContactL(KUidIccGlobalLndPhonebook, KTest9ICCSlotsLND); |
|
366 access->ReadContactL(KUidUsimAppAdnPhonebook, KTest9ICCSlotsUsim); |
|
367 |
|
368 CleanupStack::PopAndDestroy(access); |
|
369 } |
|
370 |
|
371 |
|
372 /** |
|
373 * Factory construction method. |
|
374 * @return Pointer to CPhbkRequestWriteSimultaneouslyTest object |
|
375 */ |
|
376 CPhbkRequestWriteSimultaneouslyTest* CPhbkRequestWriteSimultaneouslyTest::NewL() |
|
377 { |
|
378 CPhbkRequestWriteSimultaneouslyTest* self = new(ELeave) CPhbkRequestWriteSimultaneouslyTest(); |
|
379 return self; |
|
380 } |
|
381 |
|
382 /** |
|
383 * Default constructor. Each test step initialises it's own name. |
|
384 */ |
|
385 CPhbkRequestWriteSimultaneouslyTest::CPhbkRequestWriteSimultaneouslyTest() |
|
386 { |
|
387 SetTestStepName(_L("RequestWriteSimultaneouslyTest")); |
|
388 } |
|
389 |
|
390 /** |
|
391 * Create three threads which simultaneously attempt to request Write from |
|
392 * the Phonebook Server. |
|
393 */ |
|
394 enum TVerdict CPhbkRequestWriteSimultaneouslyTest::doTestStepL() |
|
395 { |
|
396 SetSimTsyTestNumberL(1); |
|
397 DoSyncL(); |
|
398 |
|
399 RThread thread1; |
|
400 RThread thread2; |
|
401 RThread thread3; |
|
402 // Create the threads |
|
403 User::LeaveIfError(thread1.Create(_L("ThreadX"), MultipleWriteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
404 User::LeaveIfError(thread2.Create(_L("ThreadY"), MultipleWriteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
405 User::LeaveIfError(thread3.Create(_L("ThreadZ"), MultipleWriteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
406 |
|
407 TRequestStatus reqStatus1; |
|
408 TRequestStatus reqStatus2; |
|
409 TRequestStatus reqStatus3; |
|
410 |
|
411 thread1.Logon(reqStatus1); // Notify when the thread dies |
|
412 thread2.Logon(reqStatus2); |
|
413 thread3.Logon(reqStatus3); |
|
414 thread1.Resume(); // Start the threads |
|
415 thread2.Resume(); |
|
416 thread3.Resume(); |
|
417 User::WaitForRequest(reqStatus1); // Avoid using User::WaitForAnyRequest() |
|
418 User::WaitForRequest(reqStatus2); |
|
419 User::WaitForRequest(reqStatus3); |
|
420 |
|
421 TBool req1Complete(EFalse); |
|
422 TBool req2Complete(EFalse); |
|
423 TBool req3Complete(EFalse); |
|
424 |
|
425 while(req1Complete==EFalse || req2Complete==EFalse || req3Complete==EFalse) |
|
426 { |
|
427 if (reqStatus1 != KRequestPending && req1Complete==EFalse) // Thread1 request completed |
|
428 { |
|
429 TESTCHECK(reqStatus1.Int(), KErrNone); |
|
430 req1Complete=ETrue; |
|
431 } |
|
432 |
|
433 if (reqStatus2 != KRequestPending && req2Complete==EFalse) // Thread2 request rejected |
|
434 { |
|
435 TESTCHECK(reqStatus2.Int(), KErrNone); |
|
436 req2Complete=ETrue; |
|
437 } |
|
438 |
|
439 if (reqStatus3 != KRequestPending && req3Complete==EFalse) // Thread3 request rejected |
|
440 { |
|
441 TESTCHECK(reqStatus3.Int(), KErrNone); |
|
442 req3Complete=ETrue; |
|
443 } |
|
444 |
|
445 } |
|
446 |
|
447 thread1.Close(); |
|
448 thread2.Close(); |
|
449 thread3.Close(); |
|
450 |
|
451 return TestStepResult(); |
|
452 } |
|
453 |
|
454 |
|
455 /** |
|
456 * Send Write request to the Phonebook server. |
|
457 */ |
|
458 TInt CPhbkIntegrationStressTestBase::MultipleWriteThread(TAny* /*aAny*/) |
|
459 { |
|
460 CActiveScheduler* scheduler = new CActiveScheduler; |
|
461 if(!scheduler) |
|
462 return KErrNoMemory; |
|
463 CActiveScheduler::Install(scheduler); |
|
464 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
465 TRAP_IGNORE(MultipleWriteThreadL()); |
|
466 delete cleanup; |
|
467 delete CActiveScheduler::Current(); |
|
468 return KErrNone; |
|
469 } |
|
470 |
|
471 /** |
|
472 * |
|
473 */ |
|
474 void CPhbkIntegrationStressTestBase::MultipleWriteThreadL() |
|
475 { |
|
476 CPhbkIntegrationTestUtility* access = CPhbkIntegrationTestUtility::NewL(); |
|
477 CleanupStack::PushL(access); |
|
478 access->AddContactL(KTestName, KTestNumber, KUidIccGlobalAdnPhonebook); |
|
479 access->AddContactL(KTestName, KTestNumber, KUidIccGlobalSdnPhonebook); |
|
480 access->AddContactL(KTestName, KTestNumber, KUidIccGlobalLndPhonebook); |
|
481 access->AddContactL(KTestName, KTestNumber, KUidUsimAppAdnPhonebook, KTestEMail); |
|
482 access->AddContactL(KTestName, KTestNumber, KUidIccGlobalFdnPhonebook); |
|
483 |
|
484 CleanupStack::PopAndDestroy(access); |
|
485 } |
|
486 |
|
487 /** |
|
488 * Factory construction method. |
|
489 * @return Pointer to CPhbkRequestDeleteSimultaneouslyTest object |
|
490 */ |
|
491 CPhbkRequestDeleteSimultaneouslyTest* CPhbkRequestDeleteSimultaneouslyTest::NewL() |
|
492 { |
|
493 CPhbkRequestDeleteSimultaneouslyTest* self = new(ELeave) CPhbkRequestDeleteSimultaneouslyTest(); |
|
494 return self; |
|
495 } |
|
496 |
|
497 /** |
|
498 * Default constructor. Each test step initialises it's own name. |
|
499 */ |
|
500 CPhbkRequestDeleteSimultaneouslyTest::CPhbkRequestDeleteSimultaneouslyTest() |
|
501 { |
|
502 SetTestStepName(_L("RequestDeleteSimultaneouslyTest")); |
|
503 } |
|
504 |
|
505 /** |
|
506 * Create three threads which simultaneously attempt to request Delete from |
|
507 * the Phonebook Server. |
|
508 */ |
|
509 enum TVerdict CPhbkRequestDeleteSimultaneouslyTest::doTestStepL() |
|
510 { |
|
511 RThread thread1; |
|
512 RThread thread2; |
|
513 RThread thread3; |
|
514 // Create the threads |
|
515 User::LeaveIfError(thread1.Create(_L("Thread10"), MultipleDeleteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
516 User::LeaveIfError(thread2.Create(_L("Thread11"), MultipleDeleteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
517 User::LeaveIfError(thread3.Create(_L("Thread12"), MultipleDeleteThread, KDefaultStackSize, 0x2000, 0x20000, NULL)); |
|
518 |
|
519 TRequestStatus reqStatus1; |
|
520 TRequestStatus reqStatus2; |
|
521 TRequestStatus reqStatus3; |
|
522 |
|
523 thread1.Logon(reqStatus1); // Notify when the thread dies |
|
524 thread2.Logon(reqStatus2); |
|
525 thread3.Logon(reqStatus3); |
|
526 thread1.Resume(); // Start the thread |
|
527 thread2.Resume(); |
|
528 thread3.Resume(); |
|
529 User::WaitForRequest(reqStatus1); // Avoid using User::WaitForAnyRequest() |
|
530 User::WaitForRequest(reqStatus2); |
|
531 User::WaitForRequest(reqStatus3); |
|
532 |
|
533 TBool req1Complete(EFalse); |
|
534 TBool req2Complete(EFalse); |
|
535 TBool req3Complete(EFalse); |
|
536 |
|
537 while(req1Complete==EFalse || req2Complete==EFalse || req3Complete==EFalse) |
|
538 { |
|
539 if (reqStatus1 != KRequestPending && req1Complete==EFalse) // Thread1 request completed |
|
540 { |
|
541 TESTCHECK(reqStatus1.Int(), KErrNone); |
|
542 req1Complete=ETrue; |
|
543 } |
|
544 |
|
545 if (reqStatus2 != KRequestPending && req2Complete==EFalse) // Thread2 request rejected |
|
546 { |
|
547 TESTCHECK(reqStatus2.Int(), KErrNone); |
|
548 req2Complete=ETrue; |
|
549 } |
|
550 |
|
551 if (reqStatus3 != KRequestPending && req3Complete==EFalse) // Thread3 request rejected |
|
552 { |
|
553 TESTCHECK(reqStatus3.Int(), KErrNone); |
|
554 req3Complete=ETrue; |
|
555 } |
|
556 } |
|
557 |
|
558 //User::After(5000000); |
|
559 thread1.Close(); |
|
560 thread2.Close(); |
|
561 thread3.Close(); |
|
562 |
|
563 return TestStepResult(); |
|
564 } |
|
565 |
|
566 /** |
|
567 * Send Delete request to the Phonebook server. |
|
568 */ |
|
569 TInt CPhbkIntegrationStressTestBase::MultipleDeleteThread(TAny* /*aAny*/) |
|
570 { |
|
571 CActiveScheduler* scheduler = new CActiveScheduler; |
|
572 if(!scheduler) |
|
573 return KErrNoMemory; |
|
574 CActiveScheduler::Install(scheduler); |
|
575 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
576 TRAP_IGNORE(MultipleDeleteThreadL()); |
|
577 delete cleanup; |
|
578 delete CActiveScheduler::Current(); |
|
579 return KErrNone; |
|
580 } |
|
581 |
|
582 /** |
|
583 * Multiple delete thread |
|
584 */ |
|
585 void CPhbkIntegrationStressTestBase::MultipleDeleteThreadL() |
|
586 { |
|
587 CPhbkIntegrationTestUtility* access = CPhbkIntegrationTestUtility::NewL(); |
|
588 CleanupStack::PushL(access); |
|
589 access->DeleteContactL(KUidIccGlobalAdnPhonebook, 2); |
|
590 access->DeleteContactL(KUidIccGlobalSdnPhonebook, 2); |
|
591 access->DeleteContactL(KUidIccGlobalLndPhonebook, 2); |
|
592 access->DeleteContactL(KUidUsimAppAdnPhonebook, 2); |
|
593 access->DeleteContactL(KUidIccGlobalFdnPhonebook, 2); |
|
594 |
|
595 CleanupStack::PopAndDestroy(access); |
|
596 } |
|
597 |
|
598 |
|
599 /** |
|
600 * Factory construction method. |
|
601 * @return Pointer to CPhbkRequestSyncAndReadSimultaneouslyTest object |
|
602 */ |
|
603 CPhbkRequestSyncAndReadSimultaneouslyTest* CPhbkRequestSyncAndReadSimultaneouslyTest::NewL() |
|
604 { |
|
605 CPhbkRequestSyncAndReadSimultaneouslyTest* self = new(ELeave) CPhbkRequestSyncAndReadSimultaneouslyTest(); |
|
606 return self; |
|
607 } |
|
608 |
|
609 /** |
|
610 * Default constructor. Each test step initialises it's own name. |
|
611 */ |
|
612 CPhbkRequestSyncAndReadSimultaneouslyTest::CPhbkRequestSyncAndReadSimultaneouslyTest() |
|
613 { |
|
614 SetTestStepName(_L("RequestSyncAndReadSimultaneouslyTest")); |
|
615 } |
|
616 |
|
617 /** |
|
618 * Request a synch and read simultaneously |
|
619 */ |
|
620 enum TVerdict CPhbkRequestSyncAndReadSimultaneouslyTest::doTestStepL() |
|
621 { |
|
622 SetSimTsyTestNumberL(9); |
|
623 |
|
624 // Ensure manual sync only |
|
625 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual)); |
|
626 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); |
|
627 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalLndPhonebook)); |
|
628 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook)); |
|
629 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook)); |
|
630 |
|
631 TRequestStatus status; |
|
632 // For each phonebook start the sync and attempt to read |
|
633 |
|
634 // Synchronise Global ADN |
|
635 iSession.DoSynchronisation(status); |
|
636 User::After(6000000); |
|
637 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
638 // const CContactIdArray* sortedItems = iDb->SortedItemsL(); |
|
639 |
|
640 //Read Global ADN |
|
641 CPhbkIntegrationTestUtility* access = CPhbkIntegrationTestUtility::NewL(); |
|
642 CleanupStack::PushL(access); |
|
643 access->ReadContactL(KUidIccGlobalAdnPhonebook, KTest9ICCSlotsADN); |
|
644 CleanupStack::PopAndDestroy(access); |
|
645 |
|
646 //wait for end of sync |
|
647 User::WaitForRequest(status); |
|
648 TESTCHECKL(status.Int(), KErrNone); |
|
649 |
|
650 // Synchronise Global SDN |
|
651 iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook); |
|
652 User::After(6000000); |
|
653 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
654 // sortedItems = iDb->SortedItemsL(); |
|
655 |
|
656 //Read Global SDN |
|
657 access = CPhbkIntegrationTestUtility::NewL(); |
|
658 CleanupStack::PushL(access); |
|
659 access->ReadContactL(KUidIccGlobalSdnPhonebook, KTest9ICCSlotsSDN); |
|
660 CleanupStack::PopAndDestroy(access); |
|
661 |
|
662 //wait for end of sync |
|
663 User::WaitForRequest(status); |
|
664 TESTCHECKL(status.Int(), KErrNone); |
|
665 |
|
666 // Synchronise Global LND |
|
667 iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook); |
|
668 User::After(6000000); |
|
669 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
670 // sortedItems = iDb->SortedItemsL(); |
|
671 |
|
672 //Read Global LND |
|
673 access = CPhbkIntegrationTestUtility::NewL(); |
|
674 CleanupStack::PushL(access); |
|
675 access->ReadContactL(KUidIccGlobalLndPhonebook, KTest9ICCSlotsLND); |
|
676 CleanupStack::PopAndDestroy(access); |
|
677 |
|
678 //wait for end of sync |
|
679 User::WaitForRequest(status); |
|
680 TESTCHECKL(status.Int(), KErrNone); |
|
681 |
|
682 // Synchronise Usim App |
|
683 iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook); |
|
684 User::After(6000000); |
|
685 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
686 // sortedItems = iDb->SortedItemsL(); |
|
687 |
|
688 //Read Usim App |
|
689 access = CPhbkIntegrationTestUtility::NewL(); |
|
690 CleanupStack::PushL(access); |
|
691 access->ReadContactL(KUidUsimAppAdnPhonebook, KTest9ICCSlotsUsim); |
|
692 CleanupStack::PopAndDestroy(access); |
|
693 |
|
694 //wait for end of sync |
|
695 User::WaitForRequest(status); |
|
696 TESTCHECKL(status.Int(), KErrNone); |
|
697 |
|
698 // Synchronise Global FDN |
|
699 iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook); |
|
700 User::After(6000000); |
|
701 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
702 // sortedItems = iDb->SortedItemsL(); |
|
703 |
|
704 //Read Global FDN |
|
705 access = CPhbkIntegrationTestUtility::NewL(); |
|
706 CleanupStack::PushL(access); |
|
707 access->ReadContactL(KUidIccGlobalFdnPhonebook, KTest9ICCSlotsFDN); |
|
708 CleanupStack::PopAndDestroy(access); |
|
709 |
|
710 //wait for end of sync |
|
711 User::WaitForRequest(status); |
|
712 TESTCHECKL(status.Int(), KErrNone); |
|
713 |
|
714 return TestStepResult(); |
|
715 } |
|
716 |
|
717 |
|
718 /** |
|
719 * Factory construction method. |
|
720 * @return Pointer to CPhbkCheckServerThreadPriorityTest object |
|
721 */ |
|
722 CPhbkCheckServerThreadPriorityTest* CPhbkCheckServerThreadPriorityTest::NewL() |
|
723 { |
|
724 CPhbkCheckServerThreadPriorityTest* self = new(ELeave) CPhbkCheckServerThreadPriorityTest(); |
|
725 return self; |
|
726 } |
|
727 |
|
728 /** |
|
729 * Default constructor. Each test step initialises it's own name. |
|
730 */ |
|
731 CPhbkCheckServerThreadPriorityTest::CPhbkCheckServerThreadPriorityTest() |
|
732 { |
|
733 SetTestStepName(_L("CheckServerThreadPriorityTest")); |
|
734 } |
|
735 |
|
736 /** |
|
737 * Confirm server thread priority |
|
738 */ |
|
739 enum TVerdict CPhbkCheckServerThreadPriorityTest::doTestStepL() |
|
740 { |
|
741 // Connect to the Phonebook Server |
|
742 RPhoneBookSession session; |
|
743 User::LeaveIfError(session.Connect()); |
|
744 |
|
745 RThread phoneBookServerThread; |
|
746 _LIT(KThreadToFind,"*PhBkSyncServer*"); // PHBKSYNC_SVR_NAME |
|
747 TFindThread find(KThreadToFind); |
|
748 TFullName findName; |
|
749 TInt findErr = find.Next(findName); |
|
750 TESTCHECKL(findErr, KErrNone); |
|
751 TInt ret = phoneBookServerThread.Open(findName); |
|
752 |
|
753 // Check the server thread priority level |
|
754 TESTCHECKL(ret, KErrNone); |
|
755 TThreadPriority serverPriority(phoneBookServerThread.Priority()); |
|
756 TESTCHECK(serverPriority, EPriorityNormal); |
|
757 |
|
758 phoneBookServerThread.Close(); |
|
759 session.Close(); |
|
760 |
|
761 return TestStepResult(); |
|
762 } |
|
763 |
|
764 |
|
765 /** |
|
766 * Factory construction method. |
|
767 * @return Pointer to CPhbkServerLostFileRecoveryTest object |
|
768 */ |
|
769 CPhbkServerLostFileRecoveryTest* CPhbkServerLostFileRecoveryTest::NewL() |
|
770 { |
|
771 CPhbkServerLostFileRecoveryTest* self = new(ELeave) CPhbkServerLostFileRecoveryTest(); |
|
772 return self; |
|
773 } |
|
774 |
|
775 /** |
|
776 * Default constructor. Each test step initialises it's own name. |
|
777 */ |
|
778 CPhbkServerLostFileRecoveryTest::CPhbkServerLostFileRecoveryTest() |
|
779 { |
|
780 SetTestStepName(_L("ServerLostFileRecoveryTest")); |
|
781 } |
|
782 |
|
783 /** |
|
784 * Test server recovery after losing config files |
|
785 */ |
|
786 enum TVerdict CPhbkServerLostFileRecoveryTest::doTestStepL() |
|
787 { |
|
788 delete iDb; |
|
789 iDb=NULL; |
|
790 User::After(1000000); //1 second wait for contact to shut down |
|
791 iSession.Close(); |
|
792 ConfigurePhbkSyncToIdleL(); |
|
793 |
|
794 // *********************************************** |
|
795 // First, test situation where there are no config |
|
796 // files at all. |
|
797 // *********************************************** |
|
798 |
|
799 // Delete all INI files and the contact database |
|
800 TRAPD(ignore,CContactDatabase::DeleteDefaultFileL()); |
|
801 RFs fsSession; |
|
802 User::LeaveIfError(fsSession.Connect()); |
|
803 CleanupClosePushL(fsSession); |
|
804 |
|
805 fsSession.Delete(KContactsModelIniFile); //ignore return value |
|
806 fsSession.Delete(KPhbkSyncIniFile); //ignore return value |
|
807 |
|
808 // Verify that server starts okay |
|
809 ConfigurePhbkSyncToFullL(); |
|
810 TInt err = iSession.Connect(); |
|
811 TESTCHECKL(err, KErrNone); |
|
812 |
|
813 // Perform synchronisation |
|
814 TRAP(err, DoSyncL()); |
|
815 TESTCHECKL(err, KErrNone); |
|
816 |
|
817 // Verify that contact database is available |
|
818 TRAP(err, iDb = OpenOrCreateContactDatabaseL()); |
|
819 TESTCHECKL(err, KErrNone); |
|
820 User::After(1000000); //1 second wait |
|
821 |
|
822 // Get the groupId and template ID for each phonebook |
|
823 TContactItemId groupIdADN(KNullContactId); |
|
824 TRAP(err, iSession.GetPhoneBookId(groupIdADN, |
|
825 RPhoneBookSession::ESyncGroupId, |
|
826 KUidIccGlobalAdnPhonebook)); |
|
827 TESTCHECKCONDITIONL(groupIdADN != KNullContactId); |
|
828 |
|
829 TContactItemId groupIdSDN(KNullContactId); |
|
830 TRAP(err, iSession.GetPhoneBookId(groupIdSDN, |
|
831 RPhoneBookSession::ESyncGroupId, |
|
832 KUidIccGlobalSdnPhonebook)); |
|
833 TESTCHECKCONDITIONL(groupIdSDN != KNullContactId); |
|
834 |
|
835 TContactItemId groupIdLND(KNullContactId); |
|
836 TRAP(err, iSession.GetPhoneBookId(groupIdLND, |
|
837 RPhoneBookSession::ESyncGroupId, |
|
838 KUidIccGlobalLndPhonebook)); |
|
839 TESTCHECKCONDITIONL(groupIdLND != KNullContactId); |
|
840 |
|
841 TContactItemId groupIdUsim(KNullContactId); |
|
842 TRAP(err, iSession.GetPhoneBookId(groupIdUsim, |
|
843 RPhoneBookSession::ESyncGroupId, |
|
844 KUidUsimAppAdnPhonebook)); |
|
845 TESTCHECKCONDITIONL(groupIdUsim != KNullContactId); |
|
846 |
|
847 TContactItemId tempIdADN(KNullContactId); |
|
848 TRAP(err, iSession.GetPhoneBookId(tempIdADN, |
|
849 RPhoneBookSession::ESyncTemplateId, |
|
850 KUidIccGlobalAdnPhonebook)); |
|
851 TESTCHECKCONDITIONL(tempIdADN != KNullContactId); |
|
852 |
|
853 TContactItemId tempIdSDN(KNullContactId); |
|
854 TRAP(err, iSession.GetPhoneBookId(tempIdSDN, |
|
855 RPhoneBookSession::ESyncTemplateId, |
|
856 KUidIccGlobalSdnPhonebook)); |
|
857 TESTCHECKCONDITIONL(tempIdSDN != KNullContactId); |
|
858 |
|
859 TContactItemId tempIdLND(KNullContactId); |
|
860 TRAP(err, iSession.GetPhoneBookId(tempIdLND, |
|
861 RPhoneBookSession::ESyncTemplateId, |
|
862 KUidIccGlobalLndPhonebook)); |
|
863 TESTCHECKCONDITIONL(tempIdLND != KNullContactId); |
|
864 |
|
865 TContactItemId tempIdUsim(KNullContactId); |
|
866 TRAP(err, iSession.GetPhoneBookId(tempIdUsim, |
|
867 RPhoneBookSession::ESyncTemplateId, |
|
868 KUidUsimAppAdnPhonebook)); |
|
869 TESTCHECKCONDITIONL(tempIdUsim != KNullContactId); |
|
870 |
|
871 // shutdown existing server session and close database |
|
872 delete iDb; |
|
873 iDb=NULL; |
|
874 User::After(1000000); |
|
875 iSession.Close(); |
|
876 ConfigurePhbkSyncToIdleL(); |
|
877 |
|
878 // ************************************************ |
|
879 // Now, remove phbksync INI file only and test that |
|
880 // existing group and template ID's in the contact |
|
881 // database are adopted as required. |
|
882 // ************************************************ |
|
883 |
|
884 // Now remove phbksync INI file only |
|
885 fsSession.Delete(KPhbkSyncIniFile); |
|
886 |
|
887 // Verify that server starts okay |
|
888 ConfigurePhbkSyncToFullL(); |
|
889 err = iSession.Connect(); |
|
890 TESTCHECKL(err, KErrNone); |
|
891 |
|
892 // Perform synchronisation |
|
893 TRAP(err, DoSyncL()); |
|
894 TESTCHECKL(err, KErrNone); |
|
895 |
|
896 // Verify that contact database is available |
|
897 TRAP(err, iDb = OpenOrCreateContactDatabaseL()); |
|
898 TESTCHECKL(err, KErrNone); |
|
899 User::After(1000000); //1 second wait |
|
900 |
|
901 // Check the groupId and template ID for each phonebook is the same as before |
|
902 TContactItemId groupIdADN2(KNullContactId); |
|
903 TRAP(err, iSession.GetPhoneBookId(groupIdADN2, |
|
904 RPhoneBookSession::ESyncGroupId, |
|
905 KUidIccGlobalAdnPhonebook)); |
|
906 TESTCHECKL(groupIdADN2, groupIdADN); |
|
907 |
|
908 TContactItemId groupIdSDN2(KNullContactId); |
|
909 TRAP(err, iSession.GetPhoneBookId(groupIdSDN2, |
|
910 RPhoneBookSession::ESyncGroupId, |
|
911 KUidIccGlobalSdnPhonebook)); |
|
912 TESTCHECKL(groupIdSDN2, groupIdSDN); |
|
913 |
|
914 TContactItemId groupIdLND2(KNullContactId); |
|
915 TRAP(err, iSession.GetPhoneBookId(groupIdLND2, |
|
916 RPhoneBookSession::ESyncGroupId, |
|
917 KUidIccGlobalLndPhonebook)); |
|
918 TESTCHECKL(groupIdLND2, groupIdLND); |
|
919 |
|
920 TContactItemId groupIdUsim2(KNullContactId); |
|
921 TRAP(err, iSession.GetPhoneBookId(groupIdUsim2, |
|
922 RPhoneBookSession::ESyncGroupId, |
|
923 KUidUsimAppAdnPhonebook)); |
|
924 TESTCHECKL(groupIdUsim2, groupIdUsim); |
|
925 |
|
926 TContactItemId tempIdADN2(KNullContactId); |
|
927 TRAP(err, iSession.GetPhoneBookId(tempIdADN2, |
|
928 RPhoneBookSession::ESyncTemplateId, |
|
929 KUidIccGlobalAdnPhonebook)); |
|
930 TESTCHECKL(tempIdADN2, tempIdADN); |
|
931 |
|
932 TContactItemId tempIdSDN2(KNullContactId); |
|
933 TRAP(err, iSession.GetPhoneBookId(tempIdSDN2, |
|
934 RPhoneBookSession::ESyncTemplateId, |
|
935 KUidIccGlobalSdnPhonebook)); |
|
936 TESTCHECKL(tempIdSDN2, tempIdSDN); |
|
937 |
|
938 TContactItemId tempIdLND2(KNullContactId); |
|
939 TRAP(err, iSession.GetPhoneBookId(tempIdLND2, |
|
940 RPhoneBookSession::ESyncTemplateId, |
|
941 KUidIccGlobalLndPhonebook)); |
|
942 TESTCHECKL(tempIdLND2, tempIdLND); |
|
943 |
|
944 TContactItemId tempIdUsim2(KNullContactId); |
|
945 TRAP(err, iSession.GetPhoneBookId(tempIdUsim2, |
|
946 RPhoneBookSession::ESyncTemplateId, |
|
947 KUidUsimAppAdnPhonebook)); |
|
948 TESTCHECKL(tempIdUsim2, tempIdUsim); |
|
949 |
|
950 // shutdown existing server session and close database |
|
951 delete iDb; |
|
952 iDb=NULL; |
|
953 User::After(1000000); |
|
954 iSession.Close(); |
|
955 ConfigurePhbkSyncToIdleL(); |
|
956 |
|
957 // ************************************************ |
|
958 // Now, remove contact database only and test that |
|
959 // group and template ID's in the phbksync INI file |
|
960 // are re-created. This should result in same IDs |
|
961 // as were created when we had no config files. |
|
962 // ************************************************ |
|
963 |
|
964 // Now remove contact database only |
|
965 TRAP(ignore,CContactDatabase::DeleteDefaultFileL()); |
|
966 |
|
967 // Verify that server starts okay |
|
968 ConfigurePhbkSyncToFullL(); |
|
969 err = iSession.Connect(); |
|
970 TESTCHECKL(err, KErrNone); |
|
971 |
|
972 // Perform synchronisation |
|
973 TRAP(err, DoSyncL()); |
|
974 TESTCHECKL(err, KErrNone); |
|
975 |
|
976 // Verify that contact database is available |
|
977 TRAP(err, iDb = OpenOrCreateContactDatabaseL()); |
|
978 TESTCHECKL(err, KErrNone); |
|
979 User::After(1000000); //1 second wait |
|
980 |
|
981 // Check the groupId and template ID for each phonebook is the same as before |
|
982 TContactItemId groupIdADN3(KNullContactId); |
|
983 TRAP(err, iSession.GetPhoneBookId(groupIdADN3, |
|
984 RPhoneBookSession::ESyncGroupId, |
|
985 KUidIccGlobalAdnPhonebook)); |
|
986 TESTCHECKL(groupIdADN3, groupIdADN); |
|
987 |
|
988 TContactItemId groupIdSDN3(KNullContactId); |
|
989 TRAP(err, iSession.GetPhoneBookId(groupIdSDN3, |
|
990 RPhoneBookSession::ESyncGroupId, |
|
991 KUidIccGlobalSdnPhonebook)); |
|
992 TESTCHECKL(groupIdSDN3, groupIdSDN); |
|
993 |
|
994 TContactItemId groupIdLND3(KNullContactId); |
|
995 TRAP(err, iSession.GetPhoneBookId(groupIdLND3, |
|
996 RPhoneBookSession::ESyncGroupId, |
|
997 KUidIccGlobalLndPhonebook)); |
|
998 TESTCHECKL(groupIdLND3, groupIdLND); |
|
999 |
|
1000 TContactItemId groupIdUsim3(KNullContactId); |
|
1001 TRAP(err, iSession.GetPhoneBookId(groupIdUsim3, |
|
1002 RPhoneBookSession::ESyncGroupId, |
|
1003 KUidUsimAppAdnPhonebook)); |
|
1004 TESTCHECKL(groupIdUsim3, groupIdUsim); |
|
1005 |
|
1006 TContactItemId tempIdADN3(KNullContactId); |
|
1007 TRAP(err, iSession.GetPhoneBookId(tempIdADN3, |
|
1008 RPhoneBookSession::ESyncTemplateId, |
|
1009 KUidIccGlobalAdnPhonebook)); |
|
1010 TESTCHECKL(tempIdADN3, tempIdADN); |
|
1011 |
|
1012 TContactItemId tempIdSDN3(KNullContactId); |
|
1013 TRAP(err, iSession.GetPhoneBookId(tempIdSDN3, |
|
1014 RPhoneBookSession::ESyncTemplateId, |
|
1015 KUidIccGlobalSdnPhonebook)); |
|
1016 TESTCHECKL(tempIdSDN3, tempIdSDN); |
|
1017 |
|
1018 TContactItemId tempIdLND3(KNullContactId); |
|
1019 TRAP(err, iSession.GetPhoneBookId(tempIdLND3, |
|
1020 RPhoneBookSession::ESyncTemplateId, |
|
1021 KUidIccGlobalLndPhonebook)); |
|
1022 TESTCHECKL(tempIdLND3, tempIdLND); |
|
1023 |
|
1024 TContactItemId tempIdUsim3(KNullContactId); |
|
1025 TRAP(err, iSession.GetPhoneBookId(tempIdUsim3, |
|
1026 RPhoneBookSession::ESyncTemplateId, |
|
1027 KUidUsimAppAdnPhonebook)); |
|
1028 TESTCHECKL(tempIdUsim3, tempIdUsim); |
|
1029 |
|
1030 CleanupStack::PopAndDestroy(&fsSession); |
|
1031 return TestStepResult(); |
|
1032 } |
|
1033 |
|
1034 |
|
1035 /** |
|
1036 * Factory construction method. |
|
1037 * @return Pointer to CPhbkIntegrationBackupTest object. |
|
1038 */ |
|
1039 CPhbkIntegrationBackupTest* CPhbkIntegrationBackupTest::NewL() |
|
1040 { |
|
1041 CPhbkIntegrationBackupTest* self = new(ELeave) CPhbkIntegrationBackupTest(); |
|
1042 return self; |
|
1043 } |
|
1044 |
|
1045 /** |
|
1046 * Default constructor. |
|
1047 */ |
|
1048 CPhbkIntegrationBackupTest::CPhbkIntegrationBackupTest() |
|
1049 { |
|
1050 SetTestStepName(_L("IntegrationBackupTest")); |
|
1051 } |
|
1052 |
|
1053 /** |
|
1054 * Destructor. |
|
1055 */ |
|
1056 CPhbkIntegrationBackupTest::~CPhbkIntegrationBackupTest() |
|
1057 { |
|
1058 // NOP |
|
1059 } |
|
1060 |
|
1061 /** |
|
1062 * Simulate a backup and restore of the Contacts DB. This will require |
|
1063 * the PhBkSync server to unconfigure and close its connection to the |
|
1064 * Contacts database. |
|
1065 */ |
|
1066 enum TVerdict CPhbkIntegrationBackupTest::doTestStepL() |
|
1067 { |
|
1068 // |
|
1069 // Setup the SIM.TSY configuration and then close TE_CntSync's handle |
|
1070 // to the Contacts DB as it'll interfer with this test. Future tests |
|
1071 // will re-open it automatically. |
|
1072 // |
|
1073 SetSyncModeL(RPhoneBookSession::EManual); |
|
1074 CheckSyncModeL(RPhoneBookSession::EManual); |
|
1075 SetSimTsyTestNumberL(0); |
|
1076 DoSyncL(); |
|
1077 CheckCacheStateL(RPhoneBookSession::ECacheValid); |
|
1078 |
|
1079 delete iDb; |
|
1080 iDb = NULL; |
|
1081 |
|
1082 // |
|
1083 // Open the file server... |
|
1084 // |
|
1085 RFs fsSession; |
|
1086 User::LeaveIfError(fsSession.Connect()); |
|
1087 CleanupClosePushL(fsSession); |
|
1088 CFileMan* fileManager = CFileMan::NewL(fsSession); |
|
1089 CleanupStack::PushL(fileManager); |
|
1090 |
|
1091 // |
|
1092 // Try and copy the Contacts DB file while it is in use... |
|
1093 // |
|
1094 TInt result, resultSqlite; |
|
1095 |
|
1096 result = fileManager->Copy(KContactsDBFile, KContactsDBFileBackup); |
|
1097 resultSqlite = fileManager->Copy(KContactsSqliteDBFile, KContactsSqliteDBFileBackup); |
|
1098 TESTCHECKCONDITION((result == KErrInUse) || (resultSqlite == KErrInUse)); |
|
1099 |
|
1100 result = fileManager->Copy(KPhbkSyncIniFile, KPhbkSyncIniFileBackup); |
|
1101 TESTCHECK(result, KErrNone); |
|
1102 |
|
1103 // |
|
1104 // SQLite uses a different filename. This is stored here if in use. |
|
1105 // |
|
1106 const TDesC& databaseName = (resultSqlite == KErrInUse) ? KContactsSqliteDBFile() : KContactsDBFile(); |
|
1107 const TDesC& databaseBackupName = (resultSqlite == KErrInUse) ? KContactsSqliteDBFileBackup() : KContactsDBFileBackup(); |
|
1108 |
|
1109 // |
|
1110 // Notify the PhBkSync server that a backup is about to take place and |
|
1111 // that the server should release the Contacts DB... |
|
1112 // |
|
1113 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
1114 EBURBackupFull, EBackupBase); |
|
1115 |
|
1116 RPhoneBookSession::TPhonebookSyncMode dummySyncMode; |
|
1117 |
|
1118 result = KErrNone; |
|
1119 while (result == KErrNone) |
|
1120 { |
|
1121 result = iSession.GetSyncMode(dummySyncMode); |
|
1122 if (result == KErrNone) |
|
1123 { |
|
1124 User::After(1); |
|
1125 } |
|
1126 } |
|
1127 TESTCHECK(result, KErrNotReady); |
|
1128 |
|
1129 // |
|
1130 // Now copy the Contacts DB and PhBkSync INI files... |
|
1131 // |
|
1132 result = fileManager->Copy(databaseName, databaseBackupName); |
|
1133 TESTCHECK(result, KErrNone); |
|
1134 result = fileManager->Copy(KPhbkSyncIniFile, KPhbkSyncIniFileBackup); |
|
1135 TESTCHECK(result, KErrNone); |
|
1136 |
|
1137 // |
|
1138 // Check that a sync notification cannot be posted in this state... |
|
1139 // |
|
1140 TRequestStatus status; |
|
1141 |
|
1142 iSession.NotifyPhBkCacheStateChange(status, KUidIccGlobalAdnPhonebook); |
|
1143 User::WaitForRequest(status); |
|
1144 TESTCHECK(status.Int(), KErrNotReady); |
|
1145 |
|
1146 // |
|
1147 // Notify the PhBkSync server that the backup is over. PhBkSync will |
|
1148 // restart and continue as before... |
|
1149 // |
|
1150 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
1151 EBURNormal, ENoBackup); |
|
1152 |
|
1153 result = KErrNotReady; |
|
1154 while (result == KErrNotReady) |
|
1155 { |
|
1156 result = iSession.GetSyncMode(dummySyncMode); |
|
1157 if (result == KErrNotReady) |
|
1158 { |
|
1159 User::After(1); |
|
1160 } |
|
1161 } |
|
1162 TESTCHECK(result, KErrNone); |
|
1163 |
|
1164 // |
|
1165 // Check PhBkSync server is still running okay... |
|
1166 // |
|
1167 CheckCacheStateL(RPhoneBookSession::EUnsynchronised); |
|
1168 DoSyncL(); |
|
1169 CheckCacheStateL(RPhoneBookSession::ECacheValid); |
|
1170 |
|
1171 // |
|
1172 // Change the settings in the INI file to test that the restore works... |
|
1173 // |
|
1174 SetSyncModeL(RPhoneBookSession::EAutoSameIcc); |
|
1175 CheckSyncModeL(RPhoneBookSession::EAutoSameIcc); |
|
1176 |
|
1177 // |
|
1178 // Notify the PhBkSync server that a restore is about to take place and |
|
1179 // that the server should release the Contacts DB... |
|
1180 // |
|
1181 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
1182 EBURRestorePartial, EBackupIncrement); |
|
1183 |
|
1184 result = KErrNone; |
|
1185 while (result == KErrNone) |
|
1186 { |
|
1187 result = iSession.GetSyncMode(dummySyncMode); |
|
1188 if (result == KErrNone) |
|
1189 { |
|
1190 User::After(1); |
|
1191 } |
|
1192 } |
|
1193 TESTCHECK(result, KErrNotReady); |
|
1194 |
|
1195 // |
|
1196 // Delete the Contacts DB and PhBkSync INI files and rename the backup files |
|
1197 // to the original names. |
|
1198 // |
|
1199 result = fsSession.Delete(databaseName); |
|
1200 TESTCHECK(result, KErrNone); |
|
1201 result = fsSession.Delete(KPhbkSyncIniFile); |
|
1202 TESTCHECK(result, KErrNone); |
|
1203 result = fsSession.Rename(databaseBackupName, databaseName); |
|
1204 TESTCHECK(result, KErrNone); |
|
1205 result = fsSession.Rename(KPhbkSyncIniFileBackup, KPhbkSyncIniFile); |
|
1206 TESTCHECK(result, KErrNone); |
|
1207 |
|
1208 // |
|
1209 // Notify the PhBkSync server that the restore is over. PhBkSync will |
|
1210 // restart and continue as it did before the backup... |
|
1211 // |
|
1212 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
1213 EBURNormal, ENoBackup); |
|
1214 |
|
1215 result = KErrNotReady; |
|
1216 while (result == KErrNotReady) |
|
1217 { |
|
1218 result = iSession.GetSyncMode(dummySyncMode); |
|
1219 if (result == KErrNotReady) |
|
1220 { |
|
1221 User::After(1); |
|
1222 } |
|
1223 } |
|
1224 TESTCHECK(result, KErrNone); |
|
1225 |
|
1226 // |
|
1227 // Check PhBkSync server is running as before the backup... |
|
1228 // |
|
1229 CheckSyncModeL(RPhoneBookSession::EManual); |
|
1230 |
|
1231 CheckCacheStateL(RPhoneBookSession::EUnsynchronised); |
|
1232 DoSyncL(); |
|
1233 CheckCacheStateL(RPhoneBookSession::ECacheValid); |
|
1234 |
|
1235 // |
|
1236 // Clean up and finish the test... |
|
1237 // |
|
1238 CleanupStack::PopAndDestroy(fileManager); |
|
1239 CleanupStack::PopAndDestroy(&fsSession); |
|
1240 |
|
1241 return TestStepResult(); |
|
1242 } // CPhbkIntegrationBackupTest::doTestStepL |