|
1 // Copyright (c) 2000-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 "T_smut.h" |
|
17 #include <smss.rsg> |
|
18 #include <etelmm.h> |
|
19 #include <smutset.h> |
|
20 #include <csmsaccount.h> |
|
21 |
|
22 #include <csmsemailfields.h> |
|
23 |
|
24 #include <csmsgetdetdescinterface.h> |
|
25 |
|
26 |
|
27 const TUid KUidMsvSmsEmailFieldsStream = {0x10204C9D}; |
|
28 |
|
29 GLDEF_C TInt E32Main() |
|
30 { |
|
31 __UHEAP_MARK; |
|
32 test.Start(_L("Setup")); |
|
33 theCleanup = CTrapCleanup::New(); |
|
34 TRAPD(ret,doMainL()); |
|
35 test(ret==KErrNone); |
|
36 delete theCleanup; |
|
37 test.Console()->SetPos(0, 13); |
|
38 test.End(); |
|
39 test.Close(); |
|
40 __UHEAP_MARKEND; |
|
41 return(KErrNone); |
|
42 } |
|
43 |
|
44 LOCAL_C void doMainL() |
|
45 { |
|
46 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
47 CleanupStack::PushL(scheduler); |
|
48 CActiveScheduler::Install(scheduler); |
|
49 |
|
50 CSmsTestUtils* smsTest = CSmsTestUtils::NewL(test); |
|
51 CleanupStack::PushL(smsTest); |
|
52 TInt nextTest = 0; |
|
53 |
|
54 CSmutTest* SmcmTest = CSmutTest::NewLC(*smsTest, KNullDesC, nextTest); |
|
55 |
|
56 SmcmTest->StartL(); |
|
57 |
|
58 CleanupStack::PopAndDestroy(3, scheduler); |
|
59 } |
|
60 |
|
61 CSmutTest::CSmutTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
62 : CSmsTestBase(aSmsTest, aScriptFile, aNextTest) |
|
63 { |
|
64 } |
|
65 |
|
66 void CSmutTest::RunAutoL() |
|
67 { |
|
68 iNextTest = 0; |
|
69 |
|
70 // Testing TMsvSmsEntry |
|
71 iSmsTest.TestStart(++iNextTest, _L("TMsvSmsEntry")); |
|
72 TestSmsEntryL(); |
|
73 iSmsTest.TestFinish(iNextTest); |
|
74 |
|
75 |
|
76 // Testing settings (CSmsSettings) |
|
77 iSmsTest.TestStart(++iNextTest, _L("CSmsSettings")); |
|
78 TestSettingsL(); |
|
79 iSmsTest.TestFinish(iNextTest); |
|
80 |
|
81 // Testing number class (CSmsNumber) |
|
82 iSmsTest.TestStart(++iNextTest, _L("CSmsNumber")); |
|
83 TestNumberL(); |
|
84 iSmsTest.TestFinish(iNextTest); |
|
85 |
|
86 // Testing email fields class (CSmsEmailFields) |
|
87 iSmsTest.TestStart(++iNextTest, _L("CSmsEmailFields")); |
|
88 TestEmailFieldsL(); |
|
89 iSmsTest.TestFinish(iNextTest); |
|
90 |
|
91 // Testing with header (CSmsHeader) |
|
92 iSmsTest.TestStart(++iNextTest, _L("CSmsHeader")); |
|
93 TestHeaderL(); |
|
94 iSmsTest.TestFinish(iNextTest); |
|
95 |
|
96 // Testing with utility class (TSmsUtilities) |
|
97 iSmsTest.TestStart(++iNextTest, _L("TSmsUtilities")); |
|
98 TestSmsUtilitiesL(); |
|
99 |
|
100 // Testing with ECOM Plugin class (CSmsGetDetDescInterface) |
|
101 iSmsTest.TestStart(++iNextTest, _L("CSmsGetDetDescInterface")); |
|
102 TestSmsUtilitiesBL(); |
|
103 |
|
104 iSmsTest.TestFinish(iNextTest); |
|
105 |
|
106 iSmsTest.TestStart(++iNextTest, _L("EMS Extensions")); |
|
107 TestSmsEmsExtensionsL(); |
|
108 |
|
109 iSmsTest.TestFinish(iNextTest); |
|
110 |
|
111 } |
|
112 |
|
113 CSmutTest::~CSmutTest() |
|
114 { |
|
115 delete iSmsHeader; |
|
116 delete iRichText; |
|
117 delete iParaLayer; |
|
118 delete iCharLayer; |
|
119 delete iDBSession; |
|
120 |
|
121 } |
|
122 |
|
123 void CSmutTest::ConstructL() |
|
124 { |
|
125 iSmsTest.SetLogToFile(); |
|
126 |
|
127 iSelection = new (ELeave) CMsvEntrySelection(); |
|
128 iTimer = CTestTimer::NewL(); |
|
129 |
|
130 iParaLayer =CParaFormatLayer::NewL(); |
|
131 iCharLayer = CCharFormatLayer::NewL(); |
|
132 iRichText = CRichText::NewL(iParaLayer, iCharLayer, CEditableText::EFlatStorage,256); |
|
133 iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
134 |
|
135 CActiveScheduler::Add(this); |
|
136 } |
|
137 |
|
138 CSmutTest* CSmutTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
139 { |
|
140 CSmutTest* self = new (ELeave) CSmutTest(aSmsTest, aScriptFile, aNextTest); |
|
141 CleanupStack::PushL(self); |
|
142 |
|
143 self->ConstructL(); |
|
144 |
|
145 return self; |
|
146 } |
|
147 |
|
148 void CSmutTest::ShowMenuL() |
|
149 { |
|
150 iSmsTest.ResetMenu(); |
|
151 |
|
152 iSmsTest.AppendToMenuL(_L("Start")); |
|
153 iSmsTest.AppendToMenuL(_L("Sms Utilities")); |
|
154 iSmsTest.AppendToMenuL(_L("Sms Settings")); |
|
155 |
|
156 TInt result = iSmsTest.DisplayMenu(_L("SMS Client MTM Test")); |
|
157 |
|
158 if (result <= 0) |
|
159 return; |
|
160 |
|
161 switch (result) |
|
162 { |
|
163 case 1: |
|
164 RunAutoL(); |
|
165 break; |
|
166 case 2: |
|
167 TestSmsUtilitiesL(); |
|
168 break; |
|
169 case 3: |
|
170 TestSettingsL(); |
|
171 break; |
|
172 default: |
|
173 User::Leave(KErrArgument); |
|
174 break; |
|
175 } |
|
176 |
|
177 if (!iSmsTest.RunAuto()) |
|
178 { |
|
179 iSmsTest.Printf(_L("Press any key to continue...\n")); |
|
180 iSmsTest.Test().Getch(); |
|
181 } |
|
182 |
|
183 ShowMenuL(); |
|
184 } |
|
185 |
|
186 void CSmutTest::TestSettingsL() |
|
187 { |
|
188 iSmsTest.Printf(_L("Testing Create Settings...\n")); |
|
189 |
|
190 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
191 |
|
192 // First we test all the features of the class CSmsSettings |
|
193 // We give them different values and compare if it works |
|
194 |
|
195 CSmsSettings* settings = CSmsSettings::NewL(); |
|
196 CleanupStack::PushL(settings); |
|
197 iSmsTest(CompareSettings(*settings, *settings)); |
|
198 TestSettingsMembersL(*settings); |
|
199 TestMessageSettingsMembersL(*settings); |
|
200 |
|
201 // Lets copy the values to a different instance |
|
202 CSmsSettings* smsSettings=CSmsSettings::NewL(); |
|
203 CleanupStack::PushL(smsSettings); |
|
204 smsSettings->CopyL(*settings); |
|
205 iSmsTest(CompareSettings(*smsSettings, *settings)); |
|
206 CleanupStack::PopAndDestroy(smsSettings); |
|
207 smsSettings = NULL; |
|
208 iSmsTest.Printf(_L("Test CSmsSettings::CopyL() passed\n")); |
|
209 |
|
210 |
|
211 // Lets create a sms service in the file system with these values |
|
212 TestStoreRestoreSettingsL(*settings); |
|
213 |
|
214 // Lets make the previous test again; Lets give a settings instance some |
|
215 // values, store it, restore it and see that the values are still the same |
|
216 CSmsSettings* set2=CSmsSettings::NewL(); |
|
217 CleanupStack::PushL(set2); |
|
218 set2->AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
219 set2->AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
220 set2->AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
221 set2->AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010")); |
|
222 set2->AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010")); |
|
223 set2->SetDefaultServiceCenter(1); |
|
224 iSmsTest(set2->DefaultServiceCenter()==1); |
|
225 // Validity Period |
|
226 set2->SetValidityPeriod(ESmsVPSixHours); |
|
227 iSmsTest(set2->ValidityPeriod().Int()==ESmsVPSixHours); |
|
228 // Reply Quoted |
|
229 set2->SetReplyQuoted(EFalse); |
|
230 iSmsTest(!set2->ReplyQuoted()); |
|
231 // Reject Duplicate |
|
232 set2->SetRejectDuplicate(ETrue); |
|
233 iSmsTest(set2->RejectDuplicate()); |
|
234 // Delivery Method |
|
235 set2->SetDelivery(ESmsDeliveryUponRequest); |
|
236 iSmsTest(set2->Delivery()==ESmsDeliveryUponRequest); |
|
237 // Delivery Report |
|
238 set2->SetDeliveryReport(ETrue); |
|
239 iSmsTest(set2->DeliveryReport()); |
|
240 // Reply Path |
|
241 set2->SetReplyPath(EFalse); |
|
242 iSmsTest(!set2->ReplyPath()); |
|
243 // Message Conversion |
|
244 set2->SetMessageConversion(ESmsConvPIDNone); |
|
245 iSmsTest(set2->MessageConversion()==ESmsConvPIDNone); |
|
246 // Can Concatenate |
|
247 set2->SetCanConcatenate(ETrue); |
|
248 iSmsTest(set2->CanConcatenate()); |
|
249 // Character Set |
|
250 set2->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
251 iSmsTest(set2->CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
252 // Validity period format |
|
253 set2->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
254 iSmsTest(set2->ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet); |
|
255 // Status Report Handling |
|
256 set2->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
257 iSmsTest(set2->StatusReportHandling()==CSmsSettings::EMoveReportToInboxVisible); |
|
258 // Special Message Handling |
|
259 set2->SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
260 iSmsTest(set2->SpecialMessageHandling()==CSmsSettings::EMoveReportToInboxVisible); |
|
261 |
|
262 TestStoreRestoreSettingsL(*set2); |
|
263 |
|
264 set2->SetClass2Folder(123); |
|
265 TestStoreRestoreSettingsL(*set2); |
|
266 |
|
267 CleanupStack::PopAndDestroy(set2); |
|
268 |
|
269 iSmsTest.iServiceSettings->CopyL(*settings); // Lets copy the current setting to the service settings |
|
270 |
|
271 iSmsTest(CompareSettings(*iSmsTest.iServiceSettings, *settings)); |
|
272 |
|
273 iSmsTest.Printf(_L("CSmsSettings::CopyL() 2\n")); |
|
274 |
|
275 CleanupStack::PopAndDestroy(settings); |
|
276 |
|
277 iSmsTest.Printf(_L("Test Create Settings Passed\n")); |
|
278 |
|
279 TestSettingsStoreToCommDbL(); |
|
280 |
|
281 iSmsTest.Printf(_L("TestSettingsStoreToCommDbL Passed\n")); |
|
282 |
|
283 } |
|
284 |
|
285 |
|
286 TBool CSmutTest::CompareSettingsFiles( |
|
287 RFs& aFs, const TDesC& aCompare1, const TDesC& aCompare2 |
|
288 ) |
|
289 { |
|
290 TBool identical = ETrue; |
|
291 |
|
292 RFileReadStream stream1; |
|
293 RFileReadStream stream2; |
|
294 |
|
295 // Open each stream for binary read. |
|
296 stream1.Open(aFs, aCompare1, EFileStream | EFileRead); |
|
297 stream2.Open(aFs, aCompare2, EFileStream | EFileRead); |
|
298 |
|
299 TInt ret1 = KErrNone; |
|
300 TInt ret2 = KErrNone; |
|
301 TBool finished = EFalse; |
|
302 TUint8 byte1 = 0; |
|
303 TUint8 byte2 = 0; |
|
304 |
|
305 while (!finished) |
|
306 { |
|
307 TRAP(ret1, byte1 = stream1.ReadUint8L()); |
|
308 TRAP(ret2, byte2 = stream2.ReadUint8L()); |
|
309 |
|
310 if (byte1 != byte2 || ret1 == KErrEof || ret2 == KErrEof) |
|
311 { |
|
312 // Either file data or lengths differ. |
|
313 if ((byte1 != byte2) || (ret1 != ret2)) |
|
314 identical = EFalse; |
|
315 finished = ETrue; |
|
316 } |
|
317 } |
|
318 |
|
319 stream1.Close(); |
|
320 stream2.Close(); |
|
321 |
|
322 return identical; |
|
323 } |
|
324 |
|
325 void CSmutTest::TestStoreRestoreSettingsL(const CSmsSettings& aSettings) |
|
326 { |
|
327 StoreSettingsL(aSettings); |
|
328 |
|
329 // Lets read the service and see it the values are still ok |
|
330 CSmsSettings* set1=CSmsSettings::NewL(); |
|
331 CleanupStack::PushL(set1); |
|
332 |
|
333 RestoreSettingsL(*set1); |
|
334 |
|
335 iSmsTest(CompareSettings(*set1, aSettings)); |
|
336 |
|
337 CleanupStack::PopAndDestroy(set1); |
|
338 } |
|
339 |
|
340 void CSmutTest::TestSettingsMembersL(CSmsSettings& aSettings) |
|
341 { |
|
342 // Status Report Handling (what should be done to report messages) |
|
343 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisible); |
|
344 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EMoveReportToInboxInvisible); |
|
345 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
346 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EMoveReportToInboxVisible); |
|
347 aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReport); |
|
348 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EDiscardReport); |
|
349 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
350 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
351 aSettings.SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
352 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
353 aSettings.SetStatusReportHandling(CSmsSettings::EDiscardReportAndMatch); |
|
354 iSmsTest(aSettings.StatusReportHandling()==CSmsSettings::EDiscardReportAndMatch); |
|
355 iSmsTest.Printf(_L("Test Status Report Handling Passed\n")); |
|
356 |
|
357 // SC handling |
|
358 aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
359 aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
360 aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
361 aSettings.AddServiceCenterL(_L("Radiolinja3"),_L("+358508771010")); |
|
362 aSettings.AddServiceCenterL(_L("Radiolinja4"),_L("+358508771010")); |
|
363 iSmsTest(aSettings.GetServiceCenter(0).Name()==_L("Radiolinja0")); |
|
364 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-3); |
|
365 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-2); |
|
366 iSmsTest(aSettings.GetServiceCenter(1).Name()==_L("Radiolinja1")); |
|
367 iSmsTest(aSettings.GetServiceCenter(2).Name()==_L("Radiolinja4")); |
|
368 iSmsTest(aSettings.GetServiceCenter(2).Address()==_L("+358508771010")); |
|
369 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
370 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
371 aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); |
|
372 // aSettings.RemoveServiceCenter(aSettings.ServiceCenterCount()-1); // this would be -1 |
|
373 aSettings.AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
374 aSettings.AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
375 aSettings.AddServiceCenterL(_L("Radiolinja2"),_L("+358508771010")); |
|
376 aSettings.SetDefaultServiceCenter(1); |
|
377 iSmsTest(aSettings.DefaultServiceCenter()==1); |
|
378 aSettings.SetDefaultServiceCenter(2); |
|
379 iSmsTest(aSettings.DefaultServiceCenter()==2); |
|
380 iSmsTest.Printf(_L("Test Default SC Passed\n")); |
|
381 |
|
382 // Special Message Handling (what should be done to special messages) |
|
383 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisible); |
|
384 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EMoveReportToInboxInvisible); |
|
385 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
386 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EMoveReportToInboxVisible); |
|
387 aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReport); |
|
388 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EDiscardReport); |
|
389 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
390 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EMoveReportToInboxInvisibleAndMatch); |
|
391 aSettings.SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
392 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EMoveReportToInboxVisibleAndMatch); |
|
393 aSettings.SetSpecialMessageHandling(CSmsSettings::EDiscardReportAndMatch); |
|
394 iSmsTest(aSettings.SpecialMessageHandling()==CSmsSettings::EDiscardReportAndMatch); |
|
395 iSmsTest.Printf(_L("Test Special Message Handling Passed\n")); |
|
396 |
|
397 //CommDbAction |
|
398 aSettings.SetCommDbAction(CSmsSettings::ENone); |
|
399 iSmsTest(aSettings.CommDbAction() == CSmsSettings::ENone); |
|
400 aSettings.SetCommDbAction(CSmsSettings::EStoreToCommDb); |
|
401 iSmsTest(aSettings.CommDbAction() == CSmsSettings::EStoreToCommDb); |
|
402 iSmsTest.Printf(_L("Test CommDb Action Passed\n")); |
|
403 |
|
404 //SmsBearerAction |
|
405 aSettings.SetSmsBearerAction(CSmsSettings::ENone); |
|
406 iSmsTest(aSettings.SmsBearerAction() == CSmsSettings::ENone); |
|
407 aSettings.SetSmsBearerAction(CSmsSettings::EStoreToCommDb); |
|
408 iSmsTest(aSettings.SmsBearerAction() == CSmsSettings::EStoreToCommDb); |
|
409 iSmsTest.Printf(_L("Test SMS Bearer Action Passed\n")); |
|
410 |
|
411 //SmsBearer |
|
412 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
413 iSmsTest(aSettings.SmsBearer() == CSmsSettings::ESmsBearerPacketOnly); |
|
414 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
415 iSmsTest(aSettings.SmsBearer() == CSmsSettings::ESmsBearerPacketOnly); |
|
416 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly); |
|
417 iSmsTest(aSettings.SmsBearer() == CSmsSettings::ESmsBearerCircuitOnly); |
|
418 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerPacketPreferred); |
|
419 iSmsTest(aSettings.SmsBearer() == CSmsSettings::ESmsBearerPacketPreferred); |
|
420 aSettings.SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred); |
|
421 iSmsTest(aSettings.SmsBearer() == CSmsSettings::ESmsBearerCircuitPreferred); |
|
422 iSmsTest.Printf(_L("Test SMS Bearer Passed\n")); |
|
423 |
|
424 // Reply Quoted |
|
425 aSettings.SetReplyQuoted(EFalse); |
|
426 iSmsTest(!aSettings.ReplyQuoted()); |
|
427 aSettings.SetReplyQuoted(ETrue); |
|
428 iSmsTest(aSettings.ReplyQuoted()); |
|
429 iSmsTest.Printf(_L("Test Reply Quoted Passed\n")); |
|
430 |
|
431 // Delivery Method |
|
432 aSettings.SetDelivery(ESmsDeliveryUponRequest); |
|
433 iSmsTest(aSettings.Delivery()==ESmsDeliveryUponRequest); |
|
434 aSettings.SetDelivery(ESmsDeliveryScheduled); |
|
435 iSmsTest(aSettings.Delivery()==ESmsDeliveryScheduled); |
|
436 aSettings.SetDelivery(ESmsDeliveryImmediately); |
|
437 iSmsTest(aSettings.Delivery()==ESmsDeliveryImmediately); |
|
438 iSmsTest.Printf(_L("Test Delivery Passed\n")); |
|
439 |
|
440 // Class2Folder |
|
441 iSmsTest(aSettings.Class2Folder() == KMsvGlobalInBoxIndexEntryId); |
|
442 aSettings.SetClass2Folder(1); |
|
443 iSmsTest(aSettings.Class2Folder() == 1); |
|
444 iSmsTest.Printf(_L("Test Class2Folder Passed\n")); |
|
445 |
|
446 // Description length |
|
447 iSmsTest(aSettings.DescriptionLength() == KSmsDescriptionLength); |
|
448 aSettings.SetDescriptionLength(100); |
|
449 iSmsTest(aSettings.DescriptionLength() == 100); |
|
450 iSmsTest.Printf(_L("Test DescriptionLength Passed\n")); |
|
451 } |
|
452 |
|
453 void CSmutTest::TestMessageSettingsMembersL(CSmsMessageSettings& aSettings) |
|
454 { |
|
455 |
|
456 // Reject Duplicate |
|
457 aSettings.SetRejectDuplicate(ETrue); |
|
458 iSmsTest(aSettings.RejectDuplicate()); |
|
459 aSettings.SetRejectDuplicate(EFalse); |
|
460 iSmsTest(!aSettings.RejectDuplicate()); |
|
461 iSmsTest.Printf(_L("Test Reject Duplicate Passed\n")); |
|
462 |
|
463 // Delivery Report |
|
464 aSettings.SetDeliveryReport(ETrue); |
|
465 iSmsTest(aSettings.DeliveryReport()); |
|
466 aSettings.SetDeliveryReport(EFalse); |
|
467 iSmsTest(!aSettings.DeliveryReport()); |
|
468 iSmsTest.Printf(_L("Test Delivery Report Passed\n")); |
|
469 |
|
470 // Reply Path |
|
471 aSettings.SetReplyPath(EFalse); |
|
472 iSmsTest(aSettings.ReplyPath()==EFalse); |
|
473 aSettings.SetReplyPath(ETrue); |
|
474 iSmsTest(aSettings.ReplyPath()); |
|
475 iSmsTest.Printf(_L("Test Reply Path Passed\n")); |
|
476 |
|
477 // Validity period format |
|
478 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFNone); |
|
479 iSmsTest(aSettings.ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFNone); |
|
480 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFEnhanced); |
|
481 iSmsTest(aSettings.ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFEnhanced); |
|
482 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger); |
|
483 iSmsTest(aSettings.ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFInteger); |
|
484 aSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
485 iSmsTest(aSettings.ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet); |
|
486 iSmsTest.Printf(_L("Test Validity Period Format Passed\n")); |
|
487 |
|
488 // Message Conversion (following conversions are supported) |
|
489 aSettings.SetMessageConversion(ESmsConvFax); |
|
490 iSmsTest(aSettings.MessageConversion()==ESmsConvFax); |
|
491 aSettings.SetMessageConversion(ESmsConvX400); |
|
492 iSmsTest(aSettings.MessageConversion()==ESmsConvX400); |
|
493 aSettings.SetMessageConversion(ESmsConvPaging); |
|
494 iSmsTest(aSettings.MessageConversion()==ESmsConvPaging); |
|
495 aSettings.SetMessageConversion(ESmsConvMail); |
|
496 iSmsTest(aSettings.MessageConversion()==ESmsConvMail); |
|
497 aSettings.SetMessageConversion(ESmsConvErmes); |
|
498 iSmsTest(aSettings.MessageConversion()==ESmsConvErmes); |
|
499 aSettings.SetMessageConversion(ESmsConvSpeech); |
|
500 iSmsTest(aSettings.MessageConversion()==ESmsConvSpeech); |
|
501 aSettings.SetMessageConversion(ESmsConvPIDNone); |
|
502 iSmsTest(aSettings.MessageConversion()==ESmsConvPIDNone); |
|
503 iSmsTest.Printf(_L("Test Message Conversion Passed\n")); |
|
504 |
|
505 // Validity Period |
|
506 aSettings.SetValidityPeriod(ESmsVPHour); |
|
507 iSmsTest(aSettings.ValidityPeriod().Int()==ESmsVPHour); |
|
508 aSettings.SetValidityPeriod(ESmsVPSixHours); |
|
509 iSmsTest(aSettings.ValidityPeriod().Int()==ESmsVPSixHours); |
|
510 aSettings.SetValidityPeriod(ESmsVP24Hours); |
|
511 iSmsTest(aSettings.ValidityPeriod().Int()==ESmsVP24Hours); |
|
512 aSettings.SetValidityPeriod(ESmsVPMaximum); |
|
513 iSmsTest(aSettings.ValidityPeriod().Int()==ESmsVPMaximum); |
|
514 aSettings.SetValidityPeriod(ESmsVPWeek); |
|
515 iSmsTest(aSettings.ValidityPeriod().Int()==ESmsVPWeek); |
|
516 iSmsTest.Printf(_L("Test Validity Period Passed\n")); |
|
517 |
|
518 // Can Concatenate (write messages with more than 160 characters) |
|
519 aSettings.SetCanConcatenate(ETrue); |
|
520 iSmsTest(aSettings.CanConcatenate()); |
|
521 aSettings.SetCanConcatenate(EFalse); |
|
522 iSmsTest(aSettings.CanConcatenate()==EFalse); |
|
523 iSmsTest.Printf(_L("Test Can Concatenate Passed\n")); |
|
524 |
|
525 // Character Set (following character sets are supported) |
|
526 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
527 iSmsTest(aSettings.CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
528 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
529 iSmsTest(aSettings.CharacterSet()==TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
530 aSettings.SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
531 iSmsTest(aSettings.CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
532 iSmsTest.Printf(_L("Test Character Set Passed\n")); |
|
533 } |
|
534 |
|
535 TBool CSmutTest::CompareSettings(const CSmsSettings& aLeft, const CSmsSettings& aRight, TBool aTestSC) |
|
536 { |
|
537 TCompare compare(CompareMessageSettings(aLeft, aRight)); |
|
538 |
|
539 compare(aLeft.CommDbAction() == aRight.CommDbAction()); |
|
540 compare(aLeft.SmsBearerAction() == aRight.SmsBearerAction()); |
|
541 compare(aLeft.SmsBearer() == aRight.SmsBearer()); |
|
542 compare(aLeft.Delivery() == aRight.Delivery()); |
|
543 compare(CompareBools(aLeft.ReplyQuoted(), aRight.ReplyQuoted())); |
|
544 compare(aLeft.SpecialMessageHandling() == aRight.SpecialMessageHandling()); |
|
545 compare(aLeft.StatusReportHandling() == aRight.StatusReportHandling()); |
|
546 |
|
547 if (aTestSC) |
|
548 { |
|
549 compare(aLeft.DefaultServiceCenter() == aRight.DefaultServiceCenter()); |
|
550 compare(aLeft.ServiceCenterCount() == aRight.ServiceCenterCount()); |
|
551 |
|
552 TInt count = aLeft.ServiceCenterCount(); |
|
553 |
|
554 while (count--) |
|
555 { |
|
556 compare(CompareServiceCenters(aLeft.GetServiceCenter(count), aRight.GetServiceCenter(count))); |
|
557 } |
|
558 } |
|
559 |
|
560 compare(aLeft.Class2Folder() == aRight.Class2Folder()); |
|
561 compare(aLeft.DescriptionLength() == aRight.DescriptionLength()); |
|
562 |
|
563 return compare; |
|
564 } |
|
565 |
|
566 TBool CSmutTest::CompareMessageSettings(const CSmsMessageSettings& aLeft, const CSmsMessageSettings& aRight) |
|
567 { |
|
568 TCompare compare(CompareBools(aLeft.CanConcatenate(), aRight.CanConcatenate())); |
|
569 compare(aLeft.CharacterSet() == aRight.CharacterSet()); |
|
570 compare(CompareBools(aLeft.DeliveryReport(), aRight.DeliveryReport())); |
|
571 compare(aLeft.MessageConversion() == aRight.MessageConversion()); |
|
572 compare(CompareBools(aLeft.RejectDuplicate(), aRight.RejectDuplicate())); |
|
573 compare(CompareBools(aLeft.ReplyPath(), aRight.ReplyPath())); |
|
574 compare(aLeft.ValidityPeriod() == aRight.ValidityPeriod()); |
|
575 compare(aLeft.ValidityPeriodFormat() == aRight.ValidityPeriodFormat()); |
|
576 return compare; |
|
577 } |
|
578 |
|
579 void CSmutTest::TestSettingsRestoreDefectL() |
|
580 { |
|
581 //Test fix for defects EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present) |
|
582 //and EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak) |
|
583 |
|
584 CSmsSettings* settings = CSmsSettings::NewL(); |
|
585 CleanupStack::PushL(settings); |
|
586 |
|
587 //Test defect fix for EDNAALR-4KTKTD (CSmsSettings::RestoreL() should leave if stream not present) |
|
588 const TMsvId id = iSmsTest.CreateDummyMessageToSendL(); |
|
589 Session().CleanupEntryPushL(id); |
|
590 iSmsTest.SetEntryL(id); |
|
591 |
|
592 iSmsTest.Printf(_L("TestSettingsRestoreDefectL Created dummy message\n")); |
|
593 |
|
594 TRAPD(err, RestoreSettingsL(*settings)); |
|
595 |
|
596 iSmsTest.Printf(_L("TestSettingsRestoreDefectL RestoreL 1 with error %d\n"), err); |
|
597 iSmsTest.Printf(_L("Expected %d\n"), KErrNotFound); |
|
598 iSmsTest(err == KErrNotFound); |
|
599 |
|
600 //Test defect fix for EDNAALR-4KTKLP (CSmsSettings::InternalizeL() causes memory leak) |
|
601 // iSmsTest.SetEntryL(id); |
|
602 StoreSettingsL(*settings); |
|
603 |
|
604 iSmsTest.Printf(_L("TestSettingsRestoreDefectL StoreL 1\n")); |
|
605 |
|
606 settings->AddServiceCenterL(_L("Unknown"), _L("447785016005")); |
|
607 |
|
608 RestoreSettingsL(*settings); |
|
609 |
|
610 Session().CleanupEntryPop(); |
|
611 Session().RemoveEntry(id); |
|
612 |
|
613 CleanupStack::PopAndDestroy(settings); |
|
614 iSmsTest.Printf(_L("TestSettingsRestoreDefectL RestoreL 2\n")); |
|
615 } |
|
616 |
|
617 |
|
618 void CSmutTest::TestSettingsStoreToCommDbL() |
|
619 { |
|
620 iSmsTest.Test().Next(_L("Storing CSmsSettings to CommDb\n")); |
|
621 iSmsTest.Printf(_L("Test Store Settings to CommDb\n")); |
|
622 |
|
623 CSmsSettings* settings1 = CSmsSettings::NewL(); |
|
624 CleanupStack::PushL(settings1); |
|
625 |
|
626 CSmsSettings* settings2 = CSmsSettings::NewL(); |
|
627 CleanupStack::PushL(settings2); |
|
628 |
|
629 iSmsTest(CompareSettings(*settings1, *settings2)); |
|
630 |
|
631 settings1->SetCommDbAction(CSmsSettings::EStoreToCommDb); |
|
632 settings1->AddServiceCenterL(_L("Vodafone"), _L("+447785016005")); |
|
633 settings1->SetDeliveryReport(ETrue); |
|
634 settings1->SetValidityPeriod(1000); |
|
635 |
|
636 iSmsTest.SetEntryL(iSmsTest.iSmsServiceId); |
|
637 |
|
638 StoreSettingsL(*settings1); |
|
639 iSmsTest.Printf(_L("\tNew Settings...\n")); |
|
640 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
641 |
|
642 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+3854354433")); |
|
643 |
|
644 StoreSettingsL(*settings1); |
|
645 iSmsTest.Printf(_L("\tSC Address Changed...\n")); |
|
646 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
647 |
|
648 settings1->SetDeliveryReport(EFalse); |
|
649 |
|
650 StoreSettingsL(*settings1); |
|
651 iSmsTest.Printf(_L("\tDelivery Report Changed...\n")); |
|
652 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
653 |
|
654 settings1->SetValidityPeriod(2000); |
|
655 |
|
656 StoreSettingsL(*settings1); |
|
657 iSmsTest.Printf(_L("\tValidity Period Changed...\n")); |
|
658 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
659 |
|
660 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+48996655888")); |
|
661 settings1->SetDeliveryReport(ETrue); |
|
662 settings1->SetValidityPeriod(3000); |
|
663 |
|
664 StoreSettingsL(*settings1); |
|
665 iSmsTest.Printf(_L("\tAll Settings Changed...\n")); |
|
666 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
667 |
|
668 settings1->AddServiceCenterL(_L("Radio"), _L("+385669988")); |
|
669 settings1->SetDefaultServiceCenter(settings1->ServiceCenterCount()-1); |
|
670 |
|
671 StoreSettingsL(*settings1); |
|
672 iSmsTest.Printf(_L("\tDefaultSC Changed...\n")); |
|
673 iSmsTest(CompareSettingsAndCommDbL(*settings1)); |
|
674 |
|
675 settings1->SetCommDbAction(CSmsSettings::ENone); |
|
676 settings1->GetServiceCenter(settings1->DefaultServiceCenter()).SetAddressL(_L("+123456789")); |
|
677 settings1->SetDeliveryReport(EFalse); |
|
678 settings1->SetValidityPeriod(4000); |
|
679 |
|
680 iSmsTest.Printf(_L("\tTesting Setting Different from CommDb...\n")); |
|
681 iSmsTest(!CompareSettingsAndCommDbL(*settings1)); |
|
682 |
|
683 TInt count = settings1->ServiceCenterCount(); |
|
684 |
|
685 while (count--) |
|
686 { |
|
687 settings1->RemoveServiceCenter(count); |
|
688 } |
|
689 |
|
690 iSmsTest.Printf(_L("\tTesting Setting Different from CommDb...\n")); |
|
691 iSmsTest(!CompareSettingsAndCommDbL(*settings1)); |
|
692 |
|
693 iSmsTest.Printf(_L("\tRestore settings from store...\n")); |
|
694 RestoreSettingsL(*settings2); |
|
695 iSmsTest(CompareSettingsAndCommDbL(*settings2)); |
|
696 |
|
697 //Test SMS Bearer |
|
698 |
|
699 iSmsTest.Printf(_L("\tTest Store SMS Bearer...\n")); |
|
700 |
|
701 //Test 1 |
|
702 |
|
703 settings1->SetSmsBearerAction(CSmsSettings::EStoreToCommDb); |
|
704 settings1->SetSmsBearer(CSmsSettings::ESmsBearerPacketOnly); |
|
705 |
|
706 StoreSettingsL(*settings1); |
|
707 iSmsTest(CompareSettingsAndSmsBearerL(*settings1)); |
|
708 |
|
709 //Test 2 |
|
710 |
|
711 settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitOnly); |
|
712 iSmsTest(!CompareSettingsAndSmsBearerL(*settings1)); |
|
713 |
|
714 //Test 3 |
|
715 |
|
716 StoreSettingsL(*settings1); |
|
717 iSmsTest(CompareSettingsAndSmsBearerL(*settings1)); |
|
718 |
|
719 RestoreSettingsL(*settings2); |
|
720 iSmsTest(CompareSettingsAndSmsBearerL(*settings2)); |
|
721 |
|
722 //Test 4 |
|
723 |
|
724 settings1->SetSmsBearerAction(CSmsSettings::ENone); |
|
725 StoreSettingsL(*settings1); |
|
726 iSmsTest(CompareSettingsAndSmsBearerL(*settings1)); |
|
727 |
|
728 //Test 5 |
|
729 |
|
730 settings1->SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred); |
|
731 iSmsTest(!CompareSettingsAndSmsBearerL(*settings1)); |
|
732 StoreSettingsL(*settings1); |
|
733 iSmsTest(!CompareSettingsAndSmsBearerL(*settings1)); |
|
734 |
|
735 CleanupStack::PopAndDestroy(2); //settings1, settings2 |
|
736 } |
|
737 |
|
738 TBool CSmutTest::CompareSettingsAndCommDbL(const CSmsSettings& aSettings) const |
|
739 { |
|
740 TCompare compare = ETrue; |
|
741 TBuf<256> scAddress; |
|
742 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
743 TRAPD(err, globalSettingsRecord.LoadL(*iDBSession)); |
|
744 if(err != KErrNone) |
|
745 { |
|
746 User::Leave(KErrNotFound); |
|
747 } |
|
748 CCDModemBearerRecord *modemBearerRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
749 CleanupStack::PushL(modemBearerRecord); |
|
750 modemBearerRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS); |
|
751 modemBearerRecord->LoadL(*iDBSession); |
|
752 scAddress = modemBearerRecord->iMessageCentreNumber; |
|
753 |
|
754 if (aSettings.DefaultServiceCenter() < 0 || !aSettings.ServiceCenterCount()) |
|
755 { |
|
756 compare(!scAddress.Length()); |
|
757 } |
|
758 else |
|
759 { |
|
760 compare(scAddress == aSettings.GetServiceCenter(aSettings.DefaultServiceCenter()).Address()); |
|
761 } |
|
762 |
|
763 TUint32 valPeriod = 0; |
|
764 valPeriod = modemBearerRecord->iMessageValidityPeriod; |
|
765 compare(valPeriod == (TUint32) aSettings.ValidityPeriod().Int()); |
|
766 |
|
767 TBool delReport = EFalse; |
|
768 delReport = modemBearerRecord->iMessageDeliveryReport; |
|
769 compare(delReport ? aSettings.DeliveryReport() : !aSettings.DeliveryReport()); |
|
770 |
|
771 CleanupStack::PopAndDestroy(modemBearerRecord); |
|
772 |
|
773 return compare; |
|
774 } |
|
775 |
|
776 TBool CSmutTest::CompareSettingsAndSmsBearerL(const CSmsSettings& aSettings) const |
|
777 { |
|
778 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
779 globalSettingsRecord.LoadL(*iDBSession); |
|
780 TUint32 smsBearer = ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer; |
|
781 TCompare compare(smsBearer == (TUint32) aSettings.SmsBearer()); |
|
782 return compare; |
|
783 } |
|
784 |
|
785 void CSmutTest::StoreNumberL(const CSmsNumber& aNumber, TUid aStreamId) |
|
786 { |
|
787 CMsvStore* store = iSmsTest.EditStoreL(); // lets edit the entry |
|
788 CleanupStack::PushL(store); |
|
789 |
|
790 RMsvWriteStream out; |
|
791 out.AssignLC(*store, aStreamId); // file stream id ok? |
|
792 aNumber.ExternalizeL(out); // lets extrenalise the instance |
|
793 out.CommitL(); |
|
794 store->CommitL(); |
|
795 |
|
796 CleanupStack::PopAndDestroy(2, store); |
|
797 } |
|
798 |
|
799 void CSmutTest::RestoreNumberL(CSmsNumber& rNumber, TUid aStreamId) |
|
800 { |
|
801 CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading |
|
802 CleanupStack::PushL(store); |
|
803 |
|
804 RMsvReadStream in; |
|
805 in.OpenLC(*store, aStreamId); // lets open the store for |
|
806 rNumber.InternalizeL(in); // internalising the address/name |
|
807 |
|
808 CleanupStack::PopAndDestroy(2, store); |
|
809 } |
|
810 |
|
811 void CSmutTest::StoreHeaderL(const CSmsHeader& aHeader) |
|
812 { |
|
813 CMsvStore* store = iSmsTest.EditStoreL(); |
|
814 CleanupStack::PushL(store); |
|
815 |
|
816 aHeader.StoreL(*store); |
|
817 store->CommitL(); |
|
818 |
|
819 CleanupStack::PopAndDestroy(store); |
|
820 } |
|
821 |
|
822 void CSmutTest::RestoreHeaderL(CSmsHeader& aHeader) |
|
823 { |
|
824 CMsvStore* store = iSmsTest.ReadStoreL(); |
|
825 CleanupStack::PushL(store); |
|
826 |
|
827 aHeader.RestoreL(*store); |
|
828 |
|
829 CleanupStack::PopAndDestroy(store); |
|
830 } |
|
831 |
|
832 void CSmutTest::StoreSettingsL(const CSmsSettings& aSettings) |
|
833 { |
|
834 CSmsAccount* account = CSmsAccount::NewLC(); |
|
835 account->SaveSettingsL(aSettings); |
|
836 CleanupStack::PopAndDestroy(account); |
|
837 } |
|
838 |
|
839 void CSmutTest::RestoreSettingsL(CSmsSettings& aSettings) |
|
840 { |
|
841 CSmsAccount* account = CSmsAccount::NewLC(); |
|
842 account->LoadSettingsL(aSettings); |
|
843 CleanupStack::PopAndDestroy(account); |
|
844 } |
|
845 |
|
846 TBool CSmutTest::CompareServiceCenters(const CSmsServiceCenter& aLeft, const CSmsServiceCenter& aRight) |
|
847 { |
|
848 TCompare compare(aLeft.Name() == aRight.Name()); |
|
849 compare(aLeft.Address() == aRight.Address()); |
|
850 return compare; |
|
851 } |
|
852 |
|
853 TBool CSmutTest::CompareNumbers(const CSmsNumber& aLeft, const CSmsNumber& aRight) |
|
854 { |
|
855 TCompare compare(aLeft.Name() == aRight.Name()); |
|
856 compare(aLeft.Address() == aRight.Address()); |
|
857 compare(aLeft.LogId() == aRight.LogId()); |
|
858 compare(aLeft.AckStatus(ESmsAckTypeDelivery) == aRight.AckStatus(ESmsAckTypeDelivery)); |
|
859 return compare; |
|
860 } |
|
861 |
|
862 void CSmutTest::TestNumberL() |
|
863 { |
|
864 iSmsTest.Test().Next(_L("Testing CSmsNumber")); |
|
865 iSmsTest.Printf(_L("Preparing test CSmsNumber")); |
|
866 |
|
867 TMsvId id=iSmsTest.CreateDummyMessageToSendL(); |
|
868 Session().CleanupEntryPushL(id); |
|
869 iSmsTest.SetEntryL(id); |
|
870 |
|
871 CSmsNumber* number0=CSmsNumber::NewL(); |
|
872 CleanupStack::PushL(number0); |
|
873 |
|
874 CSmsNumber* number=CSmsNumber::NewL(); // create the instance |
|
875 CleanupStack::PushL(number); |
|
876 |
|
877 // Testing the features of CSmsNumber |
|
878 // The max length for a name is 256 characters |
|
879 // The max length for a number is 20 characters |
|
880 |
|
881 // Lets take an ordinary number, test it, then store and restore it |
|
882 // and see if the values are still ok. |
|
883 |
|
884 number->SetNameL(_L("Radiolinja1")); |
|
885 number->SetAddressL(_L("+358508771010")); |
|
886 number->SetLogId(123456789); |
|
887 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
888 |
|
889 iSmsTest(number->Name()==_L("Radiolinja1")); // name ok? |
|
890 iSmsTest(number->Address()==_L("+358508771010")); // number ok? |
|
891 iSmsTest(number->LogId() == 123456789); |
|
892 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful); |
|
893 |
|
894 StoreNumberL(*number); |
|
895 RestoreNumberL(*number0); |
|
896 iSmsTest(CompareNumbers(*number0, *number)); |
|
897 |
|
898 // Lets try the max length of the telephone address, store and |
|
899 // restore it and see if it works |
|
900 |
|
901 number->SetNameL(_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?")); |
|
902 number->SetAddressL(_L("+0123456789012345678")); |
|
903 number->SetLogId(987654321); |
|
904 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError); |
|
905 |
|
906 iSmsTest(number->Name()==_L("Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?Whatsthemaximumlengthforthis?")); |
|
907 iSmsTest(number->Address()==_L("+0123456789012345678")); |
|
908 iSmsTest(number->LogId() == 987654321); |
|
909 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError); |
|
910 |
|
911 StoreNumberL(*number); |
|
912 RestoreNumberL(*number0); |
|
913 iSmsTest(CompareNumbers(*number, *number0)); |
|
914 |
|
915 // Lets use special Scandinavian letters both in the name and |
|
916 // address, store and restore and see if they are ok |
|
917 number->SetNameL(_L("ÖÄÅåöä")); |
|
918 number->SetAddressL(_L("åäöÅÄÖ")); |
|
919 number->SetLogId(123456789); |
|
920 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
921 |
|
922 iSmsTest(number->Name()==_L("ÖÄÅåöä")); |
|
923 iSmsTest(number->Address()==_L("åäöÅÄÖ")); |
|
924 iSmsTest(number->LogId() == 123456789); |
|
925 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful); |
|
926 |
|
927 StoreNumberL(*number); |
|
928 RestoreNumberL(*number0); |
|
929 iSmsTest(CompareNumbers(*number, *number0)); |
|
930 |
|
931 // Lets try if both the number and the name can be empty, |
|
932 // store and restore it and see if they still match |
|
933 number->SetNameL(_L("")); |
|
934 number->SetAddressL(_L("")); |
|
935 number->SetLogId(987654321); |
|
936 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckError); |
|
937 |
|
938 iSmsTest(number->Name()==_L("")); |
|
939 iSmsTest(number->Address()==_L("")); |
|
940 iSmsTest(number->LogId() == 987654321); |
|
941 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckError); |
|
942 |
|
943 StoreNumberL(*number); |
|
944 RestoreNumberL(*number0); |
|
945 iSmsTest(CompareNumbers(*number, *number0)); |
|
946 |
|
947 // Lets try [alt+255] as both the name and number, store and |
|
948 // restore it and see if it works |
|
949 number->SetNameL(_L(" ")); //alt+255 |
|
950 number->SetAddressL(_L(" ")); |
|
951 number->SetLogId(123456789); |
|
952 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EAckSuccessful); |
|
953 |
|
954 iSmsTest(number->Name()==_L(" ")); |
|
955 iSmsTest(number->Address()==_L(" ")); |
|
956 iSmsTest(number->LogId() == 123456789); |
|
957 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EAckSuccessful); |
|
958 |
|
959 StoreNumberL(*number); |
|
960 RestoreNumberL(*number0); |
|
961 iSmsTest(CompareNumbers(*number, *number0)); |
|
962 |
|
963 // Test CSmsNumber::CopyL() |
|
964 |
|
965 number->SetNameL(_L("DavidCuando")); |
|
966 number->SetAddressL(_L("+447747065627")); |
|
967 number->SetLogId(118888); |
|
968 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck); |
|
969 |
|
970 iSmsTest(number->Name()==_L("DavidCuando")); |
|
971 iSmsTest(number->Address()==_L("+447747065627")); |
|
972 iSmsTest(number->LogId() == 118888); |
|
973 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck); |
|
974 |
|
975 number0->CopyL(*number); |
|
976 iSmsTest(CompareNumbers(*number0, *number)); |
|
977 |
|
978 CleanupStack::PopAndDestroy(2, number0); |
|
979 |
|
980 // Test NewL(CSmsNumber&) |
|
981 |
|
982 number=CSmsNumber::NewL(); // create the instance |
|
983 CleanupStack::PushL(number); |
|
984 |
|
985 number->SetNameL(_L("DavidCuando")); |
|
986 number->SetAddressL(_L("+447747065627")); |
|
987 number->SetLogId(118888); |
|
988 number->SetAckStatus(ESmsAckTypeDelivery, CSmsNumber::EPendingAck); |
|
989 |
|
990 iSmsTest(number->Name()==_L("DavidCuando")); |
|
991 iSmsTest(number->Address()==_L("+447747065627")); |
|
992 iSmsTest(number->LogId() == 118888); |
|
993 iSmsTest(number->AckStatus(ESmsAckTypeDelivery) == CSmsNumber::EPendingAck); |
|
994 |
|
995 number0=CSmsNumber::NewL(*number); |
|
996 CleanupStack::PushL(number0); |
|
997 |
|
998 iSmsTest(CompareNumbers(*number0, *number)); |
|
999 CleanupStack::PopAndDestroy(2, number); |
|
1000 |
|
1001 //Test for defect EDNMOHN-4LDDK8 |
|
1002 number=CSmsNumber::NewL(); // create the instance |
|
1003 CleanupStack::PushL(number); |
|
1004 |
|
1005 StoreNumberL(*number); |
|
1006 RestoreNumberL(*number); |
|
1007 |
|
1008 number->SetAddressL(_L("+4477676545")); |
|
1009 //End Test for defect EDNMOHN-4LDDK8 |
|
1010 |
|
1011 CleanupStack::PopAndDestroy(number); |
|
1012 |
|
1013 Session().CleanupEntryPop(); |
|
1014 Session().RemoveEntry(id); |
|
1015 } |
|
1016 |
|
1017 void CSmutTest::StoreEmailFieldsL(const CSmsEmailFields& aEmailFields) |
|
1018 { |
|
1019 CMsvStore* store = iSmsTest.EditStoreL(); |
|
1020 CleanupStack::PushL(store); |
|
1021 |
|
1022 aEmailFields.StoreL(*store); |
|
1023 store->CommitL(); |
|
1024 |
|
1025 CleanupStack::PopAndDestroy(store); |
|
1026 } |
|
1027 |
|
1028 void CSmutTest::RestoreEmailFieldsL(CSmsEmailFields& aEmailFields) |
|
1029 { |
|
1030 CMsvStore* store = iSmsTest.ReadStoreL(); // prepare the store for reading |
|
1031 CleanupStack::PushL(store); |
|
1032 |
|
1033 aEmailFields.RestoreL(*store); |
|
1034 |
|
1035 CleanupStack::PopAndDestroy(store); |
|
1036 } |
|
1037 |
|
1038 TBool CSmutTest::CompareEmailFields(const CSmsEmailFields& aFields1, const CSmsEmailFields& aFields2) |
|
1039 { |
|
1040 TBool same = CompareEmailFieldsAddresses(aFields1.Addresses(), aFields2.Addresses()); |
|
1041 if( same ) |
|
1042 same = (aFields2.Subject().Compare(aFields1.Subject()) == 0); |
|
1043 if( same ) |
|
1044 same = (!aFields2.HasAddress()&&!aFields1.HasAddress() || aFields2.HasAddress()&&aFields1.HasAddress()); |
|
1045 if( same ) |
|
1046 same = (aFields2.Length() == aFields1.Length()); |
|
1047 return same; |
|
1048 } |
|
1049 |
|
1050 TBool CSmutTest::CompareEmailFieldsAddresses(const MDesCArray& aAddresses1, const MDesCArray& aAddresses2) |
|
1051 { |
|
1052 TBool same = (aAddresses1.MdcaCount() == aAddresses2.MdcaCount()); |
|
1053 if( same ) |
|
1054 { |
|
1055 TInt count = aAddresses1.MdcaCount(); |
|
1056 while( same && count-- > 0) |
|
1057 { |
|
1058 same = (aAddresses2.MdcaPoint(count).Compare(aAddresses1.MdcaPoint(count)) == 0); |
|
1059 } |
|
1060 } |
|
1061 return same; |
|
1062 } |
|
1063 |
|
1064 void CSmutTest::TestEmailFieldsL() |
|
1065 { |
|
1066 iSmsTest.Test().Next(_L("Testing CSmsEmailFields")); |
|
1067 iSmsTest.Printf(_L("Preparing test CSmsEmailFields")); |
|
1068 |
|
1069 TMsvId id=iSmsTest.CreateDummyMessageToSendL(); |
|
1070 Session().CleanupEntryPushL(id); |
|
1071 iSmsTest.SetEntryL(id); |
|
1072 |
|
1073 _LIT(KTestAddress, "support@symbian.com"); |
|
1074 _LIT(KTestSubject, "Happy Days!"); |
|
1075 |
|
1076 // Test CSmsEmailFields::NewL() |
|
1077 CSmsEmailFields* fields1 = CSmsEmailFields::NewL(); |
|
1078 CleanupStack::PushL(fields1); |
|
1079 |
|
1080 iSmsTest(fields1->Addresses().MdcaCount()==0); |
|
1081 iSmsTest(fields1->Subject().Compare(KNullDesC()) == 0); |
|
1082 iSmsTest(!fields1->HasAddress()); |
|
1083 iSmsTest(fields1->Length() == 0); |
|
1084 |
|
1085 // Test address and subject accessors, has-address, length and reset methods |
|
1086 fields1->AddAddressL(KNullDesC); // empty address - does nothing! |
|
1087 iSmsTest(fields1->Addresses().MdcaCount()==0); |
|
1088 iSmsTest(fields1->Subject().Compare(KNullDesC()) == 0); |
|
1089 iSmsTest(!fields1->HasAddress()); |
|
1090 iSmsTest(fields1->Length() == 0); |
|
1091 |
|
1092 fields1->AddAddressL(KTestAddress); |
|
1093 iSmsTest(fields1->Addresses().MdcaCount()==1); |
|
1094 iSmsTest(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) == 0); |
|
1095 iSmsTest(fields1->HasAddress()); |
|
1096 iSmsTest(fields1->Length() == KTestAddress().Length() + 1); |
|
1097 |
|
1098 fields1->SetSubjectL(KTestSubject); |
|
1099 iSmsTest(fields1->HasAddress()); |
|
1100 iSmsTest(fields1->Length() == KTestAddress().Length() + KTestSubject().Length() + 2); |
|
1101 |
|
1102 fields1->Reset(); |
|
1103 iSmsTest(fields1->Addresses().MdcaCount()==0); |
|
1104 iSmsTest(fields1->Subject().Compare(KNullDesC()) == 0); |
|
1105 iSmsTest(!fields1->HasAddress()); |
|
1106 iSmsTest(fields1->Length() == 0); |
|
1107 |
|
1108 fields1->SetSubjectL(KTestSubject); |
|
1109 iSmsTest(fields1->Subject().Compare(KTestSubject) == 0); |
|
1110 iSmsTest(!fields1->HasAddress()); |
|
1111 iSmsTest(fields1->Length() == KTestSubject().Length() + 2); |
|
1112 |
|
1113 fields1->AddAddressL(KTestAddress); |
|
1114 iSmsTest(fields1->Addresses().MdcaCount()==1); |
|
1115 iSmsTest(fields1->Addresses().MdcaPoint(0).Compare(KTestAddress) == 0); |
|
1116 iSmsTest(fields1->HasAddress()); |
|
1117 iSmsTest(fields1->Length() == KTestAddress().Length() + KTestSubject().Length() + 2); |
|
1118 |
|
1119 // Test multiple addresses - add empty address -> not added |
|
1120 fields1->AddAddressL(KNullDesC); |
|
1121 iSmsTest(fields1->Addresses().MdcaCount()==1); |
|
1122 |
|
1123 _LIT(KTestAddress2, "support2@symbian.com"); |
|
1124 fields1->AddAddressL(KTestAddress2); |
|
1125 iSmsTest(fields1->Addresses().MdcaCount()==2); |
|
1126 iSmsTest(fields1->Addresses().MdcaPoint(1).Compare(KTestAddress2) == 0); |
|
1127 iSmsTest(fields1->HasAddress()); |
|
1128 // NOTE - length check; 3 -> 2 for subject delimiters, 1 for address comma separtor. |
|
1129 iSmsTest(fields1->Length() == KTestAddress().Length() + KTestAddress2().Length() + KTestSubject().Length() + 3); |
|
1130 |
|
1131 // Test copy factory c'tor |
|
1132 CSmsEmailFields* fields2 = CSmsEmailFields::NewL(*fields1); |
|
1133 CleanupStack::PushL(fields2); |
|
1134 |
|
1135 iSmsTest(CompareEmailFields(*fields2, *fields1)); |
|
1136 |
|
1137 // Test store and restore |
|
1138 StoreEmailFieldsL(*fields1); |
|
1139 fields2->Reset(); |
|
1140 RestoreEmailFieldsL(*fields2); |
|
1141 |
|
1142 iSmsTest(CompareEmailFields(*fields2, *fields1)); |
|
1143 |
|
1144 fields1->Reset(); |
|
1145 StoreEmailFieldsL(*fields1); |
|
1146 RestoreEmailFieldsL(*fields2); |
|
1147 |
|
1148 iSmsTest(CompareEmailFields(*fields2, *fields1)); |
|
1149 |
|
1150 CleanupStack::PopAndDestroy(2, fields1); |
|
1151 |
|
1152 // Test parsing - expected data. |
|
1153 _LIT(KTestBodyData, "Some body text#( )#"); |
|
1154 |
|
1155 _LIT(KTestParseAddress1, "user1@symbian.com"); |
|
1156 _LIT(KTestParseSubject1, ""); |
|
1157 _LIT(KTestEmail1, "user1@symbian.com Some body text#( )#"); |
|
1158 TestEmailFieldsParsePassL(KTestEmail1, KTestParseAddress1, KTestParseSubject1, KTestBodyData); |
|
1159 |
|
1160 _LIT(KTestParseFullAddress1, "Some User <user1@symbian.com>"); |
|
1161 _LIT(KTestEmail2, "Some User <user1@symbian.com> Some body text#( )#"); |
|
1162 TestEmailFieldsParsePassL(KTestEmail2, KTestParseFullAddress1, KTestParseSubject1, KTestBodyData); |
|
1163 |
|
1164 _LIT(KTestParseAddress2, "user2@symbian.com"); |
|
1165 _LIT(KTestParseSubject2, "subject (2)"); |
|
1166 _LIT(KTestEmail3, "user2@symbian.com##subject (2)#Some body text#( )#"); |
|
1167 TestEmailFieldsParsePassL(KTestEmail3, KTestParseAddress2, KTestParseSubject2, KTestBodyData); |
|
1168 |
|
1169 _LIT(KTestParseFullAddress2, "Some User <user2@symbian.com>"); |
|
1170 _LIT(KTestEmail4, "Some User <user2@symbian.com>##subject (2)#Some body text#( )#"); |
|
1171 TestEmailFieldsParsePassL(KTestEmail4, KTestParseFullAddress2, KTestParseSubject2, KTestBodyData); |
|
1172 |
|
1173 _LIT(KTestParseAddress3, "user3@symbian.com"); |
|
1174 _LIT(KTestParseSubject3, "subject #3"); |
|
1175 _LIT(KTestEmail5, "user3@symbian.com(subject #3)Some body text#( )#"); |
|
1176 TestEmailFieldsParsePassL(KTestEmail5, KTestParseAddress3, KTestParseSubject3, KTestBodyData); |
|
1177 |
|
1178 _LIT(KTestParseFullAddress3, "Some User <user3@symbian.com>"); |
|
1179 _LIT(KTestEmail6, "Some User <user3@symbian.com>(subject #3)Some body text#( )#"); |
|
1180 TestEmailFieldsParsePassL(KTestEmail6, KTestParseFullAddress3, KTestParseSubject3, KTestBodyData); |
|
1181 |
|
1182 _LIT(KTestParseAddress4, "user4@symbian.com"); |
|
1183 _LIT(KTestParseSubject4, ""); |
|
1184 _LIT(KTestEmail7, "user4@symbian.com()Some body text#( )#"); |
|
1185 TestEmailFieldsParsePassL(KTestEmail7, KTestParseAddress4, KTestParseSubject4, KTestBodyData); |
|
1186 |
|
1187 _LIT(KTestParseFullAddress4, "Some User <user4@symbian.com>"); |
|
1188 _LIT(KTestEmail8, "Some User <user4@symbian.com>()Some body text#( )#"); |
|
1189 TestEmailFieldsParsePassL(KTestEmail8, KTestParseFullAddress4, KTestParseSubject4, KTestBodyData); |
|
1190 |
|
1191 _LIT(KTestParseAddress5, "user5@symbian.com"); |
|
1192 _LIT(KTestParseSubject5, ""); |
|
1193 _LIT(KTestEmail9, "user5@symbian.com###Some body text#( )#"); |
|
1194 TestEmailFieldsParsePassL(KTestEmail9, KTestParseAddress5, KTestParseSubject5, KTestBodyData); |
|
1195 |
|
1196 _LIT(KTestParseFullAddress5, "Some User <user5@symbian.com>"); |
|
1197 _LIT(KTestEmail10, "Some User <user5@symbian.com>###Some body text#( )#"); |
|
1198 TestEmailFieldsParsePassL(KTestEmail10, KTestParseFullAddress5, KTestParseSubject5, KTestBodyData); |
|
1199 |
|
1200 // Test parsing - corrupt but parse-able data. |
|
1201 _LIT(KTestCorruptAddress1, "user1@symbian.com"); |
|
1202 _LIT(KTestCorruptSubject1, "smiley ;"); |
|
1203 _LIT(KTestCorruptBody1, " subject)Some body text"); |
|
1204 _LIT(KTestCorruptEmail1, "user1@symbian.com(smiley ;) subject)Some body text"); |
|
1205 TestEmailFieldsParsePassL(KTestCorruptEmail1, KTestCorruptAddress1, KTestCorruptSubject1, KTestCorruptBody1); |
|
1206 |
|
1207 _LIT(KTestCorruptAddress2, "user1@symbian.com"); |
|
1208 _LIT(KTestCorruptSubject2, ""); |
|
1209 _LIT(KTestCorruptBody2, "(bad subject)Some body text"); |
|
1210 _LIT(KTestCorruptEmail2, "user1@symbian.com (bad subject)Some body text"); |
|
1211 TestEmailFieldsParsePassL(KTestCorruptEmail2, KTestCorruptAddress2, KTestCorruptSubject2, KTestCorruptBody2); |
|
1212 |
|
1213 _LIT(KTestCorruptAddress3, "user1@symbian.com"); |
|
1214 _LIT(KTestCorruptSubject3, ""); |
|
1215 _LIT(KTestCorruptBody3, "bad subject##Some body text"); |
|
1216 _LIT(KTestCorruptEmail3, "user1@symbian.com###bad subject##Some body text"); |
|
1217 TestEmailFieldsParsePassL(KTestCorruptEmail3, KTestCorruptAddress3, KTestCorruptSubject3, KTestCorruptBody3); |
|
1218 |
|
1219 // Test parsing - corrupt and fail. |
|
1220 _LIT(KTestFailEmail1, "user#domain1.domain2 Some body text"); |
|
1221 TestEmailFieldsParseFailL(KTestFailEmail1); |
|
1222 |
|
1223 _LIT(KTestFailEmail2, "user@domain1.domain2+Some+body+text"); |
|
1224 TestEmailFieldsParseFailL(KTestFailEmail2); |
|
1225 |
|
1226 _LIT(KTestFailEmail3, "user@domain1.domain2##(subject)Some+body+text"); |
|
1227 TestEmailFieldsParseFailL(KTestFailEmail3); |
|
1228 |
|
1229 _LIT(KTestFailEmail4, "user@domain1.domain2(##subject#Some+body+text"); |
|
1230 TestEmailFieldsParseFailL(KTestFailEmail4); |
|
1231 |
|
1232 _LIT(KTestFailEmail5, "user1@symbian.com#bad subject#Some body text"); |
|
1233 TestEmailFieldsParseFailL(KTestFailEmail5); |
|
1234 |
|
1235 // Test composing - ok |
|
1236 _LIT(KTestComposeAddress1, "user1@domain1.domain2"); |
|
1237 _LIT(KTestComposeSubject1, ""); |
|
1238 _LIT(KTestComposeFields1, "user1@domain1.domain2 "); |
|
1239 TestEmailFieldsComposeL(KTestComposeFields1, KTestComposeAddress1, KNullDesC, KTestComposeSubject1); |
|
1240 |
|
1241 _LIT(KTestComposeAddress2, "user2@domain1.domain2"); |
|
1242 _LIT(KTestComposeSubject2, "a subject"); |
|
1243 _LIT(KTestComposeFields2, "user2@domain1.domain2(a subject)"); |
|
1244 TestEmailFieldsComposeL(KTestComposeFields2, KTestComposeAddress2, KNullDesC, KTestComposeSubject2); |
|
1245 |
|
1246 _LIT(KTestComposeFields3, "user1@domain1.domain2,user2@domain1.domain2 "); |
|
1247 TestEmailFieldsComposeL(KTestComposeFields3, KTestComposeAddress1, KTestComposeAddress2, KTestComposeSubject1); |
|
1248 |
|
1249 _LIT(KTestComposeFields4, "user2@domain1.domain2,user1@domain1.domain2(a subject)"); |
|
1250 TestEmailFieldsComposeL(KTestComposeFields4, KTestComposeAddress2, KTestComposeAddress1, KTestComposeSubject2); |
|
1251 |
|
1252 // Testing composing - fail, no address. |
|
1253 CSmsEmailFields* fields3 = CSmsEmailFields::NewL(); |
|
1254 CleanupStack::PushL(fields3); |
|
1255 |
|
1256 fields3->AddAddressL(KNullDesC); |
|
1257 fields3->SetSubjectL(KTestSubject); |
|
1258 |
|
1259 TRAPD(err, fields3->ComposeLC()); |
|
1260 |
|
1261 iSmsTest(err==KErrCorrupt); |
|
1262 |
|
1263 CleanupStack::PopAndDestroy(fields3); |
|
1264 |
|
1265 Session().CleanupEntryPop(); |
|
1266 Session().RemoveEntry(id); |
|
1267 } |
|
1268 |
|
1269 void CSmutTest::TestEmailFieldsParsePassL(const TDesC& aMessage, const TDesC& aAddress, const TDesC& aSubject, const TDesC& aBody) |
|
1270 { |
|
1271 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
1272 CleanupStack::PushL(fields); |
|
1273 |
|
1274 TInt pos = fields->ParseL(aMessage); |
|
1275 |
|
1276 TPtrC body(aMessage.Mid(pos)); |
|
1277 iSmsTest(fields->HasAddress()); |
|
1278 iSmsTest(fields->Addresses().MdcaCount()==1); |
|
1279 iSmsTest(fields->Addresses().MdcaPoint(0).Compare(aAddress) == 0); |
|
1280 iSmsTest(fields->Subject().Compare(aSubject) == 0); |
|
1281 iSmsTest(body.Compare(aBody) == 0); |
|
1282 |
|
1283 CleanupStack::PopAndDestroy(fields); |
|
1284 } |
|
1285 |
|
1286 void CSmutTest::TestEmailFieldsParseFailL(const TDesC& aMessage) |
|
1287 { |
|
1288 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
1289 CleanupStack::PushL(fields); |
|
1290 |
|
1291 TInt pos = fields->ParseL(aMessage); |
|
1292 |
|
1293 iSmsTest(pos == KErrCorrupt); |
|
1294 |
|
1295 CleanupStack::PopAndDestroy(fields); |
|
1296 } |
|
1297 |
|
1298 void CSmutTest::TestEmailFieldsComposeL(const TDesC& aFields, const TDesC& aAddress1, const TDesC& aAddress2, const TDesC& aSubject) |
|
1299 { |
|
1300 CSmsEmailFields* fields = CSmsEmailFields::NewL(); |
|
1301 CleanupStack::PushL(fields); |
|
1302 |
|
1303 fields->AddAddressL(aAddress1); |
|
1304 fields->AddAddressL(aAddress2); |
|
1305 fields->SetSubjectL(aSubject); |
|
1306 HBufC* buffer = fields->ComposeLC(); |
|
1307 |
|
1308 iSmsTest(aFields.Compare(*buffer) == 0); |
|
1309 |
|
1310 CleanupStack::PopAndDestroy(2, fields); // fields, buffer |
|
1311 } |
|
1312 |
|
1313 void CSmutTest::TestHeaderL() |
|
1314 { |
|
1315 |
|
1316 // Testing class CSmsHeader |
|
1317 iSmsTest.Test().Next(_L("Testing CSmsHeader")); |
|
1318 |
|
1319 // A CSmsHeader can be of 6 different types |
|
1320 // First we test constructing ESmsDeliver |
|
1321 delete iSmsHeader; // deleting the previous one |
|
1322 iSmsHeader = NULL; |
|
1323 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); // constructing |
|
1324 iSmsTest(iSmsHeader->Type()==CSmsPDU::ESmsDeliver); // type ok? |
|
1325 |
|
1326 CSmsDeliver& deliver = iSmsHeader->Deliver(); // lets get the CSmsPDU of the CSmsHeader |
|
1327 const CSmsDeliver& deliver2 = iSmsHeader->Deliver(); |
|
1328 |
|
1329 iSmsTest(deliver.Type() == CSmsPDU::ESmsDeliver); // Are the types ok? |
|
1330 iSmsTest(deliver2.Type() == CSmsPDU::ESmsDeliver); |
|
1331 |
|
1332 // Type ESmsCommand |
|
1333 delete iSmsHeader; // deleting previous |
|
1334 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsCommand,*iRichText); |
|
1335 iSmsTest(iSmsHeader->Type()==CSmsPDU::ESmsCommand); |
|
1336 |
|
1337 CSmsCommand& command=iSmsHeader->Command(); |
|
1338 const CSmsCommand& command2=iSmsHeader->Command(); |
|
1339 |
|
1340 iSmsTest(command.Type() == CSmsPDU::ESmsCommand); |
|
1341 iSmsTest(command2.Type() == CSmsPDU::ESmsCommand); |
|
1342 |
|
1343 // Type ESmsStatusReport |
|
1344 delete iSmsHeader; // deleting the previous one |
|
1345 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsStatusReport,*iRichText); |
|
1346 iSmsTest(iSmsHeader->Type()==CSmsPDU::ESmsStatusReport); |
|
1347 |
|
1348 CSmsStatusReport& statusreport=iSmsHeader->StatusReport(); |
|
1349 const CSmsStatusReport& statusreport2=iSmsHeader->StatusReport(); |
|
1350 |
|
1351 iSmsTest(statusreport.Type() == CSmsPDU::ESmsStatusReport); |
|
1352 iSmsTest(statusreport2.Type() == CSmsPDU::ESmsStatusReport); |
|
1353 |
|
1354 // Type ESmsSubmit |
|
1355 delete iSmsHeader; // deleting the previous one |
|
1356 iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
1357 iSmsTest(iSmsHeader->Type()==CSmsPDU::ESmsSubmit); |
|
1358 |
|
1359 CSmsSubmit& submit=iSmsHeader->Submit(); |
|
1360 const CSmsSubmit& submit2=iSmsHeader->Submit(); |
|
1361 |
|
1362 iSmsTest(submit.Type() == CSmsPDU::ESmsSubmit); |
|
1363 iSmsTest(submit2.Type() == CSmsPDU::ESmsSubmit); |
|
1364 |
|
1365 // Lets access the CSmsMessage of our header |
|
1366 CSmsMessage& message=iSmsHeader->Message(); |
|
1367 const CSmsMessage& message2=iSmsHeader->Message(); |
|
1368 |
|
1369 iSmsTest(message.Type() == CSmsPDU::ESmsSubmit); |
|
1370 iSmsTest(message2.Type() == CSmsPDU::ESmsSubmit); |
|
1371 |
|
1372 // Lets test the features of CSmsHeader with different values |
|
1373 iSmsHeader->SetReplyPathProvided(ETrue); |
|
1374 iSmsTest(iSmsHeader->ReplyPathProvided()); |
|
1375 iSmsHeader->SetReplyPathProvided(EFalse); |
|
1376 iSmsTest(!iSmsHeader->ReplyPathProvided()); |
|
1377 |
|
1378 iSmsHeader->SetBioMsgIdType(EBioMsgIdUnknown); |
|
1379 iSmsTest(iSmsHeader->BioMsgIdType()==EBioMsgIdUnknown); |
|
1380 iSmsHeader->SetBioMsgIdType(EBioMsgIdIana); |
|
1381 iSmsTest(iSmsHeader->BioMsgIdType()==EBioMsgIdIana); |
|
1382 iSmsHeader->SetBioMsgIdType(EBioMsgIdNbs); |
|
1383 iSmsTest(iSmsHeader->BioMsgIdType()==EBioMsgIdNbs); |
|
1384 iSmsHeader->SetBioMsgIdType(EBioMsgIdWap); |
|
1385 iSmsTest(iSmsHeader->BioMsgIdType()==EBioMsgIdWap); |
|
1386 iSmsHeader->SetBioMsgIdType(EBioMsgIdWapSecure); |
|
1387 iSmsTest(iSmsHeader->BioMsgIdType()==EBioMsgIdWapSecure); |
|
1388 |
|
1389 // Lets set the service center number |
|
1390 iSmsHeader->SetServiceCenterAddressL(_L("+350508771010")); |
|
1391 iSmsTest(iSmsHeader->ServiceCenterAddress()==_L("+350508771010")); |
|
1392 |
|
1393 // Lets set one recipient for the message |
|
1394 CArrayPtrFlat<CSmsNumber>& recipients = iSmsHeader->Recipients(); |
|
1395 CSmsNumber* number=CSmsNumber::NewL(); |
|
1396 CleanupStack::PushL(number); |
|
1397 number->SetAddressL(_L("+358503367709")); |
|
1398 recipients.AppendL(number); |
|
1399 CleanupStack::Pop(); |
|
1400 |
|
1401 // Setting settings of the message |
|
1402 CSmsSettings* smsset = CSmsSettings::NewL(); |
|
1403 CleanupStack::PushL(smsset); |
|
1404 smsset->AddServiceCenterL(_L("Hippo"), _L("+358508771010")); |
|
1405 smsset->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
1406 smsset->SetDelivery(ESmsDeliveryImmediately); |
|
1407 smsset->SetDeliveryReport(EFalse); |
|
1408 smsset->SetMessageConversion(ESmsConvPIDNone); |
|
1409 smsset->SetRejectDuplicate(ETrue); |
|
1410 smsset->SetReplyPath(EFalse); |
|
1411 smsset->SetValidityPeriod(ESmsVP24Hours); |
|
1412 smsset->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
1413 // And copying them to the CSmsHeader |
|
1414 iSmsHeader->SetSmsSettingsL(*smsset); |
|
1415 CleanupStack::PopAndDestroy(smsset); |
|
1416 |
|
1417 CSmsSettings* smsset2 = CSmsSettings::NewL(); |
|
1418 CleanupStack::PushL(smsset2); |
|
1419 // Lets get the same setting from the CSmsHeader |
|
1420 iSmsHeader->GetSmsSettingsL(*smsset2); |
|
1421 // And compare that they are ok! |
|
1422 iSmsTest(smsset2->CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
1423 iSmsTest(!smsset2->DeliveryReport()); |
|
1424 iSmsTest(smsset2->MessageConversion()==ESmsConvPIDNone); |
|
1425 iSmsTest(smsset2->RejectDuplicate()); |
|
1426 iSmsTest(!smsset2->ReplyPath()); |
|
1427 iSmsTest(smsset2->ValidityPeriod().Int()==ESmsVP24Hours); |
|
1428 iSmsTest(smsset2->ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet); |
|
1429 CleanupStack::PopAndDestroy(smsset2); |
|
1430 |
|
1431 //Test Set/FromAddress() |
|
1432 iSmsHeader->SetFromAddressL(_L("+358503367709")); |
|
1433 iSmsTest(iSmsHeader->FromAddress()==_L("+358503367709")); |
|
1434 |
|
1435 //Test Set/EmailFields() |
|
1436 _LIT(KTestAddress, "user@domain1.domain2"); |
|
1437 _LIT(KTestSubject, "a subject"); |
|
1438 |
|
1439 CSmsEmailFields* fields1 = CSmsEmailFields::NewL(); |
|
1440 CleanupStack::PushL(fields1); |
|
1441 |
|
1442 fields1->AddAddressL(KTestAddress); |
|
1443 fields1->SetSubjectL(KTestSubject); |
|
1444 |
|
1445 // Test the PID field value - should be ESmsConvPIDNone... |
|
1446 CSmsSettings* smsset3 = CSmsSettings::NewL(); |
|
1447 CleanupStack::PushL(smsset3); |
|
1448 |
|
1449 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1450 iSmsTest(smsset3->MessageConversion()==ESmsConvPIDNone); |
|
1451 |
|
1452 // Set the email fields - check the email fields and the PID value (should |
|
1453 // be ESmsConvMail). |
|
1454 iSmsHeader->SetEmailFieldsL(*fields1); |
|
1455 const CSmsEmailFields& fields2 = iSmsHeader->EmailFields(); |
|
1456 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1457 |
|
1458 iSmsTest(CompareEmailFields(*fields1, fields2)); |
|
1459 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1460 |
|
1461 // Reset the fields and then set back in the header - should reset the PID |
|
1462 // value to ESmsConvPIDNone |
|
1463 fields1->Reset(); |
|
1464 iSmsHeader->SetEmailFieldsL(*fields1); |
|
1465 |
|
1466 const CSmsEmailFields& fields3 = iSmsHeader->EmailFields(); |
|
1467 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1468 |
|
1469 iSmsTest(CompareEmailFields(*fields1, fields3)); |
|
1470 iSmsTest(smsset3->MessageConversion()==ESmsConvPIDNone); |
|
1471 |
|
1472 // Set the reply email fields - check email fields (both address and subject) |
|
1473 // and the PID value (should be ESmsConvMail) |
|
1474 _LIT(KEmailReplySubjectFormat, "Re: %S"); |
|
1475 _LIT(KEmailReplySubject, "Re: a subject"); |
|
1476 |
|
1477 // First test with no subject... |
|
1478 fields1->AddAddressL(KTestAddress); |
|
1479 |
|
1480 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
1481 const CSmsEmailFields& replyFields1 = iSmsHeader->EmailFields(); |
|
1482 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1483 |
|
1484 iSmsTest(CompareEmailFieldsAddresses(replyFields1.Addresses(), fields1->Addresses())); |
|
1485 iSmsTest(replyFields1.Subject().Compare(KNullDesC) == 0); |
|
1486 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1487 |
|
1488 // Now set the subject... |
|
1489 fields1->SetSubjectL(KTestSubject); |
|
1490 |
|
1491 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
1492 const CSmsEmailFields& replyFields2 = iSmsHeader->EmailFields(); |
|
1493 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1494 |
|
1495 iSmsTest(CompareEmailFieldsAddresses(replyFields2.Addresses(), fields1->Addresses())); |
|
1496 iSmsTest(replyFields2.Subject().Compare(KEmailReplySubject()) == 0); |
|
1497 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1498 |
|
1499 // Repeat - test for (lack of) Re: chain. |
|
1500 fields1->SetSubjectL(KEmailReplySubject); |
|
1501 |
|
1502 iSmsHeader->SetReplyEmailFieldsL(*fields1, KEmailReplySubjectFormat); |
|
1503 const CSmsEmailFields& replyFields3 = iSmsHeader->EmailFields(); |
|
1504 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1505 |
|
1506 iSmsTest(CompareEmailFieldsAddresses(replyFields3.Addresses(), fields1->Addresses())); |
|
1507 iSmsTest(replyFields3.Subject().Compare(KEmailReplySubject()) == 0); |
|
1508 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1509 |
|
1510 // Set the forward email fields - check email fields (both address and subject) |
|
1511 // and the PID value (should be ESmsConvMail) |
|
1512 _LIT(KEmailForwardSubjectFormat, "Fw: %S"); |
|
1513 _LIT(KEmailForwardSubject, "Fw: a subject"); |
|
1514 |
|
1515 // First test with no subject... |
|
1516 fields1->Reset(); |
|
1517 fields1->AddAddressL(KTestAddress); |
|
1518 |
|
1519 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
1520 const CSmsEmailFields& forwardFields1 = iSmsHeader->EmailFields(); |
|
1521 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1522 |
|
1523 iSmsTest(!forwardFields1.HasAddress()); |
|
1524 iSmsTest(forwardFields1.Addresses().MdcaCount()==0); |
|
1525 iSmsTest(forwardFields1.Subject().Compare(KNullDesC) == 0); |
|
1526 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1527 |
|
1528 // Now set the subject... |
|
1529 fields1->SetSubjectL(KTestSubject); |
|
1530 |
|
1531 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
1532 const CSmsEmailFields& forwardFields2 = iSmsHeader->EmailFields(); |
|
1533 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1534 |
|
1535 iSmsTest(!forwardFields2.HasAddress()); |
|
1536 iSmsTest(forwardFields2.Addresses().MdcaCount()==0); |
|
1537 iSmsTest(forwardFields2.Subject().Compare(KEmailForwardSubject()) == 0); |
|
1538 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1539 |
|
1540 // Repeat - test for (lack of) Fw: chain. |
|
1541 fields1->SetSubjectL(KEmailForwardSubject); |
|
1542 |
|
1543 iSmsHeader->SetForwardEmailFieldsL(*fields1, KEmailForwardSubjectFormat); |
|
1544 const CSmsEmailFields& forwardFields3 = iSmsHeader->EmailFields(); |
|
1545 iSmsHeader->GetSmsSettingsL(*smsset3); |
|
1546 |
|
1547 iSmsTest(!forwardFields3.HasAddress()); |
|
1548 iSmsTest(forwardFields3.Addresses().MdcaCount()==0); |
|
1549 iSmsTest(forwardFields3.Subject().Compare(KEmailForwardSubject()) == 0); |
|
1550 iSmsTest(smsset3->MessageConversion()==ESmsConvMail); |
|
1551 |
|
1552 // Reset the fields and set back in the header. |
|
1553 fields1->Reset(); |
|
1554 iSmsHeader->SetEmailFieldsL(*fields1); |
|
1555 |
|
1556 CleanupStack::PopAndDestroy(2, fields1); |
|
1557 |
|
1558 //Lets store and restore the CSmsHeader and test that the values are right |
|
1559 TMsvId id = iSmsTest.CreateDummyMessageToSendL(); |
|
1560 Session().CleanupEntryPushL(id); |
|
1561 iSmsTest.SetEntryL(id); |
|
1562 |
|
1563 StoreHeaderL(*iSmsHeader); |
|
1564 |
|
1565 // Check that the email fields stream is not present, as there is no email |
|
1566 // fields data. |
|
1567 CMsvStore* store1 = iSmsTest.ReadStoreL(); |
|
1568 CleanupStack::PushL(store1); |
|
1569 iSmsTest(!store1->IsPresentL(KUidMsvSmsEmailFieldsStream)); |
|
1570 CleanupStack::PopAndDestroy(store1); |
|
1571 |
|
1572 CSmsHeader* header1 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
1573 CleanupStack::PushL(header1); |
|
1574 |
|
1575 RestoreHeaderL(*header1); |
|
1576 |
|
1577 //Values ok? |
|
1578 iSmsTest(iSmsHeader->Type()==header1->Type()); |
|
1579 iSmsTest(!header1->ReplyPathProvided()); |
|
1580 iSmsTest(header1->ServiceCenterAddress()==_L("+350508771010")); |
|
1581 iSmsTest(iSmsHeader->Recipients().Count()==header1->Recipients().Count()); |
|
1582 iSmsTest(iSmsHeader->BioMsgIdType()==header1->BioMsgIdType()); |
|
1583 iSmsTest(iSmsHeader->FromAddress()==header1->FromAddress()); |
|
1584 |
|
1585 // Lets get the setting of the message |
|
1586 CSmsSettings* smsset4 = CSmsSettings::NewL(); |
|
1587 CleanupStack::PushL(smsset4); |
|
1588 header1->GetSmsSettingsL(*smsset4); |
|
1589 |
|
1590 // And compare that they are the original values |
|
1591 iSmsTest(smsset4->CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
1592 iSmsTest(!smsset4->DeliveryReport()); |
|
1593 iSmsTest(smsset4->MessageConversion()==ESmsConvPIDNone); |
|
1594 iSmsTest(smsset4->RejectDuplicate()); |
|
1595 iSmsTest(!smsset4->ReplyPath()); |
|
1596 iSmsTest(smsset4->ValidityPeriod().Int()==ESmsVP24Hours); |
|
1597 iSmsTest(smsset4->ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet); |
|
1598 |
|
1599 CleanupStack::PopAndDestroy(2, header1); |
|
1600 |
|
1601 // Test with email fields data. |
|
1602 CSmsEmailFields* fields8 = CSmsEmailFields::NewL(); |
|
1603 CleanupStack::PushL(fields8); |
|
1604 fields8->AddAddressL(KTestAddress); |
|
1605 fields8->SetSubjectL(KTestSubject); |
|
1606 iSmsHeader->SetEmailFieldsL(*fields8); |
|
1607 |
|
1608 StoreHeaderL(*iSmsHeader); |
|
1609 |
|
1610 // Check that the email fields stream is present, as there is now email |
|
1611 // fields data. |
|
1612 CMsvStore* store2 = iSmsTest.EditStoreL(); |
|
1613 CleanupStack::PushL(store2); |
|
1614 iSmsTest(store2->IsPresentL(KUidMsvSmsEmailFieldsStream)); |
|
1615 CleanupStack::PopAndDestroy(store2); |
|
1616 |
|
1617 CSmsHeader* header2 = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
1618 CleanupStack::PushL(header2); |
|
1619 |
|
1620 RestoreHeaderL(*header2); |
|
1621 |
|
1622 iSmsTest(iSmsHeader->Type()==header2->Type()); |
|
1623 iSmsTest(!header2->ReplyPathProvided()); |
|
1624 iSmsTest(header2->ServiceCenterAddress()==_L("+350508771010")); |
|
1625 iSmsTest(iSmsHeader->Recipients().Count()==header2->Recipients().Count()); |
|
1626 iSmsTest(iSmsHeader->BioMsgIdType()==header2->BioMsgIdType()); |
|
1627 iSmsTest(iSmsHeader->FromAddress()==header2->FromAddress()); |
|
1628 |
|
1629 CSmsSettings* smsset5 = CSmsSettings::NewL(); |
|
1630 CleanupStack::PushL(smsset5); |
|
1631 header2->GetSmsSettingsL(*smsset5); |
|
1632 |
|
1633 iSmsTest(smsset5->CharacterSet()==TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
1634 iSmsTest(!smsset5->DeliveryReport()); |
|
1635 iSmsTest(smsset5->MessageConversion()==ESmsConvMail); |
|
1636 iSmsTest(smsset5->RejectDuplicate()); |
|
1637 iSmsTest(!smsset5->ReplyPath()); |
|
1638 iSmsTest(smsset5->ValidityPeriod().Int()==ESmsVP24Hours); |
|
1639 iSmsTest(smsset5->ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet); |
|
1640 |
|
1641 const CSmsEmailFields& fields9 = iSmsHeader->EmailFields(); |
|
1642 iSmsTest(CompareEmailFields(*fields8, fields9)); |
|
1643 |
|
1644 CleanupStack::PopAndDestroy(3, fields8); |
|
1645 |
|
1646 //Test NewL that takes a CSmsMessage - pretend it's an email message. |
|
1647 RFs fs; |
|
1648 User::LeaveIfError(fs.Connect()); |
|
1649 CleanupClosePushL(fs); |
|
1650 |
|
1651 // Test un-corrupt email - add an appropriate email message |
|
1652 _LIT(KTestEmailAddress1, "user@domain1.domain2"); |
|
1653 _LIT(KTestEmailSubject1, "a subject"); |
|
1654 _LIT(KTestEmailBody1, "some body text"); |
|
1655 _LIT(KTestEmailMessage1, "user@domain1.domain2##a subject#some body text"); |
|
1656 |
|
1657 CSmsMessage* email1 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse); |
|
1658 CleanupStack::PushL(email1); |
|
1659 |
|
1660 CSmsBufferBase& buffer1 = email1->Buffer(); |
|
1661 buffer1.Reset(); |
|
1662 buffer1.InsertL(0, KTestEmailMessage1()); |
|
1663 |
|
1664 // Set the PID for email. |
|
1665 CSmsPDU& pdu1 = email1->SmsPDU(); |
|
1666 if( pdu1.ProtocolIdentifierPresent() ) |
|
1667 { |
|
1668 pdu1.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking); |
|
1669 pdu1.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice); |
|
1670 pdu1.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail); |
|
1671 } |
|
1672 |
|
1673 // create a new SMS header |
|
1674 delete iSmsHeader; |
|
1675 iSmsHeader = NULL; |
|
1676 iSmsHeader = CSmsHeader::NewL(email1); |
|
1677 CleanupStack::Pop(email1); |
|
1678 |
|
1679 // Check that the header is correct... |
|
1680 // Email fields... |
|
1681 const CSmsEmailFields& fields10 = iSmsHeader->EmailFields(); |
|
1682 iSmsTest(fields10.HasAddress()); |
|
1683 iSmsTest(fields10.Addresses().MdcaCount()==1); |
|
1684 iSmsTest(fields10.Addresses().MdcaPoint(0).Compare(KTestEmailAddress1) == 0); |
|
1685 iSmsTest(fields10.Subject().Compare(KTestEmailSubject1) == 0); |
|
1686 |
|
1687 // Message body... |
|
1688 CSmsBufferBase& body1 = iSmsHeader->Message().Buffer(); |
|
1689 TInt length1 = body1.Length(); |
|
1690 HBufC* buf1 = HBufC::NewLC(length1); |
|
1691 TPtr bufPtr1(buf1->Des()); |
|
1692 body1.Extract(bufPtr1, 0, length1); |
|
1693 |
|
1694 iSmsTest(bufPtr1.Compare(KTestEmailBody1) == 0); |
|
1695 |
|
1696 CleanupStack::PopAndDestroy(buf1); |
|
1697 |
|
1698 // Test corrupt email. |
|
1699 _LIT(KTestEmailBody2, "user@domain1.domain2##a subjectsome body text"); |
|
1700 _LIT(KTestEmailMessage2, "user@domain1.domain2##a subjectsome body text"); |
|
1701 |
|
1702 CSmsMessage* email2 = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, CSmsEditorBuffer::NewL(*iRichText), EFalse); |
|
1703 CleanupStack::PushL(email2); |
|
1704 |
|
1705 CSmsBufferBase& buffer2 = email2->Buffer(); |
|
1706 buffer2.Reset(); |
|
1707 buffer2.InsertL(0, KTestEmailMessage2()); |
|
1708 |
|
1709 // Set the PID for email. |
|
1710 CSmsPDU& pdu2 = email2->SmsPDU(); |
|
1711 if( pdu2.ProtocolIdentifierPresent() ) |
|
1712 { |
|
1713 pdu2.SetPIDType(TSmsProtocolIdentifier::ESmsPIDTelematicInterworking); |
|
1714 pdu2.SetTelematicDeviceIndicator(TSmsProtocolIdentifier::ESmsTelematicDevice); |
|
1715 pdu2.SetTelematicDeviceType(TSmsProtocolIdentifier::ESmsInternetElectronicMail); |
|
1716 } |
|
1717 |
|
1718 // create a new SMS header |
|
1719 delete iSmsHeader; |
|
1720 iSmsHeader = NULL; |
|
1721 iSmsHeader = CSmsHeader::NewL(email2); |
|
1722 CleanupStack::Pop(email2); |
|
1723 |
|
1724 // Check that the header is correct... |
|
1725 // Email fields... |
|
1726 const CSmsEmailFields& fields11 = iSmsHeader->EmailFields(); |
|
1727 iSmsTest(!fields11.HasAddress()); |
|
1728 iSmsTest(fields11.Addresses().MdcaCount()==0); |
|
1729 iSmsTest(fields11.Subject().Compare(KNullDesC) == 0); |
|
1730 iSmsTest(fields11.Length() == 0); |
|
1731 |
|
1732 // Message body... |
|
1733 CSmsBufferBase& body2 = iSmsHeader->Message().Buffer(); |
|
1734 TInt length2 = body2.Length(); |
|
1735 HBufC* buf2 = HBufC::NewLC(length2); |
|
1736 TPtr bufPtr2(buf2->Des()); |
|
1737 body2.Extract(bufPtr2, 0, length2); |
|
1738 |
|
1739 iSmsTest(bufPtr2.Compare(KTestEmailBody2) == 0); |
|
1740 |
|
1741 CleanupStack::PopAndDestroy(buf2); |
|
1742 |
|
1743 CleanupStack::PopAndDestroy(&fs); |
|
1744 |
|
1745 Session().CleanupEntryPop(); |
|
1746 Session().RemoveEntry(id); |
|
1747 } |
|
1748 |
|
1749 _LIT(KGetDescriptionTestMessage, "Finland to win the ice hockey world champs"); |
|
1750 |
|
1751 #include <emsuserpromptie.h> |
|
1752 #include <emssoundie.h> |
|
1753 _LIT8(KUserMelody, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" |
|
1754 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"); // Melody file |
|
1755 |
|
1756 _LIT(KTestEmsVariousMsg1,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); |
|
1757 |
|
1758 void CSmutTest::TestSmsEmsExtensionsL() |
|
1759 // Test the modifications for EMS |
|
1760 { |
|
1761 // Set up a standard sms message first |
|
1762 iRichText->Reset(); |
|
1763 iRichText->InsertL(0, KTestEmsVariousMsg1); |
|
1764 // Make a Deliver so we can get at the protocol identifier |
|
1765 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); |
|
1766 CleanupStack::PushL(header); |
|
1767 |
|
1768 // Create 2 EMS Melody objects followed by a User Prompt Indicator |
|
1769 |
|
1770 // Create first Melody EMS object |
|
1771 CEmsSoundIE* object = CEmsSoundIE::NewL(KUserMelody()); |
|
1772 CleanupStack::PushL(object); |
|
1773 // Insert the sound object after the 5th byte of the message |
|
1774 object->SetStartPosition(5); |
|
1775 // Add it to the CSmsMessage |
|
1776 header->Message().AddEMSInformationElementL(*object); |
|
1777 CleanupStack::PopAndDestroy(object); |
|
1778 |
|
1779 // Create a second Melody EMS object |
|
1780 CEmsSoundIE* object2 = CEmsSoundIE::NewL(KUserMelody()); |
|
1781 CleanupStack::PushL(object2); |
|
1782 // Insert the sound object after the 5th byte of the message |
|
1783 object2->SetStartPosition(5); |
|
1784 // Add it to the CSmsMessage |
|
1785 header->Message().AddEMSInformationElementL(*object2); |
|
1786 CleanupStack::PopAndDestroy(object2); |
|
1787 |
|
1788 // Create a user prompt indicator and tell it there are 2 EMS objects |
|
1789 CEmsUserPrompt* prompt = CEmsUserPrompt::NewL(2); |
|
1790 CleanupStack::PushL(prompt); |
|
1791 // Add it after the 5th byte of the message |
|
1792 prompt->SetStartPosition(5); |
|
1793 // Add it to the CSmsMessage |
|
1794 header->Message().AddEMSInformationElementL(*prompt); |
|
1795 CleanupStack::PopAndDestroy(prompt); |
|
1796 |
|
1797 // Test the TMsvSmsEntry derived class |
|
1798 TMsvSmsEntry entry; |
|
1799 // Check the Existing sms message for User Prompt indicator |
|
1800 const RPointerArray<const CEmsInformationElement>& emsElements= header->Message().GetEMSInformationElementsL(); |
|
1801 // Loop through the array checking for a user prompt indicator element |
|
1802 TInt i(0); |
|
1803 for(;i<emsElements.Count();i++) |
|
1804 { |
|
1805 if(emsElements[i]->Identifier() == CSmsInformationElement::ESmsEnhancedUserPromptIndicator) |
|
1806 { |
|
1807 // Set user prompt indicator bit in iMtmData2 |
|
1808 entry.SetUserPromptIndicator(ETrue); |
|
1809 break; |
|
1810 } |
|
1811 } |
|
1812 // Check the user prompt indicator is set |
|
1813 if(!entry.UserPromptIndicator()) |
|
1814 User::Leave(KErrCorrupt); |
|
1815 // Check we can clear it |
|
1816 entry.SetUserPromptIndicator(EFalse); |
|
1817 if(entry.UserPromptIndicator()) |
|
1818 User::Leave(KErrCorrupt); |
|
1819 |
|
1820 // Convenient reference to PDU |
|
1821 CSmsDeliver& pdu = STATIC_CAST(CSmsDeliver&,header->Message().SmsPDU()); |
|
1822 // Set up the Protocol Identifier to read back |
|
1823 pdu.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType); |
|
1824 pdu.SetShortMessageType(TSmsProtocolIdentifier::ESmsReplaceShortMessageType1); |
|
1825 |
|
1826 // Read from the pdu and set the TMsvSmsEntry copy |
|
1827 entry.SetProtocolIdentifier(*pdu.ProtocolIdentifier()); |
|
1828 // Read it back and check the value |
|
1829 if(entry.ProtocolIdentifier() != *pdu.ProtocolIdentifier()) |
|
1830 { |
|
1831 User::Leave(KErrCorrupt); |
|
1832 } |
|
1833 |
|
1834 CleanupStack::PopAndDestroy(); //header |
|
1835 |
|
1836 } |
|
1837 |
|
1838 void CSmutTest::TestSmsUtilitiesL() |
|
1839 { |
|
1840 iSmsTest.Test().Next(_L("Testing TSmsUtilities")); |
|
1841 |
|
1842 iRichText->Reset(); |
|
1843 iRichText->InsertL(0, KGetDescriptionTestMessage); |
|
1844 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
1845 CleanupStack::PushL(header); |
|
1846 |
|
1847 TestSmsUtilities1L(*header); |
|
1848 TestSmsUtilities2L(*header); |
|
1849 TestSmsUtilities3L(*header); |
|
1850 |
|
1851 CleanupStack::PopAndDestroy(); //header |
|
1852 |
|
1853 TestSmsUtilitiesTimeStampsL(); |
|
1854 } |
|
1855 |
|
1856 void CSmutTest::TestSmsUtilitiesBL() |
|
1857 { |
|
1858 iSmsTest.Test().Next(_L("Testing ECOM Plugin for SMS GetDetDesc interface")); |
|
1859 |
|
1860 iRichText->Reset(); |
|
1861 iRichText->InsertL(0, KGetDescriptionTestMessage); |
|
1862 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit,*iRichText); |
|
1863 CleanupStack::PushL(header); |
|
1864 |
|
1865 TestSmsUtilities4L(*header); |
|
1866 TestSmsUtilities5L(*header); |
|
1867 TestSmsUtilities3L(*header); |
|
1868 |
|
1869 CleanupStack::PopAndDestroy(); //header |
|
1870 } |
|
1871 |
|
1872 void CSmutTest::TestSmsUtilities1L(CSmsHeader& aHeader) |
|
1873 /** |
|
1874 * @test Tests TSmsUtilities::GetDescription() |
|
1875 */ |
|
1876 { |
|
1877 iSmsTest.Printf(_L("Testing TSmsUtilities::GetDescription() - use varying values to test trucation\n")); |
|
1878 |
|
1879 RResourceFile resFile; |
|
1880 iSmsTest.OpenResourceFileL(KSmsResourceFile, resFile); |
|
1881 CleanupClosePushL(resFile); |
|
1882 |
|
1883 //Test GetDescription() |
|
1884 |
|
1885 TPtrC buf(KGetDescriptionTestMessage); |
|
1886 const TInt maxLength = buf.Length(); |
|
1887 HBufC* desBuf = HBufC::NewLC(maxLength); |
|
1888 TPtr desc = desBuf->Des(); |
|
1889 |
|
1890 for( TInt length=1; length <= maxLength; ++length ) |
|
1891 { |
|
1892 iSmsTest.Printf(_L("-> trucating to length %d\n"), length); |
|
1893 |
|
1894 desc.Zero(); |
|
1895 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, length)); |
|
1896 |
|
1897 iSmsTest.Printf(_L("-> GetDescription() : %S\n"), &desc); |
|
1898 |
|
1899 iSmsTest(desc.Length()<=length); |
|
1900 iSmsTest(desc == buf.Left(desc.Length()) ); //this won't work if buf contains CEditableText::EParagraphDelimiter |
|
1901 } |
|
1902 desc.Zero(); |
|
1903 |
|
1904 //Test Special Message Indication |
|
1905 |
|
1906 CSmsPDU& pdu = aHeader.Message().SmsPDU(); |
|
1907 CSmsUserData& userData = pdu.UserData(); |
|
1908 TBuf8<2> msgInd; |
|
1909 msgInd.Copy(_L("AA")); |
|
1910 |
|
1911 //Add information element |
|
1912 msgInd[0] = TSmsUtilities::EEmailMessageWaiting; |
|
1913 msgInd[1] = 0x00000001; //1 message |
|
1914 |
|
1915 iSmsTest.Printf(_L("\tAdding information element (Email) to UD\n")); |
|
1916 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
1917 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc)); |
|
1918 CheckDescriptionL(resFile, R_MESSAGE_INDICATION_EMAIL_ONE, desc, 2); |
|
1919 |
|
1920 // Set the maximum length of desc to be less than the description. |
|
1921 // The description should truncate to fit into desc. |
|
1922 User::LeaveIfError(TSmsUtilities::GetDescription(aHeader.Message(), desc, 10)); |
|
1923 iSmsTest(desc.Length() == 10); //Check that the Length of desc is the specified max length. |
|
1924 |
|
1925 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EVoiceMessageWaiting, R_MESSAGE_INDICATION_VOICEMAIL_ONE); |
|
1926 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EFaxMessageWaiting, R_MESSAGE_INDICATION_FAX_ONE); |
|
1927 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EEmailMessageWaiting, R_MESSAGE_INDICATION_EMAIL_ONE); |
|
1928 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EOtherMessageWaiting, R_MESSAGE_INDICATION_OTHER_ONE); |
|
1929 |
|
1930 CleanupStack::PopAndDestroy(2, &resFile); |
|
1931 |
|
1932 iSmsTest.Printf(_L("Passed\n")); |
|
1933 } |
|
1934 |
|
1935 CSmsMessage* CSmutTest::CreateSmsMessageLC(const TDesC8& aHexPdu) const |
|
1936 { |
|
1937 HBufC8* binaryPdu = ConvertToBinaryLC(aHexPdu); |
|
1938 TGsmSms pdu; |
|
1939 pdu.SetPdu(*binaryPdu); |
|
1940 CleanupStack::PopAndDestroy(binaryPdu); |
|
1941 CSmsMessage* message = CSmsMessage::NewL(iSmsTest.FileSession(), pdu, CSmsBuffer::NewL()); |
|
1942 CleanupStack::PushL(message); |
|
1943 return message; |
|
1944 } |
|
1945 |
|
1946 HBufC8* CSmutTest::ConvertToBinaryLC(const TDesC8& aHex) const |
|
1947 { |
|
1948 const TInt len = aHex.Length(); |
|
1949 if (len % 2 != 0) |
|
1950 User::Leave(KErrArgument); |
|
1951 |
|
1952 HBufC8* pdu = HBufC8::NewLC(len / 2); |
|
1953 TPtr8 ptr(pdu->Des()); |
|
1954 |
|
1955 for (TInt i = 0; i < len; i += 2) |
|
1956 { |
|
1957 TLex8 lex(aHex.Mid(i, 2)); |
|
1958 TUint8 val; |
|
1959 User::LeaveIfError(lex.Val(val, EHex)); |
|
1960 ptr.Append(val); |
|
1961 } |
|
1962 |
|
1963 return pdu; |
|
1964 } |
|
1965 |
|
1966 _LIT(KGetDetailsResult, "\t\tNum In: \"%S\" Name Out: \"%S\"\n"); |
|
1967 |
|
1968 void CSmutTest::TestSmsUtilities2L(CSmsHeader& aHeader) |
|
1969 { |
|
1970 //Test GetDetails |
|
1971 |
|
1972 iSmsTest.Printf(_L("Test TSmsUtilities::GetDetails()\n")); |
|
1973 |
|
1974 _LIT(KLongTel, "+378458932945284754456302945754938539"); |
|
1975 |
|
1976 _LIT(KMikkoTel, "+358503367709"); |
|
1977 _LIT(KMikkoFirst, "Mikko"); |
|
1978 _LIT(KMikkoLast, "Rintala"); |
|
1979 _LIT(KMikkoEmail, "mikko@nokia.com"); |
|
1980 |
|
1981 _LIT(KUnqualifiedTel, "8503367710"); |
|
1982 _LIT(KUnqualifiedTel1, "+358503367710"); |
|
1983 _LIT(KUnqualifiedFirst, "Unq"); |
|
1984 _LIT(KUnqualifiedLast, "Wallified"); |
|
1985 _LIT(KUnqualifiedEmail, "unqalified@diysurgery.com"); |
|
1986 |
|
1987 // _LIT(KAnthonyTel, " + 4 "); //is valid |
|
1988 _LIT(KAnthonyTel, "+ 7 "); //is valid |
|
1989 _LIT(KAnthonyFirst, "Anthony"); |
|
1990 _LIT(KAnthonyLast, "Alexander"); |
|
1991 _LIT(KAnthonyEmail, "test@symbian.com"); |
|
1992 |
|
1993 _LIT(KHarriTel, "+8"); //is valid |
|
1994 _LIT(KHarriFirst, "HarriHarriHarriHarriHarriHarriHarri"); |
|
1995 _LIT(KHarriLast, "RäisänenRäisänenRäisänenRäisänenRäisänen"); |
|
1996 _LIT(KHarriEmail, "harri@nokia.com"); |
|
1997 |
|
1998 _LIT(KDupTel, "+44207435676"); |
|
1999 _LIT(KDupFirst1, "Keval"); |
|
2000 _LIT(KDupLast1, "Pindoria"); |
|
2001 _LIT(KDupFirst2, "Jackie"); |
|
2002 _LIT(KDupLast2, "Chan"); |
|
2003 |
|
2004 _LIT(KBadTel1, "This is a bad Telephone"); |
|
2005 _LIT(KBadTel2, " 5 "); |
|
2006 _LIT(KBadTel3, "5+"); |
|
2007 _LIT(KBadTel4, "*5565434556"); |
|
2008 |
|
2009 _LIT(KBadFirst, "BadFirstName"); |
|
2010 _LIT(KBadLast, "BadLastName"); |
|
2011 |
|
2012 _LIT(KNoNameTel, "+449005434"); |
|
2013 |
|
2014 _LIT(KDummy, "+44444"); |
|
2015 |
|
2016 TRAPD(err, iSmsTest.DeleteContactsFileL()); |
|
2017 iSmsTest(err == KErrNotFound || err == KErrNone); |
|
2018 |
|
2019 iSmsTest.Printf(_L("\tTesting without contacts\n")); |
|
2020 |
|
2021 //Simple test |
|
2022 TPtrC testTel(KMikkoTel); |
|
2023 TBuf<KSmsDetailsLength> details; |
|
2024 |
|
2025 aHeader.Message().SetToFromAddressL(testTel); |
|
2026 TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
2027 iSmsTest.Printf(KGetDetailsResult, &testTel, &details); |
|
2028 iSmsTest(testTel.FindF(details) != KErrNotFound); //details should contain testTel as there is no contact. |
|
2029 |
|
2030 TestInvalidContact(testTel, details); |
|
2031 |
|
2032 testTel.Set(KAnthonyTel); |
|
2033 aHeader.Message().SetToFromAddressL(testTel); |
|
2034 err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
2035 iSmsTest.Printf(KGetDetailsResult, &testTel, &details); |
|
2036 iSmsTest(testTel.FindF(details) != KErrNotFound); //details should contain testTel as there is no contact. |
|
2037 iSmsTest(err == KErrNone); |
|
2038 |
|
2039 TestInvalidContact(testTel, details); |
|
2040 |
|
2041 // Testing with long telephone number. |
|
2042 // The telephone number should truncate to fit into details. |
|
2043 TestInvalidContact(KLongTel, details); |
|
2044 iSmsTest(details.Length() == KSmsDetailsLength); //Length of details should be the default max length. |
|
2045 |
|
2046 //Add contacts |
|
2047 |
|
2048 iSmsTest.Printf(_L("\tAdding Contacts\n")); |
|
2049 |
|
2050 //Adding good telephone numbers |
|
2051 |
|
2052 TContactItemId contId = iSmsTest.CreateContactL(KAnthonyFirst, KAnthonyLast, KAnthonyTel, KAnthonyEmail); |
|
2053 iSmsTest(contId != KNullContactId); |
|
2054 |
|
2055 contId = iSmsTest.CreateContactL(KMikkoFirst, KMikkoLast, KMikkoTel, KMikkoEmail); |
|
2056 iSmsTest(contId != KNullContactId); |
|
2057 |
|
2058 contId = iSmsTest.CreateContactL(KUnqualifiedFirst, KUnqualifiedLast, KUnqualifiedTel, KUnqualifiedEmail); |
|
2059 iSmsTest(contId != KNullContactId); |
|
2060 |
|
2061 contId = iSmsTest.CreateContactL(KHarriFirst, KHarriLast, KHarriTel, KHarriEmail); |
|
2062 iSmsTest(contId != KNullContactId); |
|
2063 |
|
2064 //Adding a duplicate telephone |
|
2065 |
|
2066 contId = iSmsTest.CreateContactL(KDupFirst1, KDupLast1, KDupTel, KNullDesC); |
|
2067 iSmsTest(contId != KNullContactId); |
|
2068 |
|
2069 contId = iSmsTest.CreateContactL(KDupFirst2, KDupLast2, KDupTel, KNullDesC); |
|
2070 iSmsTest(contId != KNullContactId); |
|
2071 |
|
2072 //Adding bad telephone numbers |
|
2073 |
|
2074 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel1, KNullDesC); |
|
2075 iSmsTest(contId != KNullContactId); |
|
2076 |
|
2077 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel2, KNullDesC); |
|
2078 iSmsTest(contId != KNullContactId); |
|
2079 |
|
2080 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel3, KNullDesC); |
|
2081 iSmsTest(contId != KNullContactId); |
|
2082 |
|
2083 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel4, KNullDesC); |
|
2084 iSmsTest(contId != KNullContactId); |
|
2085 |
|
2086 //Adding no name contact |
|
2087 |
|
2088 contId = iSmsTest.CreateContactL(KNullDesC, KNullDesC, KNoNameTel, KNullDesC); |
|
2089 iSmsTest(contId != KNullContactId); |
|
2090 |
|
2091 iSmsTest.Printf(_L("\tTesting with valid telephone numbers\n")); |
|
2092 |
|
2093 TestValidTel(KAnthonyTel, KAnthonyFirst, KAnthonyLast, KNullDesC, details); |
|
2094 TestValidTel(KMikkoTel, KMikkoFirst, KMikkoLast, KNullDesC, details); |
|
2095 // Test below was added for INC040050. The number of digits matched |
|
2096 // against in GetDetails changed and resulted in undesirable behaviour |
|
2097 // when searching for an unqualified number with a fully qualified number. |
|
2098 TestValidTel(KUnqualifiedTel1, KUnqualifiedFirst, KUnqualifiedLast, KNullDesC, details); |
|
2099 TestValidTel(KHarriTel, _L("Räisänen"), KNullDesC, _L("Harri"), details); |
|
2100 |
|
2101 iSmsTest.Printf(_L("\tTesting with invalid telephone numbers\n")); |
|
2102 |
|
2103 TestInvalidTelephone(KBadTel1, details); |
|
2104 TestInvalidTelephone(KBadTel2, details); |
|
2105 TestInvalidTelephone(KBadTel3, details); |
|
2106 TestInvalidTelephone(KBadTel4, details); |
|
2107 |
|
2108 iSmsTest.Printf(_L("\tTesting with duplicate telephone numbers\n")); |
|
2109 |
|
2110 TestDuplicateContact(KDupTel, details); |
|
2111 |
|
2112 iSmsTest.Printf(_L("\tTesting No Names telephone number\n")); |
|
2113 |
|
2114 TestInvalidContact(KNoNameTel, details); |
|
2115 TestInvalidContact(KDummy, details); |
|
2116 |
|
2117 iSmsTest.Printf(_L("Passed\n")); |
|
2118 } |
|
2119 |
|
2120 void CSmutTest::TestValidTel(const TDesC& aTel, const TDesC& aExpect1, const TDesC& aExpect2, const TDesC& aNotExpect, TDes& rDetails) |
|
2121 { |
|
2122 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, rDetails); |
|
2123 iSmsTest.Printf(KGetDetailsResult, &aTel, &rDetails); |
|
2124 |
|
2125 if (aExpect1.Length()) |
|
2126 iSmsTest(rDetails.FindF(aExpect1) != KErrNotFound); |
|
2127 |
|
2128 if (aExpect2.Length()) |
|
2129 iSmsTest(rDetails.FindF(aExpect2) != KErrNotFound); |
|
2130 |
|
2131 if (aNotExpect.Length()) |
|
2132 iSmsTest(rDetails.FindF(aNotExpect) == KErrNotFound); |
|
2133 |
|
2134 iSmsTest(err == KErrNone); |
|
2135 } |
|
2136 |
|
2137 void CSmutTest::TestInvalidTelephone(const TDesC& aTel, TDes& aDetails) |
|
2138 { |
|
2139 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2140 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2141 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as aTel is invalid. |
|
2142 iSmsTest(err == KErrNone); |
|
2143 } |
|
2144 |
|
2145 void CSmutTest::TestInvalidContact(const TDesC& aTel, TDes& aDetails) |
|
2146 { |
|
2147 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2148 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2149 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as the contact is invalid. |
|
2150 iSmsTest(err == KErrNone); |
|
2151 } |
|
2152 |
|
2153 void CSmutTest::TestDuplicateContact(const TDesC& aTel, TDes& aDetails) |
|
2154 { |
|
2155 TInt err = TSmsUtilities::GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2156 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2157 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as there is duplicate contact. |
|
2158 iSmsTest(err == KErrNone); |
|
2159 } |
|
2160 |
|
2161 void CSmutTest::TestSmsUtilities3L(CSmsHeader& aHeader) |
|
2162 { |
|
2163 iSmsTest.Printf(_L("Test TSmsUtilities::ServiceIdL()\n")); |
|
2164 |
|
2165 TMsvId id2 = KMsvNullIndexEntryId; |
|
2166 // First tested function is ServiceIdL() |
|
2167 TSmsUtilities::ServiceIdL(*iSmsTest.iMsvEntry, id2); |
|
2168 iSmsTest(id2 == iSmsTest.iSmsServiceId); |
|
2169 iSmsTest.Printf(_L("\tPassed\n")); |
|
2170 |
|
2171 iSmsTest.Printf(_L("Test TSmsUtilities::PopulateMsgEntry()\n")); |
|
2172 TMsvEntry entry; |
|
2173 TSmsUtilities::PopulateMsgEntry(entry,aHeader.Message(), iSmsTest.iSmsServiceId); |
|
2174 // todo More tests |
|
2175 iSmsTest.Printf(_L("\tPassed\n")); |
|
2176 } |
|
2177 |
|
2178 void CSmutTest::TestSmsUtilitiesTimeStampsL() |
|
2179 { |
|
2180 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*iRichText); |
|
2181 CleanupStack::PushL(header); |
|
2182 |
|
2183 header->Message().SetTime(1); |
|
2184 CSmsDeliver& deliver = header->Deliver(); |
|
2185 deliver.SetServiceCenterTimeStamp(2); |
|
2186 |
|
2187 CSmsSettings* settings = CSmsSettings::NewL(); |
|
2188 CleanupStack::PushL(settings); |
|
2189 RestoreSettingsL(*settings); |
|
2190 |
|
2191 // Default settings should be to use the time that the SMS message time (the time |
|
2192 // that the SMS arrives at the phone) as opposed to the time it arrives at the |
|
2193 // service centre. |
|
2194 |
|
2195 iSmsTest.Printf(_L("Test PopulateMsgEntry() with settings to use SMS message time\n")); |
|
2196 |
|
2197 TMsvEntry entry; |
|
2198 TSmsUtilities::PopulateMsgEntry(entry, header->Message(), iSmsTest.iSmsServiceId, *settings); |
|
2199 iSmsTest(entry.iDate == 1); |
|
2200 iSmsTest.Printf(_L("\tPassed\n")); |
|
2201 |
|
2202 // Now test that we use the service centre timestamp if the SMS setting flag |
|
2203 // requires us to do so. |
|
2204 iSmsTest.Printf(_L("Test PopulateMsgEntry() with settings to use service center timestamp\n")); |
|
2205 |
|
2206 settings->SetUseServiceCenterTimeStampForDate(ETrue); |
|
2207 |
|
2208 TSmsUtilities::PopulateMsgEntry(entry, header->Message(), iSmsTest.iSmsServiceId, *settings); |
|
2209 iSmsTest(entry.iDate == 2); |
|
2210 iSmsTest.Printf(_L("\tPassed\n")); |
|
2211 |
|
2212 CleanupStack::PopAndDestroy(2, header); |
|
2213 } |
|
2214 |
|
2215 void CSmutTest::TestSmsUtilities4L(CSmsHeader& aHeader) |
|
2216 /** |
|
2217 * @test Tests CSmsGetDetDescInterface::GetDescription() default implementation |
|
2218 * |
|
2219 * This is a modified version of TestSmsUtilities1L(CSmsHeader& aHeader), modified to use the |
|
2220 * CSmsGetDetDescInterface ECOM plugin interface instead of the TSmsUtilies |
|
2221 * interface for ::GetDescription |
|
2222 */ |
|
2223 { |
|
2224 iSmsTest.Printf(_L("Testing CSmsGetDetDescInterface::GetDescription() - use varying values to test trucation\n")); |
|
2225 |
|
2226 RResourceFile resFile; |
|
2227 iSmsTest.OpenResourceFileL(KSmsResourceFile, resFile); |
|
2228 CleanupClosePushL(resFile); |
|
2229 |
|
2230 //Test GetDescription() |
|
2231 |
|
2232 TPtrC buf(KGetDescriptionTestMessage); |
|
2233 const TInt maxLength = buf.Length(); |
|
2234 HBufC* desBuf = HBufC::NewLC(maxLength); // on the CleanupStack |
|
2235 TPtr desc = desBuf->Des(); |
|
2236 |
|
2237 // load ECOM interface used to create SMS details and description values. |
|
2238 iSmsTest.Printf(_L("Loading ECOM Plugin...\n")); |
|
2239 CSmsGetDetDescInterface* getDetDesc = CSmsGetDetDescInterface::NewL(); |
|
2240 CleanupStack::PushL(getDetDesc); |
|
2241 iSmsTest.Printf(_L("... Plugin loaded\n")); |
|
2242 |
|
2243 for( TInt length=1; length <= maxLength; ++length ) |
|
2244 { |
|
2245 iSmsTest.Printf(_L("-> trucating to length %d\n"), length); |
|
2246 |
|
2247 desc.Zero(); |
|
2248 User::LeaveIfError(getDetDesc->GetDescription(aHeader.Message(), desc, length)); |
|
2249 |
|
2250 iSmsTest.Printf(_L("-> GetDescription() : %S\n"), &desc); |
|
2251 |
|
2252 iSmsTest(desc.Length()<=length); |
|
2253 iSmsTest(desc == buf.Left(desc.Length()) ); //this won't work if buf contains CEditableText::EParagraphDelimiter |
|
2254 } |
|
2255 desc.Zero(); |
|
2256 |
|
2257 //Test Special Message Indication |
|
2258 |
|
2259 CSmsPDU& pdu = aHeader.Message().SmsPDU(); |
|
2260 CSmsUserData& userData = pdu.UserData(); |
|
2261 TBuf8<2> msgInd; |
|
2262 msgInd.Copy(_L("AA")); |
|
2263 |
|
2264 //Add information element |
|
2265 msgInd[0] = TSmsUtilities::EEmailMessageWaiting; |
|
2266 msgInd[1] = 0x00000001; //1 message |
|
2267 |
|
2268 iSmsTest.Printf(_L("\tAdding information element (Email) to UD\n")); |
|
2269 userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, msgInd); |
|
2270 User::LeaveIfError(getDetDesc->GetDescription(aHeader.Message(), desc)); |
|
2271 CheckDescriptionL(resFile, R_MESSAGE_INDICATION_EMAIL_ONE, desc, 2); |
|
2272 |
|
2273 // Set the maximum length of desc to be less than the description. |
|
2274 // The description should truncate to fit into desc. |
|
2275 User::LeaveIfError(getDetDesc->GetDescription(aHeader.Message(), desc, 10)); |
|
2276 iSmsTest(desc.Length() == 10); //Check that the Length of desc is the specified max length. |
|
2277 |
|
2278 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EVoiceMessageWaiting, R_MESSAGE_INDICATION_VOICEMAIL_ONE); |
|
2279 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EFaxMessageWaiting, R_MESSAGE_INDICATION_FAX_ONE); |
|
2280 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EEmailMessageWaiting, R_MESSAGE_INDICATION_EMAIL_ONE); |
|
2281 TestSpecialSmsMessageIndicationPduL(resFile, TSmsUtilities::EOtherMessageWaiting, R_MESSAGE_INDICATION_OTHER_ONE); |
|
2282 |
|
2283 CleanupStack::PopAndDestroy(getDetDesc); |
|
2284 REComSession::FinalClose(); |
|
2285 |
|
2286 CleanupStack::PopAndDestroy(2, &resFile); |
|
2287 |
|
2288 iSmsTest.Printf(_L("Passed\n")); |
|
2289 } |
|
2290 |
|
2291 void CSmutTest::TestSmsUtilities5L(CSmsHeader& aHeader) |
|
2292 /** |
|
2293 * @test Tests CSmsGetDetDescInterface::GetDetails() default implementation |
|
2294 * |
|
2295 * This is a modified version of TestSmsUtilities2L(CSmsHeader& aHeader), modified to use the |
|
2296 * CSmsGetDetDescInterface ECOM plugin interface instead of the TSmsUtilies |
|
2297 * interface for ::GetDetails |
|
2298 */ |
|
2299 { |
|
2300 //Test GetDetails |
|
2301 |
|
2302 iSmsTest.Printf(_L("Test CSmsGetDetDescInterface::GetDetails()\n")); |
|
2303 |
|
2304 _LIT(KLongTel, "+378458932945284754456302945754938539"); |
|
2305 |
|
2306 _LIT(KMikkoTel, "+358503367709"); |
|
2307 _LIT(KMikkoFirst, "Mikko"); |
|
2308 _LIT(KMikkoLast, "Rintala"); |
|
2309 _LIT(KMikkoEmail, "mikko@nokia.com"); |
|
2310 |
|
2311 _LIT(KUnqualifiedTel, "8503367710"); |
|
2312 _LIT(KUnqualifiedTel1, "+358503367710"); |
|
2313 _LIT(KUnqualifiedFirst, "Unq"); |
|
2314 _LIT(KUnqualifiedLast, "Wallified"); |
|
2315 _LIT(KUnqualifiedEmail, "unqalified@diysurgery.com"); |
|
2316 |
|
2317 _LIT(KAnthonyTel, "+ 7 "); //is valid |
|
2318 _LIT(KAnthonyFirst, "Anthony"); |
|
2319 _LIT(KAnthonyLast, "Alexander"); |
|
2320 _LIT(KAnthonyEmail, "test@symbian.com"); |
|
2321 |
|
2322 _LIT(KHarriTel, "+8"); //is valid |
|
2323 _LIT(KHarriFirst, "HarriHarriHarriHarriHarriHarriHarri"); |
|
2324 _LIT(KHarriLast, "RäisänenRäisänenRäisänenRäisänenRäisänen"); |
|
2325 _LIT(KHarriEmail, "harri@nokia.com"); |
|
2326 |
|
2327 _LIT(KDupTel, "+44207435676"); |
|
2328 _LIT(KDupFirst1, "Keval"); |
|
2329 _LIT(KDupLast1, "Pindoria"); |
|
2330 _LIT(KDupFirst2, "Jackie"); |
|
2331 _LIT(KDupLast2, "Chan"); |
|
2332 |
|
2333 _LIT(KBadTel1, "This is a bad Telephone"); |
|
2334 _LIT(KBadTel2, " 5 "); |
|
2335 _LIT(KBadTel3, "5+"); |
|
2336 _LIT(KBadTel4, "*5565434556"); |
|
2337 |
|
2338 _LIT(KBadFirst, "BadFirstName"); |
|
2339 _LIT(KBadLast, "BadLastName"); |
|
2340 |
|
2341 _LIT(KNoNameTel, "+449005434"); |
|
2342 |
|
2343 _LIT(KDummy, "+44444"); |
|
2344 |
|
2345 // load ECOM interface used to create SMS details and description values. |
|
2346 iSmsTest.Printf(_L("Loading ECOM Plugin...\n")); |
|
2347 CSmsGetDetDescInterface* getDetDesc = CSmsGetDetDescInterface::NewL(); |
|
2348 CleanupStack::PushL(getDetDesc); |
|
2349 iSmsTest.Printf(_L("... Plugin loaded\n")); |
|
2350 |
|
2351 |
|
2352 TRAPD(err, iSmsTest.DeleteContactsFileL()); |
|
2353 iSmsTest(err == KErrNotFound || err == KErrNone); |
|
2354 |
|
2355 iSmsTest.Printf(_L("\tTesting without contacts\n")); |
|
2356 |
|
2357 //Simple test |
|
2358 TPtrC testTel(KMikkoTel); |
|
2359 TBuf<KSmsDetailsLength> details; |
|
2360 |
|
2361 aHeader.Message().SetToFromAddressL(testTel); |
|
2362 getDetDesc->GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
2363 iSmsTest.Printf(KGetDetailsResult, &testTel, &details); |
|
2364 iSmsTest(testTel.FindF(details) != KErrNotFound); //details should contain testTel as there is no contact. |
|
2365 |
|
2366 TestInvalidContact(testTel, details); |
|
2367 |
|
2368 testTel.Set(KAnthonyTel); |
|
2369 aHeader.Message().SetToFromAddressL(testTel); |
|
2370 err = getDetDesc->GetDetails(iSmsTest.FileSession(), aHeader.Message(), details); |
|
2371 iSmsTest.Printf(KGetDetailsResult, &testTel, &details); |
|
2372 iSmsTest(testTel.FindF(details) != KErrNotFound); //details should contain testTel as there is no contact. |
|
2373 iSmsTest(err == KErrNone); |
|
2374 |
|
2375 TestInvalidContact(testTel, details); |
|
2376 |
|
2377 // Testing with long telephone number. |
|
2378 // The telephone number should truncate to fit into details. |
|
2379 TestInvalidContact(KLongTel, details); |
|
2380 iSmsTest(details.Length() == KSmsDetailsLength); //Length of details should be the default max length. |
|
2381 |
|
2382 //Add contacts |
|
2383 |
|
2384 iSmsTest.Printf(_L("\tAdding Contacts\n")); |
|
2385 |
|
2386 //Adding good telephone numbers |
|
2387 |
|
2388 TContactItemId contId = iSmsTest.CreateContactL(KAnthonyFirst, KAnthonyLast, KAnthonyTel, KAnthonyEmail); |
|
2389 iSmsTest(contId != KNullContactId); |
|
2390 |
|
2391 contId = iSmsTest.CreateContactL(KMikkoFirst, KMikkoLast, KMikkoTel, KMikkoEmail); |
|
2392 iSmsTest(contId != KNullContactId); |
|
2393 |
|
2394 contId = iSmsTest.CreateContactL(KUnqualifiedFirst, KUnqualifiedLast, KUnqualifiedTel, KUnqualifiedEmail); |
|
2395 iSmsTest(contId != KNullContactId); |
|
2396 |
|
2397 contId = iSmsTest.CreateContactL(KHarriFirst, KHarriLast, KHarriTel, KHarriEmail); |
|
2398 iSmsTest(contId != KNullContactId); |
|
2399 |
|
2400 //Adding a duplicate telephone |
|
2401 |
|
2402 contId = iSmsTest.CreateContactL(KDupFirst1, KDupLast1, KDupTel, KNullDesC); |
|
2403 iSmsTest(contId != KNullContactId); |
|
2404 |
|
2405 contId = iSmsTest.CreateContactL(KDupFirst2, KDupLast2, KDupTel, KNullDesC); |
|
2406 iSmsTest(contId != KNullContactId); |
|
2407 |
|
2408 //Adding bad telephone numbers |
|
2409 |
|
2410 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel1, KNullDesC); |
|
2411 iSmsTest(contId != KNullContactId); |
|
2412 |
|
2413 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel2, KNullDesC); |
|
2414 iSmsTest(contId != KNullContactId); |
|
2415 |
|
2416 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel3, KNullDesC); |
|
2417 iSmsTest(contId != KNullContactId); |
|
2418 |
|
2419 contId = iSmsTest.CreateContactL(KBadFirst, KBadLast, KBadTel4, KNullDesC); |
|
2420 iSmsTest(contId != KNullContactId); |
|
2421 |
|
2422 //Adding no name contact |
|
2423 |
|
2424 contId = iSmsTest.CreateContactL(KNullDesC, KNullDesC, KNoNameTel, KNullDesC); |
|
2425 iSmsTest(contId != KNullContactId); |
|
2426 |
|
2427 iSmsTest.Printf(_L("\tTesting with valid telephone numbers\n")); |
|
2428 |
|
2429 TestValidTel(*getDetDesc, KAnthonyTel, KAnthonyFirst, KAnthonyLast, KNullDesC, details); |
|
2430 TestValidTel(*getDetDesc, KMikkoTel, KMikkoFirst, KMikkoLast, KNullDesC, details); |
|
2431 // Test below was added for INC040050. The number of digits matched |
|
2432 // against in GetDetails changed and resulted in undesirable behaviour |
|
2433 // when searching for an unqualified number with a fully qualified number. |
|
2434 TestValidTel(*getDetDesc, KUnqualifiedTel1, KUnqualifiedFirst, KUnqualifiedLast, KNullDesC, details); |
|
2435 TestValidTel(*getDetDesc, KHarriTel, _L("Räisänen"), KNullDesC, _L("Harri"), details); |
|
2436 |
|
2437 iSmsTest.Printf(_L("\tTesting with invalid telephone numbers\n")); |
|
2438 |
|
2439 TestInvalidTelephone(*getDetDesc, KBadTel1, details); |
|
2440 TestInvalidTelephone(*getDetDesc, KBadTel2, details); |
|
2441 TestInvalidTelephone(*getDetDesc, KBadTel3, details); |
|
2442 TestInvalidTelephone(*getDetDesc, KBadTel4, details); |
|
2443 |
|
2444 iSmsTest.Printf(_L("\tTesting with duplicate telephone numbers\n")); |
|
2445 |
|
2446 TestDuplicateContact(*getDetDesc, KDupTel, details); |
|
2447 |
|
2448 iSmsTest.Printf(_L("\tTesting No Names telephone number\n")); |
|
2449 |
|
2450 TestInvalidContact(*getDetDesc, KNoNameTel, details); |
|
2451 TestInvalidContact(*getDetDesc, KDummy, details); |
|
2452 |
|
2453 CleanupStack::PopAndDestroy(getDetDesc); |
|
2454 REComSession::FinalClose(); |
|
2455 |
|
2456 iSmsTest.Printf(_L("Passed\n")); |
|
2457 } |
|
2458 |
|
2459 void CSmutTest::TestValidTel(CSmsGetDetDescInterface& aGetDetDesc, const TDesC& aTel, const TDesC& aExpect1, const TDesC& aExpect2, const TDesC& aNotExpect, TDes& rDetails) |
|
2460 { |
|
2461 TInt err = aGetDetDesc.GetDetails(iSmsTest.FileSession(), aTel, rDetails); |
|
2462 iSmsTest.Printf(KGetDetailsResult, &aTel, &rDetails); |
|
2463 |
|
2464 if (aExpect1.Length()) |
|
2465 iSmsTest(rDetails.FindF(aExpect1) != KErrNotFound); |
|
2466 |
|
2467 if (aExpect2.Length()) |
|
2468 iSmsTest(rDetails.FindF(aExpect2) != KErrNotFound); |
|
2469 |
|
2470 if (aNotExpect.Length()) |
|
2471 iSmsTest(rDetails.FindF(aNotExpect) == KErrNotFound); |
|
2472 |
|
2473 iSmsTest(err == KErrNone); |
|
2474 } |
|
2475 |
|
2476 void CSmutTest::TestInvalidTelephone(CSmsGetDetDescInterface& aGetDetDesc, const TDesC& aTel, TDes& aDetails) |
|
2477 { |
|
2478 TInt err = aGetDetDesc.GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2479 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2480 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as aTel is invalid. |
|
2481 iSmsTest(err == KErrNone); |
|
2482 } |
|
2483 |
|
2484 void CSmutTest::TestInvalidContact(CSmsGetDetDescInterface& aGetDetDesc, const TDesC& aTel, TDes& aDetails) |
|
2485 { |
|
2486 TInt err = aGetDetDesc.GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2487 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2488 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as the contact is invalid. |
|
2489 iSmsTest(err == KErrNone); |
|
2490 } |
|
2491 |
|
2492 void CSmutTest::TestDuplicateContact(CSmsGetDetDescInterface& aGetDetDesc, const TDesC& aTel, TDes& aDetails) |
|
2493 { |
|
2494 TInt err = aGetDetDesc.GetDetails(iSmsTest.FileSession(), aTel, aDetails); |
|
2495 iSmsTest.Printf(KGetDetailsResult, &aTel, &aDetails); |
|
2496 iSmsTest(aTel.FindF(aDetails) != KErrNotFound); //aDetails should contain aTel as there is duplicate contact. |
|
2497 iSmsTest(err == KErrNone); |
|
2498 } |
|
2499 |
|
2500 void CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TSmsUtilities::TSmsUtilitiesSpecialMessageType aMessageType, TInt aId) |
|
2501 { |
|
2502 iSmsTest.Printf(_L("\tTestSpecialSmsMessageIndicationPduL Type=%d..."), aMessageType); |
|
2503 |
|
2504 const TUint8 KMaxCount = 0xFF; |
|
2505 for (TUint8 i = 0; i < KMaxCount; i++) |
|
2506 { |
|
2507 TInt resId = aId; |
|
2508 if (i != 1) |
|
2509 resId++; |
|
2510 |
|
2511 TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType), i, resId); |
|
2512 TestSpecialSmsMessageIndicationPduL(aResFile, STATIC_CAST(TUint8, aMessageType | 0x80), i, resId); |
|
2513 } |
|
2514 |
|
2515 iSmsTest.Printf(_L("Passed\n")); |
|
2516 } |
|
2517 |
|
2518 void CSmutTest::TestSpecialSmsMessageIndicationPduL(RResourceFile& aResFile, TUint8 aMessageType, TUint8 aMessageCount, TInt aId) |
|
2519 { |
|
2520 _LIT8(KFaxIndicationPdu, "440B916407586704F900002010011153710406040102810200"); |
|
2521 const TInt KIndicationPosition = 44; |
|
2522 TBuf<KSmsDescriptionLength> desc; |
|
2523 |
|
2524 //Replace the Message Indication in this PDU |
|
2525 RMobileSmsMessaging::TMobileSmsGsmTpdu miPdu(KFaxIndicationPdu); |
|
2526 _LIT8(KFormat, "%02X%02X"); |
|
2527 TPtr8 ptr(&miPdu[KIndicationPosition], 0, 4); |
|
2528 ptr.AppendFormat(KFormat, aMessageType, aMessageCount); |
|
2529 |
|
2530 |
|
2531 CSmsMessage* msg = CreateSmsMessageLC(miPdu); |
|
2532 User::LeaveIfError(TSmsUtilities::GetDescription(*msg, desc)); |
|
2533 CleanupStack::PopAndDestroy(msg); |
|
2534 |
|
2535 if (aMessageCount != 1) |
|
2536 CheckDescriptionL(aResFile, aId, desc, aMessageCount); |
|
2537 else |
|
2538 CheckDescriptionL(aResFile, aId, desc); |
|
2539 } |
|
2540 |
|
2541 void CSmutTest::CheckDescriptionL(RResourceFile& aResFile, TInt aId, TRefByValue<const TDesC> aDesc, ...) |
|
2542 { |
|
2543 const TDesC& ref = aDesc; |
|
2544 |
|
2545 TBuf<256> resDesc; |
|
2546 TBuf<256> resString; |
|
2547 |
|
2548 VA_LIST list; |
|
2549 VA_START(list, aDesc); |
|
2550 |
|
2551 iSmsTest.ReadResourceStringL(aResFile, aId, resString); |
|
2552 resDesc.AppendFormatList(resString, list); |
|
2553 |
|
2554 if (ref != resDesc) |
|
2555 { |
|
2556 iSmsTest.Printf(_L("\tMISMATCH Desc \"%S\" Resource \"%S\"\n"), &ref, &resDesc); |
|
2557 iSmsTest(EFalse); |
|
2558 } |
|
2559 } |
|
2560 |
|
2561 TBool CSmutTest::CheckSmsEntry( |
|
2562 const TMsvSmsEntry& aEntry, |
|
2563 TBool aClassExpected, |
|
2564 TSmsDataCodingScheme::TSmsClass aClass, |
|
2565 TUint8 aPID, |
|
2566 TBool aUPI, |
|
2567 TMsvSmsEntry::TMsvSmsEntryAckSummary aDeliverySummary, |
|
2568 TBool aValidMessageId, |
|
2569 TInt32 aMessageId) const |
|
2570 { |
|
2571 TCompare retVal(ETrue); |
|
2572 |
|
2573 TSmsDataCodingScheme::TSmsClass dummyClass; |
|
2574 |
|
2575 retVal((aEntry.Class(dummyClass) && aClassExpected) || (!aEntry.Class(dummyClass) && !aClassExpected)); |
|
2576 |
|
2577 if (aClassExpected) |
|
2578 retVal(dummyClass == aClass); |
|
2579 |
|
2580 retVal(aEntry.ProtocolIdentifier() == aPID); |
|
2581 retVal((aEntry.UserPromptIndicator() && aUPI) || (!aEntry.UserPromptIndicator() && !aUPI)); |
|
2582 |
|
2583 retVal(aEntry.AckSummary(ESmsAckTypeDelivery) == aDeliverySummary); |
|
2584 |
|
2585 TInt32 dummyMessageId; |
|
2586 |
|
2587 retVal( (aEntry.MessageId(dummyMessageId) && aValidMessageId) || (!aEntry.MessageId(dummyMessageId) && !aValidMessageId) ); |
|
2588 if( aValidMessageId ) |
|
2589 retVal( dummyMessageId == aMessageId ); |
|
2590 |
|
2591 return retVal; |
|
2592 } |
|
2593 |
|
2594 void CSmutTest::TestSmsEntryL() |
|
2595 { |
|
2596 iSmsTest.Test().Next(_L("Testing TMsvSmsEntry")); |
|
2597 |
|
2598 TMsvSmsEntry entry; |
|
2599 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2600 |
|
2601 entry.SetUserPromptIndicator(ETrue); |
|
2602 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2603 |
|
2604 entry.SetUserPromptIndicator(EFalse); |
|
2605 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 0, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2606 |
|
2607 entry.SetProtocolIdentifier(123); |
|
2608 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 123, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2609 |
|
2610 entry.SetProtocolIdentifier(100); |
|
2611 entry.SetUserPromptIndicator(ETrue); |
|
2612 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2613 |
|
2614 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0); |
|
2615 iSmsTest(CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass0, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2616 |
|
2617 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass1); |
|
2618 iSmsTest(CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass1, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2619 |
|
2620 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass2); |
|
2621 iSmsTest(CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass2, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2622 |
|
2623 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass3); |
|
2624 iSmsTest(CheckSmsEntry(entry, ETrue, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2625 |
|
2626 entry.SetClass(EFalse); |
|
2627 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, ETrue, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2628 |
|
2629 entry.SetUserPromptIndicator(EFalse); |
|
2630 iSmsTest(CheckSmsEntry(entry, EFalse, TSmsDataCodingScheme::ESmsClass3, 100, EFalse, TMsvSmsEntry::ENoAckSummary, EFalse, 0)); |
|
2631 |
|
2632 entry.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass0); |
|
2633 |
|
2634 TInt classCounter, upiCounter, classDef, deliverySummary, messageIdValid; |
|
2635 TSmsDataCodingScheme::TSmsClass tempClass; |
|
2636 TMsvSmsEntry::TMsvSmsEntryAckSummary tempDelivery; |
|
2637 TUint8 pidCounter; |
|
2638 TInt32 messageId = 123456789; |
|
2639 |
|
2640 for (classCounter = 0; classCounter < 4; classCounter++) |
|
2641 { |
|
2642 for (pidCounter = 0; pidCounter < 128; pidCounter++) |
|
2643 { |
|
2644 for (upiCounter = 0; upiCounter < 2; upiCounter++) |
|
2645 { |
|
2646 for (classDef = 0; classDef < 2; classDef++) |
|
2647 { |
|
2648 for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary ) |
|
2649 { |
|
2650 for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid) |
|
2651 { |
|
2652 entry = TMsvSmsEntry(); |
|
2653 tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter); |
|
2654 tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary); |
|
2655 entry.SetClass(classDef, tempClass); |
|
2656 entry.SetProtocolIdentifier(pidCounter); |
|
2657 entry.SetUserPromptIndicator(upiCounter); |
|
2658 entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery); |
|
2659 entry.SetMessageId(messageId, messageIdValid); |
|
2660 iSmsTest(CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId)); |
|
2661 } |
|
2662 } |
|
2663 } |
|
2664 } |
|
2665 } |
|
2666 } |
|
2667 |
|
2668 for (classCounter = 0; classCounter < 4; classCounter++) |
|
2669 { |
|
2670 for (pidCounter = 0; pidCounter < 128; pidCounter++) |
|
2671 { |
|
2672 for (upiCounter = 0; upiCounter < 2; upiCounter++) |
|
2673 { |
|
2674 for (classDef = 0; classDef < 2; classDef++) |
|
2675 { |
|
2676 for( deliverySummary = 0; deliverySummary < 5; ++deliverySummary ) |
|
2677 { |
|
2678 for( messageIdValid = 0; messageIdValid < 2; ++messageIdValid) |
|
2679 { |
|
2680 tempClass = static_cast<TSmsDataCodingScheme::TSmsClass>(classCounter); |
|
2681 tempDelivery = static_cast<TMsvSmsEntry::TMsvSmsEntryAckSummary>(deliverySummary); |
|
2682 entry.SetClass(classDef, tempClass); |
|
2683 entry.SetProtocolIdentifier(pidCounter); |
|
2684 entry.SetUserPromptIndicator(upiCounter); |
|
2685 entry.SetAckSummary(ESmsAckTypeDelivery, tempDelivery); |
|
2686 entry.SetMessageId(messageId, messageIdValid); |
|
2687 iSmsTest(CheckSmsEntry(entry, classDef, tempClass, pidCounter, upiCounter, tempDelivery, messageIdValid, messageId)); |
|
2688 } |
|
2689 } |
|
2690 } |
|
2691 } |
|
2692 } |
|
2693 } |
|
2694 } |