|
1 // Copyright (c) 2001-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 // Test programme for Phonebook Buffers |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TE_Sync.h" |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <e32test.h> |
|
22 #include <cntdb.h> |
|
23 #include <cntitem.h> |
|
24 #include <cntfield.h> |
|
25 #include <cntfldst.h> |
|
26 #include <etelmm.h> |
|
27 #include <c32root.h> |
|
28 #include <e32property.h> |
|
29 |
|
30 _LIT16(KTel,"1234567890"); |
|
31 _LIT16(KText,"TelNo 567"); |
|
32 _LIT16(KTelOverwrite,"07700900000"); |
|
33 _LIT16(KTextOverwrite,"Overwrite 1"); |
|
34 _LIT16(KTelNoSlot,"+442079460001"); |
|
35 _LIT16(KTextNoSlot,"No slot"); |
|
36 _LIT16(KTelWithLetters,"5678943Abc34"); |
|
37 _LIT16(KTelExceedMax,"12345678901234567890123456789"); |
|
38 _LIT16(KNameNormal,"Exceed"); |
|
39 _LIT16(KTextExceedMax,"MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName 1123");//244 long |
|
40 _LIT16(KTelNormal,"07700900002"); |
|
41 _LIT16(KTelMax,"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"); |
|
42 _LIT16(KEntryMaxName,"MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName MaximName ");//230 long |
|
43 _LIT16(KTextMaxNum,"Max Number"); |
|
44 _LIT16(KTextNonAlphabet,"(:,)=(),"); |
|
45 _LIT16(KTelLookUp,"561234567890"); |
|
46 _LIT16(KTextLookUp,"Look Up"); |
|
47 _LIT(KInternationalPrefix,"+"); |
|
48 |
|
49 #include <f32file.h> |
|
50 #include <f32ver.h> |
|
51 #include <f32dbg.h> |
|
52 #include <e32cons.h> |
|
53 #include <e32twin.h> |
|
54 |
|
55 #include <cntsync.h> |
|
56 |
|
57 |
|
58 CTestOpen::CTestOpen() |
|
59 { |
|
60 SetTestStepName(_L("TestOpen")); |
|
61 } |
|
62 |
|
63 enum TVerdict CTestOpen::doTestStepL() |
|
64 /** |
|
65 Connection and disconnection test. |
|
66 @return TVerdict result of running the test. |
|
67 */ |
|
68 { |
|
69 // |
|
70 // Close the session... |
|
71 // |
|
72 iSession.Close(); |
|
73 |
|
74 // |
|
75 // Delete PhBkSync INI file and Contacts DB... |
|
76 // |
|
77 ConfigurePhbkSyncToIdleL(); |
|
78 |
|
79 RFs fs; |
|
80 User::LeaveIfError(fs.Connect()); // Connect to File server |
|
81 CleanupClosePushL(fs); |
|
82 _LIT(KPhbkSyncIniFile,"C:\\Private\\102030A1\\Phbksync.ini"); |
|
83 TInt err(fs.Delete(KPhbkSyncIniFile)); // Delete PhBkSync.INI file |
|
84 TESTCHECKCONDITION(err == KErrNone || err==KErrNotFound || err==KErrPathNotFound); // Deleted successfully OR no default INI file |
|
85 TRAP(err,CContactDatabase::DeleteDefaultFileL()); // Delete default ContactsDb |
|
86 TESTCHECKCONDITION(err == KErrNone || err == KErrNotFound); // Deleted successfully OR no default ContactsDb |
|
87 CleanupStack::PopAndDestroy(&fs); |
|
88 |
|
89 ConfigurePhbkSyncToFullL(); |
|
90 |
|
91 // |
|
92 // Connect to PhBkSync Server... |
|
93 // |
|
94 TInt ret=iSession.Connect(); |
|
95 TESTCHECKL(ret, KErrNone); |
|
96 |
|
97 return TestStepResult(); |
|
98 } |
|
99 |
|
100 |
|
101 CTestDoSynchronisation::CTestDoSynchronisation() |
|
102 { |
|
103 SetTestStepName(_L("TestDoSynchronisation")); |
|
104 } |
|
105 |
|
106 enum TVerdict CTestDoSynchronisation::doTestStepL() |
|
107 /** |
|
108 Do Synchronisation test. |
|
109 @return TVerdict result of running the test. |
|
110 */ |
|
111 { |
|
112 TRequestStatus status; |
|
113 iSession.DoSynchronisation(status); // Send a Read-Contact-ICC request |
|
114 User::WaitForRequest(status); |
|
115 TESTCHECKL(status.Int(), KErrNone); |
|
116 |
|
117 return TestStepResult(); |
|
118 } |
|
119 |
|
120 CTestDeleteContactFromICC::CTestDeleteContactFromICC() |
|
121 { |
|
122 SetTestStepName(_L("TestDeleteContactFromICC")); |
|
123 } |
|
124 |
|
125 enum TVerdict CTestDeleteContactFromICC::doTestStepL() |
|
126 /** |
|
127 Delete Contact from ICC test. |
|
128 @return TVerdict result of running the test. |
|
129 */ |
|
130 { |
|
131 TRequestStatus status; |
|
132 TContactItemId id(GetValidUIDFromContactsDbL()); |
|
133 iSession.DeleteContact(status, id); // Delete the contact |
|
134 User::WaitForRequest(status); |
|
135 TESTCHECKL(status.Int(), KErrNone); |
|
136 return TestStepResult(); |
|
137 } |
|
138 |
|
139 CTestDeleteContactInvalidIdFromICC::CTestDeleteContactInvalidIdFromICC() |
|
140 { |
|
141 SetTestStepName(_L("TestDeleteContactInvalidIdFromICC")); |
|
142 } |
|
143 |
|
144 enum TVerdict CTestDeleteContactInvalidIdFromICC::doTestStepL() |
|
145 /** |
|
146 Delete Contact with invalid ID from ICC test. |
|
147 @return TVerdict result of running the test. |
|
148 */ |
|
149 { |
|
150 TRequestStatus status; |
|
151 TContactItemId id(7777); |
|
152 iSession.DeleteContact(status, id); // Delete the contact |
|
153 User::WaitForRequest(status); |
|
154 TESTCHECKL(status.Int(), KErrArgument); |
|
155 return TestStepResult(); |
|
156 } |
|
157 |
|
158 CTestValidateContact::CTestValidateContact() |
|
159 { |
|
160 SetTestStepName(_L("TestValidateContact")); |
|
161 } |
|
162 |
|
163 enum TVerdict CTestValidateContact::doTestStepL() |
|
164 /** |
|
165 Validate Contact test. |
|
166 @return TVerdict result of running the test. |
|
167 */ |
|
168 { |
|
169 TContactItemId id(GetValidUIDFromContactsDbL()); |
|
170 TInt ret(iSession.ValidateContact(MContactSynchroniser::ERead,id)); |
|
171 TESTCHECKL(ret, KErrNone); |
|
172 id = GetValidUIDFromContactsDbL(); |
|
173 ret = iSession.ValidateContact(MContactSynchroniser::EEdit,id); |
|
174 TESTCHECKL(ret, KErrNone); |
|
175 id = GetValidUIDFromContactsDbL(); |
|
176 ret = iSession.ValidateContact(MContactSynchroniser::ESearch,id); |
|
177 TESTCHECKL(ret, KErrNone); |
|
178 return TestStepResult(); |
|
179 } |
|
180 |
|
181 CTestValidateContactAccessLockedTest::CTestValidateContactAccessLockedTest() |
|
182 { |
|
183 SetTestStepName(_L("TestValidateContactAccessLockedTest")); |
|
184 } |
|
185 |
|
186 enum TVerdict CTestValidateContactAccessLockedTest::doTestStepL() |
|
187 /** |
|
188 Validate Contact - ICC PIN locked test. |
|
189 @return TVerdict result of running the test. |
|
190 */ |
|
191 { |
|
192 TContactItemId id(GetValidUIDFromContactsDbL()); |
|
193 TInt ret(iSession.ValidateContact(MContactSynchroniser::ERead,id)); |
|
194 TESTCHECKCONDITIONL(ret == KErrAccessDenied || ret == KErrNone ); |
|
195 return TestStepResult(); |
|
196 } |
|
197 |
|
198 CTestValidateContactInvalidUIDTest::CTestValidateContactInvalidUIDTest() |
|
199 { |
|
200 SetTestStepName(_L("TestValidateContactInvalidUIDTest")); |
|
201 } |
|
202 |
|
203 enum TVerdict CTestValidateContactInvalidUIDTest::doTestStepL() |
|
204 /** |
|
205 Validate Contact - Invalid UID test. |
|
206 @return TVerdict result of running the test. |
|
207 */ |
|
208 { |
|
209 TInt ret(iSession.ValidateContact(MContactSynchroniser::ERead,-1)); |
|
210 TESTCHECKL(ret, KErrNotFound); |
|
211 ret = iSession.ValidateContact(MContactSynchroniser::EEdit,8888); |
|
212 TESTCHECKL(ret, KErrNotFound); |
|
213 ret = iSession.ValidateContact(MContactSynchroniser::ESearch,99999); |
|
214 TESTCHECKL(ret, KErrNotFound); |
|
215 return TestStepResult(); |
|
216 } |
|
217 |
|
218 CTestGetSyncMode::CTestGetSyncMode() |
|
219 { |
|
220 SetTestStepName(_L("TestGetSyncMode")); |
|
221 } |
|
222 |
|
223 enum TVerdict CTestGetSyncMode::doTestStepL() |
|
224 /** |
|
225 Get Sync Mode test. |
|
226 @return TVerdict result of running the test. |
|
227 */ |
|
228 { |
|
229 RPhoneBookSession::TPhonebookSyncMode syncMode; // Get current sync mode |
|
230 iSession.GetSyncMode(syncMode); |
|
231 TESTCHECKL(syncMode, RPhoneBookSession::EManual); |
|
232 return TestStepResult(); |
|
233 } |
|
234 |
|
235 CTestSetSyncMode::CTestSetSyncMode() |
|
236 { |
|
237 SetTestStepName(_L("TestSetSyncMode")); |
|
238 } |
|
239 |
|
240 enum TVerdict CTestSetSyncMode::doTestStepL() |
|
241 /** |
|
242 Set Sync Mode - Auto/Same/Manual test. |
|
243 @return TVerdict result of running the test. |
|
244 */ |
|
245 { |
|
246 // EAutoCurrentIcc |
|
247 RPhoneBookSession::TPhonebookSyncMode syncMode; // sync mode |
|
248 syncMode = RPhoneBookSession::EAutoCurrentIcc; |
|
249 iSession.SetSyncMode(syncMode); // Set sync mode |
|
250 syncMode = RPhoneBookSession::EManual; // reset sync mode to something else just in case |
|
251 iSession.GetSyncMode(syncMode); |
|
252 TESTCHECKL(syncMode, RPhoneBookSession::EAutoCurrentIcc); |
|
253 |
|
254 // EAutoSameIcc |
|
255 syncMode = RPhoneBookSession::EAutoSameIcc; |
|
256 iSession.SetSyncMode(syncMode); // Set sync mode |
|
257 syncMode = RPhoneBookSession::EManual; // reset sync mode to something else just in case |
|
258 iSession.GetSyncMode(syncMode); |
|
259 TESTCHECKL(syncMode, RPhoneBookSession::EAutoSameIcc); |
|
260 |
|
261 // EManual |
|
262 syncMode = RPhoneBookSession::EManual; |
|
263 iSession.SetSyncMode(syncMode); // Set sync mode |
|
264 syncMode = RPhoneBookSession::EAutoSameIcc; // reset sync mode to something else just in case |
|
265 iSession.GetSyncMode(syncMode); |
|
266 TESTCHECKL(syncMode, RPhoneBookSession::EManual); |
|
267 return TestStepResult(); |
|
268 } |
|
269 |
|
270 CTestUpdateLookUpTableFailure::CTestUpdateLookUpTableFailure() |
|
271 { |
|
272 SetTestStepName(_L("TestUpdateLookUpTableFailure")); |
|
273 } |
|
274 |
|
275 enum TVerdict CTestUpdateLookUpTableFailure::doTestStepL() |
|
276 /** |
|
277 Update look-up table - Failure test. |
|
278 @return TVerdict result of running the test. |
|
279 */ |
|
280 { |
|
281 TContactItemId uid(100); |
|
282 TInt slot(200); |
|
283 TInt ret(iSession.UpdateLookuptable(uid, slot)); // Failure test cases, so make up some slot numbers |
|
284 TESTCHECKL(ret, KErrNotFound); |
|
285 return TestStepResult(); |
|
286 } |
|
287 |
|
288 CTestUpdateLookUpTableSuccess::CTestUpdateLookUpTableSuccess() |
|
289 { |
|
290 SetTestStepName(_L("TestUpdateLookUpTableSuccess")); |
|
291 } |
|
292 |
|
293 enum TVerdict CTestUpdateLookUpTableSuccess::doTestStepL() |
|
294 /** |
|
295 Update look-up table - Success test. |
|
296 @return TVerdict result of running the test. |
|
297 */ |
|
298 { |
|
299 // First populate the name and number fields - Synchroniser Internal Format |
|
300 TContactICCEntry iccEntry; |
|
301 iccEntry.iName.Format(KTextLookUp); // Supplied |
|
302 iccEntry.iNumber.Format(KTelLookUp); // Supplied |
|
303 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
304 iccEntry.iContactUID=KNullContactId; // Only for testing purposes, reset Contact UID value |
|
305 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
306 |
|
307 CContactDatabase *ContactsDb=NULL; |
|
308 TRAPD(err,ContactsDb=CContactDatabase::OpenL()); // First try to open existing database |
|
309 if (err != KErrNone) |
|
310 { |
|
311 TRAP(err,CContactDatabase::CreateL()); // There is no existing database, so create default one |
|
312 if (err == KErrNone) |
|
313 ContactsDb=CContactDatabase::OpenL(); // Open new database |
|
314 } |
|
315 CleanupStack::PushL(ContactsDb); |
|
316 |
|
317 TContactItemId id = ContactsDb->ICCTemplateIdL(); |
|
318 CContactItem* iccTemplate = ContactsDb->ReadContactL(id); |
|
319 CleanupStack::PushL(iccTemplate); |
|
320 |
|
321 CContactICCEntry* item = CContactICCEntry::NewL(*iccTemplate); // Create an ICC entry |
|
322 CleanupStack::PopAndDestroy(iccTemplate); |
|
323 CleanupStack::PushL(item); |
|
324 |
|
325 // Create phone number field |
|
326 TBuf<RMobilePhone::KMaxMobileTelNumberSize> number; |
|
327 if(iccEntry.iTON==RMobilePhone::EInternationalNumber) |
|
328 number.Append(KInternationalPrefix); // Append '+' prefix if International Number |
|
329 number.Append(iccEntry.iNumber); |
|
330 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, number, item); |
|
331 |
|
332 // Create name field |
|
333 TBuf<TContactICCEntry::KMaxPhBkNameSize> name; |
|
334 name.Copy(iccEntry.iName); |
|
335 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, name, item); |
|
336 |
|
337 if(iccEntry.iSlotNum!=KSyncIndexNotSupplied) // it is not a new entry so slot number is supplied |
|
338 { |
|
339 // Create slot number field |
|
340 HBufC* buf = HBufC::NewL(5); |
|
341 TPtr indexPtr(buf->Des()); |
|
342 indexPtr.AppendNum(iccEntry.iSlotNum); |
|
343 TPtrC indexPtrC = indexPtr.Mid(0); |
|
344 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldICCSlot, KUidContactFieldVCardMapNotRequired, indexPtrC, item); |
|
345 delete buf; |
|
346 } |
|
347 |
|
348 // Send a Write-Contact-ICC request |
|
349 TRequestStatus status; |
|
350 |
|
351 iSession.WriteContact(status, *item, iccEntry.iSlotNum); |
|
352 User::WaitForRequest(status); |
|
353 TESTCHECKL(status.Int(), KErrNone); |
|
354 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we received new slot number |
|
355 |
|
356 TContactItemId lookupUID = 78; // Make up a Contacts UID value |
|
357 TInt ret(iSession.UpdateLookuptable(lookupUID, iccEntry.iSlotNum)); // New entry successully written |
|
358 // so try to update look-up table |
|
359 TESTCHECK(ret, KErrNone); |
|
360 |
|
361 CleanupStack::PopAndDestroy(2); // item and ContactsDb |
|
362 return TestStepResult(); |
|
363 } |
|
364 |
|
365 CTestGetContactFormat::CTestGetContactFormat() |
|
366 { |
|
367 SetTestStepName(_L("TestGetContactFormat")); |
|
368 } |
|
369 |
|
370 enum TVerdict CTestGetContactFormat::doTestStepL() |
|
371 /** |
|
372 Get Contact Format test. This method gets the current contact format. |
|
373 The expected output test results may not be valid for different |
|
374 ICCs/Phones. |
|
375 */ |
|
376 { |
|
377 RPhoneBookSession::TContactFieldsV1 contactFormat; |
|
378 RPhoneBookSession::TContactFieldsV1Pckg contactFormatPckg(contactFormat); |
|
379 iSession.GetContactFormat(contactFormatPckg); // Get contact format |
|
380 TESTCHECK(contactFormat.iNameField.iCount, 1); |
|
381 TESTCHECKCONDITION(contactFormat.iNameField.iDisplayed); |
|
382 TESTCHECK(contactFormat.iNumberField.iCount, 1); |
|
383 TESTCHECKCONDITION(contactFormat.iNumberField.iDisplayed); |
|
384 TESTCHECK(contactFormat.iIccSlotField.iLength, -1); |
|
385 TESTCHECK(contactFormat.iIccSlotField.iCount, 1); |
|
386 TESTCHECKCONDITION(contactFormat.iIccSlotField.iDisplayed); |
|
387 return TestStepResult(); |
|
388 } |
|
389 |
|
390 CTestGetPhoneBookCacheState::CTestGetPhoneBookCacheState() |
|
391 { |
|
392 SetTestStepName(_L("TestGetPhoneBookCacheState")); |
|
393 } |
|
394 |
|
395 enum TVerdict CTestGetPhoneBookCacheState::doTestStepL() |
|
396 /** |
|
397 Get Cache state test. |
|
398 */ |
|
399 { |
|
400 RPhoneBookSession::TSyncState cacheState; |
|
401 TInt ret(iSession.GetPhoneBookCacheState(cacheState)); // Get phone book Cache state |
|
402 TESTCHECKL(ret, KErrNone); |
|
403 TESTCHECKL(cacheState, RPhoneBookSession::ECacheValid); |
|
404 return TestStepResult(); |
|
405 } |
|
406 |
|
407 CTestGetLastSyncError::CTestGetLastSyncError() |
|
408 { |
|
409 SetTestStepName(_L("TestGetLastSyncError")); |
|
410 } |
|
411 |
|
412 enum TVerdict CTestGetLastSyncError::doTestStepL() |
|
413 /** |
|
414 GetLastSyncError test. |
|
415 @return TVerdict result of running the test. |
|
416 */ |
|
417 { |
|
418 TInt lastError; |
|
419 TInt ret(iSession.GetLastSyncError(lastError)); // Get last phone book Cache error |
|
420 TESTCHECKL(ret, KErrNone); |
|
421 TESTCHECKL(lastError, KErrNone); |
|
422 return TestStepResult(); |
|
423 } |
|
424 |
|
425 CTestNotifyCacheStateChange::CTestNotifyCacheStateChange() |
|
426 { |
|
427 SetTestStepName(_L("TestNotifyCacheStateChange")); |
|
428 } |
|
429 |
|
430 enum TVerdict CTestNotifyCacheStateChange::doTestStepL() |
|
431 /** |
|
432 tNotifyCacheStateChange Test. |
|
433 @return TVerdict result of running the test. |
|
434 */ |
|
435 { |
|
436 iSession.SetSyncMode(RPhoneBookSession::EManual); |
|
437 TRequestStatus status, status2; |
|
438 RPhoneBookSession::TSyncState cacheState; |
|
439 iSession.NotifyPhBkCacheStateChange(status); |
|
440 iSession.DoSynchronisation(status2); |
|
441 |
|
442 User::WaitForRequest(status); |
|
443 TESTCHECKL(status.Int(), KErrNone); |
|
444 |
|
445 iSession.NotifyPhBkCacheStateChange(status); |
|
446 TInt ret(iSession.GetPhoneBookCacheState(cacheState)); // Get phone book Cache state |
|
447 TESTCHECKL(ret, KErrNone); |
|
448 if (cacheState==RPhoneBookSession::ECacheValid) |
|
449 { |
|
450 iSession.CancelRequest(ESyncNotifyCacheStateChangeCancelClient); |
|
451 User::WaitForRequest(status); |
|
452 TESTCHECKL(status2.Int(), KErrNone);//the sync has completed |
|
453 User::WaitForRequest(status2); |
|
454 } |
|
455 else |
|
456 { |
|
457 User::WaitForRequest(status); |
|
458 User::WaitForRequest(status2); |
|
459 iSession.GetPhoneBookCacheState(cacheState); |
|
460 TESTCHECKL(cacheState, RPhoneBookSession::ECacheValid); |
|
461 } |
|
462 return TestStepResult(); |
|
463 } |
|
464 |
|
465 CTestGetPhoneBookId::CTestGetPhoneBookId() |
|
466 { |
|
467 SetTestStepName(_L("TestGetPhoneBookId")); |
|
468 } |
|
469 |
|
470 enum TVerdict CTestGetPhoneBookId::doTestStepL() |
|
471 /** |
|
472 Get PhoneBook Id Test. |
|
473 @return TVerdict result of running the test. |
|
474 */ |
|
475 { |
|
476 TContactItemId uid(KErrNotFound); |
|
477 TInt ret(iSession.GetPhoneBookId(uid, RPhoneBookSession::ESyncGroupId)); // Group ID |
|
478 TESTCHECKL(ret, KErrNone); |
|
479 TESTCHECKCONDITION(uid != KErrNotFound); // Make sure we received valid values |
|
480 ret = iSession.GetPhoneBookId(uid, RPhoneBookSession::ESyncTemplateId); // Template ID |
|
481 TESTCHECKL(ret, KErrNone); |
|
482 TESTCHECKCONDITION(uid != KErrNotFound); // Make sure we received valid values |
|
483 return TestStepResult(); |
|
484 } |
|
485 |
|
486 CTestReset::CTestReset() |
|
487 { |
|
488 SetTestStepName(_L("TestReset")); |
|
489 } |
|
490 |
|
491 enum TVerdict CTestReset::doTestStepL() |
|
492 /** |
|
493 Reset test. |
|
494 @return TVerdict result of running the test. |
|
495 */ |
|
496 { |
|
497 TContactICCEntry i; |
|
498 i.Reset(); |
|
499 return TestStepResult(); |
|
500 } |
|
501 |
|
502 CTestVersionTest::CTestVersionTest() |
|
503 { |
|
504 SetTestStepName(_L("TestVersionTest")); |
|
505 } |
|
506 |
|
507 enum TVerdict CTestVersionTest::doTestStepL() |
|
508 /** |
|
509 Test Version. |
|
510 @return TVerdict result of running the test. |
|
511 */ |
|
512 { |
|
513 TVersion version; |
|
514 version = iSession.Version(); |
|
515 INFO_PRINTF4(_L("The version number of PhBkSync is %d.%d.%d"), |
|
516 version.iMajor, version.iMinor, version.iBuild); |
|
517 |
|
518 TESTCHECK(version.iMajor, 1); |
|
519 TESTCHECK(version.iMinor, 2); |
|
520 TESTCHECK(version.iBuild, 1); |
|
521 |
|
522 return TestStepResult(); |
|
523 } |
|
524 |
|
525 CTestCancelDoSyncRequest::CTestCancelDoSyncRequest() |
|
526 { |
|
527 SetTestStepName(_L("TestCancelDoSyncRequest")); |
|
528 } |
|
529 |
|
530 enum TVerdict CTestCancelDoSyncRequest::doTestStepL() |
|
531 /** |
|
532 Cancel DoSync request test. |
|
533 @return TVerdict result of running the test. |
|
534 */ |
|
535 { |
|
536 TRequestStatus status; |
|
537 iSession.DoSynchronisation(status); // DoSync first, since EManual is set by default |
|
538 iSession.CancelRequest(EDoSynchronisationCancelClient); |
|
539 User::WaitForRequest(status); |
|
540 TESTCHECKCONDITION(status.Int() == KErrNone || status.Int() == KErrCancel); |
|
541 |
|
542 iSession.CancelRequest(EDoSynchronisationCancelClient); // Now try to cancel DoSynchronisation request |
|
543 return TestStepResult(); |
|
544 } |
|
545 |
|
546 CTestCancelDeleteRequest::CTestCancelDeleteRequest() |
|
547 { |
|
548 SetTestStepName(_L("TestCancelDeleteRequest")); |
|
549 } |
|
550 |
|
551 enum TVerdict CTestCancelDeleteRequest::doTestStepL() |
|
552 /** |
|
553 Cancel Delete request test. |
|
554 @return TVerdict result of running the test. |
|
555 */ |
|
556 { |
|
557 TRequestStatus status; |
|
558 TContactItemId id(GetValidUIDFromContactsDbL()); |
|
559 iSession.DeleteContact(status, id); // Delete a contact |
|
560 iSession.CancelRequest(ESyncDeleteCntFromICCCancelClient); // Cancel outstanding delete request |
|
561 User::WaitForRequest(status); |
|
562 TESTCHECKCONDITION(status.Int() == KErrNone || status.Int() == KErrCancel); |
|
563 |
|
564 iSession.CancelRequest(ESyncDeleteCntFromICCCancelClient); // Now try to cancel Delete request |
|
565 // with no outstanding delete request |
|
566 return TestStepResult(); |
|
567 } |
|
568 |
|
569 CTestCancelWriteRequest::CTestCancelWriteRequest() |
|
570 { |
|
571 SetTestStepName(_L("TestCancelWriteRequest")); |
|
572 } |
|
573 |
|
574 enum TVerdict CTestCancelWriteRequest::doTestStepL() |
|
575 /** |
|
576 Cancel Write request test. |
|
577 @return TVerdict result of running the test. |
|
578 */ |
|
579 { |
|
580 // First populate the name and number fields - Synchroniser Internal Format |
|
581 TContactICCEntry iccEntry; |
|
582 iccEntry.iName.Format(KText); // Supplied |
|
583 iccEntry.iNumber.Format(KTel); // Supplied |
|
584 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
585 iccEntry.iContactUID=1; // This is usually generated by the Contacts Model, but since we are not using |
|
586 // the contacts model to write this entry we will have to make up a number. |
|
587 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
588 |
|
589 CContactDatabase *ContactsDb=NULL; |
|
590 TRAPD(err,ContactsDb=CContactDatabase::OpenL()); // First try to open existing database |
|
591 if (err != KErrNone) |
|
592 { |
|
593 TRAP(err,CContactDatabase::CreateL()); // There is no existing database, so create default one |
|
594 if (err == KErrNone) |
|
595 ContactsDb=CContactDatabase::OpenL(); // Open new database |
|
596 } |
|
597 CleanupStack::PushL(ContactsDb); |
|
598 |
|
599 TContactItemId id = ContactsDb->ICCTemplateIdL(); |
|
600 CContactItem* iccTemplate = ContactsDb->ReadContactL(id); |
|
601 CleanupStack::PushL(iccTemplate); |
|
602 |
|
603 CContactICCEntry* item = CContactICCEntry::NewL(*iccTemplate); // Create an ICC entry |
|
604 CleanupStack::PopAndDestroy(iccTemplate); |
|
605 CleanupStack::PushL(item); |
|
606 |
|
607 // Create phone number field |
|
608 TBuf<RMobilePhone::KMaxMobileTelNumberSize> number; |
|
609 if(iccEntry.iTON==RMobilePhone::EInternationalNumber) |
|
610 number.Append(KInternationalPrefix); // Append '+' prefix if International Number |
|
611 number.Append(iccEntry.iNumber); |
|
612 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, number, item); |
|
613 |
|
614 // Create name field |
|
615 TBuf<TContactICCEntry::KMaxPhBkNameSize> name; |
|
616 name.Copy(iccEntry.iName); |
|
617 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, name, item); |
|
618 |
|
619 if(iccEntry.iSlotNum!=KSyncIndexNotSupplied) // it is not a new entry so slot number is supplied |
|
620 { |
|
621 // Create slot number field |
|
622 HBufC* buf = HBufC::NewL(5); |
|
623 TPtr indexPtr(buf->Des()); |
|
624 indexPtr.AppendNum(iccEntry.iSlotNum); |
|
625 TPtrC indexPtrC = indexPtr.Mid(0); |
|
626 AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldICCSlot, KUidContactFieldVCardMapNotRequired, indexPtrC, item); |
|
627 delete buf; |
|
628 } |
|
629 |
|
630 // Send a Write-Contact-ICC request |
|
631 TRequestStatus status; |
|
632 |
|
633 iSession.WriteContact(status, *item, iccEntry.iSlotNum); |
|
634 iSession.CancelRequest(ESyncWriteCntToICCCancelClient); |
|
635 User::WaitForRequest(status); |
|
636 TESTCHECKCONDITION(status.Int() == KErrNone || status.Int() == KErrCancel); |
|
637 |
|
638 iSession.CancelRequest(ESyncWriteCntToICCCancelClient); // Now try to cancel Write request |
|
639 // with no outstanding delete request |
|
640 CleanupStack::PopAndDestroy(item); |
|
641 CleanupStack::PopAndDestroy(ContactsDb); |
|
642 return TestStepResult(); |
|
643 } |
|
644 |
|
645 CTestWriteContactToICCTest::CTestWriteContactToICCTest() |
|
646 { |
|
647 SetTestStepName(_L("TestWriteContactToICCTest")); |
|
648 } |
|
649 |
|
650 enum TVerdict CTestWriteContactToICCTest::doTestStepL() |
|
651 /** |
|
652 Write Contact to ICC test. |
|
653 @return TVerdict result of running the test. |
|
654 */ |
|
655 { |
|
656 // First populate the name and number fields - Synchroniser Internal Format |
|
657 TContactICCEntry iccEntry; |
|
658 TRequestStatus status; |
|
659 iccEntry.iName.Format(KText); // Supplied |
|
660 iccEntry.iNumber.Format(KTel); // Supplied |
|
661 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
662 iccEntry.iContactUID=1; // This is usually generated by the Contacts Model, but since we are not using |
|
663 // the contacts model to write this entry we will have to make up a number. |
|
664 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
665 |
|
666 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
667 TESTCHECKL(status.Int(), KErrNone); |
|
668 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
669 |
|
670 return TestStepResult(); |
|
671 } |
|
672 |
|
673 CTestWriteContactToICCOverwriteTest::CTestWriteContactToICCOverwriteTest() |
|
674 { |
|
675 SetTestStepName(_L("TestWriteContactToICCOverwriteTest")); |
|
676 } |
|
677 |
|
678 enum TVerdict CTestWriteContactToICCOverwriteTest::doTestStepL() |
|
679 /** |
|
680 Write Contact to ICC test - Overwrite existing entry. |
|
681 @return TVerdict result of running the test. |
|
682 */ |
|
683 { |
|
684 // First populate the name and number fields - Synchroniser Internal Format |
|
685 TContactICCEntry iccEntry; |
|
686 TRequestStatus status; |
|
687 iccEntry.iName.Format(KTextOverwrite); // Supplied |
|
688 iccEntry.iNumber.Format(KTelOverwrite); // Supplied |
|
689 iccEntry.iSlotNum=10; // Index for this entry is supplied |
|
690 iccEntry.iContactUID=1; |
|
691 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
692 |
|
693 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
694 TESTCHECKL(status.Int(), KErrNone); |
|
695 TESTCHECK(iccEntry.iSlotNum, 10); // Make sure we receive a value |
|
696 |
|
697 return TestStepResult(); |
|
698 } |
|
699 |
|
700 CTestWriteContactToICCNoSlotTest::CTestWriteContactToICCNoSlotTest() |
|
701 { |
|
702 SetTestStepName(_L("TestWriteContactToICCNoSlotTest")); |
|
703 } |
|
704 |
|
705 enum TVerdict CTestWriteContactToICCNoSlotTest::doTestStepL() |
|
706 /** |
|
707 Local function that creates a CTestData object. This method writes a |
|
708 new entry to the ICC. The index field is not specified. |
|
709 @return TVerdict result of running the test. |
|
710 */ |
|
711 { |
|
712 // First populate the name and number fields - Synchroniser Internal Format |
|
713 TRequestStatus status; |
|
714 TContactICCEntry iccEntry; |
|
715 iccEntry.iName.Format(KTextNoSlot); // Supplied |
|
716 iccEntry.iNumber.Format(KTelNoSlot); // Supplied |
|
717 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
718 iccEntry.iContactUID=2; |
|
719 iccEntry.iTON=RMobilePhone::EInternationalNumber; |
|
720 |
|
721 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
722 TESTCHECKL(status.Int(), KErrNone); |
|
723 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
724 |
|
725 return TestStepResult(); |
|
726 } |
|
727 |
|
728 CTestWriteContactToICCInvalidSlotTest::CTestWriteContactToICCInvalidSlotTest() |
|
729 { |
|
730 SetTestStepName(_L("TestWriteContactToICCInvalidSlotTest")); |
|
731 } |
|
732 |
|
733 enum TVerdict CTestWriteContactToICCInvalidSlotTest::doTestStepL() |
|
734 /** |
|
735 Write Contact to ICC - Invalid Slot number test. |
|
736 @return TVerdict result of running the test. |
|
737 */ |
|
738 { |
|
739 // First populate the name and number fields - Synchroniser Internal Format |
|
740 TRequestStatus status; |
|
741 TContactICCEntry iccEntry; |
|
742 iccEntry.iName.Format(KText); // Supplied |
|
743 iccEntry.iNumber.Format(KTel); // Supplied |
|
744 iccEntry.iSlotNum=230; // Invalid slot number |
|
745 iccEntry.iContactUID=3; |
|
746 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
747 |
|
748 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
749 TESTCHECKL(status.Int(), KErrArgument); |
|
750 TESTCHECK(iccEntry.iSlotNum, 230); // Make sure slot number has not changed |
|
751 |
|
752 return TestStepResult(); |
|
753 } |
|
754 |
|
755 CTestWriteContactToICCBlankNumTest::CTestWriteContactToICCBlankNumTest() |
|
756 { |
|
757 SetTestStepName(_L("TestWriteContactToICCBlankNumTest")); |
|
758 } |
|
759 |
|
760 enum TVerdict CTestWriteContactToICCBlankNumTest::doTestStepL() |
|
761 /** |
|
762 Write Contact to ICC - Blank Number test. |
|
763 @return TVerdict result of running the test. |
|
764 */ |
|
765 { |
|
766 // First populate the name and number fields - Synchroniser Internal Format |
|
767 TRequestStatus status; |
|
768 TContactICCEntry iccEntry; |
|
769 iccEntry.iName.Format(KText); |
|
770 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
771 iccEntry.iContactUID=4; |
|
772 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
773 |
|
774 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
775 TESTCHECKL(status.Int(), KErrNone); |
|
776 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
777 |
|
778 return TestStepResult(); |
|
779 } |
|
780 |
|
781 CTestWriteContactToICCBlankNameTest::CTestWriteContactToICCBlankNameTest() |
|
782 { |
|
783 SetTestStepName(_L("TestWriteContactToICCBlankNameTest")); |
|
784 } |
|
785 |
|
786 enum TVerdict CTestWriteContactToICCBlankNameTest::doTestStepL() |
|
787 /** |
|
788 Write Contact to ICC - Blank Name test. |
|
789 @return TVerdict result of running the test. |
|
790 */ |
|
791 { |
|
792 // First populate the name and number fields - Synchroniser Internal Format |
|
793 TRequestStatus status; |
|
794 TContactICCEntry iccEntry; |
|
795 iccEntry.iNumber.Format(KTel); |
|
796 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
797 iccEntry.iContactUID=5; |
|
798 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
799 |
|
800 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
801 // TESTCHECKL(status.Int(), KErrNone); // Commented out as this is applicable to a Nokia phone only |
|
802 // TESTCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value - Nokia phone only |
|
803 |
|
804 return TestStepResult(); |
|
805 } |
|
806 |
|
807 CTestWriteContactToICCExceedMaxNameTest::CTestWriteContactToICCExceedMaxNameTest() |
|
808 { |
|
809 SetTestStepName(_L("TestWriteContactToICCExceedMaxNameTest")); |
|
810 } |
|
811 |
|
812 enum TVerdict CTestWriteContactToICCExceedMaxNameTest::doTestStepL() |
|
813 /** |
|
814 Write Contact to ICC - Exceed Max Name test. |
|
815 @return TVerdict result of running the test. |
|
816 */ |
|
817 { |
|
818 // First populate the name and number fields - Synchroniser Internal Format |
|
819 TRequestStatus status; |
|
820 TContactICCEntry iccEntry; |
|
821 iccEntry.iName.Format(KTextExceedMax); // Exceeds max num of characters |
|
822 iccEntry.iNumber.Format(KTelNormal); // Matching name which does not exceed max number of characters |
|
823 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
824 iccEntry.iContactUID=6; |
|
825 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
826 |
|
827 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
828 TESTCHECKCONDITIONL(status.Int() == KErrGeneral || status.Int() == KErrOverflow); |
|
829 TESTCHECK(iccEntry.iSlotNum, KSyncIndexNotSupplied); // No slot number assigned for this entry |
|
830 |
|
831 return TestStepResult(); |
|
832 } |
|
833 |
|
834 CTestWriteContactToICCExceedMaxNumTest::CTestWriteContactToICCExceedMaxNumTest() |
|
835 { |
|
836 SetTestStepName(_L("TestWriteContactToICCExceedMaxNumTest")); |
|
837 } |
|
838 |
|
839 enum TVerdict CTestWriteContactToICCExceedMaxNumTest::doTestStepL() |
|
840 /** |
|
841 Write Contact to ICC - Exceed Max Number test. |
|
842 @return TVerdict result of running the test. |
|
843 */ |
|
844 { |
|
845 // First populate the name and number fields - Synchroniser Internal Format |
|
846 TContactICCEntry iccEntry; |
|
847 TRequestStatus status; |
|
848 iccEntry.iName.Format(KNameNormal); // Matching name which does not exceed max number of characters |
|
849 iccEntry.iNumber.Format(KTelExceedMax); // Exceeds max num of characters |
|
850 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
851 iccEntry.iContactUID=7; |
|
852 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
853 |
|
854 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
855 |
|
856 return TestStepResult(); |
|
857 } |
|
858 |
|
859 CTestWriteContactToICCMaxNumTest::CTestWriteContactToICCMaxNumTest() |
|
860 { |
|
861 SetTestStepName(_L("TestWriteContactToICCMaxNumTest")); |
|
862 } |
|
863 |
|
864 enum TVerdict CTestWriteContactToICCMaxNumTest::doTestStepL() |
|
865 /** |
|
866 Write Contact to ICC - Max Number test. |
|
867 @return TVerdict result of running the test. |
|
868 */ |
|
869 { |
|
870 // First populate the name and number fields - Synchroniser Internal Format |
|
871 TContactICCEntry iccEntry; |
|
872 TRequestStatus status; |
|
873 iccEntry.iName.Format(KTextMaxNum); |
|
874 iccEntry.iNumber.Format(KTelMax); // Supplied |
|
875 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
876 iccEntry.iContactUID=8; |
|
877 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
878 |
|
879 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
880 if ((status.Int() != KErrGeneral) && (status.Int() != KErrOverflow)) // MMTSY returns KErrGeneral for this |
|
881 { |
|
882 TESTCHECKL(status.Int(), KErrNone); |
|
883 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
884 } |
|
885 |
|
886 return TestStepResult(); |
|
887 } |
|
888 |
|
889 CTestWriteContactToICCMaxNameTest::CTestWriteContactToICCMaxNameTest() |
|
890 { |
|
891 SetTestStepName(_L("TestWriteContactToICCMaxNameTest")); |
|
892 } |
|
893 |
|
894 enum TVerdict CTestWriteContactToICCMaxNameTest::doTestStepL() |
|
895 /** |
|
896 Write Contact to ICC - Max Name test. |
|
897 @return TVerdict result of running the test. |
|
898 */ |
|
899 { |
|
900 // First populate the name and number fields - Synchroniser Internal Format |
|
901 TContactICCEntry iccEntry; |
|
902 TRequestStatus status; |
|
903 iccEntry.iName.Format(KEntryMaxName); // Supplied |
|
904 iccEntry.iNumber.Format(KTel); |
|
905 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
906 iccEntry.iContactUID=9; |
|
907 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
908 |
|
909 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
910 if (status.Int() != KErrOverflow) |
|
911 { |
|
912 TESTCHECKL(status.Int(), KErrNone); |
|
913 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
914 } |
|
915 |
|
916 return TestStepResult(); |
|
917 } |
|
918 |
|
919 CTestWriteContactToICCNumLettersTest::CTestWriteContactToICCNumLettersTest() |
|
920 { |
|
921 SetTestStepName(_L("TestWriteContactToICCNumLettersTest")); |
|
922 } |
|
923 |
|
924 enum TVerdict CTestWriteContactToICCNumLettersTest::doTestStepL() |
|
925 /** |
|
926 Write Contact to ICC - Number with letters test. |
|
927 @return TVerdict result of running the test. |
|
928 */ |
|
929 { |
|
930 // First populate the name and number fields - Synchroniser Internal Format |
|
931 TContactICCEntry iccEntry; |
|
932 TRequestStatus status; |
|
933 iccEntry.iName.Format(KText); // Supplied |
|
934 iccEntry.iNumber.Format(KTelWithLetters); |
|
935 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
936 iccEntry.iContactUID=10; |
|
937 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
938 |
|
939 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
940 TESTCHECKCONDITIONL(status.Int() == KErrGeneral || status.Int() == KErrNone); |
|
941 TESTCHECKCONDITION(iccEntry.iSlotNum == KSyncIndexNotSupplied || iccEntry.iSlotNum == 18); // No slot number allocated for this entry |
|
942 |
|
943 return TestStepResult(); |
|
944 } |
|
945 |
|
946 CTestWriteContactToICCObsecureTest::CTestWriteContactToICCObsecureTest() |
|
947 { |
|
948 SetTestStepName(_L("TestWriteContactToICCObsecureTest")); |
|
949 } |
|
950 |
|
951 enum TVerdict CTestWriteContactToICCObsecureTest::doTestStepL() |
|
952 /** |
|
953 Write Contact to ICC - Name with non-alphabetical characters test. |
|
954 @return TVerdict result of running the test. |
|
955 */ |
|
956 { |
|
957 // First populate the name and number fields - Synchroniser Internal Format |
|
958 TContactICCEntry iccEntry; |
|
959 TRequestStatus status; |
|
960 iccEntry.iName.Format(KTextNonAlphabet); |
|
961 iccEntry.iNumber.Format(KTel); |
|
962 // iccEntry.iNumber.Format(KTelWithpw); |
|
963 iccEntry.iSlotNum=-1; // This is only for testing purposes, to indicate that it is a new entry |
|
964 iccEntry.iContactUID=11; |
|
965 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
966 |
|
967 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
968 TESTCHECKL(status.Int(), KErrNone); |
|
969 TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied); // Make sure we receive a value |
|
970 |
|
971 return TestStepResult(); |
|
972 } |
|
973 |
|
974 CTestSlotHandlingTest::CTestSlotHandlingTest() |
|
975 { |
|
976 SetTestStepName(_L("TestSlotHandlingTest")); |
|
977 } |
|
978 |
|
979 enum TVerdict CTestSlotHandlingTest::doTestStepL() |
|
980 /** |
|
981 Slot Handling Test. |
|
982 @return TVerdict result of running the test. |
|
983 */ |
|
984 { |
|
985 TInt aSlot; |
|
986 TContactItemId aId=KNullContactId; |
|
987 TInt numSlots; |
|
988 TInt err = iSession.GetNumSlots(numSlots); |
|
989 TESTCHECKL(err, KErrNone); |
|
990 TESTCHECKL(numSlots, 200); |
|
991 |
|
992 RArray<TInt> freeSlotArray; |
|
993 CleanupClosePushL(freeSlotArray); |
|
994 |
|
995 iSession.GetFreeSlotsL(freeSlotArray); |
|
996 |
|
997 TInt FirstUsedSlot; |
|
998 TBool free(EFalse); |
|
999 |
|
1000 |
|
1001 TInt i; |
|
1002 for (FirstUsedSlot=1; FirstUsedSlot<numSlots; FirstUsedSlot++) |
|
1003 { |
|
1004 free=EFalse; |
|
1005 for (i=0;i<freeSlotArray.Count();i++) |
|
1006 { |
|
1007 if (FirstUsedSlot==freeSlotArray[i]) |
|
1008 { |
|
1009 free=ETrue; |
|
1010 break; |
|
1011 } |
|
1012 } |
|
1013 if(free==EFalse) |
|
1014 { |
|
1015 break; |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 err = iSession.GetSlotId(FirstUsedSlot, aId); |
|
1020 TESTCHECKL(err, KErrNone); |
|
1021 TESTCHECKCONDITIONL(aId > KNullContactId); |
|
1022 |
|
1023 aSlot = freeSlotArray[0]; |
|
1024 err = iSession.GetSlotId(aSlot, aId); |
|
1025 TESTCHECKL(err, KErrNotFound); |
|
1026 |
|
1027 CleanupStack::PopAndDestroy(&freeSlotArray); |
|
1028 |
|
1029 return TestStepResult(); |
|
1030 } |
|
1031 |
|
1032 CTestWriteToSlotTest::CTestWriteToSlotTest() |
|
1033 { |
|
1034 SetTestStepName(_L("TestWriteToSlotTest")); |
|
1035 } |
|
1036 |
|
1037 enum TVerdict CTestWriteToSlotTest::doTestStepL() |
|
1038 /** |
|
1039 Write To Slot Test. |
|
1040 @return TVerdict result of running the test. |
|
1041 */ |
|
1042 { |
|
1043 TInt aSlot; |
|
1044 TContactItemId aId=KNullContactId; |
|
1045 TInt numSlots; |
|
1046 TInt err = iSession.GetNumSlots(numSlots); |
|
1047 TESTCHECKL(err, KErrNone); |
|
1048 TESTCHECKL(numSlots, 200); |
|
1049 |
|
1050 RArray<TInt> freeSlotArray; |
|
1051 CleanupClosePushL(freeSlotArray); |
|
1052 |
|
1053 iSession.GetFreeSlotsL(freeSlotArray); |
|
1054 |
|
1055 //TInt i; |
|
1056 //for (i=0; i<freeSlotArray.Count(); i++) |
|
1057 // { |
|
1058 // Log(_L("%d"),freeSlotArray[i]); |
|
1059 // } |
|
1060 //Log(_L("")); |
|
1061 |
|
1062 TContactICCEntry iccEntry; |
|
1063 TRequestStatus status; |
|
1064 iccEntry.iName.Format(KText); // Supplied |
|
1065 iccEntry.iNumber.Format(KTel); // Supplied |
|
1066 iccEntry.iSlotNum=-1; |
|
1067 iccEntry.iContactUID=15; // This is usually generated by the Contacts Model, but since we are not using |
|
1068 // the contacts model to write this entry we will have to make up a number. |
|
1069 iccEntry.iTON=RMobilePhone::EUnknownNumber; |
|
1070 |
|
1071 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
1072 TESTCHECKL(status.Int(), KErrNone); |
|
1073 |
|
1074 iSession.GetFreeSlotsL(freeSlotArray); |
|
1075 //TInt j; |
|
1076 //for (j=0; j<freeSlotArray.Count(); j++) |
|
1077 // { |
|
1078 // Log(_L("%d"),freeSlotArray[j]); |
|
1079 // } |
|
1080 //Log(_L("")); |
|
1081 |
|
1082 aSlot=freeSlotArray[0]; |
|
1083 err = iSession.GetSlotId(aSlot, aId); |
|
1084 TESTCHECKL(err, KErrNotFound); |
|
1085 |
|
1086 //Add Entry at slot |
|
1087 iccEntry.iContactUID=15; |
|
1088 iccEntry.iSlotNum=25;//now the slot is specified |
|
1089 WriteContactToICCL(iccEntry, status); // Write an entry to ICC |
|
1090 TESTCHECKL(status.Int(), KErrNone); |
|
1091 |
|
1092 iSession.GetFreeSlotsL(freeSlotArray); |
|
1093 //TInt jj; |
|
1094 //for (jj=0; jj<freeSlotArray.Count(); jj++) |
|
1095 // { |
|
1096 // Log(_L("%d"),freeSlotArray[jj]); |
|
1097 // } |
|
1098 //Log(_L("")); |
|
1099 |
|
1100 aSlot=25; |
|
1101 err = iSession.GetSlotId(aSlot, aId); |
|
1102 TESTCHECKL(err, KErrNone); |
|
1103 |
|
1104 //Edit entry same slot // |
|
1105 /* iccEntry.iSlotNum=25; |
|
1106 iccEntry.iName.Format(KTextOverwrite); |
|
1107 WriteContactToICCL(iccEntry, status); |
|
1108 for (i=0; i<freeSlotArray.Count(); i++) |
|
1109 { |
|
1110 Log(_L("%d"),freeSlotArray[i]); |
|
1111 } |
|
1112 Log(_L("")); |
|
1113 TESTCHECKCONDITIONL(aId > KNullContactId); |
|
1114 */ |
|
1115 |
|
1116 CleanupStack::PopAndDestroy(&freeSlotArray); |
|
1117 |
|
1118 return TestStepResult(); |
|
1119 } |
|
1120 |
|
1121 CTestConnectionTest::CTestConnectionTest() |
|
1122 { |
|
1123 SetTestStepName(_L("TestConnectionTest")); |
|
1124 } // CTestConnectionTest::CTestConnectionTest |
|
1125 |
|
1126 |
|
1127 /** |
|
1128 * Connection and disconnection test. |
|
1129 * |
|
1130 * @return TVerdict result of running the test. |
|
1131 */ |
|
1132 enum TVerdict CTestConnectionTest::doTestStepL() |
|
1133 { |
|
1134 // |
|
1135 // Connect to PhBkSync Server and wait 30 seconds... |
|
1136 // |
|
1137 RPhoneBookSession sessionTest; |
|
1138 |
|
1139 TInt ret(sessionTest.Connect()); // this one should start the server |
|
1140 TESTCHECK(ret, KErrNone); |
|
1141 User::After(30*1000000); |
|
1142 sessionTest.Close(); |
|
1143 |
|
1144 return TestStepResult(); |
|
1145 } // CTestConnectionTest::doTestStepL |
|
1146 |
|
1147 |
|
1148 CTestFailedPhoneStartup::CTestFailedPhoneStartup() |
|
1149 { |
|
1150 SetTestStepName(_L("TestFailedPhoneStartup")); |
|
1151 } // CTestFailedPhoneStartup::CTestFailedPhoneStartup |
|
1152 |
|
1153 |
|
1154 /** |
|
1155 * Connection and disconnection test. |
|
1156 * |
|
1157 * @return TVerdict result of running the test. |
|
1158 */ |
|
1159 enum TVerdict CTestFailedPhoneStartup::doTestStepL() |
|
1160 { |
|
1161 // |
|
1162 // Shutdown the server if possible (only works if the server is in |
|
1163 // debug mode). |
|
1164 // |
|
1165 iSession.ShutdownServer(EFalse); |
|
1166 iSession.Close(); |
|
1167 |
|
1168 // |
|
1169 // Delete the SIMTSY config file so that the server cannot startup... |
|
1170 // |
|
1171 RFs fs; |
|
1172 TInt deleteResult; |
|
1173 |
|
1174 User::LeaveIfError(fs.Connect()); |
|
1175 CleanupClosePushL(fs); |
|
1176 |
|
1177 deleteResult = fs.Delete(KConfigFilename); |
|
1178 TESTCHECKCONDITION(deleteResult == KErrNone || deleteResult == KErrNotFound); |
|
1179 |
|
1180 CleanupStack::PopAndDestroy(&fs); |
|
1181 |
|
1182 // |
|
1183 // Connect to PhBkSync Server (restarting it). The next result will vary |
|
1184 // depending on whether the server is a UDeb or URel version. |
|
1185 // |
|
1186 // For UDeb the shutdown and reconnect will exercise the defect scenario |
|
1187 // of the TSY not opening. Initially (now that the server configures |
|
1188 // asynchronously) this will succeed but this fail. |
|
1189 // |
|
1190 // For a URel server the shutdown will not have happened and the delete |
|
1191 // of the config.txt would not be noticed. Therefore the reconnect would |
|
1192 // succeed with no problems. |
|
1193 // |
|
1194 TInt ret; |
|
1195 |
|
1196 ret = iSession.Connect(); |
|
1197 #ifdef _DEBUG |
|
1198 TESTCHECK(ret, KErrNone); |
|
1199 #else |
|
1200 TESTCHECK(ret, KErrNone); |
|
1201 #endif |
|
1202 |
|
1203 // |
|
1204 // Test if the server managed to configure successfully... |
|
1205 // |
|
1206 RPhoneBookSession::TPhonebookSyncMode syncMode; |
|
1207 |
|
1208 ret = iSession.GetSyncMode(syncMode); |
|
1209 #ifdef _DEBUG |
|
1210 TESTCHECK(ret, KErrServerTerminated); |
|
1211 #else |
|
1212 TESTCHECK(ret, KErrNone); |
|
1213 #endif |
|
1214 |
|
1215 return TestStepResult(); |
|
1216 } // CTestFailedPhoneStartup::doTestStepL |
|
1217 |