|
1 // Copyright (c) 2005-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 <smss.rsg> |
|
17 #include <csmsaccount.h> |
|
18 #include <csmsemailfields.h> |
|
19 |
|
20 #include "T_smutTE.h" |
|
21 #include <gsmuieoperations.h> |
|
22 |
|
23 const TUid KUidMsvSmsEmailFieldsStream = {0x10204C9D}; |
|
24 const TInt KLogID1 = 123456789; |
|
25 const TInt KLogID2 = 987654321; |
|
26 const TInt KLogID3 = 118888; |
|
27 |
|
28 CSmutTest::CSmutTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest,CTestStep& aTestStep) |
|
29 : CSmsTestBase(aSmsTest, aScriptFile, aNextTest), iTestStep(aTestStep) |
|
30 { |
|
31 } |
|
32 |
|
33 void CSmutTest::RunAutoL() |
|
34 { |
|
35 } |
|
36 |
|
37 CSmutTest::~CSmutTest() |
|
38 { |
|
39 delete iSmsHeader; |
|
40 delete iRichText; |
|
41 delete iParaLayer; |
|
42 delete iCharLayer; |
|
43 iDBSession->Close(); |
|
44 delete iDBSession; |
|
45 } |
|
46 |
|
47 void CSmutTest::ConstructL() |
|
48 { |
|
49 iSmsTest.SetLogToFile(); |
|
50 |
|
51 iSelection = new (ELeave) CMsvEntrySelection(); |
|
52 iTimer = CTestTimer::NewL(); |
|
53 |
|
54 iParaLayer =CParaFormatLayer::NewL(); |
|
55 iCharLayer = CCharFormatLayer::NewL(); |
|
56 iRichText = CRichText::NewL(iParaLayer, iCharLayer, CEditableText::EFlatStorage,256); |
|
57 iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
58 |
|
59 CActiveScheduler::Add(this); |
|
60 } |
|
61 |
|
62 CSmutTest* CSmutTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest,CTestStep& aTestStep) |
|
63 { |
|
64 CSmutTest* self = new (ELeave) CSmutTest(aSmsTest, aScriptFile, aNextTest, aTestStep); |
|
65 CleanupStack::PushL(self); |
|
66 |
|
67 self->ConstructL(); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 void CSmutTest::ShowMenuL() |
|
73 { |
|
74 } |
|
75 |
|
76 TVerdict CSmutTest::TestSettingsL() |
|
77 { |
|
78 iTestStep.INFO_PRINTF1(_L("Testing Create Settings...")); |
|
79 |
|
80 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
81 |
|
82 // First we test all the features of the class CSmsSettings |
|
83 // We give them different values and compare if it works |
|
84 |
|
85 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
86 if(!CompareSettings(*settings, *settings)) |
|
87 { |
|
88 CleanupStack::PopAndDestroy(settings); |
|
89 return EFail; |
|
90 } |
|
91 if(!TestSettingsMembersL(*settings)) |
|
92 { |
|
93 CleanupStack::PopAndDestroy(settings); |
|
94 return EFail; |
|
95 } |
|
96 TestMessageSettingsMembersL(*settings); |
|
97 |
|
98 // Lets copy the values to a different instance |
|
99 CSmsSettings* smsSettings=CSmsSettings::NewLC(); |
|
100 smsSettings->CopyL(*settings); |
|
101 if(!CompareSettings(*smsSettings, *settings)) |
|
102 { |
|
103 CleanupStack::PopAndDestroy(2,settings); |
|
104 return EFail; |
|
105 } |
|
106 CleanupStack::PopAndDestroy(smsSettings); |
|
107 smsSettings = NULL; |
|
108 iTestStep.INFO_PRINTF1(_L("Test CSmsSettings::CopyL() passed")); |
|
109 |
|
110 // Lets create a sms service in the file system with these values |
|
111 TestStoreRestoreSettingsL(*settings); |
|
112 |
|
113 // Lets make the previous test again; Lets give a settings instance some |
|
114 // values, store it, restore it and see that the values are still the same |
|
115 CSmsSettings* set2=CSmsSettings::NewLC(); |
|
116 set2->AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
117 set2->AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
118 set2->AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
119 set2->AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010")); |
|
120 set2->AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010")); |
|
121 set2->SetDefaultServiceCenter(1); |
|
122 iSmsTest(set2->DefaultServiceCenter()==1); |
|
123 // Validity Period |
|
124 set2->SetValidityPeriod(ESmsVPSixHours); |
|
125 if(set2->ValidityPeriod().Int()!=ESmsVPSixHours) |
|
126 { |
|
127 CleanupStack::PopAndDestroy(2,settings); |
|
128 return EFail; |
|
129 } |
|
130 // Reply Quoted |
|
131 set2->SetReplyQuoted(EFalse); |
|
132 if(set2->ReplyQuoted()) |
|
133 { |
|
134 CleanupStack::PopAndDestroy(2,settings); |
|
135 return EFail; |
|
136 } |
|
137 // Reject Duplicate |
|
138 set2->SetRejectDuplicate(ETrue); |
|
139 if(!set2->RejectDuplicate()) |
|
140 { |
|
141 CleanupStack::PopAndDestroy(2,settings); |
|
142 return EFail; |
|
143 } |
|
144 // Delivery Method |
|
145 set2->SetDelivery(ESmsDeliveryUponRequest); |
|
146 if(set2->Delivery()!=ESmsDeliveryUponRequest) |
|
147 { |
|
148 CleanupStack::PopAndDestroy(2,settings); |
|
149 return EFail; |
|
150 } |
|
151 // Delivery Report |
|
152 set2->SetDeliveryReport(ETrue); |
|
153 if(!set2->DeliveryReport()) |
|
154 { |
|
155 CleanupStack::PopAndDestroy(2,settings); |
|
156 return EFail; |
|
157 } |
|
158 // Reply Path |
|
159 set2->SetReplyPath(EFalse); |
|
160 if(set2->ReplyPath()) |
|
161 { |
|
162 CleanupStack::PopAndDestroy(2,settings); |
|
163 return EFail; |
|
164 } |
|
165 // Message Conversion |
|
166 set2->SetMessageConversion(ESmsConvPIDNone); |
|
167 if(set2->MessageConversion()!=ESmsConvPIDNone) |
|
168 { |
|
169 CleanupStack::PopAndDestroy(2,settings); |
|
170 return EFail; |
|
171 } |
|
172 // Can Concatenate |
|
173 set2->SetCanConcatenate(ETrue); |
|
174 if(!set2->CanConcatenate()) |
|
175 { |
|
176 CleanupStack::PopAndDestroy(2,settings); |
|
177 return EFail; |
|
178 } |
|
179 // Character Set |
|
180 set2->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
181 if(set2->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet8Bit) |
|
182 { |
|
183 CleanupStack::PopAndDestroy(2,settings); |
|
184 return EFail; |
|
185 } |
|
186 // Validity period format |
|
187 set2->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
188 if(set2->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet) |
|
189 { |
|
190 CleanupStack::PopAndDestroy(2,settings); |
|
191 return EFail; |
|
192 } |
|
193 // Status Report Handling |
|
194 set2->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
195 if(set2->StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisible) |
|
196 { |
|
197 CleanupStack::PopAndDestroy(2,settings); |
|
198 return EFail; |
|
199 } |
|
200 // Special Message Handling |
|
201 set2->SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
202 if(set2->SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisible) |
|
203 { |
|
204 CleanupStack::PopAndDestroy(2,settings); |
|
205 return EFail; |
|
206 } |
|
207 |
|
208 if(!TestStoreRestoreSettingsL(*set2)) |
|
209 { |
|
210 CleanupStack::PopAndDestroy(2,settings); |
|
211 return EFail; |
|
212 } |
|
213 |
|
214 set2->SetClass2Folder(123); |
|
215 if(!TestStoreRestoreSettingsL(*set2)) |
|
216 { |
|
217 CleanupStack::PopAndDestroy(2,settings); |
|
218 return EFail; |
|
219 } |
|
220 |
|
221 CleanupStack::PopAndDestroy(set2); |
|
222 |
|
223 iSmsTest.iServiceSettings->CopyL(*settings); // Lets copy the current setting to the service settings |
|
224 |
|
225 if(!CompareSettings(*iSmsTest.iServiceSettings, *settings)) |
|
226 { |
|
227 CleanupStack::PopAndDestroy(settings); |
|
228 return EFail; |
|
229 } |
|
230 |
|
231 iTestStep.INFO_PRINTF1(_L("CSmsSettings::CopyL() 2")); |
|
232 CleanupStack::PopAndDestroy(settings); |
|
233 iTestStep.INFO_PRINTF1(_L("Test Create Settings Passed")); |
|
234 TestSettingsStoreToCommDbL(); |
|
235 iTestStep.INFO_PRINTF1(_L("Test Create Settings Passed")); |
|
236 return EPass; |
|
237 } |
|
238 |
|
239 |
|
240 TBool CSmutTest::CompareSettingsFiles( |
|
241 RFs& aFs, const TDesC& aCompare1, const TDesC& aCompare2 |
|
242 ) |
|
243 { |
|
244 TBool identical = ETrue; |
|
245 |
|
246 RFileReadStream stream1; |
|
247 RFileReadStream stream2; |
|
248 |
|
249 // Open each stream for binary read. |
|
250 stream1.Open(aFs, aCompare1, EFileStream | EFileRead); |
|
251 stream2.Open(aFs, aCompare2, EFileStream | EFileRead); |
|
252 |
|
253 TInt ret1 = KErrNone; |
|
254 TInt ret2 = KErrNone; |
|
255 TBool finished = EFalse; |
|
256 TUint8 byte1 = 0; |
|
257 TUint8 byte2 = 0; |
|
258 |
|
259 while (!finished) |
|
260 { |
|
261 TRAP(ret1, byte1 = stream1.ReadUint8L()); |
|
262 TRAP(ret2, byte2 = stream2.ReadUint8L()); |
|
263 |
|
264 if (byte1 != byte2 || ret1 == KErrEof || ret2 == KErrEof) |
|
265 { |
|
266 // Either file data or lengths differ. |
|
267 if ((byte1 != byte2) || (ret1 != ret2)) |
|
268 identical = EFalse; |
|
269 finished = ETrue; |
|
270 } |
|
271 } |
|
272 |
|
273 stream1.Close(); |
|
274 stream2.Close(); |
|
275 |
|
276 return identical; |
|
277 } |
|
278 |
|
279 TBool CSmutTest::TestStoreRestoreSettingsL(const CSmsSettings& aSettings) |
|
280 { |
|
281 StoreSettingsL(aSettings); |
|
282 |
|
283 // Lets read the service and see it the values are still ok |
|
284 CSmsSettings* set1=CSmsSettings::NewLC(); |
|
285 |
|
286 RestoreSettingsL(*set1); |
|
287 |
|
288 if(!CompareSettings(*set1, aSettings)) |
|
289 { |
|
290 CleanupStack::PopAndDestroy(set1); |
|
291 return EFalse; |
|
292 } |
|
293 |
|
294 CleanupStack::PopAndDestroy(set1); |
|
295 |
|
296 return ETrue; |
|
297 } |
|
298 |
|
299 TBool CSmutTest::TestSettingsMembersL(CSmsSettings& aSettings) |
|
300 { |
|
301 // Status Report Handling (what should be done to report messages) |
|
302 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisible); |
|
303 if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxInvisible) |
|
304 { |
|
305 return EFalse; |
|
306 } |
|
307 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
308 if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisible) |
|
309 { |
|
310 return EFalse; |
|
311 } |
|
312 aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReport); |
|
313 if(aSettings.StatusReportHandling()!=CSmsSettings::EDiscardReport) |
|
314 { |
|
315 return EFalse; |
|
316 } |
|
317 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
318 if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxInvisibleAndMatch) |
|
319 { |
|
320 return EFalse; |
|
321 } |
|
322 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
323 if(aSettings.StatusReportHandling()!=CSmsSettings::EMoveReportToInboxVisibleAndMatch) |
|
324 { |
|
325 return EFalse; |
|
326 } |
|
327 aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReportAndMatch); |
|
328 if(aSettings.StatusReportHandling()!=CSmsSettings::EDiscardReportAndMatch) |
|
329 { |
|
330 return EFalse; |
|
331 } |
|
332 iTestStep.INFO_PRINTF1(_L("Test Status Report Handling Passed")); |
|
333 |
|
334 // SC handling |
|
335 aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
336 aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
337 aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
338 aSettings.AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010")); |
|
339 aSettings.AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010")); |
|
340 if(aSettings.GetServiceCenter(0).Name()!=_L("Radiolinja0")) |
|
341 { |
|
342 return EFalse; |
|
343 } |
|
344 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-3); |
|
345 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-2); |
|
346 if(aSettings.GetServiceCenter(1).Name()!=_L("Radiolinja1")) |
|
347 { |
|
348 return EFalse; |
|
349 } |
|
350 if(aSettings.GetServiceCenter(2).Name()!=_L("Radiolinja4")) |
|
351 { |
|
352 return EFalse; |
|
353 } |
|
354 if(aSettings.GetServiceCenter(2).Address()!=_L("+358508771010")) |
|
355 { |
|
356 return EFalse; |
|
357 } |
|
358 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
359 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
360 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
361 // aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); // this would be -1 |
|
362 aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
363 aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
364 aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
365 aSettings.SetDefaultServiceCenter(1); |
|
366 if(aSettings.DefaultServiceCenter()!=1) |
|
367 { |
|
368 return EFalse; |
|
369 } |
|
370 aSettings.SetDefaultServiceCenter(2); |
|
371 if(aSettings.DefaultServiceCenter()!=2) |
|
372 { |
|
373 return EFalse; |
|
374 } |
|
375 iTestStep.INFO_PRINTF1(_L("Test Default SC Passed")); |
|
376 |
|
377 // Special Message Handling (what should be done to special messages) |
|
378 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisible); |
|
379 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxInvisible) |
|
380 { |
|
381 return EFalse; |
|
382 } |
|
383 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
384 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisible) |
|
385 { |
|
386 return EFalse; |
|
387 } |
|
388 aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReport); |
|
389 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EDiscardReport) |
|
390 { |
|
391 return EFalse; |
|
392 } |
|
393 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
394 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxInvisibleAndMatch) |
|
395 { |
|
396 return EFalse; |
|
397 } |
|
398 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
399 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EMoveReportToInboxVisibleAndMatch) |
|
400 { |
|
401 return EFalse; |
|
402 } |
|
403 aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReportAndMatch); |
|
404 if(aSettings.SpecialMessageHandling()!=CSmsSettings::EDiscardReportAndMatch) |
|
405 { |
|
406 return EFalse; |
|
407 } |
|
408 iTestStep.INFO_PRINTF1(_L("Test Special Message Handling Passed")); |
|
409 |
|
410 //CommDbAction |
|
411 aSettings.SetCommDbAction(CSmsSettings::ENone); |
|
412 if(aSettings.CommDbAction() != CSmsSettings::ENone) |
|
413 { |
|
414 return EFalse; |
|
415 } |
|
416 aSettings.SetCommDbAction(CSmsSettings::EStoreToCommDb); |
|
417 if(aSettings.CommDbAction() != CSmsSettings::EStoreToCommDb) |
|
418 { |
|
419 return EFalse; |
|
420 } |
|
421 iTestStep.INFO_PRINTF1(_L("Test CommDb Action Passed")); |
|
422 |
|
423 //SmsBearerAction |
|
424 aSettings.SetSmsBearerAction(CSmsSettings::ENone); |
|
425 if(aSettings.SmsBearerAction() != CSmsSettings::ENone) |
|
426 { |
|
427 return EFalse; |
|
428 } |
|
429 aSettings.SetSmsBearerAction(CSmsSettings::EStoreToCommDb); |
|
430 if(aSettings.SmsBearerAction() != CSmsSettings::EStoreToCommDb) |
|
431 { |
|
432 return EFalse; |
|
433 } |
|
434 iTestStep.INFO_PRINTF1(_L("Test SMS Bearer Action Passed")); |
|
435 |
|
436 //SmsBearer |
|
437 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
438 if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketOnly) |
|
439 { |
|
440 return EFalse; |
|
441 } |
|
442 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
443 if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketOnly) |
|
444 { |
|
445 return EFalse; |
|
446 } |
|
447 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly); |
|
448 if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerCircuitOnly) |
|
449 { |
|
450 return EFalse; |
|
451 } |
|
452 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketPreferred); |
|
453 if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerPacketPreferred) |
|
454 { |
|
455 return EFalse; |
|
456 } |
|
457 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred); |
|
458 if(aSettings.SmsBearer() != CSmsSettings::ESmsBearerCircuitPreferred) |
|
459 { |
|
460 return EFalse; |
|
461 } |
|
462 iTestStep.INFO_PRINTF1(_L("Test SMS Bearer Passed")); |
|
463 |
|
464 // Reply Quoted |
|
465 aSettings.SetReplyQuoted(EFalse); |
|
466 if(aSettings.ReplyQuoted()) |
|
467 { |
|
468 return EFalse; |
|
469 } |
|
470 aSettings.SetReplyQuoted(ETrue); |
|
471 if(!aSettings.ReplyQuoted()) |
|
472 { |
|
473 return EFalse; |
|
474 } |
|
475 iTestStep.INFO_PRINTF1(_L("Test Reply Quoted Passed")); |
|
476 |
|
477 // Delivery Method |
|
478 aSettings.SetDelivery(ESmsDeliveryUponRequest); |
|
479 if(aSettings.Delivery()!=ESmsDeliveryUponRequest) |
|
480 { |
|
481 return EFalse; |
|
482 } |
|
483 aSettings.SetDelivery(ESmsDeliveryScheduled); |
|
484 if(aSettings.Delivery()!=ESmsDeliveryScheduled) |
|
485 { |
|
486 return EFalse; |
|
487 } |
|
488 aSettings.SetDelivery(ESmsDeliveryImmediately); |
|
489 if(aSettings.Delivery()!=ESmsDeliveryImmediately) |
|
490 { |
|
491 return EFalse; |
|
492 } |
|
493 iTestStep.INFO_PRINTF1(_L("Test Delivery Passed")); |
|
494 |
|
495 // Class2Folder |
|
496 if(aSettings.Class2Folder() != KMsvGlobalInBoxIndexEntryId) |
|
497 { |
|
498 return EFalse; |
|
499 } |
|
500 aSettings.SetClass2Folder(1); |
|
501 if(aSettings.Class2Folder() != 1) |
|
502 { |
|
503 return EFalse; |
|
504 } |
|
505 iTestStep.INFO_PRINTF1(_L("Test Class2Folder Passed")); |
|
506 |
|
507 // Description length |
|
508 if(aSettings.DescriptionLength() != KSmsDescriptionLength) |
|
509 { |
|
510 return EFalse; |
|
511 } |
|
512 aSettings.SetDescriptionLength(100); |
|
513 if(aSettings.DescriptionLength() != 100) |
|
514 { |
|
515 return EFalse; |
|
516 } |
|
517 iTestStep.INFO_PRINTF1(_L("Test DescriptionLength Passed")); |
|
518 |
|
519 return ETrue; |
|
520 } |
|
521 |
|
522 TBool CSmutTest::TestMessageSettingsMembersL(CSmsMessageSettings& aSettings) |
|
523 { |
|
524 |
|
525 // Reject Duplicate |
|
526 aSettings.SetRejectDuplicate(ETrue); |
|
527 if(!aSettings.RejectDuplicate()) |
|
528 { |
|
529 return EFalse; |
|
530 } |
|
531 aSettings.SetRejectDuplicate(EFalse); |
|
532 if(aSettings.RejectDuplicate()) |
|
533 { |
|
534 return EFalse; |
|
535 } |
|
536 |
|
537 iTestStep.INFO_PRINTF1(_L("Test Reject Duplicate Passed")); |
|
538 |
|
539 // Delivery Report |
|
540 aSettings.SetDeliveryReport(ETrue); |
|
541 if(!aSettings.DeliveryReport()) |
|
542 { |
|
543 return EFalse; |
|
544 } |
|
545 aSettings.SetDeliveryReport(EFalse); |
|
546 if(aSettings.DeliveryReport()) |
|
547 { |
|
548 return EFalse; |
|
549 } |
|
550 iTestStep.INFO_PRINTF1(_L("Test Delivery Report Passed")); |
|
551 |
|
552 // Reply Path |
|
553 aSettings.SetReplyPath(EFalse); |
|
554 if(aSettings.ReplyPath()!=EFalse) |
|
555 { |
|
556 return EFalse; |
|
557 } |
|
558 aSettings.SetReplyPath(ETrue); |
|
559 if(!aSettings.ReplyPath()) |
|
560 { |
|
561 return EFalse; |
|
562 } |
|
563 iTestStep.INFO_PRINTF1(_L("Test Reply Path Passed")); |
|
564 |
|
565 // Validity period format |
|
566 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFNone); |
|
567 if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFNone) |
|
568 { |
|
569 return EFalse; |
|
570 } |
|
571 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFEnhanced); |
|
572 if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFEnhanced) |
|
573 { |
|
574 return EFalse; |
|
575 } |
|
576 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger); |
|
577 if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFInteger) |
|
578 { |
|
579 return EFalse; |
|
580 } |
|
581 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
582 if(aSettings.ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet) |
|
583 { |
|
584 return EFalse; |
|
585 } |
|
586 iTestStep.INFO_PRINTF1(_L("Test Validity Period Format Passed")); |
|
587 |
|
588 // Message Conversion (following conversions are supported) |
|
589 aSettings.SetMessageConversion(ESmsConvFax); |
|
590 if(aSettings.MessageConversion()!=ESmsConvFax) |
|
591 { |
|
592 return EFalse; |
|
593 } |
|
594 aSettings.SetMessageConversion(ESmsConvX400); |
|
595 if(aSettings.MessageConversion()!=ESmsConvX400) |
|
596 { |
|
597 return EFalse; |
|
598 } |
|
599 aSettings.SetMessageConversion(ESmsConvPaging); |
|
600 if(aSettings.MessageConversion()!=ESmsConvPaging) |
|
601 { |
|
602 return EFalse; |
|
603 } |
|
604 aSettings.SetMessageConversion(ESmsConvMail); |
|
605 if(aSettings.MessageConversion()!=ESmsConvMail) |
|
606 { |
|
607 return EFalse; |
|
608 } |
|
609 aSettings.SetMessageConversion(ESmsConvErmes); |
|
610 if(aSettings.MessageConversion()!=ESmsConvErmes) |
|
611 { |
|
612 return EFalse; |
|
613 } |
|
614 aSettings.SetMessageConversion(ESmsConvSpeech); |
|
615 if(aSettings.MessageConversion()!=ESmsConvSpeech) |
|
616 { |
|
617 return EFalse; |
|
618 } |
|
619 aSettings.SetMessageConversion(ESmsConvPIDNone); |
|
620 if(aSettings.MessageConversion()!=ESmsConvPIDNone) |
|
621 { |
|
622 return EFalse; |
|
623 } |
|
624 iTestStep.INFO_PRINTF1(_L("Test Message Conversion Passed")); |
|
625 |
|
626 // Validity Period |
|
627 aSettings.SetValidityPeriod(ESmsVPHour); |
|
628 if(aSettings.ValidityPeriod().Int()!=ESmsVPHour) |
|
629 { |
|
630 return EFalse; |
|
631 } |
|
632 aSettings.SetValidityPeriod(ESmsVPSixHours); |
|
633 if(aSettings.ValidityPeriod().Int()!=ESmsVPSixHours) |
|
634 { |
|
635 return EFalse; |
|
636 } |
|
637 aSettings.SetValidityPeriod(ESmsVP24Hours); |
|
638 if(aSettings.ValidityPeriod().Int()!=ESmsVP24Hours) |
|
639 { |
|
640 return EFalse; |
|
641 } |
|
642 aSettings.SetValidityPeriod(ESmsVPMaximum); |
|
643 if(aSettings.ValidityPeriod().Int()!=ESmsVPMaximum) |
|
644 { |
|
645 return EFalse; |
|
646 } |
|
647 aSettings.SetValidityPeriod(ESmsVPWeek); |
|
648 if(aSettings.ValidityPeriod().Int()!=ESmsVPWeek) |
|
649 { |
|
650 return EFalse; |
|
651 } |
|
652 iTestStep.INFO_PRINTF1(_L("Test Validity Period Passed")); |
|
653 |
|
654 // Can Concatenate (write messages with more than 160 characters) |
|
655 aSettings.SetCanConcatenate(ETrue); |
|
656 if(!aSettings.CanConcatenate()) |
|
657 { |
|
658 return EFalse; |
|
659 } |
|
660 aSettings.SetCanConcatenate(EFalse); |
|
661 if(aSettings.CanConcatenate()!=EFalse) |
|
662 { |
|
663 return EFalse; |
|
664 } |
|
665 iTestStep.INFO_PRINTF1(_L("Test Can Concatenate Passed")); |
|
666 |
|
667 // Character Set (following character sets are supported) |
|
668 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
669 if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
670 { |
|
671 return EFalse; |
|
672 } |
|
673 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
674 if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabetUCS2) |
|
675 { |
|
676 return EFalse; |
|
677 } |
|
678 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
679 if(aSettings.CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet8Bit) |
|
680 { |
|
681 return EFalse; |
|
682 } |
|
683 iTestStep.INFO_PRINTF1(_L("Test Character Set Passed")); |
|
684 |
|
685 return ETrue; |
|
686 } |
|
687 |
|
688 TBool CSmutTest::CompareSettings(const CSmsSettings& aLeft, const CSmsSettings& aRight, TBool aTestSC) |
|
689 { |
|
690 TCompare compare(CompareMessageSettings(aLeft, aRight)); |
|
691 |
|
692 compare(aLeft.CommDbAction() == aRight.CommDbAction()); |
|
693 compare(aLeft.SmsBearerAction() == aRight.SmsBearerAction()); |
|
694 compare(aLeft.SmsBearer() == aRight.SmsBearer()); |
|
695 compare(aLeft.Delivery() == aRight.Delivery()); |
|
696 compare(CompareBools(aLeft.ReplyQuoted(), aRight.ReplyQuoted())); |
|
697 compare(aLeft.SpecialMessageHandling() == aRight.SpecialMessageHandling()); |
|
698 compare(aLeft.StatusReportHandling() == aRight.StatusReportHandling()); |
|
699 |
|
700 if (aTestSC) |
|
701 { |
|
702 compare(aLeft.DefaultServiceCenter() == aRight.DefaultServiceCenter()); |
|
703 compare(aLeft.ServiceCenterCount() == aRight.ServiceCenterCount()); |
|
704 |
|
705 TInt count = aLeft.ServiceCenterCount(); |
|
706 |
|
707 while (count--) |
|
708 { |
|
709 compare(CompareServiceCenters(aLeft.GetServiceCenter(count), aRight.GetServiceCenter(count))); |
|
710 } |
|
711 } |
|
712 |
|
713 compare(aLeft.Class2Folder() == aRight.Class2Folder()); |
|
714 compare(aLeft.DescriptionLength() == aRight.DescriptionLength()); |
|
715 |
|
716 return compare; |
|
717 } |
|
718 |
|
719 TBool CSmutTest::CompareMessageSettings(const CSmsMessageSettings& aLeft, const CSmsMessageSettings& aRight) |
|
720 { |
|
721 TCompare compare(CompareBools(aLeft.CanConcatenate(), aRight.CanConcatenate())); |
|
722 compare(aLeft.CharacterSet() == aRight.CharacterSet()); |
|
723 compare(CompareBools(aLeft.DeliveryReport(), aRight.DeliveryReport())); |
|
724 compare(aLeft.MessageConversion() == aRight.MessageConversion()); |
|
725 compare(CompareBools(aLeft.RejectDuplicate(), aRight.RejectDuplicate())); |
|
726 compare(CompareBools(aLeft.ReplyPath(), aRight.ReplyPath())); |
|
727 compare(aLeft.ValidityPeriod() == aRight.ValidityPeriod()); |
|
728 compare(aLeft.ValidityPeriodFormat() == aRight.ValidityPeriodFormat()); |
|
729 return compare; |
|
730 } |
|
731 |
|
732 void CSmutTest::TestSettingsRestoreDefectL() |
|
733 { |
|
734 //Test fix for defects EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present) |
|
735 //and EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak) |
|
736 |
|
737 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
738 |
|
739 //Test defect fix for EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present) |
|
740 const TMsvId id = iSmsTest.CreateDummyMessageToSendL(); |
|
741 Session().CleanupEntryPushL(id); |
|
742 iSmsTest.SetEntryL(id); |
|
743 |
|
744 iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL Created dummy message")); |
|
745 |
|
746 TRAPD(err, RestoreSettingsL(*settings)); |
|
747 |
|
748 iTestStep.INFO_PRINTF2(_L("TestSettingsRestoreDefectL RestoreL 1 with error %d"), err); |
|
749 iTestStep.INFO_PRINTF2(_L("Expected %d"), KErrNotFound); |
|
750 iSmsTest(err == KErrNotFound); |
|
751 |
|
752 //Test defect fix for EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak) |
|
753 // iSmsTest.SetEntryL(id); |
|
754 StoreSettingsL(*settings); |
|
755 |
|
756 iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL StoreL 1")); |
|
757 |
|
758 settings->AddServiceCenterL(_L("Unknown"), _L("447785016005")); |
|
759 |
|
760 RestoreSettingsL(*settings); |
|
761 |
|
762 Session().CleanupEntryPop(); |
|
763 Session().RemoveEntry(id); |
|
764 |
|
765 CleanupStack::PopAndDestroy(settings); |
|
766 iTestStep.INFO_PRINTF1(_L("TestSettingsRestoreDefectL RestoreL 2")); |
|
767 } |
|
768 |
|
769 |
|
770 TBool CSmutTest::TestSettingsStoreToCommDbL() |
|
771 { |
|
772 iTestStep.INFO_PRINTF1(_L("Test Store Settings to CommDb")); |
|
773 |
|
774 CSmsSettings* settings1 = CSmsSettings::NewLC(); |
|
775 CSmsSettings* settings2 = CSmsSettings::NewLC(); |
|
776 |
|
777 if(!CompareSettings(*settings1, *settings2)) |
|
778 { |
|
779 CleanupStack::PopAndDestroy(2,settings1); |
|
780 return EFalse; |
|
781 } |
|
782 |
|
783 settings1->SetCommDbAction(CSmsSettings::EStoreToCommDb); |
|
784 settings1->AddServiceCenterL(_L("Vodafone"), _L("+447785016005")); |
|
785 settings1->SetDeliveryReport(ETrue); |
|
786 settings1->SetValidityPeriod(1000); |
|
787 |
|
788 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
789 |
|
790 StoreSettingsL(*settings1); |
|
791 iTestStep.INFO_PRINTF1(_L("\tNew Settings...")); |
|
792 if(!CompareSettingsAndCommDbL(*settings1)) |
|
793 { |
|
794 CleanupStack::PopAndDestroy(2,settings1); |
|
795 return EFalse; |
|
796 } |
|
797 |
|
798 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+3854354433")); |
|
799 |
|
800 StoreSettingsL(*settings1); |
|
801 iTestStep.INFO_PRINTF1(_L("\tSC Address Changed...")); |
|
802 if(!CompareSettingsAndCommDbL(*settings1)) |
|
803 { |
|
804 CleanupStack::PopAndDestroy(2,settings1); |
|
805 return EFalse; |
|
806 } |
|
807 |
|
808 settings1->SetDeliveryReport(EFalse); |
|
809 |
|
810 StoreSettingsL(*settings1); |
|
811 iTestStep.INFO_PRINTF1(_L("\tDelivery Report Changed...")); |
|
812 if(!CompareSettingsAndCommDbL(*settings1)) |
|
813 { |
|
814 CleanupStack::PopAndDestroy(2,settings1); |
|
815 return EFalse; |
|
816 } |
|
817 |
|
818 settings1->SetValidityPeriod(2000); |
|
819 |
|
820 StoreSettingsL(*settings1); |
|
821 iTestStep.INFO_PRINTF1(_L("\tValidity Period Changed...")); |
|
822 if(!CompareSettingsAndCommDbL(*settings1)) |
|
823 { |
|
824 CleanupStack::PopAndDestroy(2,settings1); |
|
825 return EFalse; |
|
826 } |
|
827 |
|
828 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+48996655888")); |
|
829 settings1->SetDeliveryReport(ETrue); |
|
830 settings1->SetValidityPeriod(3000); |
|
831 |
|
832 StoreSettingsL(*settings1); |
|
833 iTestStep.INFO_PRINTF1(_L("\tAll Settings Changed...")); |
|
834 if(!CompareSettingsAndCommDbL(*settings1)) |
|
835 { |
|
836 CleanupStack::PopAndDestroy(2,settings1); |
|
837 return EFalse; |
|
838 } |
|
839 |
|
840 settings1->AddServiceCenterL(_L("Radio"), _L("+385669988")); |
|
841 settings1->SetDefaultServiceCenter(settings1->ServiceCenterCount()-1); |
|
842 |
|
843 StoreSettingsL(*settings1); |
|
844 iTestStep.INFO_PRINTF1(_L("\tDefaultSC Changed...")); |
|
845 if(!CompareSettingsAndCommDbL(*settings1)) |
|
846 { |
|
847 CleanupStack::PopAndDestroy(2,settings1); |
|
848 return EFalse; |
|
849 } |
|
850 |
|
851 settings1->SetCommDbAction(CSmsSettings::ENone); |
|
852 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+123456789")); |
|
853 settings1->SetDeliveryReport(EFalse); |
|
854 settings1->SetValidityPeriod(4000); |
|
855 |
|
856 iTestStep.INFO_PRINTF1(_L("\tTesting Setting Different from CommDb...")); |
|
857 if(CompareSettingsAndCommDbL(*settings1)) |
|
858 { |
|
859 CleanupStack::PopAndDestroy(2,settings1); |
|
860 return EFalse; |
|
861 } |
|
862 |
|
863 TInt count = settings1->ServiceCenterCount(); |
|
864 |
|
865 while (count--) |
|
866 { |
|
867 settings1->RemoveServiceCenter(count); |
|
868 } |
|
869 |
|
870 iTestStep.INFO_PRINTF1(_L("\tTesting Setting Different from CommDb...")); |
|
871 if(CompareSettingsAndCommDbL(*settings1)) |
|
872 { |
|
873 CleanupStack::PopAndDestroy(2,settings1); |
|
874 return EFalse; |
|
875 } |
|
876 |
|
877 iTestStep.INFO_PRINTF1(_L("\tRestore settings from store...")); |
|
878 RestoreSettingsL(*settings2); |
|
879 if(!CompareSettingsAndCommDbL(*settings2)) |
|
880 { |
|
881 CleanupStack::PopAndDestroy(2,settings1); |
|
882 return EFalse; |
|
883 } |
|
884 |
|
885 //Test SMS Bearer |
|
886 |
|
887 iTestStep.INFO_PRINTF1(_L("\tTest Store SMS Bearer...")); |
|
888 |
|
889 //Test 1 |
|
890 |
|
891 settings1->SetSmsBearerAction(CSmsSettings::EStoreToCommDb); |
|
892 settings1->SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
893 |
|
894 StoreSettingsL(*settings1); |
|
895 if(!CompareSettingsAndSmsBearerL(*settings1)) |
|
896 { |
|
897 CleanupStack::PopAndDestroy(2,settings1); |
|
898 return EFalse; |
|
899 } |
|
900 |
|
901 //Test 2 |
|
902 |
|
903 settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly); |
|
904 if(CompareSettingsAndSmsBearerL(*settings1)) |
|
905 { |
|
906 CleanupStack::PopAndDestroy(2,settings1); |
|
907 return EFalse; |
|
908 } |
|
909 |
|
910 //Test 3 |
|
911 |
|
912 StoreSettingsL(*settings1); |
|
913 if(!CompareSettingsAndSmsBearerL(*settings1)) |
|
914 { |
|
915 CleanupStack::PopAndDestroy(2,settings1); |
|
916 return EFalse; |
|
917 } |
|
918 |
|
919 RestoreSettingsL(*settings2); |
|
920 if(!CompareSettingsAndSmsBearerL(*settings2)) |
|
921 { |
|
922 return EFalse; |
|
923 } |
|
924 |
|
925 //Test 4 |
|
926 |
|
927 settings1->SetSmsBearerAction(CSmsSettings::ENone); |
|
928 StoreSettingsL(*settings1); |
|
929 if(!CompareSettingsAndSmsBearerL(*settings1)) |
|
930 { |
|
931 CleanupStack::PopAndDestroy(2,settings1); |
|
932 return EFalse; |
|
933 } |
|
934 |
|
935 //Test 5 |
|
936 |
|
937 settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred); |
|
938 if(CompareSettingsAndSmsBearerL(*settings1)) |
|
939 { |
|
940 CleanupStack::PopAndDestroy(2,settings1); |
|
941 return EFalse; |
|
942 } |
|
943 StoreSettingsL(*settings1); |
|
944 if(CompareSettingsAndSmsBearerL(*settings1)) |
|
945 { |
|
946 CleanupStack::PopAndDestroy(2,settings1); |
|
947 return EFalse; |
|
948 } |
|
949 |
|
950 CleanupStack::PopAndDestroy(2,settings1); // settings2 |
|
951 |
|
952 return ETrue; |
|
953 } |
|
954 |
|
955 TBool CSmutTest::CompareSettingsAndCommDbL(const CSmsSettings& aSettings) const |
|
956 { |
|
957 TCompare compare = ETrue; |
|
958 TBuf<256> scAddress; |
|
959 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
960 globalSettingsRecord.LoadL(*iDBSession); |
|
961 CCDModemBearerRecord *modemBearerRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
962 CleanupStack::PushL(modemBearerRecord); |
|
963 modemBearerRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS); |
|
964 modemBearerRecord->LoadL(*iDBSession); |
|
965 scAddress = modemBearerRecord->iMessageCentreNumber; |
|
966 |
|
967 if (aSettings.DefaultServiceCenter() < 0 || !aSettings.ServiceCenterCount()) |
|
968 { |
|
969 compare(!scAddress.Length()); |
|
970 } |
|
971 else |
|
972 { |
|
973 compare(scAddress == aSettings.GetServiceCenter(aSettings.DefaultServiceCenter()).Address()); |
|
974 } |
|
975 |
|
976 TUint32 valPeriod = 0; |
|
977 valPeriod = modemBearerRecord->iMessageValidityPeriod; |
|
978 compare(valPeriod == (TUint32) aSettings.ValidityPeriod().Int()); |
|
979 |
|
980 TBool delReport = EFalse; |
|
981 delReport = modemBearerRecord->iMessageDeliveryReport; |
|
982 compare(delReport ? aSettings.DeliveryReport() : !aSettings.DeliveryReport()); |
|
983 |
|
984 CleanupStack::PopAndDestroy(modemBearerRecord); |
|
985 |
|
986 return compare; |
|
987 } |
|
988 |
|
989 TBool CSmutTest::CompareSettingsAndSmsBearerL(const CSmsSettings& aSettings) const |
|
990 { |
|
991 TUint32 smsBearer=0; |
|
992 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
993 TRAPD(err, globalSettingsRecord.LoadL(*iDBSession)); |
|
994 if(err == KErrNone) |
|
995 { |
|
996 smsBearer = ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer; |
|
997 } |
|
998 TCompare compare(smsBearer == (TUint32) aSettings.SmsBearer()); |
|
999 return compare; |
|
1000 } |
|
1001 |
|
1002 void CSmutTest::StoreNumberL(const CSmsNumber& aNumber, TUid aStreamId) |
|
1003 { |
|
1004 CMsvStore* store = iSmsTest.EditStoreL(); // lets edit the entry |
|
1005 CleanupStack::PushL(store); |
|
1006 |
|
1007 RMsvWriteStream out; |
|
1008 out.AssignLC(*store, aStreamId); // file stream id ok? |
|
1009 aNumber.ExternalizeL(out); // lets extrenalise the instance |
|
1010 out.CommitL(); |
|
1011 store->CommitL(); |
|
1012 |
|
1013 CleanupStack::PopAndDestroy(2, store); |
|
1014 } |
|
1015 |
|
1016 void CSmutTest::RestoreNumberL(CSmsNumber& rNumber, TUid aStreamId) |
|
1017 { |
|
1018 CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading |
|
1019 CleanupStack::PushL(store); |
|
1020 |
|
1021 RMsvReadStream in; |
|
1022 in.OpenLC(*store, aStreamId); // lets open the store for |
|
1023 rNumber.InternalizeL(in); // internalising the address/name |
|
1024 |
|
1025 CleanupStack::PopAndDestroy(2, store); |
|
1026 } |
|
1027 |
|
1028 void CSmutTest::StoreHeaderL(const CSmsHeader& aHeader) |
|
1029 { |
|
1030 CMsvStore* store = iSmsTest.EditStoreL(); |
|
1031 CleanupStack::PushL(store); |
|
1032 |
|
1033 aHeader.StoreL(*store); |
|
1034 store->CommitL(); |
|
1035 |
|
1036 CleanupStack::PopAndDestroy(store); |
|
1037 } |
|
1038 |
|
1039 void CSmutTest::RestoreHeaderL(CSmsHeader& aHeader) |
|
1040 { |
|
1041 CMsvStore* store = iSmsTest.ReadStoreL(); |
|
1042 CleanupStack::PushL(store); |
|
1043 |
|
1044 aHeader.RestoreL(*store); |
|
1045 |
|
1046 CleanupStack::PopAndDestroy(store); |
|
1047 } |
|
1048 |
|
1049 void CSmutTest::StoreSettingsL(const CSmsSettings& aSettings) |
|
1050 { |
|
1051 CSmsAccount* account = CSmsAccount::NewLC(); |
|
1052 account->SaveSettingsL(aSettings); |
|
1053 CleanupStack::PopAndDestroy(account); |
|
1054 } |
|
1055 |
|
1056 void CSmutTest::RestoreSettingsL(CSmsSettings& aSettings) |
|
1057 { |
|
1058 CSmsAccount* account = CSmsAccount::NewLC(); |
|
1059 account->LoadSettingsL(aSettings); |
|
1060 CleanupStack::PopAndDestroy(account); |
|
1061 } |
|
1062 |
|
1063 TBool CSmutTest::CompareServiceCenters(const CSmsServiceCenter& aLeft, const CSmsServiceCenter& aRight) |
|
1064 { |
|
1065 TCompare compare(aLeft.Name() == aRight.Name()); |
|
1066 compare(aLeft.Address() == aRight.Address()); |
|
1067 return compare; |
|
1068 } |
|
1069 |
|
1070 TBool CSmutTest::CompareNumbers(const CSmsNumber& aLeft, const CSmsNumber& aRight) |
|
1071 { |
|
1072 TCompare compare(aLeft.Name() == aRight.Name()); |
|
1073 compare(aLeft.Address() == aRight.Address()); |
|
1074 compare(aLeft.LogId() == aRight.LogId()); |
|
1075 compare(aLeft.AckStatus(ESmsAckTypeDelivery) == aRight.AckStatus(ESmsAckTypeDelivery)); |
|
1076 return compare; |
|
1077 } |
|
1078 |
|
1079 TVerdict CSmutTest::TestNumberL() |
|
1080 { |
|
1081 iTestStep.INFO_PRINTF1(_L("Testing Preparing test CSmsNumber...")); |
|
1082 |
|
1083 TMsvId id=iSmsTest.CreateDummyMessageToSendL(); |
|
1084 Session().CleanupEntryPushL(id); |
|
1085 iSmsTest.SetEntryL(id); |
|
1086 |
|
1087 CSmsNumber* number0=CSmsNumber::NewL(); |
|
1088 CleanupStack::PushL(number0); |
|
1089 |
|
1090 CSmsNumber* number=CSmsNumber::NewL(); // create the instance |
|
1091 CleanupStack::PushL(number); |
|
1092 |
|
1093 // Testing the features of CSmsNumber |
|
1094 // The max length for a name is 256 characters |
|
1095 // The max length for a number is 20 characters |
|
1096 |
|
1097 // Lets take an ordinary number, test it, then store and restore it |
|
1098 // and see if the values are still ok. |
|
1099 |
|
1100 number->SetNameL(_L("Radiolinja1")); |
|
1101 number->SetAddressL(_L("+358508771010")); |
|
1102 number->SetLogId(KLogID1); |
|
1103 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
1104 |
|
1105 if(number->Name()!=_L("Radiolinja1")) // name ok? |
|
1106 { |
|
1107 CleanupStack::PopAndDestroy(2, number0); |
|
1108 Session().CleanupEntryPop(); |
|
1109 Session().RemoveEntry(id); |
|
1110 return EFail; |
|
1111 } |
|
1112 if(number->Address()!=_L("+358508771010")) // number ok? |
|
1113 { |
|
1114 CleanupStack::PopAndDestroy(2, number0); |
|
1115 Session().CleanupEntryPop(); |
|
1116 Session().RemoveEntry(id); |
|
1117 return EFail; |
|
1118 } |
|
1119 if(number->LogId() != KLogID1) |
|
1120 { |
|
1121 CleanupStack::PopAndDestroy(2, number0); |
|
1122 Session().CleanupEntryPop(); |
|
1123 Session().RemoveEntry(id); |
|
1124 return EFail; |
|
1125 } |
|
1126 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful) |
|
1127 { |
|
1128 CleanupStack::PopAndDestroy(2, number0); |
|
1129 Session().CleanupEntryPop(); |
|
1130 Session().RemoveEntry(id); |
|
1131 return EFail; |
|
1132 } |
|
1133 |
|
1134 StoreNumberL(*number); |
|
1135 RestoreNumberL(*number0); |
|
1136 if(!CompareNumbers(*number0, *number)) |
|
1137 { |
|
1138 CleanupStack::PopAndDestroy(2, number0); |
|
1139 Session().CleanupEntryPop(); |
|
1140 Session().RemoveEntry(id); |
|
1141 return EFail; |
|
1142 } |
|
1143 |
|
1144 // Lets try the max length of the telephone address, store and |
|
1145 // restore it and see if it works |
|
1146 |
|
1147 number->SetNameL(_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?")); |
|
1148 number->SetAddressL(_L("+0123456789012345678")); |
|
1149 number->SetLogId(KLogID2); |
|
1150 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError); |
|
1151 |
|
1152 if(number->Name()!=_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?")) |
|
1153 { |
|
1154 CleanupStack::PopAndDestroy(2, number0); |
|
1155 Session().CleanupEntryPop(); |
|
1156 Session().RemoveEntry(id); |
|
1157 return EFail; |
|
1158 } |
|
1159 if(number->Address()!=_L("+0123456789012345678")) |
|
1160 { |
|
1161 CleanupStack::PopAndDestroy(2, number0); |
|
1162 Session().CleanupEntryPop(); |
|
1163 Session().RemoveEntry(id); |
|
1164 return EFail; |
|
1165 } |
|
1166 if(number->LogId() != KLogID2) |
|
1167 { |
|
1168 CleanupStack::PopAndDestroy(2, number0); |
|
1169 Session().CleanupEntryPop(); |
|
1170 Session().RemoveEntry(id); |
|
1171 return EFail; |
|
1172 } |
|
1173 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckError) |
|
1174 { |
|
1175 CleanupStack::PopAndDestroy(2, number0); |
|
1176 Session().CleanupEntryPop(); |
|
1177 Session().RemoveEntry(id); |
|
1178 return EFail; |
|
1179 } |
|
1180 |
|
1181 StoreNumberL(*number); |
|
1182 RestoreNumberL(*number0); |
|
1183 if(!CompareNumbers(*number, *number0)) |
|
1184 { |
|
1185 CleanupStack::PopAndDestroy(2, number0); |
|
1186 Session().CleanupEntryPop(); |
|
1187 Session().RemoveEntry(id); |
|
1188 return EFail; |
|
1189 } |
|
1190 // Lets use special Scandinavian letters both in the name and |
|
1191 // address, store and restore and see if they are ok |
|
1192 number->SetNameL(_L("ÖÄÅåöä")); |
|
1193 number->SetAddressL(_L("åäöÅÄÖ")); |
|
1194 number->SetLogId(KLogID1); |
|
1195 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
1196 |
|
1197 if(number->Name()!=_L("ÖÄÅåöä")) |
|
1198 { |
|
1199 CleanupStack::PopAndDestroy(2, number0); |
|
1200 Session().CleanupEntryPop(); |
|
1201 Session().RemoveEntry(id); |
|
1202 return EFail; |
|
1203 } |
|
1204 if(number->Address()!=_L("åäöÅÄÖ")) |
|
1205 { |
|
1206 CleanupStack::PopAndDestroy(2, number0); |
|
1207 Session().CleanupEntryPop(); |
|
1208 Session().RemoveEntry(id); |
|
1209 return EFail; |
|
1210 } |
|
1211 if(number->LogId() != KLogID1) |
|
1212 { |
|
1213 CleanupStack::PopAndDestroy(2, number0); |
|
1214 Session().CleanupEntryPop(); |
|
1215 Session().RemoveEntry(id); |
|
1216 return EFail; |
|
1217 } |
|
1218 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful) |
|
1219 { |
|
1220 CleanupStack::PopAndDestroy(2, number0); |
|
1221 Session().CleanupEntryPop(); |
|
1222 Session().RemoveEntry(id); |
|
1223 return EFail; |
|
1224 } |
|
1225 |
|
1226 StoreNumberL(*number); |
|
1227 RestoreNumberL(*number0); |
|
1228 iSmsTest(CompareNumbers(*number, *number0)); |
|
1229 |
|
1230 // Lets try if both the number and the name can be empty, |
|
1231 // store and restore it and see if they still match |
|
1232 number->SetNameL(_L("")); |
|
1233 number->SetAddressL(_L("")); |
|
1234 number->SetLogId(KLogID2); |
|
1235 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError); |
|
1236 |
|
1237 if(number->Name()!=_L("")) |
|
1238 { |
|
1239 CleanupStack::PopAndDestroy(2, number0); |
|
1240 Session().CleanupEntryPop(); |
|
1241 Session().RemoveEntry(id); |
|
1242 return EFail; |
|
1243 } |
|
1244 if(number->Address()!=_L("")) |
|
1245 { |
|
1246 CleanupStack::PopAndDestroy(2, number0); |
|
1247 Session().CleanupEntryPop(); |
|
1248 Session().RemoveEntry(id); |
|
1249 return EFail; |
|
1250 } |
|
1251 if(number->LogId() != KLogID2) |
|
1252 { |
|
1253 CleanupStack::PopAndDestroy(2, number0); |
|
1254 Session().CleanupEntryPop(); |
|
1255 Session().RemoveEntry(id); |
|
1256 return EFail; |
|
1257 } |
|
1258 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckError) |
|
1259 { |
|
1260 CleanupStack::PopAndDestroy(2, number0); |
|
1261 Session().CleanupEntryPop(); |
|
1262 Session().RemoveEntry(id); |
|
1263 return EFail; |
|
1264 } |
|
1265 |
|
1266 StoreNumberL(*number); |
|
1267 RestoreNumberL(*number0); |
|
1268 if(!CompareNumbers(*number, *number0)) |
|
1269 { |
|
1270 CleanupStack::PopAndDestroy(2, number0); |
|
1271 Session().CleanupEntryPop(); |
|
1272 Session().RemoveEntry(id); |
|
1273 return EFail; |
|
1274 } |
|
1275 |
|
1276 // Lets try [alt+255] as both the name and number, store and |
|
1277 // restore it and see if it works |
|
1278 number->SetNameL(_L(" ")); //alt+255 |
|
1279 number->SetAddressL(_L(" ")); |
|
1280 number->SetLogId(KLogID1); |
|
1281 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
1282 |
|
1283 if(number->Name()!=_L(" ")) |
|
1284 { |
|
1285 CleanupStack::PopAndDestroy(2, number0); |
|
1286 Session().CleanupEntryPop(); |
|
1287 Session().RemoveEntry(id); |
|
1288 return EFail; |
|
1289 } |
|
1290 if(number->Address()!=_L(" ")) |
|
1291 { |
|
1292 CleanupStack::PopAndDestroy(2, number0); |
|
1293 Session().CleanupEntryPop(); |
|
1294 Session().RemoveEntry(id); |
|
1295 return EFail; |
|
1296 } |
|
1297 if(number->LogId() != KLogID1) |
|
1298 { |
|
1299 CleanupStack::PopAndDestroy(2, number0); |
|
1300 Session().CleanupEntryPop(); |
|
1301 Session().RemoveEntry(id); |
|
1302 return EFail; |
|
1303 } |
|
1304 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EAckSuccessful) |
|
1305 { |
|
1306 CleanupStack::PopAndDestroy(2, number0); |
|
1307 Session().CleanupEntryPop(); |
|
1308 Session().RemoveEntry(id); |
|
1309 return EFail; |
|
1310 } |
|
1311 |
|
1312 StoreNumberL(*number); |
|
1313 RestoreNumberL(*number0); |
|
1314 iSmsTest(CompareNumbers(*number, *number0)); |
|
1315 |
|
1316 // Test CSmsNumber::CopyL() |
|
1317 |
|
1318 number->SetNameL(_L("DavidCuando")); |
|
1319 number->SetAddressL(_L("+447747065627")); |
|
1320 number->SetLogId(KLogID3); |
|
1321 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck); |
|
1322 |
|
1323 if(number->Name()!=_L("DavidCuando")) |
|
1324 { |
|
1325 CleanupStack::PopAndDestroy(2, number0); |
|
1326 Session().CleanupEntryPop(); |
|
1327 Session().RemoveEntry(id); |
|
1328 return EFail; |
|
1329 } |
|
1330 if(number->Address()!=_L("+447747065627")) |
|
1331 { |
|
1332 CleanupStack::PopAndDestroy(2, number0); |
|
1333 Session().CleanupEntryPop(); |
|
1334 Session().RemoveEntry(id); |
|
1335 return EFail; |
|
1336 } |
|
1337 if(number->LogId() != KLogID3) |
|
1338 { |
|
1339 CleanupStack::PopAndDestroy(2, number0); |
|
1340 Session().CleanupEntryPop(); |
|
1341 Session().RemoveEntry(id); |
|
1342 return EFail; |
|
1343 } |
|
1344 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EPendingAck) |
|
1345 { |
|
1346 CleanupStack::PopAndDestroy(2, number0); |
|
1347 Session().CleanupEntryPop(); |
|
1348 Session().RemoveEntry(id); |
|
1349 return EFail; |
|
1350 } |
|
1351 |
|
1352 number0->CopyL(*number); |
|
1353 if(!CompareNumbers(*number0, *number)) |
|
1354 { |
|
1355 CleanupStack::PopAndDestroy(2, number0); |
|
1356 Session().CleanupEntryPop(); |
|
1357 Session().RemoveEntry(id); |
|
1358 return EFail; |
|
1359 } |
|
1360 |
|
1361 CleanupStack::PopAndDestroy(2, number0); |
|
1362 |
|
1363 // Test NewL(CSmsNumber&) |
|
1364 |
|
1365 number=CSmsNumber::NewL(); // create the instance |
|
1366 CleanupStack::PushL(number); |
|
1367 |
|
1368 number->SetNameL(_L("DavidCuando")); |
|
1369 number->SetAddressL(_L("+447747065627")); |
|
1370 number->SetLogId(KLogID3); |
|
1371 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck); |
|
1372 |
|
1373 if(number->Name()!=_L("DavidCuando")) |
|
1374 { |
|
1375 CleanupStack::PopAndDestroy(number); |
|
1376 Session().CleanupEntryPop(); |
|
1377 Session().RemoveEntry(id); |
|
1378 return EFail; |
|
1379 } |
|
1380 if(number->Address()!=_L("+447747065627")) |
|
1381 { |
|
1382 CleanupStack::PopAndDestroy(number); |
|
1383 Session().CleanupEntryPop(); |
|
1384 Session().RemoveEntry(id); |
|
1385 return EFail; |
|
1386 } |
|
1387 if(number->LogId() != KLogID3) |
|
1388 { |
|
1389 CleanupStack::PopAndDestroy(number); |
|
1390 Session().CleanupEntryPop(); |
|
1391 Session().RemoveEntry(id); |
|
1392 return EFail; |
|
1393 } |
|
1394 if(number->AckStatus(ESmsAckTypeDelivery) != CSmsNumber::EPendingAck) |
|
1395 { |
|
1396 CleanupStack::PopAndDestroy(number); |
|
1397 Session().CleanupEntryPop(); |
|
1398 Session().RemoveEntry(id); |
|
1399 return EFail; |
|
1400 } |
|
1401 |
|
1402 number0=CSmsNumber::NewL(*number); |
|
1403 CleanupStack::PushL(number0); |
|
1404 |
|
1405 if(!CompareNumbers(*number0, *number)) |
|
1406 { |
|
1407 CleanupStack::PopAndDestroy(2, number); |
|
1408 Session().CleanupEntryPop(); |
|
1409 Session().RemoveEntry(id); |
|
1410 return EFail; |
|
1411 } |
|
1412 CleanupStack::PopAndDestroy(2, number); |
|
1413 |
|
1414 //Test for defect EDNMOHN-4LDDK8 |
|
1415 number=CSmsNumber::NewL(); // create the instance |
|
1416 CleanupStack::PushL(number); |
|
1417 |
|
1418 StoreNumberL(*number); |
|
1419 RestoreNumberL(*number); |
|
1420 |
|
1421 number->SetAddressL(_L("+4477676545")); |
|
1422 //End Test for defect EDNMOHN-4LDDK8 |
|
1423 |
|
1424 CleanupStack::PopAndDestroy(number); |
|
1425 |
|
1426 Session().CleanupEntryPop(); |
|
1427 Session().RemoveEntry(id); |
|
1428 |
|
1429 iTestStep.INFO_PRINTF1(_L("Test CSmsNumber Passed.")); |
|
1430 return EPass; |
|
1431 } |
|
1432 |
|
1433 void CSmutTest::StoreEmailFieldsL(const CSmsEmailFields& aEmailFields) |
|
1434 { |
|
1435 CMsvStore* store = iSmsTest.EditStoreL(); |
|
1436 CleanupStack::PushL(store); |
|
1437 |
|
1438 aEmailFields.StoreL(*store); |
|
1439 store->CommitL(); |
|
1440 |
|
1441 CleanupStack::PopAndDestroy(store); |
|
1442 } |
|
1443 |
|
1444 void CSmutTest::RestoreEmailFieldsL(CSmsEmailFields& aEmailFields) |
|
1445 { |
|
1446 CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading |
|
1447 CleanupStack::PushL(store); |
|
1448 |
|
1449 aEmailFields.RestoreL(*store); |
|
1450 |
|
1451 CleanupStack::PopAndDestroy(store); |
|
1452 } |
|
1453 |
|
1454 TBool CSmutTest::CompareEmailFields(const CSmsEmailFields& aFields1, const CSmsEmailFields& aFields2) |
|
1455 { |
|
1456 TBool same = CompareEmailFieldsAddresses(aFields1.Addresses(), aFields2.Addresses()); |
|
1457 if( same ) |
|
1458 same = (aFields2.Subject().Compare(aFields1.Subject()) == 0); |
|
1459 if( same ) |
|
1460 same = (!aFields2.HasAddress()&&!aFields1.HasAddress() || aFields2.HasAddress()&&aFields1.HasAddress()); |
|
1461 if( same ) |
|
1462 same = (aFields2.Length() == aFields1.Length()); |
|
1463 return same; |
|
1464 } |
|
1465 |
|
1466 TBool CSmutTest::CompareEmailFieldsAddresses(const MDesCArray& aAddresses1, const MDesCArray& aAddresses2) |
|
1467 { |
|
1468 TBool same = (aAddresses1.MdcaCount() == aAddresses2.MdcaCount()); |
|
1469 if( same ) |
|
1470 { |
|
1471 TInt count = aAddresses1.MdcaCount(); |
|
1472 while( same && count-- > 0) |
|
1473 { |
|
1474 same = (aAddresses2.MdcaPoint(count).Compare(aAddresses1.MdcaPoint(count)) == 0); |
|
1475 } |
|
1476 } |
|
1477 return same; |
|
1478 } |
|
1479 |
|
1480 TVerdict CSmutTest::TestEmailFieldsL() |
|
1481 { |
|
1482 iTestStep.INFO_PRINTF1(_L("Preparing test CSmsEmailFields...")); |
|
1483 |
|
1484 TMsvId id=iSmsTest.CreateDummyMessageToSendL(); |
|
1485 Session().CleanupEntryPushL(id); |
|
1486 iSmsTest.SetEntryL(id); |
|
1487 |
|
1488 _LIT(KTestAddress, "support@symbian.com"); |
|
1489 _LIT(KTestSubject, "Happy Days!"); |
|
1490 |
|
1491 // Test CSmsEmailFields::NewL() |
|
1492 CSmsEmailFields* fields1 = CSmsEmailFields::NewL(); |
|
1493 CleanupStack::PushL(fields1); |
|
1494 |
|
1495 if(fields1->Addresses().MdcaCount()!=0) |
|
1496 { |
|
1497 CleanupStack::PopAndDestroy(fields1); |
|
1498 Session().CleanupEntryPop(); |
|
1499 Session().RemoveEntry(id); |
|
1500 return EFail; |
|
1501 } |
|
1502 if(fields1->Subject().Compare(KNullDesC()) != 0) |
|
1503 { |
|
1504 CleanupStack::PopAndDestroy(fields1); |
|
1505 Session().CleanupEntryPop(); |
|
1506 Session().RemoveEntry(id); |
|
1507 return EFail; |
|
1508 } |
|
1509 if(fields1->HasAddress()) |
|
1510 { |
|
1511 CleanupStack::PopAndDestroy(fields1); |
|
1512 Session().CleanupEntryPop(); |
|
1513 Session().RemoveEntry(id); |
|
1514 return EFail; |
|
1515 } |
|
1516 if(fields1->Length() != 0) |
|
1517 { |
|
1518 CleanupStack::PopAndDestroy(fields1); |
|
1519 Session().CleanupEntryPop(); |
|
1520 Session().RemoveEntry(id); |
|
1521 return EFail; |
|
1522 } |
|
1523 |
|
1524 // Test address and subject accessors, has-address, length and reset methods |
|
1525 fields1->AddAddressL(KNullDesC); // empty address - does nothing! |
|
1526 if(fields1->Addresses().MdcaCount()!=0) |
|
1527 { |
|
1528 CleanupStack::PopAndDestroy(fields1); |
|
1529 Session().CleanupEntryPop(); |
|
1530 Session().RemoveEntry(id); |
|
1531 return EFail; |
|
1532 } |
|
1533 if(fields1->Subject().Compare(KNullDesC()) != 0) |
|
1534 { |
|
1535 CleanupStack::PopAndDestroy(fields1); |
|
1536 Session().CleanupEntryPop(); |
|
1537 Session().RemoveEntry(id); |
|
1538 return EFail; |
|
1539 } |
|
1540 if(fields1->HasAddress()) |
|
1541 { |
|
1542 CleanupStack::PopAndDestroy(fields1); |
|
1543 Session().CleanupEntryPop(); |
|
1544 Session().RemoveEntry(id); |
|
1545 return EFail; |
|
1546 } |
|
1547 if(fields1->Length() != 0) |
|
1548 { |
|
1549 CleanupStack::PopAndDestroy(fields1); |
|
1550 Session().CleanupEntryPop(); |
|
1551 Session().RemoveEntry(id); |
|
1552 return EFail; |
|
1553 } |
|
1554 |
|
1555 fields1->AddAddressL(KTestAddress); |
|
1556 if(fields1->Addresses().MdcaCount()!=1) |
|
1557 { |
|
1558 CleanupStack::PopAndDestroy(fields1); |
|
1559 Session().CleanupEntryPop(); |
|
1560 Session().RemoveEntry(id); |
|
1561 return EFail; |
|
1562 } |
|
1563 if(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) != 0) |
|
1564 { |
|
1565 CleanupStack::PopAndDestroy(fields1); |
|
1566 Session().CleanupEntryPop(); |
|
1567 Session().RemoveEntry(id); |
|
1568 return EFail; |
|
1569 } |
|
1570 if(!fields1->HasAddress()) |
|
1571 { |
|
1572 CleanupStack::PopAndDestroy(fields1); |
|
1573 Session().CleanupEntryPop(); |
|
1574 Session().RemoveEntry(id); |
|
1575 return EFail; |
|
1576 } |
|
1577 if(fields1->Length() != KTestAddress().Length() + 1) |
|
1578 { |
|
1579 CleanupStack::PopAndDestroy(fields1); |
|
1580 Session().CleanupEntryPop(); |
|
1581 Session().RemoveEntry(id); |
|
1582 return EFail; |
|
1583 } |
|
1584 |
|
1585 fields1->SetSubjectL(KTestSubject); |
|
1586 if(!fields1->HasAddress()) |
|
1587 { |
|
1588 CleanupStack::PopAndDestroy(fields1); |
|
1589 Session().CleanupEntryPop(); |
|
1590 Session().RemoveEntry(id); |
|
1591 return EFail; |
|
1592 } |
|
1593 if(fields1->Length() != KTestAddress().Length() + KTestSubject().Length() + 2) |
|
1594 { |
|
1595 CleanupStack::PopAndDestroy(fields1); |
|
1596 Session().CleanupEntryPop(); |
|
1597 Session().RemoveEntry(id); |
|
1598 return EFail; |
|
1599 } |
|
1600 |
|
1601 fields1->Reset(); |
|
1602 if(fields1->Addresses().MdcaCount()!=0) |
|
1603 { |
|
1604 CleanupStack::PopAndDestroy(fields1); |
|
1605 Session().CleanupEntryPop(); |
|
1606 Session().RemoveEntry(id); |
|
1607 return EFail; |
|
1608 } |
|
1609 if(fields1->Subject().Compare(KNullDesC()) != 0) |
|
1610 { |
|
1611 CleanupStack::PopAndDestroy(fields1); |
|
1612 Session().CleanupEntryPop(); |
|
1613 Session().RemoveEntry(id); |
|
1614 return EFail; |
|
1615 } |
|
1616 if(fields1->HasAddress()) |
|
1617 { |
|
1618 CleanupStack::PopAndDestroy(fields1); |
|
1619 Session().CleanupEntryPop(); |
|
1620 Session().RemoveEntry(id); |
|
1621 return EFail; |
|
1622 } |
|
1623 if(fields1->Length() != 0) |
|
1624 { |
|
1625 CleanupStack::PopAndDestroy(fields1); |
|
1626 Session().CleanupEntryPop(); |
|
1627 Session().RemoveEntry(id); |
|
1628 return EFail; |
|
1629 } |
|
1630 |
|
1631 fields1->SetSubjectL(KTestSubject); |
|
1632 if(fields1->Subject().Compare(KTestSubject) != 0) |
|
1633 { |
|
1634 CleanupStack::PopAndDestroy(fields1); |
|
1635 Session().CleanupEntryPop(); |
|
1636 Session().RemoveEntry(id); |
|
1637 return EFail; |
|
1638 } |
|
1639 if(fields1->HasAddress()) |
|
1640 { |
|
1641 CleanupStack::PopAndDestroy(fields1); |
|
1642 Session().CleanupEntryPop(); |
|
1643 Session().RemoveEntry(id); |
|
1644 return EFail; |
|
1645 } |
|
1646 if(fields1->Length() != KTestSubject().Length() + 2) |
|
1647 { |
|
1648 CleanupStack::PopAndDestroy(fields1); |
|
1649 Session().CleanupEntryPop(); |
|
1650 Session().RemoveEntry(id); |
|
1651 return EFail; |
|
1652 } |
|
1653 |
|
1654 fields1->AddAddressL(KTestAddress); |
|
1655 if(fields1->Addresses().MdcaCount()!=1) |
|
1656 { |
|
1657 CleanupStack::PopAndDestroy(fields1); |
|
1658 Session().CleanupEntryPop(); |
|
1659 Session().RemoveEntry(id); |
|
1660 return EFail; |
|
1661 } |
|
1662 if(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) != 0) |
|
1663 { |
|
1664 CleanupStack::PopAndDestroy(fields1); |
|
1665 Session().CleanupEntryPop(); |
|
1666 Session().RemoveEntry(id); |
|
1667 return EFail; |
|
1668 } |
|
1669 if(!fields1->HasAddress()) |
|
1670 { |
|
1671 CleanupStack::PopAndDestroy(fields1); |
|
1672 Session().CleanupEntryPop(); |
|
1673 Session().RemoveEntry(id); |
|
1674 return EFail; |
|
1675 } |
|
1676 if(fields1->Length() != KTestAddress().Length() + KTestSubject().Length() + 2) |
|
1677 { |
|
1678 CleanupStack::PopAndDestroy(fields1); |
|
1679 Session().CleanupEntryPop(); |
|
1680 Session().RemoveEntry(id); |
|
1681 return EFail; |
|
1682 } |
|
1683 |
|
1684 // Test multiple addresses - add empty address -> not added |
|
1685 fields1->AddAddressL(KNullDesC); |
|
1686 if(fields1->Addresses().MdcaCount()!=1) |
|
1687 { |
|
1688 CleanupStack::PopAndDestroy(fields1); |
|
1689 Session().CleanupEntryPop(); |
|
1690 Session().RemoveEntry(id); |
|
1691 return EFail; |
|
1692 } |
|
1693 |
|
1694 _LIT(KTestAddress2, "support2@symbian.com"); |
|
1695 fields1->AddAddressL(KTestAddress2); |
|
1696 if(fields1->Addresses().MdcaCount()!=2) |
|
1697 { |
|
1698 CleanupStack::PopAndDestroy(fields1); |
|
1699 Session().CleanupEntryPop(); |
|
1700 Session().RemoveEntry(id); |
|
1701 return EFail; |
|
1702 } |
|
1703 if(fields1->Addresses().MdcaPoint(1).Compare(KTestAddress2) != 0) |
|
1704 { |
|
1705 CleanupStack::PopAndDestroy(fields1); |
|
1706 Session().CleanupEntryPop(); |
|
1707 Session().RemoveEntry(id); |
|
1708 return EFail; |
|
1709 } |
|
1710 if(!fields1->HasAddress()) |
|
1711 { |
|
1712 CleanupStack::PopAndDestroy(fields1); |
|
1713 Session().CleanupEntryPop(); |
|
1714 Session().RemoveEntry(id); |
|
1715 return EFail; |
|
1716 } |
|
1717 // NOTE - length check; 3 -> 2 for subject delimiters, 1 for address comma separtor. |
|
1718 if(fields1->Length() != KTestAddress().Length() + KTestAddress2().Length() + KTestSubject().Length() + 3) |
|
1719 { |
|
1720 CleanupStack::PopAndDestroy(fields1); |
|
1721 Session().CleanupEntryPop(); |
|
1722 Session().RemoveEntry(id); |
|
1723 return EFail; |
|
1724 } |
|
1725 |
|
1726 // Test copy factory c'tor |
|
1727 CSmsEmailFields* fields2 = CSmsEmailFields::NewL(*fields1); |
|
1728 CleanupStack::PushL(fields2); |
|
1729 |
|
1730 if(!CompareEmailFields(*fields2, *fields1)) |
|
1731 { |
|
1732 CleanupStack::PopAndDestroy(2,fields1); |
|
1733 Session().CleanupEntryPop(); |
|
1734 Session().RemoveEntry(id); |
|
1735 return EFail; |
|
1736 } |
|
1737 |
|
1738 // Test store and restore |
|
1739 StoreEmailFieldsL(*fields1); |
|
1740 fields2->Reset(); |
|
1741 RestoreEmailFieldsL(*fields2); |
|
1742 |
|
1743 if(!CompareEmailFields(*fields2, *fields1)) |
|
1744 { |
|
1745 CleanupStack::PopAndDestroy(2,fields1); |
|
1746 Session().CleanupEntryPop(); |
|
1747 Session().RemoveEntry(id); |
|
1748 return EFail; |
|
1749 } |
|
1750 |
|
1751 fields1->Reset(); |
|
1752 StoreEmailFieldsL(*fields1); |
|
1753 RestoreEmailFieldsL(*fields2); |
|
1754 |
|
1755 if(!CompareEmailFields(*fields2, *fields1)) |
|
1756 { |
|
1757 CleanupStack::PopAndDestroy(2,fields1); |
|
1758 Session().CleanupEntryPop(); |
|
1759 Session().RemoveEntry(id); |
|
1760 return EFail; |
|
1761 } |
|
1762 |
|
1763 CleanupStack::PopAndDestroy(2, fields1); |
|
1764 |
|
1765 // Test parsing - expected data. |
|
1766 _LIT(KTestBodyData, "Some body text#( )#"); |
|
1767 |
|
1768 _LIT(KTestParseAddress1, "user1@symbian.com"); |
|
1769 _LIT(KTestParseSubject1, ""); |
|
1770 _LIT(KTestEmail1, "user1@symbian.com Some body text#( )#"); |
|
1771 if(!TestEmailFieldsParsePassL(KTestEmail1, KTestParseAddress1, KTestParseSubject1, KTestBodyData)) |
|
1772 { |
|
1773 Session().CleanupEntryPop(); |
|
1774 Session().RemoveEntry(id); |
|
1775 return EFail; |
|
1776 } |
|
1777 |
|
1778 _LIT(KTestParseFullAddress1, "Some User <user1@symbian.com>"); |
|
1779 _LIT(KTestEmail2, "Some User <user1@symbian.com> Some body text#( )#"); |
|
1780 if(!TestEmailFieldsParsePassL(KTestEmail2, KTestParseFullAddress1, KTestParseSubject1, KTestBodyData)) |
|
1781 { |
|
1782 Session().CleanupEntryPop(); |
|
1783 Session().RemoveEntry(id); |
|
1784 return EFail; |
|
1785 } |
|
1786 |
|
1787 _LIT(KTestParseAddress2, "user2@symbian.com"); |
|
1788 _LIT(KTestParseSubject2, "subject (2)"); |
|
1789 _LIT(KTestEmail3, "user2@symbian.com##subject (2)#Some body text#( )#"); |
|
1790 if(!TestEmailFieldsParsePassL(KTestEmail3, KTestParseAddress2, KTestParseSubject2, KTestBodyData)) |
|
1791 { |
|
1792 Session().CleanupEntryPop(); |
|
1793 Session().RemoveEntry(id); |
|
1794 return EFail; |
|
1795 } |
|
1796 |
|
1797 _LIT(KTestParseFullAddress2, "Some User <user2@symbian.com>"); |
|
1798 _LIT(KTestEmail4, "Some User <user2@symbian.com>##subject (2)#Some body text#( )#"); |
|
1799 if(!TestEmailFieldsParsePassL(KTestEmail4, KTestParseFullAddress2, KTestParseSubject2, KTestBodyData)) |
|
1800 { |
|
1801 Session().CleanupEntryPop(); |
|
1802 Session().RemoveEntry(id); |
|
1803 return EFail; |
|
1804 } |
|
1805 |
|
1806 _LIT(KTestParseAddress3, "user3@symbian.com"); |
|
1807 _LIT(KTestParseSubject3, "subject #3"); |
|
1808 _LIT(KTestEmail5, "user3@symbian.com(subject #3)Some body text#( )#"); |
|
1809 if(!TestEmailFieldsParsePassL(KTestEmail5, KTestParseAddress3, KTestParseSubject3, KTestBodyData)) |
|
1810 { |
|
1811 Session().CleanupEntryPop(); |
|
1812 Session().RemoveEntry(id); |
|
1813 return EFail; |
|
1814 } |
|
1815 |
|
1816 _LIT(KTestParseFullAddress3, "Some User <user3@symbian.com>"); |
|
1817 _LIT(KTestEmail6, "Some User <user3@symbian.com>(subject #3)Some body text#( )#"); |
|
1818 if(!TestEmailFieldsParsePassL(KTestEmail6, KTestParseFullAddress3, KTestParseSubject3, KTestBodyData)) |
|
1819 { |
|
1820 Session().CleanupEntryPop(); |
|
1821 Session().RemoveEntry(id); |
|
1822 return EFail; |
|
1823 } |
|
1824 |
|
1825 _LIT(KTestParseAddress4, "user4@symbian.com"); |
|
1826 _LIT(KTestParseSubject4, ""); |
|
1827 _LIT(KTestEmail7, "user4@symbian.com()Some body text#( )#"); |
|
1828 if(!TestEmailFieldsParsePassL(KTestEmail7, KTestParseAddress4, KTestParseSubject4, KTestBodyData)) |
|
1829 { |
|
1830 Session().CleanupEntryPop(); |
|
1831 Session().RemoveEntry(id); |
|
1832 return EFail; |
|
1833 } |
|
1834 |
|
1835 _LIT(KTestParseFullAddress4, "Some User <user4@symbian.com>"); |
|
1836 _LIT(KTestEmail8, "Some User <user4@symbian.com>()Some body text#( )#"); |
|
1837 if(!TestEmailFieldsParsePassL(KTestEmail8, KTestParseFullAddress4, KTestParseSubject4, KTestBodyData)) |
|
1838 { |
|
1839 Session().CleanupEntryPop(); |
|
1840 Session().RemoveEntry(id); |
|
1841 return EFail; |
|
1842 } |
|
1843 |
|
1844 _LIT(KTestParseAddress5, "user5@symbian.com"); |
|
1845 _LIT(KTestParseSubject5, ""); |
|
1846 _LIT(KTestEmail9, "user5@symbian.com###Some body text#( )#"); |
|
1847 if(!TestEmailFieldsParsePassL(KTestEmail9, KTestParseAddress5, KTestParseSubject5, KTestBodyData)) |
|
1848 { |
|
1849 Session().CleanupEntryPop(); |
|
1850 Session().RemoveEntry(id); |
|
1851 return EFail; |
|
1852 } |
|
1853 |
|
1854 _LIT(KTestParseFullAddress5, "Some User <user5@symbian.com>"); |
|
1855 _LIT(KTestEmail10, "Some User <user5@symbian.com>###Some body text#( )#"); |
|
1856 if(!TestEmailFieldsParsePassL(KTestEmail10, KTestParseFullAddress5, KTestParseSubject5, KTestBodyData)) |
|
1857 { |
|
1858 Session().CleanupEntryPop(); |
|
1859 Session().RemoveEntry(id); |
|
1860 return EFail; |
|
1861 } |
|
1862 |
|
1863 // Test parsing - corrupt but parse-able data. |
|
1864 _LIT(KTestCorruptAddress1, "user1@symbian.com"); |
|
1865 _LIT(KTestCorruptSubject1, "smiley ;"); |
|
1866 _LIT(KTestCorruptBody1, " subject)Some body text"); |
|
1867 _LIT(KTestCorruptEmail1, "user1@symbian.com(smiley ;) subject)Some body text"); |
|
1868 if(!TestEmailFieldsParsePassL(KTestCorruptEmail1, KTestCorruptAddress1, KTestCorruptSubject1, KTestCorruptBody1)) |
|
1869 { |
|
1870 Session().CleanupEntryPop(); |
|
1871 Session().RemoveEntry(id); |
|
1872 return EFail; |
|
1873 } |
|
1874 |
|
1875 _LIT(KTestCorruptAddress2, "user1@symbian.com"); |
|
1876 _LIT(KTestCorruptSubject2, ""); |
|
1877 _LIT(KTestCorruptBody2, "(bad subject)Some body text"); |
|
1878 _LIT(KTestCorruptEmail2, "user1@symbian.com (bad subject)Some body text"); |
|
1879 if(!TestEmailFieldsParsePassL(KTestCorruptEmail2, KTestCorruptAddress2, KTestCorruptSubject2, KTestCorruptBody2)) |
|
1880 { |
|
1881 Session().CleanupEntryPop(); |
|
1882 Session().RemoveEntry(id); |
|
1883 return EFail; |
|
1884 } |
|
1885 |
|
1886 _LIT(KTestCorruptAddress3, "user1@symbian.com"); |
|
1887 _LIT(KTestCorruptSubject3, ""); |
|
1888 _LIT(KTestCorruptBody3, "bad subject##Some body text"); |
|
1889 _LIT(KTestCorruptEmail3, "user1@symbian.com###bad subject##Some body text"); |
|
1890 if(!TestEmailFieldsParsePassL(KTestCorruptEmail3, KTestCorruptAddress3, KTestCorruptSubject3, KTestCorruptBody3)) |
|
1891 { |
|
1892 Session().CleanupEntryPop(); |
|
1893 Session().RemoveEntry(id); |
|
1894 return EFail; |
|
1895 } |
|
1896 |
|
1897 // Test parsing - corrupt and fail. |
|
1898 _LIT(KTestFailEmail1, "user#domain1.domain2 Some body text"); |
|
1899 if(!TestEmailFieldsParseFailL(KTestFailEmail1)) |
|
1900 { |
|
1901 Session().CleanupEntryPop(); |
|
1902 Session().RemoveEntry(id); |
|
1903 return EFail; |
|
1904 } |
|
1905 |
|
1906 _LIT(KTestFailEmail2, "user@domain1.domain2+Some+body+text"); |
|
1907 if(!TestEmailFieldsParseFailL(KTestFailEmail2)) |
|
1908 { |
|
1909 Session().CleanupEntryPop(); |
|
1910 Session().RemoveEntry(id); |
|
1911 return EFail; |
|
1912 } |
|
1913 |
|
1914 _LIT(KTestFailEmail3, "user@domain1.domain2##(subject)Some+body+text"); |
|
1915 if(!TestEmailFieldsParseFailL(KTestFailEmail3)) |
|
1916 { |
|
1917 Session().CleanupEntryPop(); |
|
1918 Session().RemoveEntry(id); |
|
1919 return EFail; |
|
1920 } |
|
1921 |
|
1922 _LIT(KTestFailEmail4, "user@domain1.domain2(##subject#Some+body+text"); |
|
1923 if(!TestEmailFieldsParseFailL(KTestFailEmail4)) |
|
1924 { |
|
1925 Session().CleanupEntryPop(); |
|
1926 Session().RemoveEntry(id); |
|
1927 return EFail; |
|
1928 } |
|
1929 |
|
1930 _LIT(KTestFailEmail5, "user1@symbian.com#bad subject#Some body text"); |
|
1931 if(!TestEmailFieldsParseFailL(KTestFailEmail5)) |
|
1932 { |
|
1933 Session().CleanupEntryPop(); |
|
1934 Session().RemoveEntry(id); |
|
1935 return EFail; |
|
1936 } |
|
1937 |
|
1938 // Test composing - ok |
|
1939 _LIT(KTestComposeAddress1, "user1@domain1.domain2"); |
|
1940 _LIT(KTestComposeSubject1, ""); |
|
1941 _LIT(KTestComposeFields1, "user1@domain1.domain2 "); |
|
1942 if(!TestEmailFieldsComposeL(KTestComposeFields1, KTestComposeAddress1, KNullDesC, KTestComposeSubject1)) |
|
1943 { |
|
1944 Session().CleanupEntryPop(); |
|
1945 Session().RemoveEntry(id); |
|
1946 return EFail; |
|
1947 } |
|
1948 |
|
1949 _LIT(KTestComposeAddress2, "user2@domain1.domain2"); |
|
1950 _LIT(KTestComposeSubject2, "a subject"); |
|
1951 _LIT(KTestComposeFields2, "user2@domain1.domain2(a subject)"); |
|
1952 if(!TestEmailFieldsComposeL(KTestComposeFields2, KTestComposeAddress2, KNullDesC, KTestComposeSubject2)) |
|
1953 { |
|
1954 Session().CleanupEntryPop(); |
|
1955 Session().RemoveEntry(id); |
|
1956 return EFail; |
|
1957 } |
|
1958 |
|
1959 _LIT(KTestComposeFields3, "user1@domain1.domain2,user2@domain1.domain2 "); |
|
1960 if(!TestEmailFieldsComposeL(KTestComposeFields3, KTestComposeAddress1, KTestComposeAddress2, KTestComposeSubject1)) |
|
1961 { |
|
1962 Session().CleanupEntryPop(); |
|
1963 Session().RemoveEntry(id); |
|
1964 return EFail; |
|
1965 } |
|
1966 |
|
1967 _LIT(KTestComposeFields4, "user2@domain1.domain2,user1@domain1.domain2(a subject)"); |
|
1968 if(!TestEmailFieldsComposeL(KTestComposeFields4, KTestComposeAddress2, KTestComposeAddress1, KTestComposeSubject2)) |
|
1969 { |
|
1970 Session().CleanupEntryPop(); |
|
1971 Session().RemoveEntry(id); |
|
1972 return EFail; |
|
1973 } |
|
1974 |
|
1975 // Testing composing - fail, no address. |
|
1976 CSmsEmailFields* fields3 = CSmsEmailFields::NewL(); |
|
1977 CleanupStack::PushL(fields3); |
|
1978 |
|
1979 fields3->AddAddressL(KNullDesC); |
|
1980 fields3->SetSubjectL(KTestSubject); |
|
1981 |
|
1982 TRAPD(err, fields3->ComposeLC()); |
|
1983 |
|
1984 iSmsTest(err==KErrCorrupt); |
|
1985 |
|
1986 CleanupStack::PopAndDestroy(fields3); |
|
1987 |
|
1988 Session().CleanupEntryPop(); |
|
1989 Session().RemoveEntry(id); |
|
1990 |
|
1991 iTestStep.INFO_PRINTF1(_L("Test EmailFields Passed")); |
|
1992 return EPass; |
|
1993 } |
|
1994 |
|
1995 TBool CSmutTest::TestEmailFieldsParsePassL(const TDesC& aMessage, const TDesC& aAddress, const TDesC& aSubject, const TDesC& aBody) |
|
1996 { |
|
1997 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
1998 CleanupStack::PushL(fields); |
|
1999 |
|
2000 TInt pos = fields->ParseL(aMessage); |
|
2001 |
|
2002 TPtrC body(aMessage.Mid(pos)); |
|
2003 if(!fields->HasAddress()) |
|
2004 { |
|
2005 CleanupStack::PopAndDestroy(fields); |
|
2006 return EFalse; |
|
2007 } |
|
2008 if(fields->Addresses().MdcaCount()!=1) |
|
2009 { |
|
2010 CleanupStack::PopAndDestroy(fields); |
|
2011 return EFalse; |
|
2012 } |
|
2013 if(fields->Addresses().MdcaPoint(0).Compare(aAddress) != 0) |
|
2014 { |
|
2015 CleanupStack::PopAndDestroy(fields); |
|
2016 return EFalse; |
|
2017 } |
|
2018 if(fields->Subject().Compare(aSubject) != 0) |
|
2019 { |
|
2020 CleanupStack::PopAndDestroy(fields); |
|
2021 return EFalse; |
|
2022 } |
|
2023 if(body.Compare(aBody) != 0) |
|
2024 { |
|
2025 CleanupStack::PopAndDestroy(fields); |
|
2026 return EFalse; |
|
2027 } |
|
2028 |
|
2029 CleanupStack::PopAndDestroy(fields); |
|
2030 return ETrue; |
|
2031 } |
|
2032 |
|
2033 TBool CSmutTest::TestEmailFieldsParseFailL(const TDesC& aMessage) |
|
2034 { |
|
2035 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
2036 CleanupStack::PushL(fields); |
|
2037 |
|
2038 TInt pos = fields->ParseL(aMessage); |
|
2039 |
|
2040 CleanupStack::PopAndDestroy(fields); |
|
2041 |
|
2042 return (pos == KErrCorrupt); |
|
2043 } |
|
2044 |
|
2045 TBool CSmutTest::TestEmailFieldsComposeL(const TDesC& aFields, const TDesC& aAddress1, const TDesC& aAddress2, const TDesC& aSubject) |
|
2046 { |
|
2047 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
2048 CleanupStack::PushL(fields); |
|
2049 |
|
2050 fields->AddAddressL(aAddress1); |
|
2051 fields->AddAddressL(aAddress2); |
|
2052 fields->SetSubjectL(aSubject); |
|
2053 HBufC* buffer = fields->ComposeLC(); |
|
2054 |
|
2055 TBool result = aFields.Compare(*buffer) == 0; |
|
2056 CleanupStack::PopAndDestroy(2, fields); // fields, buffer |
|
2057 |
|
2058 return result; |
|
2059 } |
|
2060 |
|
2061 TVerdict CSmutTest::TestHeaderL() |
|
2062 { |
|
2063 |
|
2064 // Testing class CSmsHeader |
|
2065 iTestStep.INFO_PRINTF1(_L("Testing CSmsHeader...")); |
|
2066 |
|
2067 // A CSmsHeader can be of 6 different types |
|
2068 // First we test constructing ESmsDeliver |
|
2069 delete iSmsHeader; // deleting the previous one |
|
2070 iSmsHeader = NULL; |
|
2071 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); // constructing |
|
2072 if(iSmsHeader->Type()!=CSmsPDU::ESmsDeliver) // type ok? |
|
2073 { |
|
2074 return EFail; |
|
2075 } |
|
2076 |
|
2077 CSmsDeliver& deliver = iSmsHeader->Deliver(); // lets get the CSmsPDU of the CSmsHeader |
|
2078 const CSmsDeliver& deliver2 = iSmsHeader->Deliver(); |
|
2079 |
|
2080 if(deliver.Type() != CSmsPDU::ESmsDeliver)// Are the types ok? |
|
2081 { |
|
2082 return EFail; |
|
2083 } |
|
2084 if(deliver2.Type() != CSmsPDU::ESmsDeliver) |
|
2085 { |
|
2086 return EFail; |
|
2087 } |
|
2088 |
|
2089 |
|
2090 // Lets access the CSmsMessage of our header |
|
2091 CSmsMessage& message=iSmsHeader->Message(); |
|
2092 //Get the operations |
|
2093 CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,message.GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat)); |
|
2094 //Add address |
|
2095 TPtrC replyAddress(_L("+447583927594")); |
|
2096 operations.AddReplyAddressL(replyAddress); |
|
2097 |
|
2098 //get the address back |
|
2099 if(iSmsHeader->ReplyAddressL()!=_L("+447583927594")) |
|
2100 { |
|
2101 return EFail; |
|
2102 } |
|
2103 |
|
2104 // Add a from address and make sure that the reply address is still used instead |
|
2105 iSmsHeader->SetFromAddressL(_L("+358503367709")); |
|
2106 //get the address back |
|
2107 if(iSmsHeader->ReplyAddressL()!=_L("+447583927594")) |
|
2108 { |
|
2109 return EFail; |
|
2110 } |
|
2111 |
|
2112 // Type ESmsCommand |
|
2113 delete iSmsHeader; // deleting previous |
|
2114 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsCommand,*iRichText); |
|
2115 if(iSmsHeader->Type()!=CSmsPDU::ESmsCommand) |
|
2116 { |
|
2117 return EFail; |
|
2118 } |
|
2119 |
|
2120 CSmsCommand& command=iSmsHeader->Command(); |
|
2121 const CSmsCommand& command2=iSmsHeader->Command(); |
|
2122 |
|
2123 if(command.Type() != CSmsPDU::ESmsCommand) |
|
2124 { |
|
2125 return EFail; |
|
2126 } |
|
2127 if(command2.Type() != CSmsPDU::ESmsCommand) |
|
2128 { |
|
2129 return EFail; |
|
2130 } |
|
2131 |
|
2132 // Type ESmsStatusReport |
|
2133 delete iSmsHeader; // deleting the previous one |
|
2134 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsStatusReport,*iRichText); |
|
2135 if(iSmsHeader->Type()!=CSmsPDU::ESmsStatusReport) |
|
2136 { |
|
2137 return EFail; |
|
2138 } |
|
2139 |
|
2140 CSmsStatusReport& statusreport=iSmsHeader->StatusReport(); |
|
2141 const CSmsStatusReport& statusreport2=iSmsHeader->StatusReport(); |
|
2142 |
|
2143 if(statusreport.Type() != CSmsPDU::ESmsStatusReport) |
|
2144 { |
|
2145 return EFail; |
|
2146 } |
|
2147 if(statusreport2.Type() != CSmsPDU::ESmsStatusReport) |
|
2148 { |
|
2149 return EFail; |
|
2150 } |
|
2151 |
|
2152 // Type ESmsSubmit |
|
2153 delete iSmsHeader; // deleting the previous one |
|
2154 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
2155 if(iSmsHeader->Type()!=CSmsPDU::ESmsSubmit) |
|
2156 { |
|
2157 return EFail; |
|
2158 } |
|
2159 |
|
2160 CSmsSubmit& submit=iSmsHeader->Submit(); |
|
2161 const CSmsSubmit& submit2=iSmsHeader->Submit(); |
|
2162 |
|
2163 if(submit.Type() != CSmsPDU::ESmsSubmit) |
|
2164 { |
|
2165 return EFail; |
|
2166 } |
|
2167 if(submit2.Type() != CSmsPDU::ESmsSubmit) |
|
2168 { |
|
2169 return EFail; |
|
2170 } |
|
2171 |
|
2172 // Lets access the CSmsMessage of our header |
|
2173 CSmsMessage& message1=iSmsHeader->Message(); |
|
2174 const CSmsMessage& message2=iSmsHeader->Message(); |
|
2175 |
|
2176 if(message1.Type() != CSmsPDU::ESmsSubmit) |
|
2177 { |
|
2178 return EFail; |
|
2179 } |
|
2180 if(message2.Type() != CSmsPDU::ESmsSubmit) |
|
2181 { |
|
2182 return EFail; |
|
2183 } |
|
2184 |
|
2185 // Lets test the features of CSmsHeader with different values |
|
2186 iSmsHeader->SetReplyPathProvided(ETrue); |
|
2187 if(!iSmsHeader->ReplyPathProvided()) |
|
2188 { |
|
2189 return EFail; |
|
2190 } |
|
2191 iSmsHeader->SetReplyPathProvided(EFalse); |
|
2192 if(iSmsHeader->ReplyPathProvided()) |
|
2193 { |
|
2194 return EFail; |
|
2195 } |
|
2196 |
|
2197 iSmsHeader->SetBioMsgIdType(EBioMsgIdUnknown); |
|
2198 if(iSmsHeader->BioMsgIdType()!=EBioMsgIdUnknown) |
|
2199 { |
|
2200 return EFail; |
|
2201 } |
|
2202 iSmsHeader->SetBioMsgIdType(EBioMsgIdIana); |
|
2203 if(iSmsHeader->BioMsgIdType()!=EBioMsgIdIana) |
|
2204 { |
|
2205 return EFail; |
|
2206 } |
|
2207 iSmsHeader->SetBioMsgIdType(EBioMsgIdNbs); |
|
2208 if(iSmsHeader->BioMsgIdType()!=EBioMsgIdNbs) |
|
2209 { |
|
2210 return EFail; |
|
2211 } |
|
2212 iSmsHeader->SetBioMsgIdType(EBioMsgIdWap); |
|
2213 if(iSmsHeader->BioMsgIdType()!=EBioMsgIdWap) |
|
2214 { |
|
2215 return EFail; |
|
2216 } |
|
2217 iSmsHeader->SetBioMsgIdType(EBioMsgIdWapSecure); |
|
2218 if(iSmsHeader->BioMsgIdType()!=EBioMsgIdWapSecure) |
|
2219 { |
|
2220 return EFail; |
|
2221 } |
|
2222 |
|
2223 // Lets set the service center number |
|
2224 iSmsHeader->SetServiceCenterAddressL(_L("+350508771010")); |
|
2225 if(iSmsHeader->ServiceCenterAddress()!=_L("+350508771010")) |
|
2226 { |
|
2227 return EFail; |
|
2228 } |
|
2229 |
|
2230 // Lets set one recipient for the message |
|
2231 CArrayPtrFlat<CSmsNumber>& recipients = iSmsHeader->Recipients(); |
|
2232 CSmsNumber* number=CSmsNumber::NewL(); |
|
2233 CleanupStack::PushL(number); |
|
2234 number->SetAddressL(_L("+358503367709")); |
|
2235 recipients.AppendL(number); |
|
2236 CleanupStack::Pop(); |
|
2237 |
|
2238 // Setting settings of the message |
|
2239 CSmsSettings* smsset = CSmsSettings::NewL(); |
|
2240 CleanupStack::PushL(smsset); |
|
2241 smsset->AddServiceCenterL(_L("Hippo"), _L("+358508771010")); |
|
2242 smsset->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
2243 smsset->SetDelivery(ESmsDeliveryImmediately); |
|
2244 smsset->SetDeliveryReport(EFalse); |
|
2245 smsset->SetMessageConversion(ESmsConvPIDNone); |
|
2246 smsset->SetRejectDuplicate(ETrue); |
|
2247 smsset->SetReplyPath(EFalse); |
|
2248 smsset->SetValidityPeriod(ESmsVP24Hours); |
|
2249 smsset->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
2250 // And copying them to the CSmsHeader |
|
2251 iSmsHeader->SetSmsSettingsL(*smsset); |
|
2252 CleanupStack::PopAndDestroy(smsset); |
|
2253 |
|
2254 CSmsSettings* smsset2 = CSmsSettings::NewL(); |
|
2255 CleanupStack::PushL(smsset2); |
|
2256 // Lets get the same setting from the CSmsHeader |
|
2257 iSmsHeader->GetSmsSettingsL(*smsset2); |
|
2258 // And compare that they are ok! |
|
2259 if(smsset2->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
2260 { |
|
2261 CleanupStack::PopAndDestroy(smsset2); |
|
2262 return EFail; |
|
2263 } |
|
2264 if(smsset2->DeliveryReport()) |
|
2265 { |
|
2266 CleanupStack::PopAndDestroy(smsset2); |
|
2267 return EFail; |
|
2268 } |
|
2269 if(smsset2->MessageConversion()!=ESmsConvPIDNone) |
|
2270 { |
|
2271 CleanupStack::PopAndDestroy(smsset2); |
|
2272 return EFail; |
|
2273 } |
|
2274 if(!smsset2->RejectDuplicate()) |
|
2275 { |
|
2276 CleanupStack::PopAndDestroy(smsset2); |
|
2277 return EFail; |
|
2278 } |
|
2279 if(smsset2->ReplyPath()) |
|
2280 { |
|
2281 CleanupStack::PopAndDestroy(smsset2); |
|
2282 return EFail; |
|
2283 } |
|
2284 if(smsset2->ValidityPeriod().Int()!=ESmsVP24Hours) |
|
2285 { |
|
2286 CleanupStack::PopAndDestroy(smsset2); |
|
2287 return EFail; |
|
2288 } |
|
2289 if(smsset2->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet) |
|
2290 { |
|
2291 CleanupStack::PopAndDestroy(smsset2); |
|
2292 return EFail; |
|
2293 } |
|
2294 CleanupStack::PopAndDestroy(smsset2); |
|
2295 |
|
2296 //Test Set/FromAddress() |
|
2297 iSmsHeader->SetFromAddressL(_L("+358503367709")); |
|
2298 if(iSmsHeader->ReplyAddressL()!=_L("+358503367709")) |
|
2299 { |
|
2300 return EFail; |
|
2301 } |
|
2302 |
|
2303 //Test Set/EmailFields() |
|
2304 _LIT(KTestAddress, "user@domain1.domain2"); |
|
2305 _LIT(KTestSubject, "a subject"); |
|
2306 |
|
2307 CSmsEmailFields* fields1 = CSmsEmailFields::NewL(); |
|
2308 CleanupStack::PushL(fields1); |
|
2309 |
|
2310 fields1->AddAddressL(KTestAddress); |
|
2311 fields1->SetSubjectL(KTestSubject); |
|
2312 |
|
2313 // Test the PID field value - should be ESmsConvPIDNone... |
|
2314 CSmsSettings* smsset3 = CSmsSettings::NewL(); |
|
2315 CleanupStack::PushL(smsset3); |
|
2316 |
|
2317 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2318 if(smsset3->MessageConversion()!=ESmsConvPIDNone) |
|
2319 { |
|
2320 CleanupStack::PopAndDestroy(2,smsset3); |
|
2321 return EFail; |
|
2322 } |
|
2323 |
|
2324 // Set the email fields - check the email fields and the PID value (should |
|
2325 // be ESmsConvMail). |
|
2326 iSmsHeader->SetEmailFieldsL(*fields1); |
|
2327 const CSmsEmailFields& fields2 = iSmsHeader->EmailFields(); |
|
2328 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2329 |
|
2330 if(!CompareEmailFields(*fields1, fields2)) |
|
2331 { |
|
2332 CleanupStack::PopAndDestroy(2,smsset3); |
|
2333 return EFail; |
|
2334 } |
|
2335 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2336 { |
|
2337 CleanupStack::PopAndDestroy(2,smsset3); |
|
2338 return EFail; |
|
2339 } |
|
2340 |
|
2341 // Reset the fields and then set back in the header - should reset the PID |
|
2342 // value to ESmsConvPIDNone |
|
2343 fields1->Reset(); |
|
2344 iSmsHeader->SetEmailFieldsL(*fields1); |
|
2345 |
|
2346 const CSmsEmailFields& fields3 = iSmsHeader->EmailFields(); |
|
2347 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2348 |
|
2349 if(!CompareEmailFields(*fields1, fields3)) |
|
2350 { |
|
2351 CleanupStack::PopAndDestroy(2,smsset3); |
|
2352 return EFail; |
|
2353 } |
|
2354 if(smsset3->MessageConversion()!=ESmsConvPIDNone) |
|
2355 { |
|
2356 CleanupStack::PopAndDestroy(2,smsset3); |
|
2357 return EFail; |
|
2358 } |
|
2359 |
|
2360 // Set the reply email fields - check email fields (both address and subject) |
|
2361 // and the PID value (should be ESmsConvMail) |
|
2362 _LIT(KEmailReplySubjectFormat, "Re: %S"); |
|
2363 _LIT(KEmailReplySubject, "Re: a subject"); |
|
2364 |
|
2365 // First test with no subject... |
|
2366 fields1->AddAddressL(KTestAddress); |
|
2367 |
|
2368 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
2369 const CSmsEmailFields& replyFields1 = iSmsHeader->EmailFields(); |
|
2370 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2371 |
|
2372 if(!CompareEmailFieldsAddresses(replyFields1.Addresses(), fields1->Addresses())) |
|
2373 { |
|
2374 CleanupStack::PopAndDestroy(2,smsset3); |
|
2375 return EFail; |
|
2376 } |
|
2377 if(replyFields1.Subject().Compare(KNullDesC) != 0) |
|
2378 { |
|
2379 CleanupStack::PopAndDestroy(2,smsset3); |
|
2380 return EFail; |
|
2381 } |
|
2382 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2383 { |
|
2384 CleanupStack::PopAndDestroy(2,smsset3); |
|
2385 return EFail; |
|
2386 } |
|
2387 |
|
2388 // Now set the subject... |
|
2389 fields1->SetSubjectL(KTestSubject); |
|
2390 |
|
2391 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
2392 const CSmsEmailFields& replyFields2 = iSmsHeader->EmailFields(); |
|
2393 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2394 |
|
2395 if(!CompareEmailFieldsAddresses(replyFields2.Addresses(), fields1->Addresses())) |
|
2396 { |
|
2397 CleanupStack::PopAndDestroy(2,smsset3); |
|
2398 return EFail; |
|
2399 } |
|
2400 if(replyFields2.Subject().Compare(KEmailReplySubject()) != 0) |
|
2401 { |
|
2402 CleanupStack::PopAndDestroy(2,smsset3); |
|
2403 return EFail; |
|
2404 } |
|
2405 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2406 { |
|
2407 CleanupStack::PopAndDestroy(2,smsset3); |
|
2408 return EFail; |
|
2409 } |
|
2410 |
|
2411 // Repeat - test for (lack of) Re: chain. |
|
2412 fields1->SetSubjectL(KEmailReplySubject); |
|
2413 |
|
2414 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
2415 const CSmsEmailFields& replyFields3 = iSmsHeader->EmailFields(); |
|
2416 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2417 |
|
2418 if(!CompareEmailFieldsAddresses(replyFields3.Addresses(), fields1->Addresses())) |
|
2419 { |
|
2420 CleanupStack::PopAndDestroy(2,smsset3); |
|
2421 return EFail; |
|
2422 } |
|
2423 if(replyFields3.Subject().Compare(KEmailReplySubject()) != 0) |
|
2424 { |
|
2425 CleanupStack::PopAndDestroy(2,smsset3); |
|
2426 return EFail; |
|
2427 } |
|
2428 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2429 { |
|
2430 CleanupStack::PopAndDestroy(2,smsset3); |
|
2431 return EFail; |
|
2432 } |
|
2433 |
|
2434 // Set the forward email fields - check email fields (both address and subject) |
|
2435 // and the PID value (should be ESmsConvMail) |
|
2436 _LIT(KEmailForwardSubjectFormat, "Fw: %S"); |
|
2437 _LIT(KEmailForwardSubject, "Fw: a subject"); |
|
2438 |
|
2439 // First test with no subject... |
|
2440 fields1->Reset(); |
|
2441 fields1->AddAddressL(KTestAddress); |
|
2442 |
|
2443 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
2444 const CSmsEmailFields& forwardFields1 = iSmsHeader->EmailFields(); |
|
2445 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2446 |
|
2447 if(forwardFields1.HasAddress()) |
|
2448 { |
|
2449 CleanupStack::PopAndDestroy(2,smsset3); |
|
2450 return EFail; |
|
2451 } |
|
2452 if(forwardFields1.Addresses().MdcaCount()!=0) |
|
2453 { |
|
2454 CleanupStack::PopAndDestroy(2,smsset3); |
|
2455 return EFail; |
|
2456 } |
|
2457 if(forwardFields1.Subject().Compare(KNullDesC) != 0) |
|
2458 { |
|
2459 CleanupStack::PopAndDestroy(2,smsset3); |
|
2460 return EFail; |
|
2461 } |
|
2462 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2463 { |
|
2464 CleanupStack::PopAndDestroy(2,smsset3); |
|
2465 return EFail; |
|
2466 } |
|
2467 |
|
2468 // Now set the subject... |
|
2469 fields1->SetSubjectL(KTestSubject); |
|
2470 |
|
2471 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
2472 const CSmsEmailFields& forwardFields2 = iSmsHeader->EmailFields(); |
|
2473 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2474 |
|
2475 if(forwardFields2.HasAddress()) |
|
2476 { |
|
2477 CleanupStack::PopAndDestroy(2,smsset3); |
|
2478 return EFail; |
|
2479 } |
|
2480 if(forwardFields2.Addresses().MdcaCount()!=0) |
|
2481 { |
|
2482 CleanupStack::PopAndDestroy(2,smsset3); |
|
2483 return EFail; |
|
2484 } |
|
2485 if(forwardFields2.Subject().Compare(KEmailForwardSubject()) != 0) |
|
2486 { |
|
2487 CleanupStack::PopAndDestroy(2,smsset3); |
|
2488 return EFail; |
|
2489 } |
|
2490 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2491 { |
|
2492 CleanupStack::PopAndDestroy(2,smsset3); |
|
2493 return EFail; |
|
2494 } |
|
2495 |
|
2496 // Repeat - test for (lack of) Fw: chain. |
|
2497 fields1->SetSubjectL(KEmailForwardSubject); |
|
2498 |
|
2499 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
2500 const CSmsEmailFields& forwardFields3 = iSmsHeader->EmailFields(); |
|
2501 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
2502 |
|
2503 if(forwardFields3.HasAddress()) |
|
2504 { |
|
2505 CleanupStack::PopAndDestroy(2,smsset3); |
|
2506 return EFail; |
|
2507 } |
|
2508 if(forwardFields3.Addresses().MdcaCount()!=0) |
|
2509 { |
|
2510 CleanupStack::PopAndDestroy(2,smsset3); |
|
2511 return EFail; |
|
2512 } |
|
2513 if(forwardFields3.Subject().Compare(KEmailForwardSubject()) != 0) |
|
2514 { |
|
2515 CleanupStack::PopAndDestroy(smsset3); |
|
2516 CleanupStack::PopAndDestroy(fields1); |
|
2517 return EFail; |
|
2518 } |
|
2519 if(smsset3->MessageConversion()!=ESmsConvMail) |
|
2520 { |
|
2521 CleanupStack::PopAndDestroy(2,smsset3); |
|
2522 return EFail; |
|
2523 } |
|
2524 |
|
2525 // Reset the fields and set back in the header. |
|
2526 fields1->Reset(); |
|
2527 iSmsHeader->SetEmailFieldsL(*fields1); |
|
2528 |
|
2529 CleanupStack::PopAndDestroy(2, fields1); |
|
2530 |
|
2531 //Lets store and restore the CSmsHeader and test that the values are right |
|
2532 TMsvId id = iSmsTest.CreateDummyMessageToSendL(); |
|
2533 Session().CleanupEntryPushL(id); |
|
2534 iSmsTest.SetEntryL(id); |
|
2535 |
|
2536 StoreHeaderL(*iSmsHeader); |
|
2537 |
|
2538 // Check that the email fields stream is not present, as there is no email |
|
2539 // fields data. |
|
2540 CMsvStore* store1 = iSmsTest.ReadStoreL(); |
|
2541 CleanupStack::PushL(store1); |
|
2542 if(store1->IsPresentL(KUidMsvSmsEmailFieldsStream)) |
|
2543 { |
|
2544 CleanupStack::PopAndDestroy(store1); |
|
2545 return EFail; |
|
2546 } |
|
2547 CleanupStack::PopAndDestroy(store1); |
|
2548 |
|
2549 CSmsHeader* header1 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
2550 CleanupStack::PushL(header1); |
|
2551 |
|
2552 RestoreHeaderL(*header1); |
|
2553 |
|
2554 //Values ok? |
|
2555 if(iSmsHeader->Type()!=header1->Type()) |
|
2556 { |
|
2557 CleanupStack::PopAndDestroy(header1); |
|
2558 Session().CleanupEntryPop(); |
|
2559 Session().RemoveEntry(id); |
|
2560 return EFail; |
|
2561 } |
|
2562 if(header1->ReplyPathProvided()) |
|
2563 { |
|
2564 CleanupStack::PopAndDestroy(header1); |
|
2565 Session().CleanupEntryPop(); |
|
2566 Session().RemoveEntry(id); |
|
2567 return EFail; |
|
2568 } |
|
2569 if(header1->ServiceCenterAddress()!=_L("+350508771010")) |
|
2570 { |
|
2571 CleanupStack::PopAndDestroy(header1); |
|
2572 Session().CleanupEntryPop(); |
|
2573 Session().RemoveEntry(id); |
|
2574 return EFail; |
|
2575 } |
|
2576 if(iSmsHeader->Recipients().Count()!=header1->Recipients().Count()) |
|
2577 { |
|
2578 CleanupStack::PopAndDestroy(header1); |
|
2579 Session().CleanupEntryPop(); |
|
2580 Session().RemoveEntry(id); |
|
2581 return EFail; |
|
2582 } |
|
2583 if(iSmsHeader->BioMsgIdType()!=header1->BioMsgIdType()) |
|
2584 { |
|
2585 CleanupStack::PopAndDestroy(header1); |
|
2586 Session().CleanupEntryPop(); |
|
2587 Session().RemoveEntry(id); |
|
2588 return EFail; |
|
2589 } |
|
2590 if(iSmsHeader->ReplyAddressL()!=header1->ReplyAddressL()) |
|
2591 { |
|
2592 CleanupStack::PopAndDestroy(header1); |
|
2593 Session().CleanupEntryPop(); |
|
2594 Session().RemoveEntry(id); |
|
2595 return EFail; |
|
2596 } |
|
2597 |
|
2598 // Lets get the setting of the message |
|
2599 CSmsSettings* smsset4 = CSmsSettings::NewL(); |
|
2600 CleanupStack::PushL(smsset4); |
|
2601 header1->GetSmsSettingsL(*smsset4); |
|
2602 |
|
2603 // And compare that they are the original values |
|
2604 if(smsset4->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
2605 { |
|
2606 CleanupStack::PopAndDestroy(2,smsset4); |
|
2607 Session().CleanupEntryPop(); |
|
2608 Session().RemoveEntry(id); |
|
2609 return EFail; |
|
2610 } |
|
2611 if(smsset4->DeliveryReport()) |
|
2612 { |
|
2613 CleanupStack::PopAndDestroy(2,smsset4); |
|
2614 Session().CleanupEntryPop(); |
|
2615 Session().RemoveEntry(id); |
|
2616 return EFail; |
|
2617 } |
|
2618 if(smsset4->MessageConversion()!=ESmsConvPIDNone) |
|
2619 { |
|
2620 CleanupStack::PopAndDestroy(2,smsset4); |
|
2621 Session().CleanupEntryPop(); |
|
2622 Session().RemoveEntry(id); |
|
2623 return EFail; |
|
2624 } |
|
2625 if(!smsset4->RejectDuplicate()) |
|
2626 { |
|
2627 CleanupStack::PopAndDestroy(2,smsset4); |
|
2628 Session().CleanupEntryPop(); |
|
2629 Session().RemoveEntry(id); |
|
2630 return EFail; |
|
2631 } |
|
2632 if(smsset4->ReplyPath()) |
|
2633 { |
|
2634 CleanupStack::PopAndDestroy(2,smsset4); |
|
2635 Session().CleanupEntryPop(); |
|
2636 Session().RemoveEntry(id); |
|
2637 return EFail; |
|
2638 } |
|
2639 if(smsset4->ValidityPeriod().Int()!=ESmsVP24Hours) |
|
2640 { |
|
2641 CleanupStack::PopAndDestroy(2,smsset4); |
|
2642 Session().CleanupEntryPop(); |
|
2643 Session().RemoveEntry(id); |
|
2644 return EFail; |
|
2645 } |
|
2646 if(smsset4->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet) |
|
2647 { |
|
2648 CleanupStack::PopAndDestroy(2,smsset4); |
|
2649 Session().CleanupEntryPop(); |
|
2650 Session().RemoveEntry(id); |
|
2651 return EFail; |
|
2652 } |
|
2653 |
|
2654 CleanupStack::PopAndDestroy(2, header1); |
|
2655 |
|
2656 // Test with email fields data. |
|
2657 CSmsEmailFields* fields8 = CSmsEmailFields::NewL(); |
|
2658 CleanupStack::PushL(fields8); |
|
2659 fields8->AddAddressL(KTestAddress); |
|
2660 fields8->SetSubjectL(KTestSubject); |
|
2661 iSmsHeader->SetEmailFieldsL(*fields8); |
|
2662 |
|
2663 StoreHeaderL(*iSmsHeader); |
|
2664 |
|
2665 // Check that the email fields stream is present, as there is now email |
|
2666 // fields data. |
|
2667 CMsvStore* store2 = iSmsTest.EditStoreL(); |
|
2668 CleanupStack::PushL(store2); |
|
2669 if(!store2->IsPresentL(KUidMsvSmsEmailFieldsStream)) |
|
2670 { |
|
2671 CleanupStack::PopAndDestroy(2,store2); |
|
2672 Session().CleanupEntryPop(); |
|
2673 Session().RemoveEntry(id); |
|
2674 return EFail; |
|
2675 } |
|
2676 CleanupStack::PopAndDestroy(store2); |
|
2677 |
|
2678 CSmsHeader* header2 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
2679 CleanupStack::PushL(header2); |
|
2680 |
|
2681 RestoreHeaderL(*header2); |
|
2682 |
|
2683 if(iSmsHeader->Type()!=header2->Type()) |
|
2684 { |
|
2685 CleanupStack::PopAndDestroy(2,store2); |
|
2686 Session().CleanupEntryPop(); |
|
2687 Session().RemoveEntry(id); |
|
2688 return EFail; |
|
2689 } |
|
2690 if(header2->ReplyPathProvided()) |
|
2691 { |
|
2692 CleanupStack::PopAndDestroy(2,store2); |
|
2693 Session().CleanupEntryPop(); |
|
2694 Session().RemoveEntry(id); |
|
2695 return EFail; |
|
2696 } |
|
2697 if(header2->ServiceCenterAddress()!=_L("+350508771010")) |
|
2698 { |
|
2699 CleanupStack::PopAndDestroy(2,store2); |
|
2700 Session().CleanupEntryPop(); |
|
2701 Session().RemoveEntry(id); |
|
2702 return EFail; |
|
2703 } |
|
2704 if(iSmsHeader->Recipients().Count()!=header2->Recipients().Count()) |
|
2705 { |
|
2706 CleanupStack::PopAndDestroy(2,store2); |
|
2707 Session().CleanupEntryPop(); |
|
2708 Session().RemoveEntry(id); |
|
2709 return EFail; |
|
2710 } |
|
2711 if(iSmsHeader->BioMsgIdType()!=header2->BioMsgIdType()) |
|
2712 { |
|
2713 CleanupStack::PopAndDestroy(2,store2); |
|
2714 Session().CleanupEntryPop(); |
|
2715 Session().RemoveEntry(id); |
|
2716 return EFail; |
|
2717 } |
|
2718 if(iSmsHeader->ReplyAddressL()!=header2->ReplyAddressL()) |
|
2719 { |
|
2720 CleanupStack::PopAndDestroy(2,store2); |
|
2721 Session().CleanupEntryPop(); |
|
2722 Session().RemoveEntry(id); |
|
2723 return EFail; |
|
2724 } |
|
2725 |
|
2726 CSmsSettings* smsset5 = CSmsSettings::NewL(); |
|
2727 CleanupStack::PushL(smsset5); |
|
2728 header2->GetSmsSettingsL(*smsset5); |
|
2729 |
|
2730 if(smsset5->CharacterSet()!=TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
2731 { |
|
2732 CleanupStack::PopAndDestroy(2,store2); |
|
2733 Session().CleanupEntryPop(); |
|
2734 Session().RemoveEntry(id); |
|
2735 return EFail; |
|
2736 } |
|
2737 if(smsset5->DeliveryReport()) |
|
2738 { |
|
2739 CleanupStack::PopAndDestroy(2,store2); |
|
2740 Session().CleanupEntryPop(); |
|
2741 Session().RemoveEntry(id); |
|
2742 return EFail; |
|
2743 } |
|
2744 if(smsset5->MessageConversion()!=ESmsConvMail) |
|
2745 { |
|
2746 CleanupStack::PopAndDestroy(2,store2); |
|
2747 Session().CleanupEntryPop(); |
|
2748 Session().RemoveEntry(id); |
|
2749 return EFail; |
|
2750 } |
|
2751 if(!smsset5->RejectDuplicate()) |
|
2752 { |
|
2753 CleanupStack::PopAndDestroy(2,store2); |
|
2754 Session().CleanupEntryPop(); |
|
2755 Session().RemoveEntry(id); |
|
2756 return EFail; |
|
2757 } |
|
2758 if(smsset5->ReplyPath()) |
|
2759 { |
|
2760 CleanupStack::PopAndDestroy(2,store2); |
|
2761 Session().CleanupEntryPop(); |
|
2762 Session().RemoveEntry(id); |
|
2763 return EFail; |
|
2764 } |
|
2765 if(smsset5->ValidityPeriod().Int()!=ESmsVP24Hours) |
|
2766 { |
|
2767 CleanupStack::PopAndDestroy(2,store2); |
|
2768 Session().CleanupEntryPop(); |
|
2769 Session().RemoveEntry(id); |
|
2770 return EFail; |
|
2771 } |
|
2772 if(smsset5->ValidityPeriodFormat()!=TSmsFirstOctet::ESmsVPFSemiOctet) |
|
2773 { |
|
2774 CleanupStack::PopAndDestroy(2,store2); |
|
2775 Session().CleanupEntryPop(); |
|
2776 Session().RemoveEntry(id); |
|
2777 return EFail; |
|
2778 } |
|
2779 |
|
2780 const CSmsEmailFields& fields9 = iSmsHeader->EmailFields(); |
|
2781 if(!CompareEmailFields(*fields8, fields9)) |
|
2782 { |
|
2783 CleanupStack::PopAndDestroy(2,store2); |
|
2784 Session().CleanupEntryPop(); |
|
2785 Session().RemoveEntry(id); |
|
2786 return EFail; |
|
2787 } |
|
2788 |
|
2789 CleanupStack::PopAndDestroy(3, fields8); |
|
2790 |
|
2791 //Test NewL that takes a CSmsMessage - pretend it's an email message. |
|
2792 RFs fs; |
|
2793 User::LeaveIfError(fs.Connect()); |
|
2794 CleanupClosePushL(fs); |
|
2795 |
|
2796 // Test un-corrupt email - add an appropriate email message |
|
2797 _LIT(KTestEmailAddress1, "user@domain1.domain2"); |
|
2798 _LIT(KTestEmailSubject1, "a subject"); |
|
2799 _LIT(KTestEmailBody1, "some body text"); |
|
2800 _LIT(KTestEmailMessage1, "user@domain1.domain2##a subject#some body text"); |
|
2801 |
|
2802 CSmsMessage* email1 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse); |
|
2803 CleanupStack::PushL(email1); |
|
2804 |
|
2805 CSmsBufferBase& buffer1 = email1->Buffer(); |
|
2806 buffer1.Reset(); |
|
2807 buffer1.InsertL(0, KTestEmailMessage1()); |
|
2808 |
|
2809 // Set the PID for email. |
|
2810 CSmsPDU& pdu1 = email1->SmsPDU(); |
|
2811 if( pdu1.ProtocolIdentifierPresent() ) |
|
2812 { |
|
2813 pdu1.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking); |
|
2814 pdu1.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice); |
|
2815 pdu1.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail); |
|
2816 } |
|
2817 |
|
2818 // create a new SMS header |
|
2819 delete iSmsHeader; |
|
2820 iSmsHeader = NULL; |
|
2821 CleanupStack::Pop(email1); |
|
2822 |
|
2823 TRAPD(err,iSmsHeader = CSmsHeader::NewL(email1)) |
|
2824 if(err) |
|
2825 { |
|
2826 delete email1; |
|
2827 } |
|
2828 |
|
2829 // Check that the header is correct... |
|
2830 // Email fields... |
|
2831 const CSmsEmailFields& fields10 = iSmsHeader->EmailFields(); |
|
2832 if(!fields10.HasAddress()) |
|
2833 { |
|
2834 CleanupStack::PopAndDestroy(&fs); |
|
2835 Session().CleanupEntryPop(); |
|
2836 Session().RemoveEntry(id); |
|
2837 return EFail; |
|
2838 } |
|
2839 if(fields10.Addresses().MdcaCount()!=1) |
|
2840 { |
|
2841 CleanupStack::PopAndDestroy(&fs); |
|
2842 Session().CleanupEntryPop(); |
|
2843 Session().RemoveEntry(id); |
|
2844 return EFail; |
|
2845 } |
|
2846 if(fields10.Addresses().MdcaPoint(0).Compare(KTestEmailAddress1) != 0) |
|
2847 { |
|
2848 CleanupStack::PopAndDestroy(&fs); |
|
2849 Session().CleanupEntryPop(); |
|
2850 Session().RemoveEntry(id); |
|
2851 return EFail; |
|
2852 } |
|
2853 if(fields10.Subject().Compare(KTestEmailSubject1) != 0) |
|
2854 { |
|
2855 CleanupStack::PopAndDestroy(&fs); |
|
2856 Session().CleanupEntryPop(); |
|
2857 Session().RemoveEntry(id); |
|
2858 return EFail; |
|
2859 } |
|
2860 |
|
2861 // Message body... |
|
2862 CSmsBufferBase& body1 = iSmsHeader->Message().Buffer(); |
|
2863 TInt length1 = body1.Length(); |
|
2864 HBufC* buf1 = HBufC::NewLC(length1); |
|
2865 TPtr bufPtr1(buf1->Des()); |
|
2866 body1.Extract(bufPtr1, 0, length1); |
|
2867 |
|
2868 if(bufPtr1.Compare(KTestEmailBody1) != 0) |
|
2869 { |
|
2870 CleanupStack::PopAndDestroy(2,buf1); |
|
2871 Session().CleanupEntryPop(); |
|
2872 Session().RemoveEntry(id); |
|
2873 return EFail; |
|
2874 } |
|
2875 |
|
2876 CleanupStack::PopAndDestroy(buf1); |
|
2877 |
|
2878 // Test corrupt email. |
|
2879 _LIT(KTestEmailBody2, "user@domain1.domain2##a subjectsome body text"); |
|
2880 _LIT(KTestEmailMessage2, "user@domain1.domain2##a subjectsome body text"); |
|
2881 |
|
2882 CSmsMessage* email2 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse); |
|
2883 CleanupStack::PushL(email2); |
|
2884 |
|
2885 CSmsBufferBase& buffer2 = email2->Buffer(); |
|
2886 buffer2.Reset(); |
|
2887 buffer2.InsertL(0, KTestEmailMessage2()); |
|
2888 |
|
2889 // Set the PID for email. |
|
2890 CSmsPDU& pdu2 = email2->SmsPDU(); |
|
2891 if( pdu2.ProtocolIdentifierPresent() ) |
|
2892 { |
|
2893 pdu2.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking); |
|
2894 pdu2.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice); |
|
2895 pdu2.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail); |
|
2896 } |
|
2897 |
|
2898 // create a new SMS header |
|
2899 delete iSmsHeader; |
|
2900 iSmsHeader = NULL; |
|
2901 iSmsHeader = CSmsHeader::NewL(email2); |
|
2902 CleanupStack::Pop(email2); |
|
2903 |
|
2904 // Check that the header is correct... |
|
2905 // Email fields... |
|
2906 const CSmsEmailFields& fields11 = iSmsHeader->EmailFields(); |
|
2907 if(fields11.HasAddress()) |
|
2908 { |
|
2909 CleanupStack::PopAndDestroy(&fs); |
|
2910 Session().CleanupEntryPop(); |
|
2911 Session().RemoveEntry(id); |
|
2912 return EFail; |
|
2913 } |
|
2914 if(fields11.Addresses().MdcaCount()!=0) |
|
2915 { |
|
2916 CleanupStack::PopAndDestroy(&fs); |
|
2917 Session().CleanupEntryPop(); |
|
2918 Session().RemoveEntry(id); |
|
2919 return EFail; |
|
2920 } |
|
2921 if(fields11.Subject().Compare(KNullDesC) != 0) |
|
2922 { |
|
2923 CleanupStack::PopAndDestroy(&fs); |
|
2924 Session().CleanupEntryPop(); |
|
2925 Session().RemoveEntry(id); |
|
2926 return EFail; |
|
2927 } |
|
2928 if(fields11.Length() != 0) |
|
2929 { |
|
2930 CleanupStack::PopAndDestroy(&fs); |
|
2931 Session().CleanupEntryPop(); |
|
2932 Session().RemoveEntry(id); |
|
2933 return EFail; |
|
2934 } |
|
2935 |
|
2936 // Message body... |
|
2937 CSmsBufferBase& body2 = iSmsHeader->Message().Buffer(); |
|
2938 TInt length2 = body2.Length(); |
|
2939 HBufC* buf2 = HBufC::NewLC(length2); |
|
2940 TPtr bufPtr2(buf2->Des()); |
|
2941 body2.Extract(bufPtr2, 0, length2); |
|
2942 |
|
2943 if(bufPtr2.Compare(KTestEmailBody2) != 0) |
|
2944 { |
|
2945 CleanupStack::PopAndDestroy(2,buf2); |
|
2946 Session().CleanupEntryPop(); |
|
2947 Session().RemoveEntry(id); |
|
2948 return EFail; |
|
2949 } |
|
2950 |
|
2951 // delete email1; |
|
2952 CleanupStack::PopAndDestroy(buf2); |
|
2953 |
|
2954 CleanupStack::PopAndDestroy(&fs); |
|
2955 |
|
2956 Session().CleanupEntryPop(); |
|
2957 Session().RemoveEntry(id); |
|
2958 |
|
2959 iTestStep.INFO_PRINTF1(_L("Test CSmsHeader Passed.")); |
|
2960 |
|
2961 return EPass; |
|
2962 } |
|
2963 |
|
2964 _LIT(KGetDescriptionTestMessage, "Finland to win the ice hockey world champs"); |
|
2965 |
|
2966 #include <emsuserpromptie.h> |
|
2967 #include <emssoundie.h> |
|
2968 _LIT8(KUserMelody, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" |
|
2969 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"); // Melody file |
|
2970 |
|
2971 _LIT(KTestEmsVariousMsg1,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); |
|
2972 |
|
2973 TVerdict CSmutTest::TestSmsEmsExtensionsL() |
|
2974 // Test the modifications for EMS |
|
2975 { |
|
2976 |
|
2977 iTestStep.INFO_PRINTF1(_L("Testing EMS Extensions...")); |
|
2978 |
|
2979 // Set up a standard sms message first |
|
2980 iRichText->Reset(); |
|
2981 iRichText->InsertL(0, KTestEmsVariousMsg1); |
|
2982 // Make a Deliver so we can get at the protocol identifier |
|
2983 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); |
|
2984 CleanupStack::PushL(header); |
|
2985 |
|
2986 // Create 2 EMS Melody objects followed by a User Prompt Indicator |
|
2987 |
|
2988 // Create first Melody EMS object |
|
2989 CEmsSoundIE* object = CEmsSoundIE::NewL(KUserMelody()); |
|
2990 CleanupStack::PushL(object); |
|
2991 // Insert the sound object after the 5th byte of the message |
|
2992 object->SetStartPosition(5); |
|
2993 // Add it to the CSmsMessage |
|
2994 header->Message().AddEMSInformationElementL(*object); |
|
2995 CleanupStack::PopAndDestroy(object); |
|
2996 |
|
2997 // Create a second Melody EMS object |
|
2998 CEmsSoundIE* object2 = CEmsSoundIE::NewL(KUserMelody()); |
|
2999 CleanupStack::PushL(object2); |
|
3000 // Insert the sound object after the 5th byte of the message |
|
3001 object2->SetStartPosition(5); |
|
3002 // Add it to the CSmsMessage |
|
3003 header->Message().AddEMSInformationElementL(*object2); |
|
3004 CleanupStack::PopAndDestroy(object2); |
|
3005 |
|
3006 // Create a user prompt indicator and tell it there are 2 EMS objects |
|
3007 CEmsUserPrompt* prompt = CEmsUserPrompt::NewL(2); |
|
3008 CleanupStack::PushL(prompt); |
|
3009 // Add it after the 5th byte of the message |
|
3010 prompt->SetStartPosition(5); |
|
3011 // Add it to the CSmsMessage |
|
3012 header->Message().AddEMSInformationElementL(*prompt); |
|
3013 CleanupStack::PopAndDestroy(prompt); |
|
3014 |
|
3015 // Test the TMsvSmsEntry derived class |
|
3016 TMsvSmsEntry entry; |
|
3017 // Check the Existing sms message for User Prompt indicator |
|
3018 const RPointerArray<const CEmsInformationElement>& emsElements= header->Message().GetEMSInformationElementsL(); |
|
3019 // Loop through the array checking for a user prompt indicator element |
|
3020 for(TInt i=0;i<emsElements.Count();i++) |
|
3021 { |
|
3022 if(emsElements[i]->Identifier() == CSmsInformationElement::ESmsEnhancedUserPromptIndicator) |
|
3023 { |
|
3024 // Set user prompt indicator bit in iMtmData2 |
|
3025 entry.SetUserPromptIndicator(ETrue); |
|
3026 break; |
|
3027 } |
|
3028 } |
|
3029 // Check the user prompt indicator is set |
|
3030 if(!entry.UserPromptIndicator()) |
|
3031 { |
|
3032 iTestStep.ERR_PRINTF1(_L("Cannot set user prompt.")); |
|
3033 CleanupStack::PopAndDestroy(header); |
|
3034 return EFail; |
|
3035 } |
|
3036 // Check we can clear it |
|
3037 entry.SetUserPromptIndicator(EFalse); |
|
3038 if(entry.UserPromptIndicator()) |
|
3039 { |
|
3040 iTestStep.ERR_PRINTF1(_L("Cannot clear user prompt.")); |
|
3041 CleanupStack::PopAndDestroy(header); |
|
3042 return EFail; |
|
3043 } |
|
3044 |
|
3045 // Convenient reference to PDU |
|
3046 CSmsDeliver& pdu = STATIC_CAST(CSmsDeliver&,header->Message().SmsPDU()); |
|
3047 // Set up the Protocol Identifier to read back |
|
3048 pdu.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType); |
|
3049 pdu.SetShortMessageType(TSmsProtocolIdentifier::ESmsReplaceShortMessageType1); |
|
3050 |
|
3051 // Read from the pdu and set the TMsvSmsEntry copy |
|
3052 entry.SetProtocolIdentifier(*pdu.ProtocolIdentifier()); |
|
3053 // Read it back and check the value |
|
3054 if(entry.ProtocolIdentifier() != *pdu.ProtocolIdentifier()) |
|
3055 { |
|
3056 iTestStep.ERR_PRINTF1(_L("TMsvSmsEntry::ProtocolIdentifier corrupt.")); |
|
3057 CleanupStack::PopAndDestroy(header); |
|
3058 return EFail; |
|
3059 } |
|
3060 |
|
3061 CleanupStack::PopAndDestroy(); //header |
|
3062 |
|
3063 iTestStep.INFO_PRINTF1(_L("Test EMS Extensions Passed.")); |
|
3064 |
|
3065 return EPass; |
|
3066 |
|
3067 } |
|
3068 |
|
3069 TVerdict CSmutTest::TestSmsUtilitiesL() |
|
3070 { |
|
3071 iTestStep.INFO_PRINTF1(_L("Testing TSmsUtilities....")); |
|
3072 |
|
3073 iRichText->Reset(); |
|
3074 iRichText->InsertL(0, KGetDescriptionTestMessage); |
|
3075 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
3076 CleanupStack::PushL(header); |
|
3077 |
|
3078 if(!TestSmsUtilities1L(*header)) |
|
3079 { |
|
3080 CleanupStack::PopAndDestroy(header); //header |
|
3081 return EFail; |
|
3082 } |
|
3083 |
|
3084 if(!TestSmsUtilities2L(*header)) |
|
3085 { |
|
3086 CleanupStack::PopAndDestroy(header); //header |
|
3087 return EFail; |
|
3088 } |
|
3089 |
|
3090 if(!TestSmsUtilities3L(*header)) |
|
3091 { |
|
3092 CleanupStack::PopAndDestroy(header); //header |
|
3093 return EFail; |
|
3094 } |
|
3095 |
|
3096 CleanupStack::PopAndDestroy(); //header |
|
3097 |
|
3098 iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities Passed.")); |
|
3099 |
|
3100 return EPass; |
|
3101 } |
|
3102 |
|
3103 TBool CSmutTest::TestSmsUtilities1L(CSmsHeader& aHeader) |
|
3104 /** |
|
3105 * @test Tests TSmsUtilities::GetDescription() |
|
3106 */ |
|
3107 { |
|
3108 |
|
3109 iTestStep.INFO_PRINTF1(_L("Testing TSmsUtilities::GetDescription() - use varying values to test trucation")); |
|
3110 |
|
3111 RResourceFile resFile; |
|
3112 iSmsTest.OpenResourceFileL(KSmsResourceFile, resFile); |
|
3113 CleanupClosePushL(resFile); |
|
3114 |
|
3115 //Test GetDescription() |
|
3116 |
|
3117 TPtrC buf(KGetDescriptionTestMessage); |
|
3118 const TInt maxLength = buf.Length(); |
|
3119 HBufC* desBuf = HBufC::NewLC(maxLength); |
|
3120 TPtr desc = desBuf->Des(); |
|
3121 |
|
3122 for( TInt length=1; length <= maxLength; ++length ) |
|
3123 { |
|
3124 iTestStep.INFO_PRINTF2(_L("-> trucating to length %d"), length); |
|
3125 |
|
3126 desc.Zero(); |
|
3127 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, length)); |
|
3128 |
|
3129 iTestStep.INFO_PRINTF2(_L("-> GetDescription() : %S"), &desc); |
|
3130 |
|
3131 if(desc.Length()>length) |
|
3132 { |
|
3133 CleanupStack::PopAndDestroy(2,desBuf); |
|
3134 return EFalse; |
|
3135 } |
|
3136 if(desc != buf.Left(desc.Length()) ) //this won't work if buf contains CEditableText::EParagraphDelimiter |
|
3137 { |
|
3138 CleanupStack::PopAndDestroy(2,desBuf); |
|
3139 return EFalse; |
|
3140 } |
|
3141 } |
|
3142 desc.Zero(); |
|
3143 |
|
3144 //Test Special Message Indication |
|
3145 |
|
3146 iTestStep.INFO_PRINTF1(_L("Testing Special Message Indications...")); |
|
3147 |
|
3148 CSmsPDU& pdu = aHeader.Message().SmsPDU(); |
|
3149 CSmsUserData& userData = pdu.UserData(); |
|
3150 TBuf8<2> msgInd; |
|
3151 msgInd.Copy(_L("AA")); |
|
3152 |
|
3153 //Add information element |
|
3154 msgInd[0] = TSmsUtilities::EEmailMessageWaiting; |
|
3155 msgInd[1] = 0x00000001; //1 message |
|
3156 |
|
3157 iTestStep.INFO_PRINTF1(_L("\tAdding information element (Email) to UD")); |
|
3158 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
3159 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc)); |
|
3160 if(!CheckDescriptionL(resFile, R_MESSAGE_INDICATION_EMAIL_ONE, desc, 2)) |
|
3161 { |
|
3162 CleanupStack::PopAndDestroy(2,desBuf); |
|
3163 return EFalse; |
|
3164 } |
|
3165 |
|
3166 // Set the maximum length of desc to be less than the description. |
|
3167 // The description should truncate to fit into desc. |
|
3168 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, 10)); |
|
3169 if(desc.Length() != 10) //Check that the Length of desc is the specified max length. |
|
3170 { |
|
3171 CleanupStack::PopAndDestroy(2,desBuf); |
|
3172 return EFalse; |
|
3173 } |
|
3174 |
|
3175 if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EVoiceMessageWaiting, R_MESSAGE_INDICATION_VOICEMAIL_ONE)) |
|
3176 { |
|
3177 CleanupStack::PopAndDestroy(2, &resFile); |
|
3178 return EFalse; |
|
3179 } |
|
3180 |
|
3181 if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EFaxMessageWaiting, R_MESSAGE_INDICATION_FAX_ONE)) |
|
3182 { |
|
3183 CleanupStack::PopAndDestroy(2, &resFile); |
|
3184 return EFalse; |
|
3185 } |
|
3186 if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EEmailMessageWaiting, R_MESSAGE_INDICATION_EMAIL_ONE)) |
|
3187 { |
|
3188 CleanupStack::PopAndDestroy(2, &resFile); |
|
3189 return EFalse; |
|
3190 } |
|
3191 if(!TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EOtherMessageWaiting, R_MESSAGE_INDICATION_OTHER_ONE)) |
|
3192 { |
|
3193 CleanupStack::PopAndDestroy(2, &resFile); |
|
3194 return EFalse; |
|
3195 } |
|
3196 |
|
3197 //Test video message waiting indication |
|
3198 iTestStep.INFO_PRINTF1(_L("Testing video message waiting indications...")); |
|
3199 if(!TestVideoMessageIndicationPduL(resFile, aHeader, R_MESSAGE_INDICATION_VIDEOMESSAGE_ONE)) |
|
3200 { |
|
3201 CleanupStack::PopAndDestroy(2, &resFile); |
|
3202 return EFalse; |
|
3203 } |
|
3204 |
|
3205 //Test enhanced voice mail waiting indication |
|
3206 iTestStep.INFO_PRINTF1(_L("Testing enhanced voice mail indications...")); |
|
3207 if(!TestEnhancedVoiceMailIndicationPduL(resFile, aHeader, R_MESSAGE_INDICATION_ENHANCED_VOICEMAIL_ONE)) |
|
3208 { |
|
3209 CleanupStack::PopAndDestroy(2, &resFile); |
|
3210 return EFalse; |
|
3211 } |
|
3212 |
|
3213 //Test multiple indications. |
|
3214 iTestStep.INFO_PRINTF1(_L("Testing multiple indications...")); |
|
3215 //Add a video message waiting notification (9 video messages) |
|
3216 CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)); |
|
3217 |
|
3218 TBool toStore=ETrue; |
|
3219 TUint8 messageCount=9; |
|
3220 TUint8 totalMessageCount=messageCount; |
|
3221 TSmsMessageIndicationType messageIndicationType=EGsmSmsExtendedMessageTypeWaiting; |
|
3222 TExtendedSmsIndicationType extendedType=EGsmSmsVideoMessageWaiting; |
|
3223 TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1; |
|
3224 |
|
3225 operations.RemoveAllSpecialMessageIndicationsL(); |
|
3226 operations.AddSpecialMessageIndicationL(toStore,messageIndicationType, |
|
3227 extendedType,messageProfileType,messageCount); |
|
3228 //Add an enhanced voicemail notification (5 enhanced voice mails) |
|
3229 CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation)); |
|
3230 enhancedOperations.RemoveEnhancedVoiceMailIEL(); |
|
3231 //Create CEnhancedVoiceMailNotification |
|
3232 CEnhancedVoiceMailNotification* enhancedVoiceMailNotification=CEnhancedVoiceMailNotification::NewL(); |
|
3233 CleanupStack::PushL(enhancedVoiceMailNotification); |
|
3234 messageCount=5; |
|
3235 totalMessageCount+=messageCount; |
|
3236 enhancedVoiceMailNotification->SetNumberOfVoiceMessages(messageCount); |
|
3237 enhancedOperations.AddEnhancedVoiceMailIEL(*enhancedVoiceMailNotification); |
|
3238 CleanupStack::PopAndDestroy(enhancedVoiceMailNotification); |
|
3239 |
|
3240 //Add an email message waiting notification (1 email) |
|
3241 msgInd[0] = TSmsUtilities::EEmailMessageWaiting; |
|
3242 msgInd[1] = 0x00000001; |
|
3243 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
3244 totalMessageCount++; |
|
3245 |
|
3246 //Add a fax waiting notification (2 faxes) |
|
3247 msgInd[0] = TSmsUtilities::EFaxMessageWaiting; |
|
3248 msgInd[1] = 0x00000002; |
|
3249 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
3250 totalMessageCount+=2; |
|
3251 |
|
3252 //Add a voice mail waiting notification (3 voice mails) |
|
3253 msgInd[0] = TSmsUtilities::EVoiceMessageWaiting; |
|
3254 msgInd[1] = 0x00000003; |
|
3255 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
3256 totalMessageCount+=3; |
|
3257 |
|
3258 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc)); |
|
3259 if(!CheckDescriptionL(resFile, R_MESSAGE_INDICATION_OTHER_MANY, desc, totalMessageCount)) |
|
3260 { |
|
3261 CleanupStack::PopAndDestroy(2, &resFile); |
|
3262 return EFalse; |
|
3263 } |
|
3264 iTestStep.INFO_PRINTF1(_L("Passed")); |
|
3265 |
|
3266 CleanupStack::PopAndDestroy(2, &resFile); |
|
3267 |
|
3268 return ETrue; |
|
3269 } |
|
3270 |
|
3271 CSmsMessage* CSmutTest::CreateSmsMessageLC(const TDesC8& aHexPdu) const |
|
3272 { |
|
3273 HBufC8* binaryPdu = ConvertToBinaryLC(aHexPdu); |
|
3274 TGsmSms pdu; |
|
3275 pdu.SetPdu(*binaryPdu); |
|
3276 CleanupStack::PopAndDestroy(binaryPdu); |
|
3277 CSmsMessage* message = CSmsMessage::NewL(iSmsTest.FileSession(), pdu, CSmsBuffer::NewL()); |
|
3278 CleanupStack::PushL(message); |
|
3279 return message; |
|
3280 } |
|
3281 |
|
3282 HBufC8* CSmutTest::ConvertToBinaryLC(const TDesC8& aHex) const |
|
3283 { |
|
3284 const TInt len = aHex.Length(); |
|
3285 if (len % 2 != 0) |
|
3286 User::Leave(KErrArgument); |
|
3287 |
|
3288 HBufC8* pdu = HBufC8::NewLC(len / 2); |
|
3289 TPtr8 ptr(pdu->Des()); |
|
3290 |
|
3291 for (TInt i = 0; i < len; i += 2) |
|
3292 { |
|
3293 TLex8 lex(aHex.Mid(i, 2)); |
|
3294 TUint8 val; |
|
3295 User::LeaveIfError(lex.Val(val, EHex)); |
|
3296 ptr.Append(val); |
|
3297 } |
|
3298 |
|
3299 return pdu; |
|
3300 } |
|
3301 |
|
3302 _LIT(KGetDetailsResult, "\t\tNum In: \"%S\" Name Out: \"%S\""); |
|
3303 |
|
3304 TBool CSmutTest::TestSmsUtilities2L(CSmsHeader& aHeader) |
|
3305 { |
|
3306 //Test GetDetails |
|
3307 |
|
3308 iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::GetDetails()")); |
|
3309 |
|
3310 _LIT(KLongTel, "+378458932945284754456302945754938539"); |
|
3311 |
|
3312 _LIT(KMikkoTel, "+358503367709"); |
|
3313 _LIT(KMikkoFirst, "Mikko"); |
|
3314 _LIT(KMikkoLast, "Rintala"); |
|
3315 _LIT(KMikkoEmail, "mikko@nokia.com"); |
|
3316 |
|
3317 _LIT(KUnqualifiedTel, "8503367710"); |
|
3318 _LIT(KUnqualifiedTel1, "+358503367710"); |
|
3319 _LIT(KUnqualifiedFirst, "Unq"); |
|
3320 _LIT(KUnqualifiedLast, "Wallified"); |
|
3321 _LIT(KUnqualifiedEmail, "unqalified@diysurgery.com"); |
|
3322 |
|
3323 // _LIT(KAnthonyTel, " + 4 "); //is valid |
|
3324 _LIT(KAnthonyTel, "+ 7 "); //is valid |
|
3325 _LIT(KAnthonyFirst, "Anthony"); |
|
3326 _LIT(KAnthonyLast, "Alexander"); |
|
3327 _LIT(KAnthonyEmail, "test@symbian.com"); |
|
3328 |
|
3329 _LIT(KHarriTel, "+8"); //is valid |
|
3330 _LIT(KHarriFirst, "HarriHarriHarriHarriHarriHarriHarri"); |
|
3331 _LIT(KHarriLast, "RäisänenRäisänenRäisänenRäisänenRäisänen"); |
|
3332 _LIT(KHarriEmail, "harri@nokia.com"); |
|
3333 |
|
3334 _LIT(KDupTel, "+44207435676"); |
|
3335 _LIT(KDupFirst1, "Keval"); |
|
3336 _LIT(KDupLast1, "Pindoria"); |
|
3337 _LIT(KDupFirst2, "Jackie"); |
|
3338 _LIT(KDupLast2, "Chan"); |
|
3339 |
|
3340 _LIT(KBadTel1, "This is a bad Telephone"); |
|
3341 _LIT(KBadTel2, " 5 "); |
|
3342 _LIT(KBadTel3, "5+"); |
|
3343 _LIT(KBadTel4, "*5565434556"); |
|
3344 |
|
3345 _LIT(KBadFirst, "BadFirstName"); |
|
3346 _LIT(KBadLast, "BadLastName"); |
|
3347 |
|
3348 _LIT(KNoNameTel, "+449005434"); |
|
3349 |
|
3350 _LIT(KDummy, "+44444"); |
|
3351 |
|
3352 TRAPD(err, iSmsTest.DeleteContactsFileL()); |
|
3353 |
|
3354 if(err != KErrNotFound && err != KErrNone) |
|
3355 { |
|
3356 return EFalse; |
|
3357 } |
|
3358 |
|
3359 iTestStep.INFO_PRINTF1(_L("\tTesting without contacts")); |
|
3360 |
|
3361 //Simple test |
|
3362 TPtrC testTel(KMikkoTel); |
|
3363 TBuf<KSmsDetailsLength> details; |
|
3364 |
|
3365 aHeader.Message().SetToFromAddressL(testTel); |
|
3366 TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
3367 iTestStep.INFO_PRINTF3(KGetDetailsResult, &testTel, &details); |
|
3368 if(testTel.FindF(details) == KErrNotFound) //details should contain testTel as there is no contact. |
|
3369 { |
|
3370 return EFalse; |
|
3371 } |
|
3372 |
|
3373 if(!TestInvalidContact(testTel, details)) |
|
3374 { |
|
3375 return EFalse; |
|
3376 } |
|
3377 |
|
3378 testTel.Set(KAnthonyTel); |
|
3379 aHeader.Message().SetToFromAddressL(testTel); |
|
3380 err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
3381 iTestStep.INFO_PRINTF3(KGetDetailsResult, &testTel, &details); |
|
3382 if(testTel.FindF(details) == KErrNotFound) //details should contain testTel as there is no contact. |
|
3383 { |
|
3384 return EFalse; |
|
3385 } |
|
3386 if(err != KErrNone) |
|
3387 { |
|
3388 return EFalse; |
|
3389 } |
|
3390 |
|
3391 if(!TestInvalidContact(testTel, details)) |
|
3392 { |
|
3393 return EFalse; |
|
3394 } |
|
3395 |
|
3396 // Testing with long telephone number. |
|
3397 // The telephone number should truncate to fit into details. |
|
3398 if(!TestInvalidContact(KLongTel, details)) |
|
3399 { |
|
3400 return EFalse; |
|
3401 } |
|
3402 if(details.Length() != KSmsDetailsLength) //Length of details should be the default max length. |
|
3403 { |
|
3404 return EFalse; |
|
3405 } |
|
3406 |
|
3407 //Add contacts |
|
3408 |
|
3409 iTestStep.INFO_PRINTF1(_L("\tAdding Contacts")); |
|
3410 |
|
3411 //Adding good telephone numbers |
|
3412 |
|
3413 TContactItemId contId = iSmsTest.CreateContactL(KAnthonyFirst, KAnthonyLast, KAnthonyTel, KAnthonyEmail); |
|
3414 if(contId == KNullContactId) |
|
3415 { |
|
3416 return EFalse; |
|
3417 } |
|
3418 |
|
3419 contId = iSmsTest.CreateContactL(KMikkoFirst, KMikkoLast, KMikkoTel, KMikkoEmail); |
|
3420 if(contId == KNullContactId) |
|
3421 { |
|
3422 return EFalse; |
|
3423 } |
|
3424 |
|
3425 contId = iSmsTest.CreateContactL(KUnqualifiedFirst, KUnqualifiedLast, KUnqualifiedTel, KUnqualifiedEmail); |
|
3426 if(contId == KNullContactId) |
|
3427 { |
|
3428 return EFalse; |
|
3429 } |
|
3430 |
|
3431 contId = iSmsTest.CreateContactL(KHarriFirst, KHarriLast, KHarriTel, KHarriEmail); |
|
3432 if(contId == KNullContactId) |
|
3433 { |
|
3434 return EFalse; |
|
3435 } |
|
3436 |
|
3437 //Adding a duplicate telephone |
|
3438 |
|
3439 contId = iSmsTest.CreateContactL(KDupFirst1, KDupLast1, KDupTel, KNullDesC); |
|
3440 if(contId == KNullContactId) |
|
3441 { |
|
3442 return EFalse; |
|
3443 } |
|
3444 |
|
3445 contId = iSmsTest.CreateContactL(KDupFirst2, KDupLast2, KDupTel, KNullDesC); |
|
3446 if(contId == KNullContactId) |
|
3447 { |
|
3448 return EFalse; |
|
3449 } |
|
3450 |
|
3451 //Adding bad telephone numbers |
|
3452 |
|
3453 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel1, KNullDesC); |
|
3454 if(contId == KNullContactId) |
|
3455 { |
|
3456 return EFalse; |
|
3457 } |
|
3458 |
|
3459 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel2, KNullDesC); |
|
3460 if(contId == KNullContactId) |
|
3461 { |
|
3462 return EFalse; |
|
3463 } |
|
3464 |
|
3465 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel3, KNullDesC); |
|
3466 if(contId == KNullContactId) |
|
3467 { |
|
3468 return EFalse; |
|
3469 } |
|
3470 |
|
3471 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel4, KNullDesC); |
|
3472 if(contId == KNullContactId) |
|
3473 { |
|
3474 return EFalse; |
|
3475 } |
|
3476 |
|
3477 //Adding no name contact |
|
3478 |
|
3479 contId = iSmsTest.CreateContactL(KNullDesC, KNullDesC, KNoNameTel, KNullDesC); |
|
3480 if(contId == KNullContactId) |
|
3481 { |
|
3482 return EFalse; |
|
3483 } |
|
3484 |
|
3485 iTestStep.INFO_PRINTF1(_L("\tTesting with valid telephone numbers")); |
|
3486 |
|
3487 if(!TestValidTel(KAnthonyTel, KAnthonyFirst, KAnthonyLast, KNullDesC, details)) |
|
3488 { |
|
3489 return EFalse; |
|
3490 } |
|
3491 |
|
3492 if(!TestValidTel(KMikkoTel, KMikkoFirst, KMikkoLast, KNullDesC, details)) |
|
3493 { |
|
3494 return EFalse; |
|
3495 } |
|
3496 // Test below was added for INC040050. The number of digits matched |
|
3497 // against in GetDetails changed and resulted in undesirable behaviour |
|
3498 // when searching for an unqualified number with a fully qualified number. |
|
3499 if(!TestValidTel(KUnqualifiedTel1, KUnqualifiedFirst, KUnqualifiedLast, KNullDesC, details)) |
|
3500 { |
|
3501 return EFalse; |
|
3502 } |
|
3503 if(!TestValidTel(KHarriTel, _L("Räisänen"), KNullDesC, _L("Harri"), details)) |
|
3504 { |
|
3505 return EFalse; |
|
3506 } |
|
3507 |
|
3508 iTestStep.INFO_PRINTF1(_L("\tTesting with invalid telephone numbers")); |
|
3509 |
|
3510 if(!TestInvalidTelephone(KBadTel1, details)) |
|
3511 { |
|
3512 return EFalse; |
|
3513 } |
|
3514 if(!TestInvalidTelephone(KBadTel2, details)) |
|
3515 { |
|
3516 return EFalse; |
|
3517 } |
|
3518 if(!TestInvalidTelephone(KBadTel3, details)) |
|
3519 { |
|
3520 return EFalse; |
|
3521 } |
|
3522 if(!TestInvalidTelephone(KBadTel4, details)) |
|
3523 { |
|
3524 return EFalse; |
|
3525 } |
|
3526 |
|
3527 iTestStep.INFO_PRINTF1(_L("\tTesting with duplicate telephone numbers")); |
|
3528 |
|
3529 if(!TestDuplicateContact(KDupTel, details)) |
|
3530 { |
|
3531 return EFalse; |
|
3532 } |
|
3533 |
|
3534 iTestStep.INFO_PRINTF1(_L("\tTesting No Names telephone number")); |
|
3535 |
|
3536 if(!TestInvalidContact(KNoNameTel, details)) |
|
3537 { |
|
3538 return EFalse; |
|
3539 } |
|
3540 if(!TestInvalidContact(KDummy, details)) |
|
3541 { |
|
3542 return EFalse; |
|
3543 } |
|
3544 |
|
3545 iTestStep.INFO_PRINTF1(_L("Passed")); |
|
3546 |
|
3547 return ETrue; |
|
3548 } |
|
3549 |
|
3550 TBool CSmutTest::TestValidTel(const TDesC& aTel, const TDesC& aExpect1, const TDesC& aExpect2, const TDesC& aNotExpect, TDes& rDetails) |
|
3551 { |
|
3552 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, rDetails); |
|
3553 iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &rDetails); |
|
3554 |
|
3555 if (aExpect1.Length()) |
|
3556 { |
|
3557 if(rDetails.FindF(aExpect1) == KErrNotFound) |
|
3558 { |
|
3559 return EFalse; |
|
3560 } |
|
3561 } |
|
3562 |
|
3563 |
|
3564 if (aExpect2.Length()) |
|
3565 { |
|
3566 if(rDetails.FindF(aExpect2) == KErrNotFound) |
|
3567 { |
|
3568 return EFalse; |
|
3569 } |
|
3570 } |
|
3571 |
|
3572 |
|
3573 if (aNotExpect.Length()) |
|
3574 { |
|
3575 if(rDetails.FindF(aNotExpect) != KErrNotFound) |
|
3576 { |
|
3577 return EFalse; |
|
3578 } |
|
3579 } |
|
3580 |
|
3581 if(err != KErrNone) |
|
3582 { |
|
3583 return EFalse; |
|
3584 } |
|
3585 |
|
3586 return ETrue; |
|
3587 } |
|
3588 |
|
3589 TBool CSmutTest::TestInvalidTelephone(const TDesC& aTel, TDes& aDetails) |
|
3590 { |
|
3591 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
3592 iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails); |
|
3593 if(aTel.FindF(aDetails) == KErrNotFound) //aDetails should contain aTel as aTel is invalid. |
|
3594 { |
|
3595 return EFalse; |
|
3596 } |
|
3597 if(err != KErrNone) |
|
3598 { |
|
3599 return EFalse; |
|
3600 } |
|
3601 |
|
3602 return ETrue; |
|
3603 } |
|
3604 |
|
3605 TBool CSmutTest::TestInvalidContact(const TDesC& aTel, TDes& aDetails) |
|
3606 { |
|
3607 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
3608 iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails); |
|
3609 |
|
3610 if(aTel.FindF(aDetails) == KErrNotFound) //aDetails should contain aTel as the contact is invalid. |
|
3611 { |
|
3612 return EFalse; |
|
3613 } |
|
3614 if(err != KErrNone) |
|
3615 { |
|
3616 return EFalse; |
|
3617 } |
|
3618 return ETrue; |
|
3619 } |
|
3620 |
|
3621 TBool CSmutTest::TestDuplicateContact(const TDesC& aTel, TDes& aDetails) |
|
3622 { |
|
3623 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
3624 iTestStep.INFO_PRINTF3(KGetDetailsResult, &aTel, &aDetails); |
|
3625 if(aTel.FindF(aDetails) == KErrNotFound) //aDetails should contain aTel as there is duplicate contact. |
|
3626 { |
|
3627 return EFalse; |
|
3628 } |
|
3629 if(err != KErrNone) |
|
3630 { |
|
3631 return EFalse; |
|
3632 } |
|
3633 |
|
3634 return ETrue; |
|
3635 } |
|
3636 |
|
3637 TBool CSmutTest::TestSmsUtilities3L(CSmsHeader& aHeader) |
|
3638 { |
|
3639 iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::ServiceIdL()")); |
|
3640 |
|
3641 TMsvId id2 = KMsvNullIndexEntryId; |
|
3642 // First tested function is ServiceIdL() |
|
3643 TSmsUtilities::ServiceIdL(*iSmsTest.iMsvEntry, id2); |
|
3644 if(id2 != iSmsTest.iSmsServiceId) |
|
3645 { |
|
3646 return EFalse; |
|
3647 } |
|
3648 iTestStep.INFO_PRINTF1(_L("\tPassed")); |
|
3649 |
|
3650 iTestStep.INFO_PRINTF1(_L("Test TSmsUtilities::PopulateMsgEntry()")); |
|
3651 TMsvEntry entry; |
|
3652 TSmsUtilities::PopulateMsgEntry(entry,aHeader.Message(), iSmsTest.iSmsServiceId); |
|
3653 // todo More tests |
|
3654 iTestStep.INFO_PRINTF1(_L("\tPassed")); |
|
3655 |
|
3656 return ETrue; |
|
3657 } |
|
3658 |
|
3659 TBool CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TSmsUtilities::TSmsUtilitiesSpecialMessageType aMessageType, TInt aId) |
|
3660 { |
|
3661 iTestStep.INFO_PRINTF2(_L("\tTestSpecialSmsMessageIndicationPduL Type=%d..."), aMessageType); |
|
3662 |
|
3663 const TUint8 KMaxCount = 0xFF; |
|
3664 for (TUint8 i = 0; i < KMaxCount; i++) |
|
3665 { |
|
3666 TInt resId = aId; |
|
3667 if (i != 1) |
|
3668 resId++; |
|
3669 |
|
3670 if(!TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType), i, resId)) |
|
3671 { |
|
3672 return EFalse; |
|
3673 } |
|
3674 if(!TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType | 0x80), i, resId)) |
|
3675 { |
|
3676 return EFalse; |
|
3677 } |
|
3678 } |
|
3679 |
|
3680 iTestStep.INFO_PRINTF1(_L("Passed")); |
|
3681 |
|
3682 return ETrue; |
|
3683 } |
|
3684 |
|
3685 TBool CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TUint8 aMessageType, TUint8 aMessageCount, TInt aId) |
|
3686 { |
|
3687 _LIT8(KFaxIndicationPdu, "440B916407586704F900002010011153710406040102810200"); |
|
3688 const TInt KIndicationPosition = 44; |
|
3689 TBuf<KSmsDescriptionLength> desc; |
|
3690 |
|
3691 //Replace the Message Indication in this PDU |
|
3692 RMobileSmsMessaging::TMobileSmsGsmTpdu miPdu(KFaxIndicationPdu); |
|
3693 _LIT8(KFormat, "%02X%02X"); |
|
3694 TPtr8 ptr(&miPdu[KIndicationPosition], 0, 4); |
|
3695 ptr.AppendFormat(KFormat, aMessageType, aMessageCount); |
|
3696 |
|
3697 |
|
3698 CSmsMessage* msg = CreateSmsMessageLC(miPdu); |
|
3699 User::LeaveIfError(TSmsUtilities::GetDescription(*msg, desc)); |
|
3700 CleanupStack::PopAndDestroy(msg); |
|
3701 |
|
3702 if (aMessageCount != 1) |
|
3703 return CheckDescriptionL(aResFile, aId, desc, aMessageCount); |
|
3704 else |
|
3705 return CheckDescriptionL(aResFile, aId, desc); |
|
3706 } |
|
3707 |
|
3708 TBool CSmutTest::TestVideoMessageIndicationPduL(RResourceFile& aResFile, CSmsHeader& aHeader, TInt aId) |
|
3709 { |
|
3710 //remove any enhanced voice mail indications |
|
3711 CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation)); |
|
3712 if(enhancedOperations.ContainsEnhancedVoiceMailIEL()) |
|
3713 { |
|
3714 enhancedOperations.RemoveEnhancedVoiceMailIEL(); |
|
3715 } |
|
3716 |
|
3717 const TUint8 KMaxCount = 0xFF; |
|
3718 for (TUint8 i = 0; i < KMaxCount; i++) |
|
3719 { |
|
3720 TInt resId = aId; |
|
3721 if (i != 1) |
|
3722 resId++; |
|
3723 |
|
3724 if(!TestVideoMessageIndicationPduL(aResFile, i, aHeader, resId)) |
|
3725 { |
|
3726 return EFalse; |
|
3727 } |
|
3728 } |
|
3729 |
|
3730 iTestStep.INFO_PRINTF1(_L("Passed")); |
|
3731 |
|
3732 return ETrue; |
|
3733 } |
|
3734 |
|
3735 |
|
3736 TBool CSmutTest::TestVideoMessageIndicationPduL(RResourceFile& aResFile, TUint8 aMessageCount, CSmsHeader& aHeader, TInt aId) |
|
3737 { |
|
3738 //Get the operations |
|
3739 CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)); |
|
3740 |
|
3741 TBool toStore=ETrue; |
|
3742 TSmsMessageIndicationType messageIndicationType=EGsmSmsExtendedMessageTypeWaiting; |
|
3743 TExtendedSmsIndicationType extendedType=EGsmSmsVideoMessageWaiting; |
|
3744 TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1; |
|
3745 TBuf<KSmsDescriptionLength> desc; |
|
3746 |
|
3747 operations.RemoveAllSpecialMessageIndicationsL(); |
|
3748 operations.AddSpecialMessageIndicationL(toStore,messageIndicationType, |
|
3749 extendedType,messageProfileType,aMessageCount); |
|
3750 |
|
3751 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc)); |
|
3752 |
|
3753 if(!CheckDescriptionL(aResFile, aId, desc, aMessageCount)) |
|
3754 { |
|
3755 operations.RemoveAllSpecialMessageIndicationsL(); |
|
3756 return EFalse; |
|
3757 } |
|
3758 operations.RemoveAllSpecialMessageIndicationsL(); |
|
3759 return ETrue; |
|
3760 } |
|
3761 |
|
3762 TBool CSmutTest::TestEnhancedVoiceMailIndicationPduL(RResourceFile& aResFile, CSmsHeader& aHeader, TInt aId) |
|
3763 { |
|
3764 //remove any special message indications |
|
3765 CSmsSpecialSMSMessageOperations& operations = STATIC_CAST(CSmsSpecialSMSMessageOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)); |
|
3766 operations.RemoveAllSpecialMessageIndicationsL(); |
|
3767 |
|
3768 const TUint8 KMaxCount = 0xFF; |
|
3769 for (TUint8 i = 0; i < KMaxCount; i++) |
|
3770 { |
|
3771 TInt resId = aId; |
|
3772 if (i != 1) |
|
3773 resId++; |
|
3774 |
|
3775 if(!TestEnhancedVoiceMailIndicationPduL(aResFile, i, aHeader, resId)) |
|
3776 { |
|
3777 return EFalse; |
|
3778 } |
|
3779 } |
|
3780 |
|
3781 iTestStep.INFO_PRINTF1(_L("Passed")); |
|
3782 |
|
3783 return ETrue; |
|
3784 } |
|
3785 |
|
3786 |
|
3787 TBool CSmutTest::TestEnhancedVoiceMailIndicationPduL(RResourceFile& aResFile, TUint8 aMessageCount, CSmsHeader& aHeader, TInt aId) |
|
3788 { |
|
3789 //get the operations class |
|
3790 CSmsEnhancedVoiceMailOperations& enhancedOperations = STATIC_CAST(CSmsEnhancedVoiceMailOperations&,aHeader.Message().GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation)); |
|
3791 //remove any enhanced voice mail indications |
|
3792 if(enhancedOperations.ContainsEnhancedVoiceMailIEL()) |
|
3793 { |
|
3794 enhancedOperations.RemoveEnhancedVoiceMailIEL(); |
|
3795 } |
|
3796 //Create CEnhancedVoiceMailNotification |
|
3797 CEnhancedVoiceMailNotification* enhancedVoiceMailNotification=CEnhancedVoiceMailNotification::NewL(); |
|
3798 CleanupStack::PushL(enhancedVoiceMailNotification); |
|
3799 |
|
3800 //Set the properties |
|
3801 TSmsMessageProfileType messageProfileType=EGsmSmsProfileId1; |
|
3802 enhancedVoiceMailNotification->SetProfile(messageProfileType); |
|
3803 enhancedVoiceMailNotification->SetStorage(ETrue); |
|
3804 enhancedVoiceMailNotification->SetNumberOfVoiceMessages(aMessageCount); |
|
3805 |
|
3806 enhancedOperations.AddEnhancedVoiceMailIEL(*enhancedVoiceMailNotification); |
|
3807 CleanupStack::PopAndDestroy(enhancedVoiceMailNotification); |
|
3808 |
|
3809 TBuf<KSmsDescriptionLength> desc; |
|
3810 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc)); |
|
3811 if(!CheckDescriptionL(aResFile, aId, desc, aMessageCount)) |
|
3812 { |
|
3813 return EFalse; |
|
3814 } |
|
3815 |
|
3816 |
|
3817 return ETrue; |
|
3818 } |
|
3819 |
|
3820 |
|
3821 TBool CSmutTest::CheckDescriptionL(RResourceFile& aResFile, TInt aId, TRefByValue<const TDesC> aDesc, ...) |
|
3822 { |
|
3823 const TDesC& ref = aDesc; |
|
3824 |
|
3825 TBuf<256> resDesc; |
|
3826 TBuf<256> resString; |
|
3827 |
|
3828 VA_LIST list; |
|
3829 VA_START(list, aDesc); |
|
3830 |
|
3831 iSmsTest.ReadResourceStringL(aResFile, aId, resString); |
|
3832 resDesc.AppendFormatList(resString, list); |
|
3833 |
|
3834 if (ref != resDesc) |
|
3835 { |
|
3836 iTestStep.INFO_PRINTF3(_L("\tMISMATCH Desc \"%S\" Resource \"%S\""), &ref, &resDesc); |
|
3837 return EFalse; |
|
3838 } |
|
3839 |
|
3840 return ETrue; |
|
3841 } |
|
3842 |
|
3843 TBool CSmutTest::CheckSmsEntry( |
|
3844 const TMsvSmsEntry& aEntry, |
|
3845 TBool aClassExpected, |
|
3846 TSmsDataCodingScheme::TSmsClass aClass, |
|
3847 TUint8 aPID, |
|
3848 TBool aUPI, |
|
3849 TMsvSmsEntry::TMsvSmsEntryAckSummary aDeliverySummary, |
|
3850 TBool aValidMessageId, |
|
3851 TInt32 aMessageId) const |
|
3852 { |
|
3853 TCompare retVal(ETrue); |
|
3854 |
|
3855 TSmsDataCodingScheme::TSmsClass dummyClass; |
|
3856 |
|
3857 retVal((aEntry.Class(dummyClass) && aClassExpected) || (!aEntry.Class(dummyClass) && !aClassExpected)); |
|
3858 |
|
3859 if (aClassExpected) |
|
3860 retVal(dummyClass == aClass); |
|
3861 |
|
3862 retVal(aEntry.ProtocolIdentifier() == aPID); |
|
3863 retVal((aEntry.UserPromptIndicator() && aUPI) || (!aEntry.UserPromptIndicator() && !aUPI)); |
|
3864 |
|
3865 retVal(aEntry.AckSummary(ESmsAckTypeDelivery) == aDeliverySummary); |
|
3866 |
|
3867 TInt32 dummyMessageId; |
|
3868 |
|
3869 retVal( (aEntry.MessageId(dummyMessageId) && aValidMessageId) || (!aEntry.MessageId(dummyMessageId) && !aValidMessageId) ); |
|
3870 if( aValidMessageId ) |
|
3871 retVal( dummyMessageId == aMessageId ); |
|
3872 |
|
3873 return retVal; |
|
3874 } |
|
3875 |
|
3876 TVerdict CSmutTest::TestSmsEntryL() |
|
3877 { |
|
3878 iTestStep.INFO_PRINTF1(_L("Testing TMsvSmsEntry...")); |
|
3879 |
|
3880 TMsvSmsEntry entry; |
|
3881 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3882 { |
|
3883 return EFail; |
|
3884 } |
|
3885 |
|
3886 entry.SetUserPromptIndicator(ETrue); |
|
3887 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3888 { |
|
3889 return EFail; |
|
3890 } |
|
3891 entry.SetUserPromptIndicator(EFalse); |
|
3892 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3893 { |
|
3894 return EFail; |
|
3895 } |
|
3896 entry.SetProtocolIdentifier(123); |
|
3897 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 123, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3898 { |
|
3899 return EFail; |
|
3900 } |
|
3901 entry.SetProtocolIdentifier(100); |
|
3902 entry.SetUserPromptIndicator(ETrue); |
|
3903 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3904 { |
|
3905 return EFail; |
|
3906 } |
|
3907 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0); |
|
3908 if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3909 { |
|
3910 return EFail; |
|
3911 } |
|
3912 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass1); |
|
3913 if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass1, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3914 { |
|
3915 return EFail; |
|
3916 } |
|
3917 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass2); |
|
3918 if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass2, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3919 { |
|
3920 return EFail; |
|
3921 } |
|
3922 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass3); |
|
3923 if(!CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3924 { |
|
3925 return EFail; |
|
3926 } |
|
3927 entry.SetClass(EFalse); |
|
3928 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3929 { |
|
3930 return EFail; |
|
3931 } |
|
3932 |
|
3933 entry.SetUserPromptIndicator(EFalse); |
|
3934 if(!CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)) |
|
3935 { |
|
3936 return EFail; |
|
3937 } |
|
3938 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0); |
|
3939 |
|
3940 TInt classCounter, upiCounter, classDef, deliverySummary, messageIdValid; |
|
3941 TSmsDataCodingScheme::TSmsClass tempClass; |
|
3942 TMsvSmsEntry::TMsvSmsEntryAckSummary tempDelivery; |
|
3943 TUint8 pidCounter; |
|
3944 TInt32 messageId = KLogID1; |
|
3945 |
|
3946 for (classCounter = 0; classCounter < 4; classCounter++) |
|
3947 { |
|
3948 for (pidCounter = 0; pidCounter < 128; pidCounter++) |
|
3949 { |
|
3950 for (upiCounter = 0; upiCounter < 2; upiCounter++) |
|
3951 { |
|
3952 for (classDef = 0; classDef < 2; classDef++) |
|
3953 { |
|
3954 for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary ) |
|
3955 { |
|
3956 for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid) |
|
3957 { |
|
3958 entry = TMsvSmsEntry(); |
|
3959 tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter); |
|
3960 tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary); |
|
3961 entry.SetClass(classDef, tempClass); |
|
3962 entry.SetProtocolIdentifier(pidCounter); |
|
3963 entry.SetUserPromptIndicator(upiCounter); |
|
3964 entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery); |
|
3965 entry.SetMessageId(messageId, messageIdValid); |
|
3966 if(!CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId)) |
|
3967 { |
|
3968 return EFail; |
|
3969 } |
|
3970 } |
|
3971 } |
|
3972 } |
|
3973 } |
|
3974 } |
|
3975 } |
|
3976 |
|
3977 for (classCounter = 0; classCounter < 4; classCounter++) |
|
3978 { |
|
3979 for (pidCounter = 0; pidCounter < 128; pidCounter++) |
|
3980 { |
|
3981 for (upiCounter = 0; upiCounter < 2; upiCounter++) |
|
3982 { |
|
3983 for (classDef = 0; classDef < 2; classDef++) |
|
3984 { |
|
3985 for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary ) |
|
3986 { |
|
3987 for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid) |
|
3988 { |
|
3989 tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter); |
|
3990 tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary); |
|
3991 entry.SetClass(classDef, tempClass); |
|
3992 entry.SetProtocolIdentifier(pidCounter); |
|
3993 entry.SetUserPromptIndicator(upiCounter); |
|
3994 entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery); |
|
3995 entry.SetMessageId(messageId, messageIdValid); |
|
3996 if(!CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId)) |
|
3997 { |
|
3998 return EFail; |
|
3999 } |
|
4000 } |
|
4001 } |
|
4002 } |
|
4003 } |
|
4004 } |
|
4005 } |
|
4006 |
|
4007 iTestStep.INFO_PRINTF1(_L("Test TMsvSmsEntry Passed.")); |
|
4008 return EPass; |
|
4009 } |