1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <e32uid.h> |
|
18 #include <e32std.h> |
|
19 #include <smuthdr.h> |
|
20 #include <smutset.h> |
|
21 #include <smscmds.h> |
|
22 #include "T_SmsEnum.h" |
|
23 #include <txtrich.h> |
|
24 #include <csmsaccount.h> |
|
25 |
|
26 RTest test(_L("T_SmsEnum Testrig")); |
|
27 CTrapCleanup* theCleanup; |
|
28 |
|
29 _LIT(KSmsScript, "smsenum.script"); |
|
30 |
|
31 #if defined (__WINS__) |
|
32 _LIT(KPddName,"ECDRV"); |
|
33 _LIT(KLddName,"ECOMM"); |
|
34 #else //__WINS__ |
|
35 _LIT(KPddSirName,"ESIR"); |
|
36 _LIT(KPddUartName,"ECUART4"); |
|
37 _LIT(KLddName,"ECOMM"); |
|
38 #endif //__WINS__ |
|
39 |
|
40 _LIT(KMessageData, "This is a simple text message"); |
|
41 _LIT(KRecipientOk, "+447973500446"); |
|
42 |
|
43 void CSmsEnumTest::TestCopyFromSimL(TMsvId aFolderId) |
|
44 /** |
|
45 Tests copying messages from SIM |
|
46 */ |
|
47 { |
|
48 iSmsTest.Test().Next(_L("Copy From SIM")); |
|
49 iState = EStateCopyFromSim; |
|
50 |
|
51 if (aFolderId == KErrNotFound) |
|
52 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
53 else |
|
54 MsvEntry().SetEntryL(aFolderId); |
|
55 |
|
56 delete iSelection; |
|
57 iSelection = NULL; |
|
58 iSelection = MsvEntry().ChildrenL(); |
|
59 iSelection->InsertL(0,iSmsTest.iSmsServiceId); |
|
60 |
|
61 TPckgBuf<TMsvId> pkg(KMsvGlobalInBoxIndexEntryId); |
|
62 |
|
63 delete iOperation; |
|
64 iOperation = NULL; |
|
65 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandCopyFromPhoneStore, pkg, iStatus); |
|
66 SetActive(); |
|
67 CActiveScheduler::Start(); |
|
68 } |
|
69 |
|
70 void CSmsEnumTest::TestMoveFromSimL(TMsvId aFolderId) |
|
71 /** |
|
72 Tests moving messages from SIM |
|
73 */ |
|
74 { |
|
75 iSmsTest.Test().Next(_L("Move From SIM")); |
|
76 iState = EStateMoveFromSim; |
|
77 |
|
78 if (aFolderId == KErrNotFound) |
|
79 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
80 else |
|
81 MsvEntry().SetEntryL(aFolderId); |
|
82 |
|
83 delete iSelection; |
|
84 iSelection = NULL; |
|
85 iSelection = MsvEntry().ChildrenL(); |
|
86 iSelection->InsertL(0,iSmsTest.iSmsServiceId); |
|
87 |
|
88 TPckgBuf<TMsvId> pkg(KMsvGlobalInBoxIndexEntryId); |
|
89 |
|
90 delete iOperation; |
|
91 iOperation = NULL; |
|
92 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandMoveFromPhoneStore, pkg, iStatus); |
|
93 SetActive(); |
|
94 CActiveScheduler::Start(); |
|
95 } |
|
96 |
|
97 void CSmsEnumTest::TestDeleteFromSimL() |
|
98 /** |
|
99 Tests deleting messages from SIM |
|
100 */ |
|
101 { |
|
102 iSmsTest.Test().Next(_L("Delete From SIM")); |
|
103 iState = EStateDeleteFromSim; |
|
104 |
|
105 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
106 |
|
107 delete iSelection; |
|
108 iSelection = NULL; |
|
109 iSelection = MsvEntry().ChildrenL(); |
|
110 iSelection->InsertL(0,iSmsTest.iSmsServiceId); |
|
111 |
|
112 delete iOperation; |
|
113 iOperation = NULL; |
|
114 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandDeleteFromPhoneStore, TPtrC8(), iStatus); |
|
115 SetActive(); |
|
116 CActiveScheduler::Start(); |
|
117 } |
|
118 |
|
119 TInt CSmsEnumTest::GetInboxMsgsCountL() |
|
120 /** |
|
121 Count messages in Inbox |
|
122 */ |
|
123 { |
|
124 MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
125 |
|
126 delete iSelection; |
|
127 iSelection = NULL; |
|
128 iSelection = MsvEntry().ChildrenL(); |
|
129 return iSelection->Count(); |
|
130 } |
|
131 |
|
132 void CSmsEnumTest::ClearInboxL() |
|
133 /** |
|
134 Remove all messages from the Inbox |
|
135 */ |
|
136 { |
|
137 iState = EStateClearInbox; |
|
138 MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
139 |
|
140 delete iSelection; |
|
141 iSelection = NULL; |
|
142 iSelection = MsvEntry().ChildrenL(); |
|
143 |
|
144 if (iSelection->Count() > 0) |
|
145 { |
|
146 delete iOperation; |
|
147 iOperation = NULL; |
|
148 iOperation = MsvEntry().DeleteL(*iSelection, iStatus); |
|
149 SetActive(); |
|
150 CActiveScheduler::Start(); |
|
151 } |
|
152 } |
|
153 |
|
154 void CSmsEnumTest::SaveClass2FolderIdL(TMsvId aFolderId) |
|
155 /** |
|
156 Set the class 2 folder in the service Id |
|
157 so that it will be picked up correctly by SMSS |
|
158 */ |
|
159 { |
|
160 MsvEntry().SetEntryL(iSmsTest.iSmsServiceId); |
|
161 CSmsSettings *settings=CSmsSettings::NewL(); |
|
162 CleanupStack::PushL(settings); |
|
163 |
|
164 CSmsAccount* account = CSmsAccount::NewLC(); |
|
165 TRAPD(error, account->LoadSettingsL(*settings)); |
|
166 if (error) |
|
167 { |
|
168 account->InitialiseDefaultSettingsL(*settings); |
|
169 } |
|
170 |
|
171 settings->SetClass2Folder(aFolderId); |
|
172 |
|
173 account->SaveSettingsL(*settings); |
|
174 CleanupStack::PopAndDestroy(account); |
|
175 CleanupStack::PopAndDestroy(settings); |
|
176 } |
|
177 |
|
178 TMsvId CSmsEnumTest::CreateEnumerateFolderLC(TMsvId aParent) |
|
179 { |
|
180 iSmsTest.SetEntryL(aParent); |
|
181 |
|
182 TMsvEntry entry; |
|
183 entry.SetVisible(EFalse); |
|
184 entry.iType = KUidMsvFolderEntry; |
|
185 entry.iMtm = KUidMsgTypeSMS; |
|
186 entry.iServiceId = iSmsTest.iSmsServiceId; |
|
187 iSmsTest.CreateEntryL(entry); |
|
188 |
|
189 iSmsTest.iMsvSession->CleanupEntryPushL(entry.Id()); |
|
190 return entry.Id(); |
|
191 } |
|
192 |
|
193 void CSmsEnumTest::TestCopyToSimL() |
|
194 /** |
|
195 Tests copying messages to SIM |
|
196 */ |
|
197 { |
|
198 iSmsTest.Test().Next(_L("Copy to SIM")); |
|
199 iState = EStateCopyToSim; |
|
200 |
|
201 iSelection->Reset(); |
|
202 |
|
203 TTime now; |
|
204 now.HomeTime(); |
|
205 iSelection->Reset(); |
|
206 |
|
207 iSmsTest.ReadScriptL(iScriptFile, KMsvGlobalOutBoxIndexEntryId, *iSelection, now); |
|
208 iSelection->InsertL(0,iSmsTest.iSmsServiceId); |
|
209 iSmsTest(iSelection->Count()); |
|
210 |
|
211 delete iOperation; |
|
212 iOperation = NULL; |
|
213 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandCopyToPhoneStore, TPtrC8(), iStatus); |
|
214 SetActive(); |
|
215 CActiveScheduler::Start(); |
|
216 } |
|
217 |
|
218 void CSmsEnumTest::TestMoveToSimL(TMsvId aSourceFolderId) |
|
219 /** |
|
220 Tests copying messages to SIM |
|
221 */ |
|
222 { |
|
223 iSmsTest.Test().Next(_L("Move to SIM")); |
|
224 iState = EStateMoveToSim; |
|
225 |
|
226 MsvEntry().SetEntryL(aSourceFolderId); |
|
227 |
|
228 delete iSelection; |
|
229 iSelection = NULL; |
|
230 iSelection = MsvEntry().ChildrenL(); |
|
231 iSelection->InsertL(0,iSmsTest.iSmsServiceId); |
|
232 |
|
233 iSmsTest(iSelection->Count()); |
|
234 |
|
235 delete iOperation; |
|
236 iOperation = NULL; |
|
237 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandMoveToPhoneStore, TPtrC8(), iStatus); |
|
238 SetActive(); |
|
239 CActiveScheduler::Start(); |
|
240 } |
|
241 |
|
242 void CSmsEnumTest::TestEnumerateL(TMsvId aFolderId) |
|
243 /** |
|
244 Enumerates |
|
245 */ |
|
246 { |
|
247 iSmsTest.Test().Next(_L("Enumerate SIM")); |
|
248 iState = EStateEnumerating; |
|
249 |
|
250 iSmsTest.Printf(_L("TestEnumerateL(%d)\n"), aFolderId); |
|
251 |
|
252 if (aFolderId != KErrNotFound) |
|
253 { |
|
254 iLastEnumerateFolder() = aFolderId; |
|
255 iLastEnumerateFolder.SetLength(4); |
|
256 } |
|
257 else |
|
258 iLastEnumerateFolder.SetLength(0); |
|
259 |
|
260 iSelection->Reset(); |
|
261 iSelection->AppendL(iSmsTest.iSmsServiceId); |
|
262 |
|
263 delete iOperation; |
|
264 iOperation = NULL; |
|
265 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandEnumeratePhoneStores, iLastEnumerateFolder, iStatus); |
|
266 SetActive(); |
|
267 CActiveScheduler::Start(); |
|
268 } |
|
269 |
|
270 void CSmsEnumTest::TestEnumerateAndDescLengthL(TMsvId aFolderId) |
|
271 /** |
|
272 Tests both enumeration and changing the default description length. |
|
273 */ |
|
274 { |
|
275 iSmsTest.Test().Next(_L("Enumerate SIM and non-default description length")); |
|
276 iState = EStateEnumeratingAndDescLength; |
|
277 |
|
278 iSmsTest.Printf(_L("TestEnumerateAndDescLength(%d)\n"), aFolderId); |
|
279 |
|
280 if (aFolderId != KErrNotFound) |
|
281 { |
|
282 iLastEnumerateFolder() = aFolderId; |
|
283 iLastEnumerateFolder.SetLength(4); |
|
284 } |
|
285 else |
|
286 iLastEnumerateFolder.SetLength(0); |
|
287 |
|
288 // Set the description length - first restore the sms settings |
|
289 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
290 |
|
291 CSmsAccount* account = CSmsAccount::NewLC(); |
|
292 account->LoadSettingsL(*iSmsTest.iServiceSettings); |
|
293 |
|
294 // Set the description length to 1 |
|
295 iSmsTest.iServiceSettings->SetDescriptionLength(1); |
|
296 |
|
297 // Store the sms settings |
|
298 account->SaveSettingsL(*iSmsTest.iServiceSettings); |
|
299 CleanupStack::PopAndDestroy(account); |
|
300 |
|
301 iSelection->Reset(); |
|
302 iSelection->AppendL(iSmsTest.iSmsServiceId); |
|
303 |
|
304 delete iOperation; |
|
305 iOperation = NULL; |
|
306 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandEnumeratePhoneStores, iLastEnumerateFolder, iStatus); |
|
307 SetActive(); |
|
308 CActiveScheduler::Start(); |
|
309 } |
|
310 |
|
311 void CSmsEnumTest::TestEnumerateAndDetailsFieldL() |
|
312 { |
|
313 iSmsTest.Test().Next(_L("Enumerate SIM and test that details field is ok.")); |
|
314 iState = EStateEnumeratingAndDetailsField; |
|
315 |
|
316 // First create deliver message in the inbox. |
|
317 TMsvEntry entry; |
|
318 entry.SetVisible(ETrue); |
|
319 entry.SetInPreparation(ETrue); |
|
320 entry.iServiceId = iSmsTest.iSmsServiceId; |
|
321 entry.iType = KUidMsvMessageEntry; |
|
322 entry.iMtm = KUidMsgTypeSMS; |
|
323 entry.iDate.HomeTime(); |
|
324 entry.iSize = 0; |
|
325 entry.iDescription.Set(KNullDesC); |
|
326 entry.iDetails.Set(KNullDesC); |
|
327 entry.SetSendingState(KMsvSendStateNotApplicable); |
|
328 |
|
329 // Create the SMS header object... |
|
330 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iSmsTest.iRichText); |
|
331 CleanupStack::PushL(header); |
|
332 |
|
333 // Set the body text... |
|
334 iSmsTest.iRichText->Reset(); |
|
335 iSmsTest.iRichText->InsertL(0, KMessageData); |
|
336 |
|
337 // Copy the message settings... |
|
338 header->SetSmsSettingsL(*iSmsTest.iServiceSettings); |
|
339 |
|
340 // Set recipient - need to set directly in the CSmsMessage as this a Deliver PDU |
|
341 header->Message().SetToFromAddressL(KRecipientOk); |
|
342 |
|
343 // Update entry description and details... |
|
344 entry.iDetails.Set(header->Message().ToFromAddress()); |
|
345 entry.iDescription.Set(iSmsTest.iRichText->Read(0, iSmsTest.iServiceSettings->DescriptionLength())); |
|
346 entry.SetInPreparation(EFalse); |
|
347 |
|
348 // Create the entry - set context to the global outbox. |
|
349 MsvEntry().SetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
350 MsvEntry().CreateL(entry); |
|
351 |
|
352 // Create new store and save header information |
|
353 MsvEntry().SetEntryL(entry.Id()); |
|
354 CMsvStore* store = MsvEntry().EditStoreL(); |
|
355 CleanupStack::PushL(store); |
|
356 header->StoreL(*store); |
|
357 store->StoreBodyTextL(*iSmsTest.iRichText); |
|
358 store->CommitL(); |
|
359 CleanupStack::PopAndDestroy(2, header); |
|
360 |
|
361 // Move the message to the SIM |
|
362 |
|
363 delete iSelection; |
|
364 iSelection = NULL; |
|
365 iSelection = new (ELeave) CMsvEntrySelection(); |
|
366 iSelection->AppendL(iSmsTest.iSmsServiceId); |
|
367 iSelection->AppendL(entry.Id()); |
|
368 |
|
369 iSmsTest(iSelection->Count()); |
|
370 |
|
371 delete iOperation; |
|
372 iOperation = NULL; |
|
373 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandMoveToPhoneStore, TPtrC8(), iStatus); |
|
374 SetActive(); |
|
375 CActiveScheduler::Start(); |
|
376 |
|
377 // Enumerate the SIM - first create the folder into which to enumerate |
|
378 TMsvId folder = CreateEnumerateFolderLC(KMsvGlobalInBoxIndexEntryId); |
|
379 |
|
380 iLastEnumerateFolder() = folder; |
|
381 iLastEnumerateFolder.SetLength(4); |
|
382 |
|
383 iSelection->Reset(); |
|
384 iSelection->AppendL(iSmsTest.iSmsServiceId); |
|
385 |
|
386 delete iOperation; |
|
387 iOperation = NULL; |
|
388 iOperation = Session().TransferCommandL(*iSelection, ESmsMtmCommandEnumeratePhoneStores, iLastEnumerateFolder, iStatus); |
|
389 SetActive(); |
|
390 CActiveScheduler::Start(); |
|
391 |
|
392 // Ok see if things are how it should be... |
|
393 iSmsTest.SetEntryL(folder); |
|
394 delete iSelection; |
|
395 iSelection = NULL; |
|
396 iSelection = MsvEntry().ChildrenL(); |
|
397 iSmsTest.Test()(iSelection->Count() == 1); |
|
398 |
|
399 iSmsTest.SetEntryL(iSelection->At(0)); |
|
400 entry = MsvEntry().Entry(); |
|
401 iSmsTest.Test()(entry.iDetails.Length() > 0); |
|
402 |
|
403 // Destroy the enumerate folder |
|
404 CleanupStack::PopAndDestroy(); |
|
405 } |
|
406 |
|
407 void CSmsEnumTest::TestMultipleRecipientEnumerateL() |
|
408 { |
|
409 // Clean the existing messages |
|
410 ClearInboxL(); |
|
411 TestEnumerateL(); |
|
412 User::LeaveIfError(iStatus.Int()); |
|
413 if (iSelection->Count()) |
|
414 { |
|
415 TestDeleteFromSimL(); |
|
416 User::LeaveIfError(iStatus.Int()); |
|
417 } |
|
418 |
|
419 // Copy to SIM |
|
420 TestCopyToSimL(); |
|
421 User::LeaveIfError(ErrorStatus()); |
|
422 // Count the number of messages to be copied onto SIM, |
|
423 // including multiple msgs for multiple recipients. |
|
424 TInt msgCount = 0; |
|
425 for (TInt index=1; index < (iSelection->Count()); index++) |
|
426 { |
|
427 CSmsHeader* smsHeader = iSmsTest.GetHeaderLC(iSelection->At(index)); |
|
428 if (smsHeader->Message().Type() == CSmsPDU::ESmsSubmit) |
|
429 { |
|
430 msgCount += smsHeader->Recipients().Count(); |
|
431 } |
|
432 else |
|
433 { |
|
434 ++msgCount; |
|
435 } |
|
436 CleanupStack::PopAndDestroy(smsHeader); |
|
437 } |
|
438 |
|
439 TestEnumerateL(); |
|
440 User::LeaveIfError(iStatus.Int()); |
|
441 //Count the number of messages copied onto SIM |
|
442 TInt simMsgCount = iSmsTest.iProgress.iMsgCount; |
|
443 |
|
444 // Check msg count on SIM after copy |
|
445 iSmsTest.Printf(_L("Count msgs on SIM: Expected msgs %d, Copied msgs %d\n"), msgCount, simMsgCount); |
|
446 if (msgCount != simMsgCount) |
|
447 { |
|
448 User::LeaveIfError(KErrNotFound); |
|
449 } |
|
450 |
|
451 // Clean local Inbox and copy msgs from sim |
|
452 if (iSelection->Count()) |
|
453 { |
|
454 ClearInboxL(); |
|
455 TestCopyFromSimL(); |
|
456 User::LeaveIfError(ErrorStatus()); |
|
457 } |
|
458 msgCount = GetInboxMsgsCountL(); |
|
459 |
|
460 // Check msg count in local inbox after copy from SIM |
|
461 iSmsTest.Printf(_L("Count msgs in Inbox: Expected msgs %d, Copied msgs %d\n"), simMsgCount, msgCount); |
|
462 if (msgCount != simMsgCount) |
|
463 { |
|
464 User::LeaveIfError(KErrNotFound); |
|
465 } |
|
466 |
|
467 } |
|
468 |
|
469 |
|
470 CSmsEnumTest::CSmsEnumTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
471 : CSmsTestBase(aSmsTest, aScriptFile, aNextTest), iState(EStateWaiting) |
|
472 { |
|
473 CActiveScheduler::Add(this); |
|
474 } |
|
475 |
|
476 LOCAL_C void doMainL() |
|
477 { |
|
478 #if defined (__WINS__) |
|
479 User::LoadPhysicalDevice(KPddName); |
|
480 User::LoadLogicalDevice(KLddName); |
|
481 #else //__WINS__ |
|
482 User::LoadPhysicalDevice(KPddSirName); |
|
483 User::LoadPhysicalDevice(KPddUartName); |
|
484 User::LoadLogicalDevice(KLddName); |
|
485 #endif //__WINS__ |
|
486 |
|
487 TInt r = StartC32(); |
|
488 if( (r != KErrNone) && (r != KErrAlreadyExists) ) |
|
489 test.Printf(_L("Failed to start C32 %d\n"), r); |
|
490 |
|
491 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
492 CleanupStack::PushL(scheduler); |
|
493 CActiveScheduler::Install( scheduler ); |
|
494 |
|
495 CSmsTestUtils* smsTest = CSmsTestUtils::NewL(test); |
|
496 CleanupStack::PushL(smsTest); |
|
497 TInt nextTest = 0; |
|
498 |
|
499 smsTest->NotifySaPhoneOnL(); |
|
500 |
|
501 CSmsEnumTest* enumTest = CSmsEnumTest::NewLC(*smsTest, KSmsScript, nextTest); |
|
502 |
|
503 smsTest->WaitForInitializeL(); |
|
504 |
|
505 enumTest->StartL(); |
|
506 |
|
507 //CleanupStack::PopAndDestroy(3); //SmsTest, scheduler |
|
508 CleanupStack::PopAndDestroy(enumTest); |
|
509 CleanupStack::PopAndDestroy(smsTest); |
|
510 CleanupStack::PopAndDestroy(scheduler); |
|
511 } |
|
512 |
|
513 GLDEF_C TInt E32Main() |
|
514 { |
|
515 __UHEAP_MARK; |
|
516 test.Start(_L("Setup")); |
|
517 theCleanup = CTrapCleanup::New(); |
|
518 TRAPD(ret,doMainL()); |
|
519 test.Printf(_L("doMainL completed with %d\n"), ret); |
|
520 test(ret==KErrNone); |
|
521 delete theCleanup; |
|
522 test.Console()->SetPos(0, 13); |
|
523 test.End(); |
|
524 test.Close(); |
|
525 __UHEAP_MARKEND; |
|
526 return(KErrNone); |
|
527 } |
|
528 |
|
529 void CSmsEnumTest::RunAutoL() |
|
530 /** |
|
531 Runs tests in sequence, checks iStatus |
|
532 */ |
|
533 { |
|
534 // Wait 5 seconds for everything to start up |
|
535 User::After(5000000); |
|
536 |
|
537 // Initial clean-up |
|
538 iSmsTest.TestStart(++iNextTest, _L("(Cleanup) Enumerate")); |
|
539 TestEnumerateL(); |
|
540 User::LeaveIfError(iStatus.Int()); |
|
541 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
542 |
|
543 if (iSelection->Count()) |
|
544 { |
|
545 iSmsTest.TestStart(++iNextTest, _L("(Cleanup) Delete from SIM")); |
|
546 TestDeleteFromSimL(); |
|
547 User::LeaveIfError(iStatus.Int()); |
|
548 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
549 } |
|
550 |
|
551 // Actual testing |
|
552 ClearInboxL(); |
|
553 iSmsTest.TestStart(++iNextTest, _L("Enumerate - check details field")); |
|
554 TestEnumerateAndDetailsFieldL(); |
|
555 User::LeaveIfError(ErrorStatus()); |
|
556 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
557 ClearInboxL(); |
|
558 |
|
559 iSmsTest.TestStart(++iNextTest, _L("Copy to SIM")); |
|
560 TestCopyToSimL(); |
|
561 User::LeaveIfError(ErrorStatus()); |
|
562 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
563 |
|
564 iSmsTest.TestStart(++iNextTest, _L("Enumerate")); |
|
565 TestEnumerateL(); |
|
566 User::LeaveIfError(iStatus.Int()); |
|
567 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
568 |
|
569 // iSmsTest.TestStart(++iNextTest, _L("Test UnRead Status - all messages un-read after 1st enumerate")); |
|
570 // TestUnreadStatusL(); |
|
571 // iSmsTest.TestFinish(iNextTest, KErrNone); |
|
572 |
|
573 iSmsTest.TestStart(++iNextTest, _L("Enumerate and non-default description length")); |
|
574 TestEnumerateAndDescLengthL(); |
|
575 User::LeaveIfError(iStatus.Int()); |
|
576 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
577 |
|
578 iSmsTest.TestStart(++iNextTest, _L("Test Read Status - all messages read after 2nd enumerate")); |
|
579 TestReadStatusL(); |
|
580 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
581 |
|
582 SaveClass2FolderIdL(iSmsTest.iProgress.iEnumerateFolder); |
|
583 TMsvId class2Folder = iSmsTest.iProgress.iEnumerateFolder; |
|
584 ClearInboxL(); |
|
585 |
|
586 if (iSelection->Count()) |
|
587 { |
|
588 iSmsTest.TestStart(++iNextTest, _L("Move from SIM")); |
|
589 TestMoveFromSimL(class2Folder); |
|
590 User::LeaveIfError(ErrorStatus()); |
|
591 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
592 } |
|
593 |
|
594 iSmsTest.TestStart(++iNextTest, _L("Copy to SIM")); |
|
595 TestCopyToSimL(); |
|
596 User::LeaveIfError(ErrorStatus()); |
|
597 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
598 |
|
599 iSmsTest.TestStart(++iNextTest, _L("Test SIM store status after copy to SIM")); |
|
600 TestSimStoreStatusL(class2Folder); |
|
601 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
602 |
|
603 iSmsTest.TestStart(++iNextTest, _L("Enumerate")); |
|
604 TestEnumerateL(); |
|
605 User::LeaveIfError(iStatus.Int()); |
|
606 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
607 |
|
608 if (iSelection->Count()) |
|
609 { |
|
610 iSmsTest.TestStart(++iNextTest, _L("Move from SIM")); |
|
611 TestMoveFromSimL(class2Folder); |
|
612 User::LeaveIfError(ErrorStatus()); |
|
613 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
614 } |
|
615 |
|
616 iSmsTest.TestStart(++iNextTest, _L("Test phone store status after move from SIM")); |
|
617 TestPhoneStoreStatusL(KMsvGlobalInBoxIndexEntryId); |
|
618 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
619 |
|
620 iSmsTest.TestStart(++iNextTest, _L("Move to SIM")); |
|
621 TestMoveToSimL(KMsvGlobalInBoxIndexEntryId); |
|
622 User::LeaveIfError(ErrorStatus()); |
|
623 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
624 |
|
625 iSmsTest.TestStart(++iNextTest, _L("Test SIM store status after move to SIM")); |
|
626 TestSimStoreStatusL(class2Folder); |
|
627 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
628 |
|
629 iSmsTest.TestStart(++iNextTest, _L("Copy from SIM")); |
|
630 TestCopyFromSimL(class2Folder); |
|
631 User::LeaveIfError(ErrorStatus()); |
|
632 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
633 |
|
634 iSmsTest.TestStart(++iNextTest, _L("Test phone store status after copy from SIM")); |
|
635 TestPhoneStoreStatusL(KMsvGlobalInBoxIndexEntryId); |
|
636 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
637 |
|
638 // Copy to SIM, multiple recipients |
|
639 iSmsTest.TestStart(++iNextTest, _L("Copy to SIM, multiple recipients")); |
|
640 TestMultipleRecipientEnumerateL(); |
|
641 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
642 |
|
643 TestAllEnumerateL(); |
|
644 TMsvId folder = CreateEnumerateFolderLC(KMsvGlobalInBoxIndexEntryId); |
|
645 TestAllEnumerateL(folder); |
|
646 TestAllEnumerateL(folder); |
|
647 folder = CreateEnumerateFolderLC(KMsvGlobalInBoxIndexEntryId); |
|
648 TestAllEnumerateL(folder); |
|
649 CleanupStack::PopAndDestroy(2); |
|
650 |
|
651 iSmsTest.TestStart(++iNextTest, _L("Enumerate before move")); |
|
652 TestEnumerateL(KErrNotFound); |
|
653 User::LeaveIfError(iStatus.Int()); |
|
654 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
655 |
|
656 if (iSelection->Count()) |
|
657 { |
|
658 iSmsTest.TestStart(++iNextTest, _L("Move from SIM")); |
|
659 TestMoveFromSimL(); |
|
660 User::LeaveIfError(iStatus.Int()); |
|
661 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
662 } |
|
663 } |
|
664 |
|
665 void CSmsEnumTest::TestAllEnumerateL(TMsvId aFolderId) |
|
666 { |
|
667 iSmsTest.TestStart(++iNextTest, _L("Enumerate")); |
|
668 TestEnumerateL(aFolderId); |
|
669 User::LeaveIfError(iStatus.Int()); |
|
670 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
671 |
|
672 if (iSelection->Count()) |
|
673 { |
|
674 iSmsTest.TestStart(++iNextTest, _L("Copy from SIM")); |
|
675 TestCopyFromSimL(aFolderId); |
|
676 User::LeaveIfError(ErrorStatus()); |
|
677 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
678 } |
|
679 } |
|
680 |
|
681 void CSmsEnumTest::ConstructL() |
|
682 { |
|
683 SetTestNameL(KSmsEnumTestName); |
|
684 iSmsTest.SetLogToFile(); |
|
685 |
|
686 iSelection = new (ELeave) CMsvEntrySelection(); |
|
687 iTimer = CTestTimer::NewL(); |
|
688 |
|
689 User::LeaveIfError(iSocketServ.Connect()); |
|
690 TProtocolDesc protoinfo; |
|
691 TProtocolName protocolname(KSmsDatagram); |
|
692 User::LeaveIfError(iSocketServ.FindProtocol(protocolname,protoinfo)); |
|
693 User::LeaveIfError(iSocket.Open(iSocketServ,protoinfo.iAddrFamily,protoinfo.iSockType,protoinfo.iProtocol)); |
|
694 |
|
695 TSmsAddr smsaddr; |
|
696 smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly); |
|
697 User::LeaveIfError(iSocket.Bind(smsaddr)); |
|
698 |
|
699 iParaFormat = CParaFormatLayer::NewL(); |
|
700 iCharFormat = CCharFormatLayer::NewL(); |
|
701 iBody = CRichText::NewL(iParaFormat, iCharFormat); |
|
702 iHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iBody); |
|
703 } |
|
704 |
|
705 void CSmsEnumTest::ShowMenuL() |
|
706 { |
|
707 iSmsTest.ResetMenu(); |
|
708 |
|
709 iSmsTest.AppendToMenuL(_L("Enumerate SIM")); |
|
710 iSmsTest.AppendToMenuL(_L("Copy To SIM")); |
|
711 iSmsTest.AppendToMenuL(_L("Display Log")); |
|
712 iSmsTest.AppendToMenuL(_L("Clear Log")); |
|
713 |
|
714 TInt result = iSmsTest.DisplayMenu(_L("SMS Enumerate Sim Test")); |
|
715 |
|
716 if (result <= 0) |
|
717 return; |
|
718 |
|
719 switch (result) |
|
720 { |
|
721 case 1: |
|
722 TestEnumerateL(); |
|
723 break; |
|
724 case 2: |
|
725 TestCopyToSimL(); |
|
726 break; |
|
727 case 3: |
|
728 DisplayLogL(); |
|
729 break; |
|
730 case 4: |
|
731 ClearLogL(); |
|
732 break; |
|
733 default: |
|
734 User::Leave(KErrArgument); |
|
735 break; |
|
736 } |
|
737 |
|
738 ShowMenuL(); |
|
739 } |
|
740 |
|
741 CSmsEnumTest::~CSmsEnumTest() |
|
742 { |
|
743 delete iBody; |
|
744 delete iHeader; |
|
745 delete iParaFormat; |
|
746 delete iCharFormat; |
|
747 |
|
748 iSocket.Close(); |
|
749 iSocketServ.Close(); |
|
750 } |
|
751 |
|
752 CSmsEnumTest* CSmsEnumTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
753 { |
|
754 CSmsEnumTest* self = new (ELeave) CSmsEnumTest(aSmsTest, aScriptFile, aNextTest); |
|
755 CleanupStack::PushL(self); |
|
756 |
|
757 self->ConstructL(); |
|
758 return self; |
|
759 } |
|
760 |
|
761 void CSmsEnumTest::RunL() |
|
762 /** |
|
763 Handles completed async operations |
|
764 */ |
|
765 { |
|
766 CActiveScheduler::Stop(); |
|
767 |
|
768 iSmsTest(iStatus.Int() == KErrNone); |
|
769 |
|
770 iSmsTest.SetProgressL(*iOperation); |
|
771 |
|
772 switch (iState) |
|
773 { |
|
774 case EStateEnumerating: |
|
775 { |
|
776 DoRunEnumerateL(); |
|
777 break; |
|
778 } |
|
779 case EStateEnumeratingAndDescLength: |
|
780 { |
|
781 DoRunEnumerateAndDescLengthL(); |
|
782 } break; |
|
783 case EStateCopyFromSim: |
|
784 case EStateMoveFromSim: |
|
785 case EStateDeleteFromSim: |
|
786 { |
|
787 DoRunCopyMoveDeleteFromSim(); |
|
788 break; |
|
789 } |
|
790 case EStateCopyToSim: |
|
791 { |
|
792 DoRunCopyToSim(); |
|
793 break; |
|
794 } |
|
795 case EStateClearInbox: |
|
796 { |
|
797 DoRunClearInbox(); |
|
798 break; |
|
799 } |
|
800 default: |
|
801 { |
|
802 break; |
|
803 } |
|
804 } |
|
805 |
|
806 delete iOperation; |
|
807 iOperation = NULL; |
|
808 } |
|
809 |
|
810 TInt CSmsEnumTest::ErrorStatus() |
|
811 { |
|
812 if (iStatus.Int() == KErrNone) |
|
813 return(iSmsTest.iProgress.iError); |
|
814 else |
|
815 return(iStatus.Int()); |
|
816 } |
|
817 |
|
818 void CSmsEnumTest::DoRunClearInbox() |
|
819 /** |
|
820 Checks status |
|
821 */ |
|
822 { |
|
823 TInt err = iStatus.Int(); |
|
824 iSmsTest.Printf(_L("Clear Inbox completed with error %d\n"), err); |
|
825 iState = EStateWaiting; |
|
826 } |
|
827 |
|
828 void CSmsEnumTest::DoRunCopyToSim() |
|
829 /** |
|
830 Checks status |
|
831 */ |
|
832 { |
|
833 iSmsTest.Printf(_L("Copy To SIM completed with error %d\n"), ErrorStatus()); |
|
834 |
|
835 iState = EStateWaiting; |
|
836 |
|
837 if (!iSmsTest.RunAuto()) |
|
838 { |
|
839 iSmsTest.Printf(_L("\nPress any key to continue...\n")); |
|
840 iSmsTest.Test().Getch(); |
|
841 } |
|
842 } |
|
843 |
|
844 void CSmsEnumTest::DoRunMoveToSim() |
|
845 /** |
|
846 Checks status |
|
847 */ |
|
848 { |
|
849 iSmsTest.Printf(_L("Move To SIM completed with error %d\n"), ErrorStatus()); |
|
850 |
|
851 iState = EStateWaiting; |
|
852 |
|
853 if (!iSmsTest.RunAuto()) |
|
854 { |
|
855 iSmsTest.Printf(_L("\nPress any key to continue...\n")); |
|
856 iSmsTest.Test().Getch(); |
|
857 } |
|
858 } |
|
859 |
|
860 void CSmsEnumTest::DoRunCopyMoveDeleteFromSim() |
|
861 /** |
|
862 Checks status |
|
863 */ |
|
864 { |
|
865 switch (iState) |
|
866 { |
|
867 case EStateCopyFromSim: |
|
868 iSmsTest.Printf(_L("Copy From SIM completed with error %d\n"), ErrorStatus()); |
|
869 break; |
|
870 case EStateMoveFromSim: |
|
871 iSmsTest.Printf(_L("Move From SIM completed with error %d\n"), ErrorStatus()); |
|
872 break; |
|
873 case EStateDeleteFromSim: |
|
874 iSmsTest.Printf(_L("Delete From SIM completed with error %d\n"), ErrorStatus()); |
|
875 break; |
|
876 default: |
|
877 break; |
|
878 } |
|
879 |
|
880 iState = EStateWaiting; |
|
881 |
|
882 if (!iSmsTest.RunAuto()) |
|
883 { |
|
884 iSmsTest.Printf(_L("\nPress any key to continue...\n")); |
|
885 iSmsTest.Test().Getch(); |
|
886 } |
|
887 } |
|
888 |
|
889 void CSmsEnumTest::DoRunEnumerateL() |
|
890 /** |
|
891 Checks status |
|
892 */ |
|
893 { |
|
894 TInt err = iStatus.Int(); |
|
895 |
|
896 if (err == KErrNone) |
|
897 { |
|
898 err = iSmsTest.iProgress.iError; |
|
899 iStatus = err; |
|
900 |
|
901 if (err == KErrNone) |
|
902 { |
|
903 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
904 delete iSelection; |
|
905 iSelection = NULL; |
|
906 iSelection = MsvEntry().ChildrenL(); |
|
907 |
|
908 iSmsTest.Printf(_L("%d message(s) on SIM. %d message(s) now contained in folder %d.\n"), iSmsTest.iProgress.iMsgCount, iSelection->Count(), iSmsTest.iProgress.iEnumerateFolder); |
|
909 iSmsTest.DisplayMessagesL(*iSelection); |
|
910 } |
|
911 } |
|
912 |
|
913 iSmsTest.Printf(_L("Enumerate SIM completed with %d\n"), err); |
|
914 iState = EStateWaiting; |
|
915 |
|
916 CheckParentAfterEnumerateL(); |
|
917 |
|
918 delete iOperation; |
|
919 iOperation = NULL; |
|
920 |
|
921 if (!iSmsTest.RunAuto()) |
|
922 { |
|
923 iSmsTest.Printf(_L("\nPress any key to continue...\n")); |
|
924 iSmsTest.Test().Getch(); |
|
925 |
|
926 if (iSmsTest.iProgress.iMsgCount) |
|
927 ShowMenuAfterEnumerateL(); |
|
928 } |
|
929 } |
|
930 |
|
931 void CSmsEnumTest::DoRunEnumerateAndDescLengthL() |
|
932 { |
|
933 // Print out messages and check that the description is only a char in length |
|
934 TInt err = iStatus.Int(); |
|
935 |
|
936 if (err == KErrNone) |
|
937 { |
|
938 err = iSmsTest.iProgress.iError; |
|
939 iStatus = err; |
|
940 |
|
941 if (err == KErrNone) |
|
942 { |
|
943 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
944 delete iSelection; |
|
945 iSelection = NULL; |
|
946 iSelection = MsvEntry().ChildrenL(); |
|
947 |
|
948 iSmsTest.Printf(_L("%d message(s) on SIM. %d message(s) now contained in folder %d.\n"), iSmsTest.iProgress.iMsgCount, iSelection->Count(), iSmsTest.iProgress.iEnumerateFolder); |
|
949 TInt count = iSelection->Count(); |
|
950 |
|
951 for (TInt i = 0; i < count && err==KErrNone; ++i) |
|
952 { |
|
953 // Display the message and then check the description |
|
954 TMsvId id = (*iSelection)[i]; |
|
955 iSmsTest.DisplayMessageL(id); |
|
956 |
|
957 iSmsTest.SetEntryL(id); |
|
958 if( iSmsTest.Entry().iDescription.Length() != 1 ) |
|
959 err = KErrCorrupt; |
|
960 } |
|
961 } |
|
962 } |
|
963 |
|
964 iSmsTest.Printf(_L("Enumerate SIM completed with %d\n"), err); |
|
965 iState = EStateWaiting; |
|
966 |
|
967 CheckParentAfterEnumerateL(); |
|
968 |
|
969 delete iOperation; |
|
970 iOperation = NULL; |
|
971 |
|
972 if (!iSmsTest.RunAuto()) |
|
973 { |
|
974 iSmsTest.Printf(_L("\nPress any key to continue...\n")); |
|
975 iSmsTest.Test().Getch(); |
|
976 |
|
977 if (iSmsTest.iProgress.iMsgCount) |
|
978 ShowMenuAfterEnumerateL(); |
|
979 } |
|
980 |
|
981 // Restore the description length |
|
982 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
983 |
|
984 CSmsAccount* account = CSmsAccount::NewLC(); |
|
985 account->LoadSettingsL(*iSmsTest.iServiceSettings); |
|
986 |
|
987 // Set the description length to default |
|
988 iSmsTest.iServiceSettings->SetDescriptionLength(KSmsDescriptionLength); |
|
989 |
|
990 // Store the sms settings |
|
991 account->SaveSettingsL(*iSmsTest.iServiceSettings); |
|
992 CleanupStack::PopAndDestroy(account); |
|
993 } |
|
994 |
|
995 void CSmsEnumTest::CheckParentAfterEnumerateL() |
|
996 { |
|
997 if (iLastEnumerateFolder.Length() == 0) |
|
998 { |
|
999 iSmsTest.SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
1000 const TMsvId parent = iSmsTest.Entry().Parent(); |
|
1001 if (parent != iSmsTest.iSmsServiceId) |
|
1002 { |
|
1003 iSmsTest.Printf(_L("Parent of enum folder is not the SMS service [parent=%d folder=%d service=%d]\n"), |
|
1004 parent, iSmsTest.iProgress.iEnumerateFolder, iSmsTest.iSmsServiceId); |
|
1005 User::Leave(KErrGeneral); |
|
1006 } |
|
1007 } |
|
1008 else if (iSmsTest.iProgress.iEnumerateFolder != iLastEnumerateFolder()) |
|
1009 { |
|
1010 iSmsTest.Printf(_L("Folder does not match [folder=%d request=%d]\n"), |
|
1011 iSmsTest.iProgress.iEnumerateFolder, iLastEnumerateFolder()); |
|
1012 User::Leave(KErrGeneral); |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 void CSmsEnumTest::ShowMenuAfterEnumerateL() |
|
1017 /** |
|
1018 Shows menu after enumerating |
|
1019 */ |
|
1020 { |
|
1021 iSmsTest.ResetMenu(); |
|
1022 |
|
1023 iSmsTest.AppendToMenuL(_L("Copy From Sim To Inbox")); |
|
1024 iSmsTest.AppendToMenuL(_L("Move From Sim To Inbox")); |
|
1025 iSmsTest.AppendToMenuL(_L("Delete From Sim")); |
|
1026 |
|
1027 TInt result = iSmsTest.DisplayMenu(_L("What to do with enumerated messages?")); |
|
1028 |
|
1029 if (result <= 0) |
|
1030 return; |
|
1031 |
|
1032 switch (result) |
|
1033 { |
|
1034 case 1: |
|
1035 TestCopyFromSimL(); |
|
1036 break; |
|
1037 case 2: |
|
1038 TestMoveFromSimL(); |
|
1039 break; |
|
1040 case 3: |
|
1041 TestDeleteFromSimL(); |
|
1042 break; |
|
1043 default: |
|
1044 User::Leave(KErrArgument); |
|
1045 break; |
|
1046 } |
|
1047 } |
|
1048 |
|
1049 void CSmsEnumTest::DoCancel() |
|
1050 /** |
|
1051 Cancels the async operation |
|
1052 */ |
|
1053 { |
|
1054 if (iOperation) |
|
1055 { |
|
1056 iOperation->Cancel(); |
|
1057 iSmsTest.Printf(_L("Operation Cancelled!\n")); |
|
1058 } |
|
1059 else |
|
1060 { |
|
1061 iSmsTest.Printf(_L("No operation to cancel!\n")); |
|
1062 } |
|
1063 |
|
1064 delete iOperation; |
|
1065 iOperation = NULL; |
|
1066 } |
|
1067 |
|
1068 void CSmsEnumTest::TestDeleteRemoteEntryL() |
|
1069 /** |
|
1070 Tests deleting remote entries |
|
1071 */ |
|
1072 { |
|
1073 iSmsTest.Test().Next(_L("Test Delete Remote Entry\n")); |
|
1074 |
|
1075 CMsvOperationWait* wait = CMsvOperationWait::NewLC(); |
|
1076 wait->Start(); |
|
1077 |
|
1078 iSmsTest.SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
1079 iSmsTest.SetEntryL(iSmsTest.Entry().Parent()); |
|
1080 |
|
1081 CMsvOperation* op = iSmsTest.iMsvEntry->DeleteL(iSmsTest.iProgress.iEnumerateFolder, wait->iStatus); |
|
1082 CleanupStack::PushL(op); |
|
1083 |
|
1084 CActiveScheduler::Start(); |
|
1085 |
|
1086 iSmsTest.Printf(_L("Remote DeleteL() completed with %d\n"), wait->iStatus.Int()); |
|
1087 |
|
1088 User::LeaveIfError(wait->iStatus.Int()); |
|
1089 |
|
1090 iSmsTest.SetProgressL(*op); |
|
1091 |
|
1092 iSmsTest.Printf(_L("Operation completed with %d, msg count %d\n"), iSmsTest.iProgress.iError, iSmsTest.iProgress.iMsgCount); |
|
1093 User::LeaveIfError(iSmsTest.iProgress.iError); |
|
1094 |
|
1095 CleanupStack::PopAndDestroy(2); //wait, op |
|
1096 } |
|
1097 |
|
1098 void CSmsEnumTest::TestUnreadStatusL() |
|
1099 /** |
|
1100 Tests that the unread flag of any messaged on the SIM is propagated |
|
1101 to the entries created in the class 2 folder |
|
1102 |
|
1103 These should have the Unread() flag SET after the first enumeration. |
|
1104 */ |
|
1105 { |
|
1106 iSmsTest.Test().Next(_L("Test Unread Status\n")); |
|
1107 |
|
1108 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
1109 |
|
1110 delete iSelection; |
|
1111 iSelection = NULL; |
|
1112 iSelection = MsvEntry().ChildrenL(); |
|
1113 |
|
1114 TInt count = iSelection->Count(); |
|
1115 TInt status = KErrNone; |
|
1116 |
|
1117 while (count--) |
|
1118 { |
|
1119 MsvEntry().SetEntryL(iSelection->At(count)); |
|
1120 if (!MsvEntry().Entry().Unread()) |
|
1121 { |
|
1122 status = KErrCorrupt; |
|
1123 break; |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 iSmsTest.Printf(_L("TestUnreadStatusL() completed with %d\n"), status); |
|
1128 User::LeaveIfError(status); |
|
1129 } |
|
1130 |
|
1131 void CSmsEnumTest::TestReadStatusL() |
|
1132 /** |
|
1133 Tests that the unread flag of any messaged on the SIM is propagated |
|
1134 to the entries created in the class 2 folder |
|
1135 |
|
1136 These should have the Unread() flag UNSET after the second enumeration. |
|
1137 */ |
|
1138 { |
|
1139 iSmsTest.Test().Next(_L("Test Unread Status\n")); |
|
1140 |
|
1141 MsvEntry().SetEntryL(iSmsTest.iProgress.iEnumerateFolder); |
|
1142 |
|
1143 delete iSelection; |
|
1144 iSelection = NULL; |
|
1145 iSelection = MsvEntry().ChildrenL(); |
|
1146 |
|
1147 TInt count = iSelection->Count(); |
|
1148 TInt status = KErrNone; |
|
1149 |
|
1150 while (count--) |
|
1151 { |
|
1152 MsvEntry().SetEntryL(iSelection->At(count)); |
|
1153 if (MsvEntry().Entry().Unread()) |
|
1154 { |
|
1155 status = KErrCorrupt; |
|
1156 break; |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 iSmsTest.Printf(_L("TestReadStatusL() completed with %d\n"), status); |
|
1161 User::LeaveIfError(status); |
|
1162 } |
|
1163 |
|
1164 void CSmsEnumTest::TestPhoneStoreStatusL(TMsvId aFolderId) |
|
1165 /** |
|
1166 Tests that the messages in the specified folder have the storage |
|
1167 set to ESmsPhoneStorage and have no iSlotArray members. |
|
1168 */ |
|
1169 { |
|
1170 iSmsTest.Test().Next(_L("Test Phone Store Status\n")); |
|
1171 |
|
1172 MsvEntry().SetEntryL(aFolderId); |
|
1173 |
|
1174 delete iSelection; |
|
1175 iSelection = NULL; |
|
1176 iSelection = MsvEntry().ChildrenL(); |
|
1177 |
|
1178 TInt count = iSelection->Count(); |
|
1179 TInt status = KErrNone; |
|
1180 |
|
1181 while (count--) |
|
1182 { |
|
1183 MsvEntry().SetEntryL(iSelection->At(count)); |
|
1184 CMsvStore* store = MsvEntry().ReadStoreL(); |
|
1185 CleanupStack::PushL(store); |
|
1186 iHeader->RestoreL(*store); |
|
1187 CSmsMessage& smsmessage = iHeader->Message(); |
|
1188 |
|
1189 if ((smsmessage.iSlotArray.Count() > 0) || |
|
1190 (smsmessage.Storage() != CSmsMessage::ESmsPhoneStorage)) |
|
1191 { |
|
1192 status = KErrCorrupt; |
|
1193 } |
|
1194 |
|
1195 CleanupStack::PopAndDestroy(store); |
|
1196 } |
|
1197 |
|
1198 iSmsTest.Printf(_L("TestPhoneStoreStatusL() completed with %d\n"), status); |
|
1199 User::LeaveIfError(status); |
|
1200 } |
|
1201 |
|
1202 void CSmsEnumTest::TestSimStoreStatusL(TMsvId aFolderId) |
|
1203 /** |
|
1204 Tests that the messages in the specified folder have the storage |
|
1205 set to ESmsSimStorage and have at least 1 iSlotArray member. |
|
1206 */ |
|
1207 { |
|
1208 iSmsTest.Test().Next(_L("Test Sim Store Status\n")); |
|
1209 |
|
1210 MsvEntry().SetEntryL(aFolderId); |
|
1211 |
|
1212 delete iSelection; |
|
1213 iSelection = NULL; |
|
1214 iSelection = MsvEntry().ChildrenL(); |
|
1215 |
|
1216 TInt count = iSelection->Count(); |
|
1217 TInt status = KErrNone; |
|
1218 |
|
1219 while (count--) |
|
1220 { |
|
1221 MsvEntry().SetEntryL(iSelection->At(count)); |
|
1222 CMsvStore* store = MsvEntry().ReadStoreL(); |
|
1223 CleanupStack::PushL(store); |
|
1224 iHeader->RestoreL(*store); |
|
1225 CSmsMessage& smsmessage = iHeader->Message(); |
|
1226 |
|
1227 if ((smsmessage.iSlotArray.Count() < 1) || |
|
1228 (smsmessage.Storage() != CSmsMessage::ESmsSIMStorage)) |
|
1229 { |
|
1230 status = KErrCorrupt; |
|
1231 } |
|
1232 |
|
1233 CleanupStack::PopAndDestroy(store); |
|
1234 } |
|
1235 |
|
1236 iSmsTest.Printf(_L("TestSimStoreStatusL() completed with %d\n"), status); |
|
1237 User::LeaveIfError(status); |
|
1238 } |
|