|
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 // This contains PhbkSync API DeleteContact() related Unit Test Steps |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "TE_PhBkSyncBase.h" |
|
20 #include "TestDeleteContactSteps.h" |
|
21 |
|
22 /** |
|
23 * Test deleting a contact by specifying a valid ICC slot. |
|
24 * Repeat for all supported phonebooks. |
|
25 */ |
|
26 // |
|
27 // Test step1 -- Test#73 in Unit Test Spec. Doc. // |
|
28 // |
|
29 CPhbkSyncDeleteContactTest_01::CPhbkSyncDeleteContactTest_01() |
|
30 { |
|
31 // store the name of this test step |
|
32 SetTestStepName(_L("PhbkSyncDeleteContactTest_01")); |
|
33 } |
|
34 |
|
35 CPhbkSyncDeleteContactTest_01::~CPhbkSyncDeleteContactTest_01() |
|
36 { |
|
37 } |
|
38 |
|
39 TVerdict CPhbkSyncDeleteContactTest_01::doTestStepL( ) |
|
40 { |
|
41 TContactItemId id; |
|
42 TInt result; |
|
43 TInt i(0); |
|
44 TRequestStatus status; |
|
45 |
|
46 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
47 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
48 { |
|
49 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
50 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
51 } |
|
52 |
|
53 // 2. re-use test prepared for Test#37 which contains all phonebooks. |
|
54 // All phonebooks should be synchronised automatically after this. |
|
55 SetSimTsyTestNumberL(37); |
|
56 |
|
57 User::After(3000000); // Wait for a while for auto sync |
|
58 RPhoneBookSession::TSyncState state; |
|
59 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
60 { |
|
61 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
62 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
63 { |
|
64 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
65 User::After(1000000); |
|
66 } |
|
67 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
68 } |
|
69 |
|
70 // 3. test deleting a valid ICC slot |
|
71 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
72 { |
|
73 id = GetValidUIDFromContactsDbL(iPhoneBook[i]); |
|
74 iSession.DeleteContact(status, id); |
|
75 User::WaitForRequest(status); |
|
76 TESTCHECKL(status.Int(), KErrNone); |
|
77 // check expected behaviour (entry has been deleted) |
|
78 result = iSession.ValidateContact(MContactSynchroniser::ERead, id); |
|
79 TESTCHECKL(result, KErrNotFound); |
|
80 } |
|
81 |
|
82 return TestStepResult(); |
|
83 } |
|
84 |
|
85 /** |
|
86 * Test deleting a contact by specifying a valid ICC slot |
|
87 * which contains a blank entry. |
|
88 */ |
|
89 // |
|
90 // Test step2 -- Test#74 in Unit Test Spec. Doc. // |
|
91 //** |
|
92 CPhbkSyncDeleteContactTest_02::CPhbkSyncDeleteContactTest_02() |
|
93 { |
|
94 // store the name of this test step |
|
95 SetTestStepName(_L("PhbkSyncDeleteContactTest_02")); |
|
96 } |
|
97 |
|
98 CPhbkSyncDeleteContactTest_02::~CPhbkSyncDeleteContactTest_02() |
|
99 { |
|
100 } |
|
101 |
|
102 TVerdict CPhbkSyncDeleteContactTest_02::doTestStepL( ) |
|
103 { |
|
104 TContactItemId validId, invalidId; |
|
105 TInt result; |
|
106 TInt i(0); |
|
107 TRequestStatus status; |
|
108 |
|
109 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
110 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
111 { |
|
112 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
113 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
114 } |
|
115 |
|
116 // 2. re-use test prepared for Test#37 which contains all phonebooks. |
|
117 // All phonebooks should be synchronised automatically after this. |
|
118 SetSimTsyTestNumberL(37); |
|
119 |
|
120 User::After(3000000); // Wait for a while for auto sync |
|
121 RPhoneBookSession::TSyncState state; |
|
122 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
123 { |
|
124 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
125 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
126 { |
|
127 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
128 User::After(1000000); |
|
129 } |
|
130 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
131 } |
|
132 |
|
133 // 3. test deleting a valid ICC slot which contains a blank entry |
|
134 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
135 { |
|
136 validId = GetValidUIDFromContactsDbL(iPhoneBook[i]); |
|
137 invalidId = validId + 999; // make it invalid (i.e. not exist, ugly) |
|
138 iSession.DeleteContact(status, invalidId); // should fail |
|
139 User::WaitForRequest(status); |
|
140 TESTCHECKL(status.Int(), KErrArgument); |
|
141 |
|
142 // check expected behaviour (entry is still there) |
|
143 result = iSession.ValidateContact(MContactSynchroniser::ERead, validId); |
|
144 TESTCHECKL(result, KErrNone); |
|
145 } |
|
146 |
|
147 return TestStepResult(); |
|
148 } |
|
149 |
|
150 /** |
|
151 * Test deleting a contact by specifying an invalid ICC |
|
152 * slot. Repeat for all supported phonebooks. |
|
153 */ |
|
154 // |
|
155 // Test step3 -- Test#75 in Unit Test Spec. Doc. // |
|
156 // |
|
157 CPhbkSyncDeleteContactTest_03::CPhbkSyncDeleteContactTest_03() |
|
158 { |
|
159 // store the name of this test step |
|
160 SetTestStepName(_L("PhbkSyncDeleteContactTest_03")); |
|
161 } |
|
162 |
|
163 CPhbkSyncDeleteContactTest_03::~CPhbkSyncDeleteContactTest_03() |
|
164 { |
|
165 } |
|
166 |
|
167 TVerdict CPhbkSyncDeleteContactTest_03::doTestStepL( ) |
|
168 { |
|
169 TContactItemId id; |
|
170 TRequestStatus status; |
|
171 TInt result; |
|
172 TInt i(0); |
|
173 |
|
174 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
175 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
176 { |
|
177 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
178 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
179 } |
|
180 |
|
181 // 2. re-use test prepared for Test#37 which contains all phonebooks. |
|
182 // All phonebooks should be synchronised automatically after this. |
|
183 SetSimTsyTestNumberL(37); |
|
184 |
|
185 User::After(3000000); // Wait for a while for auto sync |
|
186 RPhoneBookSession::TSyncState state; |
|
187 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
188 { |
|
189 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
190 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
191 { |
|
192 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
193 User::After(1000000); |
|
194 } |
|
195 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
196 } |
|
197 |
|
198 // 3. test deleting a invalid ICC slot |
|
199 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
200 { |
|
201 // try to delete the invalid ICC slot |
|
202 id = -3; // Note that -1 is the default UID value in lookUpTable |
|
203 iSession.DeleteContact(status, id); |
|
204 User::WaitForRequest(status); |
|
205 TESTCHECKL(status.Int(), KErrArgument); |
|
206 |
|
207 // check expected behaviour (the phonebook still exists) |
|
208 id = GetValidUIDFromContactsDbL(iPhoneBook[i]); |
|
209 result = iSession.ValidateContact(MContactSynchroniser::ERead, id); |
|
210 TESTCHECKL(result, KErrNone); |
|
211 } |
|
212 |
|
213 return TestStepResult(); |
|
214 } |
|
215 |
|
216 /** |
|
217 * Test deleting a contact from a read-only (SDN) phonebook. |
|
218 * By default, SDN and LND are read-only phonebooks. |
|
219 */ |
|
220 // |
|
221 // Test step4 -- Test#76 in Unit Test Spec. Doc. // |
|
222 // |
|
223 CPhbkSyncDeleteContactTest_04::CPhbkSyncDeleteContactTest_04() |
|
224 { |
|
225 // store the name of this test step |
|
226 SetTestStepName(_L("PhbkSyncDeleteContactTest_04")); |
|
227 } |
|
228 |
|
229 CPhbkSyncDeleteContactTest_04::~CPhbkSyncDeleteContactTest_04() |
|
230 { |
|
231 } |
|
232 |
|
233 TVerdict CPhbkSyncDeleteContactTest_04::doTestStepL( ) |
|
234 { |
|
235 TContactItemId id; |
|
236 TInt result; |
|
237 TInt i(0); |
|
238 TRequestStatus status; |
|
239 |
|
240 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
241 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
242 { |
|
243 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
244 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
245 } |
|
246 |
|
247 // 2. load the phonebooks in which SDN and LND are read-only |
|
248 SetSimTsyTestNumberL(76); // see [test76] in configuration file |
|
249 |
|
250 User::After(3000000); // Wait for a while for auto sync |
|
251 RPhoneBookSession::TSyncState state; |
|
252 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
253 { |
|
254 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
255 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
256 { |
|
257 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
258 User::After(1000000); |
|
259 } |
|
260 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
261 } |
|
262 |
|
263 // 3. test deleting a valid ICC slot from read-only SDN |
|
264 id = GetValidUIDFromContactsDbL(KUidIccGlobalSdnPhonebook); |
|
265 iSession.DeleteContact(status, id); |
|
266 User::WaitForRequest(status); |
|
267 TESTCHECKL(status.Int(), KErrAccessDenied); |
|
268 |
|
269 // 4. check expected behaviour (the entry still there) |
|
270 result = iSession.ValidateContact(MContactSynchroniser::ERead, id); |
|
271 TESTCHECKL(result, KErrNone); |
|
272 |
|
273 return TestStepResult(); |
|
274 } |
|
275 |
|
276 /** |
|
277 * Test deleting a contact, where the contact is a hidden |
|
278 * entry and the hidden key has not been verified. Repeat |
|
279 * for all supported phonebooks. |
|
280 */ |
|
281 // |
|
282 // Test step5 -- Test#77 in Unit Test Spec. Doc. // |
|
283 // |
|
284 CPhbkSyncDeleteContactTest_05::CPhbkSyncDeleteContactTest_05() |
|
285 { |
|
286 // store the name of this test step |
|
287 SetTestStepName(_L("PhbkSyncDeleteContactTest_05")); |
|
288 } |
|
289 |
|
290 CPhbkSyncDeleteContactTest_05::~CPhbkSyncDeleteContactTest_05() |
|
291 { |
|
292 } |
|
293 |
|
294 TVerdict CPhbkSyncDeleteContactTest_05::doTestStepL( ) |
|
295 { |
|
296 TRequestStatus status; |
|
297 TContactItemId validContactId; |
|
298 |
|
299 // 1. set mode as EManual for USim phonebook |
|
300 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook)); |
|
301 CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook); |
|
302 |
|
303 // load USim App ADN phonebook which contains hidden entries only |
|
304 SetSimTsyTestNumberL(77); // |
|
305 |
|
306 // 3. 10s after start up, the hidden entries become verified. |
|
307 // The Verified event will trigger the autosync operation of USim. |
|
308 // Here, wait for 10s before checking sync status. |
|
309 User::After(10*KOneSeconduS); |
|
310 |
|
311 // 4. check sync status |
|
312 RPhoneBookSession::TSyncState state; |
|
313 iSession.GetPhoneBookCacheState(state, KUidUsimAppAdnPhonebook); |
|
314 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
315 { |
|
316 iSession.GetPhoneBookCacheState(state, KUidUsimAppAdnPhonebook); |
|
317 User::After(1000000); |
|
318 } |
|
319 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
320 |
|
321 // 5. now, all hidden entries have been put into contact DB, so it |
|
322 // should be possible to get one valid hidden entry UID for USim phonebook. |
|
323 validContactId = GetValidUIDFromContactsDbL(KUidUsimAppAdnPhonebook); |
|
324 TESTCHECKCONDITIONL(validContactId != KNullContactId); |
|
325 |
|
326 // 6. wait until the hidden entries are locked again, and then try to |
|
327 // delete the hidden entry using the UID obtained. |
|
328 |
|
329 // 6.1 wait until the hidden entries become unverified again |
|
330 TInt result = KErrNone; |
|
331 result = iSession.ValidateContact(MContactSynchroniser::ERead, validContactId); |
|
332 while (result != KErrAccessDenied) |
|
333 { |
|
334 result = iSession.ValidateContact(MContactSynchroniser::ERead, validContactId); |
|
335 User::After(1000000); |
|
336 } |
|
337 TESTCHECKL(result, KErrAccessDenied); |
|
338 |
|
339 // 6.2 now let us try to delete the hidden entry from the locked USim |
|
340 iSession.DeleteContact(status, validContactId); |
|
341 User::WaitForRequest(status); |
|
342 TESTCHECKL(status.Int(), KErrAccessDenied); |
|
343 |
|
344 return TestStepResult(); |
|
345 } |
|
346 |
|
347 /** |
|
348 * Test deleting a contact after the phonebook has become |
|
349 * locked/blocked. |
|
350 */ |
|
351 // |
|
352 // Test step6 -- Test#78 in Unit Test Spec. Doc. // |
|
353 // |
|
354 CPhbkSyncDeleteContactTest_06::CPhbkSyncDeleteContactTest_06() |
|
355 { |
|
356 // store the name of this test step |
|
357 SetTestStepName(_L("PhbkSyncDeleteContactTest_06")); |
|
358 } |
|
359 |
|
360 CPhbkSyncDeleteContactTest_06::~CPhbkSyncDeleteContactTest_06() |
|
361 { |
|
362 } |
|
363 |
|
364 TVerdict CPhbkSyncDeleteContactTest_06::doTestStepL( ) |
|
365 { |
|
366 TRequestStatus status; |
|
367 // arry used to keep a valid contactId for each phonebook |
|
368 TContactItemId validContactIds[5]; |
|
369 TInt i(0); |
|
370 |
|
371 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
372 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
373 { |
|
374 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
375 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
376 } |
|
377 |
|
378 // 2. load all phonebooks which are not locked/blocked at beginning, |
|
379 // but they will be locked/blocked after 20s which should be long |
|
380 // enough for the autosync to finish. |
|
381 SetSimTsyTestNumberL(78); |
|
382 |
|
383 User::After(3000000); // Wait for a while for auto sync |
|
384 RPhoneBookSession::TSyncState state; |
|
385 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
386 { |
|
387 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
388 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
389 { |
|
390 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
391 User::After(1000000); |
|
392 } |
|
393 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
394 } |
|
395 |
|
396 // 3. get a valid UID for each phonebook and keep them somewhere |
|
397 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
398 { |
|
399 validContactIds[i] = GetValidUIDFromContactsDbL(iPhoneBook[i]); |
|
400 } |
|
401 |
|
402 // 4. wait for until the locked/blocked event to be trigged |
|
403 User::After(20*KOneSeconduS); // 20s should be more than enough |
|
404 |
|
405 // 5. use the valid UIDs obtained to do DeleteContact |
|
406 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
407 { |
|
408 iSession.DeleteContact(status, validContactIds[i]); |
|
409 User::WaitForRequest(status); |
|
410 TESTCHECKL(status.Int(), KErrAccessDenied); |
|
411 } |
|
412 |
|
413 return TestStepResult(); |
|
414 } |
|
415 |
|
416 /** |
|
417 * Test deleting a contact, but an error occurs when |
|
418 * deleting from the ICC. |
|
419 */ |
|
420 // |
|
421 // Test step7 -- Test#79 in Unit Test Spec. Doc. // |
|
422 // |
|
423 CPhbkSyncDeleteContactTest_07::CPhbkSyncDeleteContactTest_07() |
|
424 { |
|
425 // store the name of this test step |
|
426 SetTestStepName(_L("PhbkSyncDeleteContactTest_07")); |
|
427 } |
|
428 |
|
429 CPhbkSyncDeleteContactTest_07::~CPhbkSyncDeleteContactTest_07() |
|
430 { |
|
431 } |
|
432 |
|
433 TVerdict CPhbkSyncDeleteContactTest_07::doTestStepL( ) |
|
434 { |
|
435 // the events PhoneTerminated defined in TSY should be tested in |
|
436 // the same manner as test78. Unfortunately, the Terminated event |
|
437 // doesn't work in TSY. Therefore, this test is temporarily commented |
|
438 // out. |
|
439 |
|
440 /***** |
|
441 TRequestStatus status; |
|
442 // arry used to keep a valid contactId for each phonebook |
|
443 TContactItemId validContactIds[5]; |
|
444 TInt i(0); |
|
445 |
|
446 // 1. set mode as EAutoCurrentIcc for all phonebooks |
|
447 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
448 { |
|
449 User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i])); |
|
450 CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]); |
|
451 } |
|
452 |
|
453 // 2. load all phonebooks which are unlocked at bgining, |
|
454 // but they will be locked/blocked after 20s which should be long |
|
455 // enough for the autosync to finish. |
|
456 SetSimTsyTestNumberL(79); |
|
457 |
|
458 User::After(3000000); // Wait for a while for auto sync |
|
459 RPhoneBookSession::TSyncState state; |
|
460 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
461 { |
|
462 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
463 while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out |
|
464 { |
|
465 iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); |
|
466 User::After(1000000); |
|
467 } |
|
468 TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state |
|
469 } |
|
470 |
|
471 // 3. get a valid UID for each phonebook and keep them somewhere |
|
472 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
473 { |
|
474 validContactIds[i] = GetValidUIDFromContactsDbL(iPhoneBook[i]); |
|
475 } |
|
476 |
|
477 // 4. wait for until the locked/blocked event to be trigged |
|
478 User::After(20*KOneSeconduS); // 20s should be more than enough |
|
479 |
|
480 // 5. use the valid UIDs obtained to do DeleteContact |
|
481 for (i=0; i<KTotalNumberOfPhoneBook; i++) |
|
482 { |
|
483 iSession.DeleteContact(status, validContactIds[i]); |
|
484 User::WaitForRequest(status); |
|
485 TESTCHECKL(status.Int(), KErrAccessDenied); |
|
486 } |
|
487 *****/ |
|
488 |
|
489 return TestStepResult(); |
|
490 } |
|
491 |