|
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 |
|
18 #include "te_cntsyncbase.h" |
|
19 #include "te_cntsyncdelete.h" |
|
20 |
|
21 _LIT(KDeletedNameInADN, "ADN Delete Test"); |
|
22 _LIT(KDeletedNameInSDN, "SDN Delete Test"); |
|
23 _LIT(KDeletedNameInLND, "LND Delete Test"); |
|
24 _LIT(KDeletedNameInUsim,"Usim Delete Test"); |
|
25 _LIT(KDeletedNameInFDN, "FDN Delete Test"); |
|
26 |
|
27 _LIT(KDeletedNumberInADN, "0202020323909094394"); |
|
28 _LIT(KDeletedNumberInSDN, "1212121323919194394"); |
|
29 _LIT(KDeletedNumberInLND, "2222222323929294394"); |
|
30 _LIT(KDeletedNumberInUsim,"3232323323939394394"); |
|
31 _LIT(KDeletedNumberInFDN, "4242424343949494394"); |
|
32 |
|
33 _LIT(KDeletedEmailInUsim,"example@here"); |
|
34 |
|
35 _LIT(KSearchStringInADN, "AAAAAAAAAAAAAAAAA"); |
|
36 _LIT(KSearchStringInSDN, "BBBBBBBBBBBBBBBBB"); |
|
37 _LIT(KSearchStringInLND, "CCCCCCCCCCCCCCCCC"); |
|
38 _LIT(KSearchStringInUsim,"DDDDDDDDDDDDDDDDD"); |
|
39 _LIT(KSearchStringInFDN, "EEEEEEEEEEEEEEEEE"); |
|
40 |
|
41 _LIT(KSearchNameInADN, "ADN Name"); |
|
42 _LIT(KSearchNameInSDN, "SDN Name"); |
|
43 _LIT(KSearchNameInLND, "LND Name"); |
|
44 _LIT(KSearchNameInUsim,"Usim Name"); |
|
45 _LIT(KSearchNameInFDN, "FDN Name"); |
|
46 |
|
47 |
|
48 /** |
|
49 * Factory construction method. |
|
50 * @return Pointer to CPhbkDeleteICCContactTest object |
|
51 */ |
|
52 CPhbkDeleteICCContactTest* CPhbkDeleteICCContactTest::NewL() |
|
53 { |
|
54 CPhbkDeleteICCContactTest* self = new(ELeave) CPhbkDeleteICCContactTest(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 /** |
|
59 * Default constructor. Each test step initialises it's own name. |
|
60 */ |
|
61 CPhbkDeleteICCContactTest::CPhbkDeleteICCContactTest() |
|
62 { |
|
63 SetTestStepName(_L("DeleteICCContactTest")); |
|
64 } |
|
65 |
|
66 /** Delete an ICC entry - normal case */ |
|
67 enum TVerdict CPhbkDeleteICCContactTest::doTestStepL() |
|
68 { |
|
69 SetSimTsyTestNumberL(0); |
|
70 DoSyncL(); |
|
71 |
|
72 DeleteContactL(KUidIccGlobalAdnPhonebook); |
|
73 DeleteContactL(KUidIccGlobalSdnPhonebook); |
|
74 DeleteContactL(KUidIccGlobalLndPhonebook); |
|
75 DeleteContactL(KUidUsimAppAdnPhonebook); |
|
76 DeleteContactL(KUidIccGlobalFdnPhonebook); |
|
77 |
|
78 return TestStepResult(); |
|
79 } |
|
80 |
|
81 |
|
82 /** |
|
83 * Factory construction method. |
|
84 * @return Pointer to CPhbkDeleteEntryInvalidUIDTest object |
|
85 */ |
|
86 CPhbkDeleteEntryInvalidUIDTest* CPhbkDeleteEntryInvalidUIDTest::NewL() |
|
87 { |
|
88 CPhbkDeleteEntryInvalidUIDTest* self = new(ELeave) CPhbkDeleteEntryInvalidUIDTest(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 /** |
|
93 * Default constructor. Each test step initialises it's own name. |
|
94 */ |
|
95 CPhbkDeleteEntryInvalidUIDTest::CPhbkDeleteEntryInvalidUIDTest() |
|
96 { |
|
97 SetTestStepName(_L("DeleteEntryInvalidUIDTest")); |
|
98 } |
|
99 |
|
100 /** Delete an ICC entry - invalid UID */ |
|
101 enum TVerdict CPhbkDeleteEntryInvalidUIDTest::doTestStepL() |
|
102 { |
|
103 TContactItemId id(1500); // Exceeded max number on ICC |
|
104 TRAPD(err, iDb->DeleteContactL(id)); |
|
105 TESTCHECKL(err, KErrNotFound); |
|
106 |
|
107 id = -2; // Negative UID |
|
108 TRAP(err, iDb->DeleteContactL(id)); |
|
109 TESTCHECKL(err, KErrNotFound); |
|
110 |
|
111 id = 6789; // Out-of-range UID |
|
112 TRAP(err, iDb->DeleteContactL(id)); |
|
113 TESTCHECKL(err, KErrNotFound); |
|
114 |
|
115 return TestStepResult(); |
|
116 } |
|
117 |
|
118 |
|
119 /** |
|
120 * Factory construction method. |
|
121 * @return Pointer to CPhbkDeleteAllEntriesTest object |
|
122 */ |
|
123 CPhbkDeleteAllEntriesTest* CPhbkDeleteAllEntriesTest::NewL() |
|
124 { |
|
125 CPhbkDeleteAllEntriesTest* self = new(ELeave) CPhbkDeleteAllEntriesTest(); |
|
126 return self; |
|
127 } |
|
128 |
|
129 /** |
|
130 * Default constructor. Each test step initialises it's own name. |
|
131 */ |
|
132 CPhbkDeleteAllEntriesTest::CPhbkDeleteAllEntriesTest() |
|
133 { |
|
134 SetTestStepName(_L("DeleteAllEntriesTest")); |
|
135 } |
|
136 |
|
137 /** Delete all ICC entries one at a time */ |
|
138 enum TVerdict CPhbkDeleteAllEntriesTest::doTestStepL() |
|
139 { |
|
140 SetSimTsyTestNumberL(0); |
|
141 DoSyncL(); |
|
142 |
|
143 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
144 const CContactIdArray* sortedItems = iDb->SortedItemsL(); |
|
145 TContactItemId id(KNullContactId); |
|
146 TInt count = sortedItems->Count(); |
|
147 |
|
148 TInt err(KErrNone); |
|
149 for(TInt i=0; i<=count-1;i++) |
|
150 { |
|
151 id = (*sortedItems)[0]; |
|
152 iDb->DeleteContactL(id); |
|
153 CContactItem* item=NULL; //check the item has been removed from the database |
|
154 TRAP(err, item = iDb->ReadContactL(id)); |
|
155 TESTCHECKL(err, KErrNotFound); |
|
156 delete item; |
|
157 } |
|
158 |
|
159 return TestStepResult(); |
|
160 } |
|
161 |
|
162 |
|
163 /** |
|
164 * Factory construction method. |
|
165 * @return Pointer to CPhbkDeleteEntryICCLockedTest object |
|
166 */ |
|
167 CPhbkDeleteEntryICCLockedTest* CPhbkDeleteEntryICCLockedTest::NewL() |
|
168 { |
|
169 CPhbkDeleteEntryICCLockedTest* self = new(ELeave) CPhbkDeleteEntryICCLockedTest(); |
|
170 return self; |
|
171 } |
|
172 |
|
173 /** |
|
174 * Default constructor. Each test step initialises it's own name. |
|
175 */ |
|
176 CPhbkDeleteEntryICCLockedTest::CPhbkDeleteEntryICCLockedTest() |
|
177 { |
|
178 SetTestStepName(_L("DeleteEntryICCLockedTest")); |
|
179 } |
|
180 |
|
181 /** Delete an ICC entry - ICC locked */ |
|
182 enum TVerdict CPhbkDeleteEntryICCLockedTest::doTestStepL() |
|
183 { |
|
184 SetSimTsyTestNumberL(2); |
|
185 DoSyncL(); |
|
186 |
|
187 // Access ICC and wait for it to be locked |
|
188 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
189 const CContactIdArray* sortedItems = iDb->SortedItemsL(); |
|
190 TContactItemId id = (*sortedItems)[0]; |
|
191 TInt err(KErrNone); |
|
192 while(err==KErrNone) // Wait for ICC to become locked |
|
193 { |
|
194 User::After(1000000); // Wait a second and try again. |
|
195 CContactICCEntry* failEntry=NULL; |
|
196 TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked |
|
197 delete failEntry; |
|
198 } |
|
199 TESTCHECKL(err, KErrAccessDenied); |
|
200 |
|
201 TRAP(err, DeleteContactL(KUidIccGlobalAdnPhonebook)); |
|
202 TESTCHECKL(err, KErrAccessDenied); |
|
203 |
|
204 TRAP(err, DeleteContactL(KUidIccGlobalSdnPhonebook)); |
|
205 TESTCHECKL(err, KErrAccessDenied); |
|
206 |
|
207 TRAP(err, DeleteContactL(KUidIccGlobalLndPhonebook)); |
|
208 TESTCHECKL(err, KErrAccessDenied); |
|
209 |
|
210 TRAP(err, DeleteContactL(KUidUsimAppAdnPhonebook)); |
|
211 TESTCHECKL(err, KErrAccessDenied); |
|
212 |
|
213 TRAP(err, DeleteContactL(KUidIccGlobalFdnPhonebook)); |
|
214 TESTCHECKL(err, KErrAccessDenied); |
|
215 |
|
216 return TestStepResult(); |
|
217 } |
|
218 |
|
219 |
|
220 /** |
|
221 * Factory construction method. |
|
222 * @return Pointer to CPhbkDeleteEntryICCDeleteFailsTest object |
|
223 */ |
|
224 CPhbkDeleteEntryICCDeleteFailsTest* CPhbkDeleteEntryICCDeleteFailsTest::NewL() |
|
225 { |
|
226 CPhbkDeleteEntryICCDeleteFailsTest* self = new(ELeave) CPhbkDeleteEntryICCDeleteFailsTest(); |
|
227 return self; |
|
228 } |
|
229 |
|
230 /** |
|
231 * Default constructor. Each test step initialises it's own name. |
|
232 */ |
|
233 CPhbkDeleteEntryICCDeleteFailsTest::CPhbkDeleteEntryICCDeleteFailsTest() |
|
234 { |
|
235 SetTestStepName(_L("DeleteEntryICCDeleteFailsTest")); |
|
236 } |
|
237 |
|
238 /** Delete an ICC entry - ICC delete fails */ |
|
239 enum TVerdict CPhbkDeleteEntryICCDeleteFailsTest::doTestStepL() |
|
240 { |
|
241 SetSimTsyTestNumberL(4); |
|
242 DoSyncL(); |
|
243 |
|
244 TRAPD(err, DeleteContactL(KUidIccGlobalAdnPhonebook)); |
|
245 TESTCHECKL(err, KErrBadHandle); |
|
246 |
|
247 TRAP(err, DeleteContactL(KUidIccGlobalSdnPhonebook)); |
|
248 TESTCHECKL(err, KErrBadHandle); |
|
249 |
|
250 TRAP(err, DeleteContactL(KUidIccGlobalLndPhonebook)); |
|
251 TESTCHECKL(err, KErrBadHandle); |
|
252 |
|
253 TRAP(err, DeleteContactL(KUidUsimAppAdnPhonebook)); |
|
254 TESTCHECKL(err, KErrBadHandle); |
|
255 |
|
256 TRAP(err, DeleteContactL(KUidIccGlobalFdnPhonebook)); |
|
257 TESTCHECKL(err, KErrBadHandle); |
|
258 |
|
259 return TestStepResult(); |
|
260 } |
|
261 |
|
262 |
|
263 /** |
|
264 * Factory construction method. |
|
265 * @return Pointer to CPhbkDeleteEntryReadOnlyAccessTest object |
|
266 */ |
|
267 CPhbkDeleteEntryReadOnlyAccessTest* CPhbkDeleteEntryReadOnlyAccessTest::NewL() |
|
268 { |
|
269 CPhbkDeleteEntryReadOnlyAccessTest* self = new(ELeave) CPhbkDeleteEntryReadOnlyAccessTest(); |
|
270 return self; |
|
271 } |
|
272 |
|
273 /** |
|
274 * Default constructor. Each test step initialises it's own name. |
|
275 */ |
|
276 CPhbkDeleteEntryReadOnlyAccessTest::CPhbkDeleteEntryReadOnlyAccessTest() |
|
277 { |
|
278 SetTestStepName(_L("DeleteEntryReadOnlyAccessTest")); |
|
279 } |
|
280 |
|
281 /** Delete an ICC entry - read-only phonebook */ |
|
282 enum TVerdict CPhbkDeleteEntryReadOnlyAccessTest::doTestStepL() |
|
283 { |
|
284 SetSimTsyTestNumberL(12); |
|
285 DoSyncL(); |
|
286 |
|
287 TRAPD(err, DeleteContactL(KUidIccGlobalAdnPhonebook)); |
|
288 TESTCHECKL(err, KErrAccessDenied); |
|
289 |
|
290 TRAP(err, DeleteContactL(KUidIccGlobalSdnPhonebook)); |
|
291 TESTCHECKL(err, KErrAccessDenied); |
|
292 |
|
293 TRAP(err, DeleteContactL(KUidIccGlobalLndPhonebook)); |
|
294 TESTCHECKL(err, KErrAccessDenied); |
|
295 |
|
296 TRAP(err, DeleteContactL(KUidUsimAppAdnPhonebook)); |
|
297 TESTCHECKL(err, KErrAccessDenied); |
|
298 |
|
299 TRAP(err, DeleteContactL(KUidIccGlobalFdnPhonebook)); |
|
300 TESTCHECKL(err, KErrAccessDenied); |
|
301 |
|
302 return TestStepResult(); |
|
303 } |
|
304 |
|
305 |
|
306 /** |
|
307 * Factory construction method. |
|
308 * @return Pointer to CPhbkDeleteArrayOneEntryTest object |
|
309 */ |
|
310 CPhbkDeleteArrayOneEntryTest* CPhbkDeleteArrayOneEntryTest::NewL() |
|
311 { |
|
312 CPhbkDeleteArrayOneEntryTest* self = new(ELeave) CPhbkDeleteArrayOneEntryTest(); |
|
313 return self; |
|
314 } |
|
315 |
|
316 /** |
|
317 * Default constructor. Each test step initialises it's own name. |
|
318 */ |
|
319 CPhbkDeleteArrayOneEntryTest::CPhbkDeleteArrayOneEntryTest() |
|
320 { |
|
321 SetTestStepName(_L("DeleteArrayOneEntryTest")); |
|
322 } |
|
323 |
|
324 /** Delete an array of ICC entries - one entry in the array */ |
|
325 enum TVerdict CPhbkDeleteArrayOneEntryTest::doTestStepL() |
|
326 { |
|
327 SetSimTsyTestNumberL(10); |
|
328 DoSyncL(); |
|
329 |
|
330 // * |
|
331 // * MJH - 12 Sept 2002 |
|
332 // * Assumptions for test data: |
|
333 // * |
|
334 // * Each phonebook must use a unique number format in order that the array |
|
335 // * of entries to be deleted only contains a single entry. |
|
336 // * |
|
337 |
|
338 DeleteArrayWithOneEntryL(KDeletedNumberInADN, KDeletedNameInADN, KUidIccGlobalAdnPhonebook); |
|
339 DeleteArrayWithOneEntryL(KDeletedNumberInSDN, KDeletedNameInSDN, KUidIccGlobalSdnPhonebook); |
|
340 DeleteArrayWithOneEntryL(KDeletedNumberInLND, KDeletedNameInLND, KUidIccGlobalLndPhonebook); |
|
341 DeleteArrayWithOneEntryL(KDeletedNumberInUsim, KDeletedNameInUsim, KUidUsimAppAdnPhonebook, KDeletedEmailInUsim); |
|
342 DeleteArrayWithOneEntryL(KDeletedNumberInFDN, KDeletedNameInFDN, KUidIccGlobalFdnPhonebook); |
|
343 |
|
344 return TestStepResult(); |
|
345 } |
|
346 |
|
347 |
|
348 /** |
|
349 * Factory construction method. |
|
350 * @return Pointer to CPhbkDeleteArrayInvalidIdTest object |
|
351 */ |
|
352 CPhbkDeleteArrayInvalidIdTest* CPhbkDeleteArrayInvalidIdTest::NewL() |
|
353 { |
|
354 CPhbkDeleteArrayInvalidIdTest* self = new(ELeave) CPhbkDeleteArrayInvalidIdTest(); |
|
355 return self; |
|
356 } |
|
357 |
|
358 /** |
|
359 * Default constructor. Each test step initialises it's own name. |
|
360 */ |
|
361 CPhbkDeleteArrayInvalidIdTest::CPhbkDeleteArrayInvalidIdTest() |
|
362 { |
|
363 SetTestStepName(_L("DeleteArrayInvalidIdTest")); |
|
364 } |
|
365 |
|
366 /** Delete an array of ICC entries - invalid ID added to the array */ |
|
367 enum TVerdict CPhbkDeleteArrayInvalidIdTest::doTestStepL() |
|
368 { |
|
369 SetSimTsyTestNumberL(10); |
|
370 DoSyncL(); |
|
371 |
|
372 // * |
|
373 // * MJH - 12 Sept 2002 |
|
374 // * Assumptions for test data: |
|
375 // * |
|
376 // * Each phonebook must use a unique number format in order that the array |
|
377 // * of entries to be deleted only relates to that phonebook. |
|
378 // * |
|
379 |
|
380 DeleteArrayWithInvalidIdL(KDeletedNumberInADN); |
|
381 DeleteArrayWithInvalidIdL(KDeletedNumberInSDN); |
|
382 DeleteArrayWithInvalidIdL(KDeletedNumberInLND); |
|
383 DeleteArrayWithInvalidIdL(KDeletedNumberInUsim); |
|
384 DeleteArrayWithInvalidIdL(KDeletedNumberInFDN); |
|
385 |
|
386 return TestStepResult(); |
|
387 } |
|
388 |
|
389 |
|
390 /** |
|
391 * Factory construction method. |
|
392 * @return Pointer to CPhbkDeleteArrayMultipleEntriesTest object |
|
393 */ |
|
394 CPhbkDeleteArrayMultipleEntriesTest* CPhbkDeleteArrayMultipleEntriesTest::NewL() |
|
395 { |
|
396 CPhbkDeleteArrayMultipleEntriesTest* self = new(ELeave) CPhbkDeleteArrayMultipleEntriesTest(); |
|
397 return self; |
|
398 } |
|
399 |
|
400 /** |
|
401 * Default constructor. Each test step initialises it's own name. |
|
402 */ |
|
403 CPhbkDeleteArrayMultipleEntriesTest::CPhbkDeleteArrayMultipleEntriesTest() |
|
404 { |
|
405 SetTestStepName(_L("DeleteArrayMultipleEntriesTest")); |
|
406 } |
|
407 |
|
408 /** Delete an array of ICC entries - multiple entries in the array */ |
|
409 enum TVerdict CPhbkDeleteArrayMultipleEntriesTest::doTestStepL() |
|
410 { |
|
411 SetSimTsyTestNumberL(10); |
|
412 DoSyncL(); |
|
413 |
|
414 // * |
|
415 // * MJH - 12 Sept 2002 |
|
416 // * Assumptions for test data: |
|
417 // * |
|
418 // * Each phonebook must use a unique format of name for its entries in order |
|
419 // * that the array of entries to be deleted only relates to that phonebook. |
|
420 // * |
|
421 |
|
422 DeleteArrayWithMultEntryL(KDeletedNumberInADN, KSearchStringInADN, KUidIccGlobalAdnPhonebook); |
|
423 DeleteArrayWithMultEntryL(KDeletedNumberInSDN, KSearchStringInSDN, KUidIccGlobalSdnPhonebook); |
|
424 DeleteArrayWithMultEntryL(KDeletedNumberInLND, KSearchStringInLND, KUidIccGlobalLndPhonebook); |
|
425 DeleteArrayWithMultEntryL(KDeletedNumberInUsim, KSearchStringInUsim, KUidUsimAppAdnPhonebook, KDeletedEmailInUsim); |
|
426 DeleteArrayWithMultEntryL(KDeletedNumberInFDN, KSearchStringInFDN, KUidIccGlobalFdnPhonebook); |
|
427 |
|
428 return TestStepResult(); |
|
429 } |
|
430 |
|
431 |
|
432 /** Delete and then Add Multiple entries */ |
|
433 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithMultEntryL(const TDesC& aNumber, const TDesC& aName, const TUid aPhoneBook, const TDesC& aEmail) |
|
434 { |
|
435 CContactItemFieldDef* def=new(ELeave) CContactItemFieldDef(); |
|
436 CleanupStack::PushL(def); |
|
437 def->AppendL(KUidContactFieldFamilyName); |
|
438 CContactIdArray* array=iDb->FindLC(aName,def); |
|
439 TInt count(array->Count()); |
|
440 TESTCHECKCONDITIONL(count != 0); // make sure there is at least one entry in array |
|
441 TRAPD(err, iDb->DeleteContactsL(*array)); |
|
442 TESTCHECKL(err, KErrNone); |
|
443 |
|
444 // Now add same number of entries to Contacts DB |
|
445 CPhbkIntegrationTestUtility* add = CPhbkIntegrationTestUtility::NewL(); |
|
446 CleanupStack::PushL(add); |
|
447 for(TInt i=0; i<count; i++) |
|
448 add->AddContactL(aName, aNumber, aPhoneBook, aEmail); // now write new entry |
|
449 |
|
450 CleanupStack::PopAndDestroy(3,def); // array & def & add? |
|
451 } |
|
452 |
|
453 /** |
|
454 * Factory construction method. |
|
455 * @return Pointer to CPhbkDeleteArrayICCLockedTest object |
|
456 */ |
|
457 CPhbkDeleteArrayICCLockedTest* CPhbkDeleteArrayICCLockedTest::NewL() |
|
458 { |
|
459 CPhbkDeleteArrayICCLockedTest* self = new(ELeave) CPhbkDeleteArrayICCLockedTest(); |
|
460 return self; |
|
461 } |
|
462 |
|
463 /** |
|
464 * Default constructor. Each test step initialises it's own name. |
|
465 */ |
|
466 CPhbkDeleteArrayICCLockedTest::CPhbkDeleteArrayICCLockedTest() |
|
467 { |
|
468 SetTestStepName(_L("DeleteArrayICCLockedTest")); |
|
469 } |
|
470 |
|
471 /** Delete an array of ICC entries - ICC locked */ |
|
472 enum TVerdict CPhbkDeleteArrayICCLockedTest::doTestStepL() |
|
473 { |
|
474 SetSimTsyTestNumberL(2); |
|
475 DoSyncL(); |
|
476 |
|
477 // * |
|
478 // * MJH - 12 Sept 2002 |
|
479 // * Assumptions for test data: |
|
480 // * |
|
481 // * Each phonebook must use a unique format of name for its entries in order |
|
482 // * that the array of entries to be deleted only relates to that phonebook. |
|
483 // * |
|
484 // * The value of KTest2ICCSlots defines the total number of entries |
|
485 // * for ALL phonebooks. |
|
486 // * |
|
487 |
|
488 // Access ICC and wait for it to become locked |
|
489 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
490 const CContactIdArray* sortedItems = iDb->SortedItemsL(); |
|
491 TInt count(sortedItems->Count()); |
|
492 TESTCHECKL(count, KTest2ICCSlots); |
|
493 TContactItemId id = (*sortedItems)[0]; |
|
494 |
|
495 TInt err(KErrNone); |
|
496 while(err==KErrNone) // Wait for ICC to become locked |
|
497 { |
|
498 User::After(1000000); // Wait a second and try again. |
|
499 CContactICCEntry* failEntry=NULL; |
|
500 TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked |
|
501 delete failEntry; |
|
502 } |
|
503 TESTCHECKCONDITIONL(err == KErrAccessDenied || err == KErrNotReady); |
|
504 |
|
505 DeleteArrayWithICCLockedL(KSearchStringInADN, KErrAccessDenied); |
|
506 DeleteArrayWithICCLockedL(KSearchStringInSDN, KErrAccessDenied); |
|
507 DeleteArrayWithICCLockedL(KSearchStringInLND, KErrAccessDenied); |
|
508 DeleteArrayWithICCLockedL(KSearchStringInUsim, KErrAccessDenied); |
|
509 DeleteArrayWithICCLockedL(KSearchStringInFDN, KErrAccessDenied); |
|
510 |
|
511 return TestStepResult(); |
|
512 } |
|
513 |
|
514 |
|
515 /** |
|
516 * Factory construction method. |
|
517 * @return Pointer to CPhbkDeleteArrayReadOnlyAccessTest object |
|
518 */ |
|
519 CPhbkDeleteArrayReadOnlyAccessTest* CPhbkDeleteArrayReadOnlyAccessTest::NewL() |
|
520 { |
|
521 CPhbkDeleteArrayReadOnlyAccessTest* self = new(ELeave) CPhbkDeleteArrayReadOnlyAccessTest(); |
|
522 return self; |
|
523 } |
|
524 |
|
525 /** |
|
526 * Default constructor. Each test step initialises it's own name. |
|
527 */ |
|
528 CPhbkDeleteArrayReadOnlyAccessTest::CPhbkDeleteArrayReadOnlyAccessTest() |
|
529 { |
|
530 SetTestStepName(_L("DeleteArrayReadOnlyAccessTest")); |
|
531 } |
|
532 |
|
533 /** Delete an array of ICC entries - Read-only Access */ |
|
534 enum TVerdict CPhbkDeleteArrayReadOnlyAccessTest::doTestStepL() |
|
535 { |
|
536 SetSimTsyTestNumberL(12); |
|
537 DoSyncL(); |
|
538 |
|
539 // * |
|
540 // * MJH - 12 Sept 2002 |
|
541 // * Assumptions for test data: |
|
542 // * |
|
543 // * Each phonebook must use a unique format of name for its entries in order |
|
544 // * that the array of entries to be deleted only relates to that phonebook. |
|
545 // * |
|
546 |
|
547 DeleteArrayWithFailureL(KSearchNameInADN, KErrAccessDenied); |
|
548 DeleteArrayWithFailureL(KSearchNameInSDN, KErrAccessDenied); |
|
549 DeleteArrayWithFailureL(KSearchNameInLND, KErrAccessDenied); |
|
550 DeleteArrayWithFailureL(KSearchNameInUsim, KErrAccessDenied); |
|
551 DeleteArrayWithFailureL(KSearchNameInFDN, KErrAccessDenied); |
|
552 |
|
553 return TestStepResult(); |
|
554 } |
|
555 |
|
556 |
|
557 /** |
|
558 * Factory construction method. |
|
559 * @return Pointer to CPhbkDeleteArrayICCDeleteFailsTest object |
|
560 */ |
|
561 CPhbkDeleteArrayICCDeleteFailsTest* CPhbkDeleteArrayICCDeleteFailsTest::NewL() |
|
562 { |
|
563 CPhbkDeleteArrayICCDeleteFailsTest* self = new(ELeave) CPhbkDeleteArrayICCDeleteFailsTest(); |
|
564 return self; |
|
565 } |
|
566 |
|
567 /** |
|
568 * Default constructor. Each test step initialises it's own name. |
|
569 */ |
|
570 CPhbkDeleteArrayICCDeleteFailsTest::CPhbkDeleteArrayICCDeleteFailsTest() |
|
571 { |
|
572 SetTestStepName(_L("DeleteArrayICCDeleteFailsTest")); |
|
573 } |
|
574 |
|
575 /** Delete an array of ICC entries - ICC delete fails */ |
|
576 enum TVerdict CPhbkDeleteArrayICCDeleteFailsTest::doTestStepL() |
|
577 { |
|
578 SetSimTsyTestNumberL(4); |
|
579 DoSyncL(); |
|
580 |
|
581 DeleteArrayWithFailureL(KDeletedNameInADN, KErrBadHandle); |
|
582 DeleteArrayWithFailureL(KDeletedNameInSDN, KErrBadHandle); |
|
583 DeleteArrayWithFailureL(KDeletedNameInLND, KErrBadHandle); |
|
584 DeleteArrayWithFailureL(KDeletedNameInUsim, KErrBadHandle); |
|
585 DeleteArrayWithFailureL(KDeletedNameInFDN, KErrBadHandle); |
|
586 |
|
587 return TestStepResult(); |
|
588 } |
|
589 |
|
590 |
|
591 /** |
|
592 * Factory construction method. |
|
593 * @return Pointer to CPhbkDeleteArrayInvalidUIDTest object |
|
594 */ |
|
595 CPhbkDeleteArrayInvalidUIDTest* CPhbkDeleteArrayInvalidUIDTest::NewL() |
|
596 { |
|
597 CPhbkDeleteArrayInvalidUIDTest* self = new(ELeave) CPhbkDeleteArrayInvalidUIDTest(); |
|
598 return self; |
|
599 } |
|
600 |
|
601 /** |
|
602 * Default constructor. Each test step initialises it's own name. |
|
603 */ |
|
604 CPhbkDeleteArrayInvalidUIDTest::CPhbkDeleteArrayInvalidUIDTest() |
|
605 { |
|
606 SetTestStepName(_L("DeleteArrayInvalidUIDTest")); |
|
607 } |
|
608 |
|
609 /** Delete an array of ICC entries - array contains both valid and invalid UIDs */ |
|
610 enum TVerdict CPhbkDeleteArrayInvalidUIDTest::doTestStepL() |
|
611 { |
|
612 SetSimTsyTestNumberL(121); |
|
613 DoSyncL(); |
|
614 |
|
615 // * |
|
616 // * MJH - 12 Sept 2002 |
|
617 // * Assumptions for test data: |
|
618 // * |
|
619 // * Each phonebook must use a unique format of name for its entries in order |
|
620 // * that the array of entries to be deleted only relates to that phonebook. |
|
621 // * |
|
622 |
|
623 DeleteArrayWithInvalidUIDL(KSearchNameInADN); |
|
624 DeleteArrayWithInvalidUIDL(KSearchNameInSDN); |
|
625 DeleteArrayWithInvalidUIDL(KSearchNameInLND); |
|
626 DeleteArrayWithInvalidUIDL(KSearchNameInUsim); |
|
627 DeleteArrayWithInvalidUIDL(KSearchNameInFDN); |
|
628 |
|
629 return TestStepResult(); |
|
630 } |
|
631 |
|
632 |
|
633 /** |
|
634 * Factory construction method. |
|
635 * @return Pointer to CPhbkDeleteArrayFullPhonebookTest object |
|
636 */ |
|
637 CPhbkDeleteArrayFullPhonebookTest* CPhbkDeleteArrayFullPhonebookTest::NewL() |
|
638 { |
|
639 CPhbkDeleteArrayFullPhonebookTest* self = new(ELeave) CPhbkDeleteArrayFullPhonebookTest(); |
|
640 return self; |
|
641 } |
|
642 |
|
643 /** |
|
644 * Default constructor. Each test step initialises it's own name. |
|
645 */ |
|
646 CPhbkDeleteArrayFullPhonebookTest::CPhbkDeleteArrayFullPhonebookTest() |
|
647 { |
|
648 SetTestStepName(_L("DeleteArrayFullPhonebookTest")); |
|
649 } |
|
650 |
|
651 /** Delete an array of ICC entries - all entries in full phonebook */ |
|
652 enum TVerdict CPhbkDeleteArrayFullPhonebookTest::doTestStepL() |
|
653 { |
|
654 #if 1 |
|
655 // |
|
656 // This test has issues with a defect in the current CntModel implementation so it is best |
|
657 // not to run it, otherwise it takes down CntModel and TE_CntSync takes an extra hour to |
|
658 // abort all the remaining tests. |
|
659 // |
|
660 INFO_PRINTF1(_L("<font color=Orange>The current CntModel implementation will not support this test!</font>")); |
|
661 SetTestStepResult(EPass); |
|
662 #else |
|
663 SetSimTsyTestNumberL(0); |
|
664 DoSyncL(); |
|
665 |
|
666 // * |
|
667 // * MJH - 12 Sept 2002 |
|
668 // * Assumptions for test data: |
|
669 // * |
|
670 // * Each phonebook must use a unique format of name for its entries in order |
|
671 // * that the array of entries to be deleted only relates to that phonebook. |
|
672 // * |
|
673 |
|
674 DeleteWholePhonebookL(KSearchStringInADN); |
|
675 DeleteWholePhonebookL(KSearchStringInSDN); |
|
676 DeleteWholePhonebookL(KSearchStringInLND); |
|
677 DeleteWholePhonebookL(KSearchStringInUsim); |
|
678 DeleteWholePhonebookL(KSearchStringInFDN); |
|
679 #endif |
|
680 |
|
681 return TestStepResult(); |
|
682 } |
|
683 |
|
684 |
|
685 /** |
|
686 * Factory construction method. |
|
687 * @return Pointer to CPhbkDeleteSlotEntryTwiceTest object |
|
688 */ |
|
689 CPhbkDeleteSlotEntryTwiceTest* CPhbkDeleteSlotEntryTwiceTest::NewL() |
|
690 { |
|
691 CPhbkDeleteSlotEntryTwiceTest* self = new(ELeave) CPhbkDeleteSlotEntryTwiceTest(); |
|
692 return self; |
|
693 } |
|
694 |
|
695 /** |
|
696 * Default constructor. Each test step initialises it's own name. |
|
697 */ |
|
698 CPhbkDeleteSlotEntryTwiceTest::CPhbkDeleteSlotEntryTwiceTest() |
|
699 { |
|
700 SetTestStepName(_L("DeleteSlotEntryTwiceTest")); |
|
701 } |
|
702 |
|
703 /** Delete from a given slot, twice */ |
|
704 enum TVerdict CPhbkDeleteSlotEntryTwiceTest::doTestStepL() |
|
705 { |
|
706 SetSimTsyTestNumberL(23); |
|
707 DoSyncL(); |
|
708 |
|
709 DeleteSlotTwiceL(KDeletedNumberInADN, KDeletedNameInADN, KUidIccGlobalAdnPhonebook); |
|
710 DeleteSlotTwiceL(KDeletedNumberInSDN, KDeletedNameInSDN, KUidIccGlobalSdnPhonebook); |
|
711 DeleteSlotTwiceL(KDeletedNumberInLND, KDeletedNameInLND, KUidIccGlobalLndPhonebook); |
|
712 DeleteSlotTwiceL(KDeletedNumberInUsim, KDeletedNameInUsim, KUidUsimAppAdnPhonebook, KDeletedEmailInUsim); |
|
713 DeleteSlotTwiceL(KDeletedNumberInFDN, KDeletedNameInFDN, KUidIccGlobalFdnPhonebook); |
|
714 |
|
715 return TestStepResult(); |
|
716 } |
|
717 |
|
718 |
|
719 /** Delete an ICC contact - normal case */ |
|
720 void CPhbkDeleteIntegrationTestBase::DeleteContactL(TUid aPhonebookUid) |
|
721 { |
|
722 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
723 // get the unique groupId for the given phonebook |
|
724 TContactItemId groupId(KNullContactId); |
|
725 User::LeaveIfError(iSession.GetPhoneBookId(groupId, |
|
726 RPhoneBookSession::ESyncGroupId, |
|
727 aPhonebookUid)); |
|
728 TESTCHECKCONDITIONL(groupId != KNullContactId); |
|
729 |
|
730 // based on the groupId, get items belonging to the phonebook |
|
731 CContactGroup* group = NULL; |
|
732 TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId))); |
|
733 TESTCHECKL(err, KErrNone); |
|
734 CleanupStack::PushL(group); |
|
735 const CContactIdArray* array = group->ItemsContained(); |
|
736 |
|
737 // delete first item |
|
738 TContactItemId id = (*array)[0]; |
|
739 iDb->DeleteContactL(id); |
|
740 |
|
741 //check the item has been removed from the database |
|
742 CContactItem* item=NULL; |
|
743 TRAP(err, item = iDb->ReadContactL(id)); |
|
744 TESTCHECKL(err, KErrNotFound); |
|
745 delete item; |
|
746 CleanupStack::PopAndDestroy(); // group |
|
747 } |
|
748 |
|
749 /** Delete and then Add Single entry */ |
|
750 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithOneEntryL(const TDesC& aNumber, const TDesC& aName, const TUid aPhoneBook, const TDesC& aEmail) |
|
751 { |
|
752 CContactIdArray* array = iDb->MatchPhoneNumberL(aNumber,KMaxPhoneMatchLength); |
|
753 CleanupStack::PushL(array); |
|
754 TESTCHECKL(array->Count(), 1); // make sure there is only 1 entry in array |
|
755 TContactItemId deleteId=(*array)[0]; |
|
756 iDb->DeleteContactsL(*array); |
|
757 CContactItem* item=NULL; // check the item has been removed from the database |
|
758 TRAPD(err, item = iDb->ReadContactL(deleteId)); |
|
759 TESTCHECKL(err, KErrNotFound); |
|
760 |
|
761 delete item; |
|
762 CPhbkIntegrationTestUtility* add = CPhbkIntegrationTestUtility::NewL(); |
|
763 CleanupStack::PushL(add); |
|
764 add->AddContactL(aName, aNumber, aPhoneBook, aEmail); // now write new entry |
|
765 |
|
766 CleanupStack::PopAndDestroy(2); // array & add |
|
767 } |
|
768 |
|
769 /** Delete array with invalid UID added */ |
|
770 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithInvalidIdL(const TDesC& aNumber) |
|
771 { |
|
772 CContactIdArray* array = iDb->MatchPhoneNumberL(aNumber,KMaxPhoneMatchLength); |
|
773 CleanupStack::PushL(array); |
|
774 TESTCHECKL(array->Count(), 1); // make sure there is only 1 entry in array |
|
775 TContactItemId invalidUID1(1500); // invalid UID |
|
776 array->AddL(invalidUID1); // Add invalid UID |
|
777 TRAPD(err, iDb->DeleteContactsL(*array)); // array contains invalid UID |
|
778 TESTCHECKL(err, KErrNotFound); |
|
779 TRAP_IGNORE(iDb->RecoverL()); |
|
780 CleanupStack::PopAndDestroy(); // array |
|
781 } |
|
782 |
|
783 /** Delete array with failure */ |
|
784 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithFailureL(const TDesC& aName, const TInt aExpectedError) |
|
785 { |
|
786 CContactItemFieldDef* def=new(ELeave) CContactItemFieldDef(); |
|
787 CleanupStack::PushL(def); |
|
788 def->AppendL(KUidContactFieldFamilyName); |
|
789 CContactIdArray* array=iDb->FindLC(aName,def); |
|
790 |
|
791 TInt count(array->Count()); |
|
792 TESTCHECKCONDITIONL(count != 0); // make sure there is at least one entry in array |
|
793 TRAPD(err, iDb->DeleteContactsL(*array)); |
|
794 TESTCHECKL(err, aExpectedError); |
|
795 |
|
796 TInt i(0); |
|
797 for(i=0; i<count; i++) |
|
798 { |
|
799 TContactItemId deleteId=(*array)[i]; |
|
800 CContactItem* item=NULL; // check the item has NOT been removed from the database |
|
801 TRAP(err, item = iDb->ReadContactL(deleteId)); |
|
802 TESTCHECKL(err, KErrNone); |
|
803 delete item; |
|
804 } |
|
805 |
|
806 CleanupStack::PopAndDestroy(2); // def, array |
|
807 } |
|
808 |
|
809 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithICCLockedL(const TDesC& aName, const TInt aExpectedError) |
|
810 { |
|
811 CContactItemFieldDef* def=new(ELeave) CContactItemFieldDef(); |
|
812 CleanupStack::PushL(def); |
|
813 def->AppendL(KUidContactFieldFamilyName); |
|
814 TInt error(KErrAccessDenied); |
|
815 |
|
816 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
817 const CContactIdArray* sortedItems = iDb->SortedItemsL(); |
|
818 TContactItemId id = (*sortedItems)[0]; |
|
819 while (error==KErrAccessDenied || error==KErrNotReady || error==KErrNotFound) // Wait for ICC to become unlocked again |
|
820 { |
|
821 User::After(1000000); // Wait a second and try again. |
|
822 CContactICCEntry* failEntry=NULL; |
|
823 TRAP(error, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked |
|
824 delete failEntry; |
|
825 } |
|
826 TESTCHECKL(error, KErrNone); |
|
827 |
|
828 WaitForSyncToCompleteL(); |
|
829 |
|
830 CContactIdArray* array = (CContactIdArray*)iDb->FindLC(aName,def); // Entry unavailable due to ICC being locked |
|
831 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
832 sortedItems = iDb->SortedItemsL(); |
|
833 id = (*sortedItems)[0]; |
|
834 while (error==KErrNone || error==KErrNotReady) // Wait for ICC to become locked again |
|
835 { |
|
836 User::After(1000000); // Wait a second and try again. |
|
837 CContactICCEntry* failEntry=NULL; |
|
838 TRAP(error, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked |
|
839 delete failEntry; |
|
840 } |
|
841 TESTCHECKL(error, KErrAccessDenied); |
|
842 |
|
843 TInt count(array->Count()); |
|
844 TESTCHECKCONDITIONL(count != 0); // make sure there is at least one entry in array |
|
845 TRAPD(err, iDb->DeleteContactsL(*array)); |
|
846 TESTCHECKL(err, aExpectedError); |
|
847 |
|
848 CleanupStack::PopAndDestroy(2); // def, array |
|
849 } |
|
850 |
|
851 /** Delete with invalid UIDs */ |
|
852 void CPhbkDeleteIntegrationTestBase::DeleteArrayWithInvalidUIDL(const TDesC& aName) |
|
853 { |
|
854 CContactItemFieldDef* def=new(ELeave) CContactItemFieldDef(); |
|
855 CleanupStack::PushL(def); |
|
856 def->AppendL(KUidContactFieldFamilyName); |
|
857 CContactIdArray* array=iDb->FindLC(aName,def); |
|
858 |
|
859 TContactItemId invalidUID1(8955), invalidUID2(35457), invalidUID3(5555); |
|
860 |
|
861 array->AddL(invalidUID1); // Add some invalid UIDs |
|
862 array->AddL(invalidUID2); |
|
863 array->AddL(invalidUID3); |
|
864 |
|
865 TRAPD(err,iDb->DeleteContactsL(*array)); |
|
866 TESTCHECK(err, KErrNotFound); |
|
867 |
|
868 TRAP_IGNORE(iDb->RecoverL()); // Recovers the database from a rollback. First closes all |
|
869 // tables and then reopens them after the recover. |
|
870 TInt count(array->Count()); |
|
871 for(TInt i=0; i<count; i++) |
|
872 { |
|
873 // |
|
874 // Check items are not in the database... |
|
875 // |
|
876 TContactItemId deleteId((*array)[i]); |
|
877 CContactItem* item=NULL; |
|
878 |
|
879 TRAP(err, item = iDb->ReadContactL(deleteId)); |
|
880 delete item; |
|
881 |
|
882 TESTCHECK(err, KErrNotFound); |
|
883 } |
|
884 |
|
885 CleanupStack::PopAndDestroy(2); // def, array |
|
886 } |
|
887 |
|
888 /** Delete whole phonebook */ |
|
889 void CPhbkDeleteIntegrationTestBase::DeleteWholePhonebookL(const TDesC& aName) |
|
890 { |
|
891 CContactItemFieldDef* def=new(ELeave) CContactItemFieldDef(); |
|
892 CleanupStack::PushL(def); |
|
893 def->AppendL(KUidContactFieldFamilyName); |
|
894 |
|
895 CContactIdArray* array=iDb->FindLC(aName,def); |
|
896 TRAPD(err,iDb->DeleteContactsL(*array)); |
|
897 TESTCHECKL(err, KErrNone); |
|
898 |
|
899 TInt count(array->Count()); |
|
900 for(TInt i=0; i<count; i++) |
|
901 { |
|
902 TContactItemId deleteId((*array)[i]); |
|
903 CContactItem* item=NULL; // check items have been removed from the database |
|
904 TRAP(err, item = iDb->ReadContactL(deleteId)); |
|
905 TESTCHECKL(err, KErrNotFound); |
|
906 delete item; |
|
907 } |
|
908 |
|
909 CleanupStack::PopAndDestroy(2); // def |
|
910 } |
|
911 |
|
912 /** Delete an ICC contact - normal case */ |
|
913 void CPhbkDeleteIntegrationTestBase::DeleteSlotTwiceL(const TDesC& aNumber, const TDesC& aName, const TUid aPhonebook, const TDesC& aEmail) |
|
914 { |
|
915 iDb->SetDbViewContactType(KUidContactICCEntry); |
|
916 // get the unique groupId for the given phonebook |
|
917 TContactItemId groupId(KNullContactId); |
|
918 User::LeaveIfError(iSession.GetPhoneBookId(groupId, |
|
919 RPhoneBookSession::ESyncGroupId, |
|
920 aPhonebook)); |
|
921 TESTCHECKCONDITIONL(groupId != KNullContactId); |
|
922 |
|
923 // based on the groupId, get items belonging to the phonebook |
|
924 CContactGroup* group = NULL; |
|
925 TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId))); |
|
926 TESTCHECKL(err, KErrNone); |
|
927 CleanupStack::PushL(group); |
|
928 const CContactIdArray* array = group->ItemsContained(); |
|
929 |
|
930 // delete first item |
|
931 TContactItemId id((*array)[0]); |
|
932 iDb->DeleteContactL(id); |
|
933 |
|
934 //check the item has been removed from the database |
|
935 CContactItem* item=NULL; |
|
936 TRAP(err, item = iDb->ReadContactL(id)); |
|
937 TESTCHECKL(err, KErrNotFound); |
|
938 |
|
939 delete item; |
|
940 // verify that there is a free slot |
|
941 RArray<TInt> slotNums; |
|
942 CleanupClosePushL(slotNums); |
|
943 iSession.GetFreeSlotsL(slotNums, aPhonebook); |
|
944 TESTCHECKCONDITIONL(slotNums.Count() > 0); |
|
945 |
|
946 // Now add a new item - which should use the vacated slot |
|
947 CPhbkIntegrationTestUtility* add = CPhbkIntegrationTestUtility::NewL(); |
|
948 CleanupStack::PushL(add); |
|
949 add->AddContactL(aName, aNumber, aPhonebook, aEmail); |
|
950 |
|
951 // delete this new item - to verify that the delete on same slot is permitted |
|
952 TInt ret = iSession.GetSlotId(slotNums[0], id, aPhonebook); |
|
953 TESTCHECKL(ret, KErrNone); |
|
954 |
|
955 item=NULL; |
|
956 TRAP(err, item = static_cast<CContactICCEntry*>(iDb->ReadContactL(id))); |
|
957 TESTCHECKL(err, KErrNone); |
|
958 delete item; |
|
959 TRAP(err, iDb->DeleteContactL(id)); |
|
960 TESTCHECKL(err, KErrNone); |
|
961 |
|
962 CleanupStack::PopAndDestroy(3); // add, group, slotNums |
|
963 } |
|
964 |