|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This program is designed the test of the . |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include "Te_SimSms.h" |
|
23 #include "Te_SimSmsUtil.h" // for catsmsutils |
|
24 |
|
25 |
|
26 //------------------------------------------------------------------ |
|
27 // ** TEST SimSms STEPS *** |
|
28 |
|
29 //------------------------------------------------------------------ |
|
30 |
|
31 CTestUtilClass::CTestUtilClass() |
|
32 /** Each test step initialises it's own name |
|
33 */ |
|
34 { |
|
35 // store the name of this test case |
|
36 // this is the name that is used by the script file |
|
37 SetTestStepName(_L("TestUtilClass")); |
|
38 } |
|
39 //------------------------------------------------------------------ |
|
40 |
|
41 TVerdict CTestUtilClass::doTestStepL( void ) |
|
42 /** |
|
43 * This functions tests most of CATSmsUtils class |
|
44 */ |
|
45 { |
|
46 INFO_PRINTF1(_L("CATSmsUtils.")); |
|
47 TestUtilClass_Step1L(); |
|
48 TestUtilClass_Step2L(); |
|
49 TestUtilClass_Step3L(); |
|
50 TestUtilClass_Step3point1L(); |
|
51 TestUtilClass_Step4L(); |
|
52 TestUtilClass_Step5L(); |
|
53 INFO_PRINTF1(_L("TESTL(s) passed")); |
|
54 return TestStepResult(); |
|
55 } |
|
56 |
|
57 void CTestUtilClass::TestUtilClass_Step1L() |
|
58 { |
|
59 TBuf8<400> buf; |
|
60 |
|
61 // |
|
62 // Test AppendAddress |
|
63 // |
|
64 RMobilePhone::TMobileAddress addr; |
|
65 |
|
66 buf.Zero(); |
|
67 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
68 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
69 addr.iTelNumber.Copy(_L("44 7785 014 208")); |
|
70 |
|
71 INFO_PRINTF1(_L("..")); |
|
72 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
73 |
|
74 if(buf.CompareF(_L8("0c91447758102480"))!=0) |
|
75 TESTL(KErrCorrupt); |
|
76 |
|
77 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
78 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
79 addr.iTelNumber.Copy(_L("01632960000")); |
|
80 |
|
81 buf.Zero(); |
|
82 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
83 if(buf.CompareF(_L8("0b914483056100f5"))!=0) |
|
84 TESTL(KErrCorrupt); |
|
85 |
|
86 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
87 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
88 addr.iTelNumber.Copy(_L("# * 44 77 85 01 60 05")); |
|
89 |
|
90 buf.Zero(); |
|
91 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
92 if(buf.CompareF(_L8("0e91ab01632960000"))!=0) |
|
93 TESTL(KErrCorrupt); |
|
94 } |
|
95 |
|
96 void CTestUtilClass::TestUtilClass_Step2L() |
|
97 { |
|
98 // |
|
99 // Test AppendBinaryDataToAscii |
|
100 // |
|
101 |
|
102 TBuf8<10> testPdu; |
|
103 testPdu.Append(0x00); |
|
104 testPdu.Append(0x10); |
|
105 testPdu.Append(0x20); |
|
106 testPdu.Append(0x40); |
|
107 testPdu.Append(0xf3); |
|
108 testPdu.Append(0x7b); |
|
109 testPdu.Append(0x99); |
|
110 testPdu.Append(0x5e); |
|
111 testPdu.Append(0x01); |
|
112 testPdu.Append(0x02); |
|
113 |
|
114 TBuf8<400> buf; |
|
115 buf.Zero(); |
|
116 INFO_PRINTF1(_L("..")); |
|
117 CATSmsUtils::AppendDataToAscii(buf,testPdu); |
|
118 |
|
119 if(buf.Compare(_L8("00102040f37b995e0102"))!=0) |
|
120 TESTL(KErrCorrupt); |
|
121 |
|
122 TBuf8<10> testPdu2; |
|
123 |
|
124 INFO_PRINTF1(_L("..")); |
|
125 TESTL(KErrNone == CATSmsUtils::ConvertAsciiToBinary(buf,testPdu2)); |
|
126 if(testPdu.Compare(testPdu2)!=0) |
|
127 TESTL(KErrCorrupt); |
|
128 } |
|
129 |
|
130 void CTestUtilClass::TestUtilClass_Step3L() |
|
131 { |
|
132 // |
|
133 // Test removal of SCA from a PDU |
|
134 // |
|
135 |
|
136 // Create a PDU |
|
137 RMobilePhone::TMobileAddress addr; |
|
138 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
139 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
140 addr.iTelNumber.Copy(_L("# * 44 7785 016 005")); |
|
141 |
|
142 TBuf8<400> buf; |
|
143 buf.Zero(); |
|
144 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
145 if(buf.CompareF(_L8("0e91ab01632960000"))!=0) |
|
146 TESTL(KErrCorrupt); |
|
147 |
|
148 _LIT8(KDummyData,"dummy data"); // must have even number of chars |
|
149 buf.Append(KDummyData); |
|
150 |
|
151 // fill data with garbage |
|
152 addr.iTypeOfNumber=RMobilePhone::EAbbreviatedNumber; |
|
153 addr.iNumberPlan=RMobilePhone::EPrivateNumberPlan; |
|
154 addr.iTelNumber.Copy(KTelNumberGarbage); |
|
155 |
|
156 // Get SCA from PDU and validate the output |
|
157 INFO_PRINTF1(_L("..")); |
|
158 TESTL(KErrNone == CATSmsUtils::ReadAndRemoveAddressFromAscii(buf,addr)); |
|
159 if(addr.iTypeOfNumber!=RMobilePhone::EInternationalNumber || |
|
160 addr.iNumberPlan!=RMobilePhone::EIsdnNumberPlan || |
|
161 addr.iTelNumber.Compare(_L("#*01632960000"))!=0 || |
|
162 buf.Compare(KDummyData)!=0) |
|
163 TESTL(KErrCorrupt); |
|
164 } |
|
165 |
|
166 void CTestUtilClass::TestUtilClass_Step3point1L() |
|
167 { |
|
168 // |
|
169 // Test reading of SCA form a PDU (no removal) |
|
170 // |
|
171 |
|
172 // Create a PDU |
|
173 RMobilePhone::TMobileAddress addr; |
|
174 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
175 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
176 addr.iTelNumber.Copy(_L("44 7785 016 005")); |
|
177 |
|
178 TBuf8<400> buf; |
|
179 buf.Zero(); |
|
180 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
181 if(buf.CompareF(_L8("0c91447758100650"))!=0) |
|
182 TESTL(KErrCorrupt); |
|
183 |
|
184 // fill data with garbage |
|
185 addr.iTypeOfNumber=RMobilePhone::ESubscriberNumber; |
|
186 addr.iNumberPlan=RMobilePhone::EDataNumberPlan; |
|
187 addr.iTelNumber.Copy(KTelNumberGarbage); |
|
188 |
|
189 // Get SCA from PDU and validate the output |
|
190 INFO_PRINTF1(_L("..")); |
|
191 TESTL(KErrNone == CATSmsUtils::ReadAddressFromAscii(buf,addr)); |
|
192 if(addr.iTypeOfNumber!=RMobilePhone::EInternationalNumber || |
|
193 addr.iNumberPlan!=RMobilePhone::EIsdnNumberPlan || |
|
194 addr.iTelNumber.Compare(_L("01632960000"))!=0 || |
|
195 buf.Length()!=16) |
|
196 TESTL(KErrCorrupt); |
|
197 |
|
198 // Create a PDU |
|
199 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
200 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
201 addr.iTelNumber.Copy(_L("44 7785 016 005")); |
|
202 |
|
203 buf.Zero(); |
|
204 TESTL(KErrNone == CATSmsUtils::AppendAddressToAscii(buf,addr)); |
|
205 if(buf.CompareF(_L8("0c91447758100650"))!=0) |
|
206 TESTL(KErrCorrupt); |
|
207 |
|
208 // Modify PDU so it uses 03.40 SCA length format |
|
209 buf[1]=static_cast<TUint8>(TChar('7')); |
|
210 |
|
211 // fill data with garbage |
|
212 addr.iTypeOfNumber=RMobilePhone::ESubscriberNumber; |
|
213 addr.iNumberPlan=RMobilePhone::EDataNumberPlan; |
|
214 addr.iTelNumber.Copy(KTelNumberGarbage); |
|
215 |
|
216 // Get SCA from PDU (specifying PDU is in 03.40 format) and validate the output |
|
217 INFO_PRINTF1(_L("..")); |
|
218 TESTL(KErrNone == CATSmsUtils::ReadAddressFromAscii(buf,addr,ETrue)); |
|
219 if(addr.iTypeOfNumber!=RMobilePhone::EInternationalNumber || |
|
220 addr.iNumberPlan!=RMobilePhone::EIsdnNumberPlan || |
|
221 addr.iTelNumber.Compare(_L("01632960000"))!=0 || |
|
222 buf.Length()!=16) |
|
223 TESTL(KErrCorrupt); |
|
224 } |
|
225 |
|
226 |
|
227 void CTestUtilClass::TestUtilClass_Step4L() |
|
228 { |
|
229 // |
|
230 // Test ParseRxResultsForCSCAResponse |
|
231 // |
|
232 // fill data with garbage |
|
233 RMobilePhone::TMobileAddress addr; |
|
234 addr.iTypeOfNumber=RMobilePhone::ESubscriberNumber; |
|
235 addr.iNumberPlan=RMobilePhone::EDataNumberPlan; |
|
236 addr.iTelNumber.Copy(_L("000111000111000111000111")); |
|
237 |
|
238 // setup a response to be parsed |
|
239 _LIT8(KAddressValue,"01632960000"); |
|
240 _LIT8(KAddressType,"129"); |
|
241 TPtrC8 addressValue(KAddressValue); |
|
242 TPtrC8 addressType(KAddressType); |
|
243 |
|
244 // Parse reponse and validate output |
|
245 INFO_PRINTF1(_L("..")); |
|
246 TESTL(KErrNone == CATSmsUtils::CopyAddressStringToAddressStruct(addressValue,addressType,addr)); |
|
247 if(addr.iTypeOfNumber!=RMobilePhone::EUnknownNumber || |
|
248 addr.iNumberPlan!=RMobilePhone::EIsdnNumberPlan || |
|
249 addr.iTelNumber.Compare(_L("01632960000"))!=0) |
|
250 TESTL(KErrCorrupt); |
|
251 } |
|
252 |
|
253 void CTestUtilClass::TestUtilClass_Step5L() |
|
254 { |
|
255 |
|
256 // |
|
257 // Test conversion of Type-Of-Adddress to a decimal |
|
258 // |
|
259 RMobilePhone::TMobileAddress addr; |
|
260 addr.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
261 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
262 addr.iTelNumber.Copy(_L("44 7785 016 005")); |
|
263 TUint val; |
|
264 INFO_PRINTF1(_L("..")); |
|
265 CATSmsUtils::GetTypeOfAddressInDecimal(addr,val); |
|
266 if(val!=145) |
|
267 TESTL(KErrCorrupt); |
|
268 addr.iTypeOfNumber=RMobilePhone::EUnknownNumber; |
|
269 addr.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
270 addr.iTelNumber.Copy(_L("44 7785 016 005")); |
|
271 INFO_PRINTF1(_L("..")); |
|
272 CATSmsUtils::GetTypeOfAddressInDecimal(addr,val); |
|
273 if(val!=129) |
|
274 TESTL(KErrCorrupt); |
|
275 } |
|
276 |
|
277 |
|
278 //------------------------------------------------------------------ |
|
279 |
|
280 CGetCaps::CGetCaps() |
|
281 /** Each test step initialises it's own name |
|
282 */ |
|
283 { |
|
284 // store the name of this test case |
|
285 // this is the name that is used by the script file |
|
286 SetTestStepName(_L("GetCaps")); |
|
287 } |
|
288 //------------------------------------------------------------------ |
|
289 |
|
290 TVerdict CGetCaps::doTestStepL( void ) |
|
291 /** |
|
292 * This function tests the capabilities API of the Messaging subssession. |
|
293 */ |
|
294 { |
|
295 INFO_PRINTF1(_L("Get Capabilities.")); |
|
296 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(iSmsCaps); |
|
297 TESTL(KErrNone == iSms.GetCaps(smsCapsPckg)); |
|
298 |
|
299 return TestStepResult(); |
|
300 } |
|
301 //------------------------------------------------------------------ |
|
302 |
|
303 CTestSmspList::CTestSmspList() |
|
304 /** Each test step initialises it's own name |
|
305 */ |
|
306 { |
|
307 // store the name of this test case |
|
308 // this is the name that is used by the script file |
|
309 SetTestStepName(_L("TestSmspList")); |
|
310 } |
|
311 //------------------------------------------------------------------ |
|
312 |
|
313 TVerdict CTestSmspList::doTestStepL( void ) |
|
314 /** |
|
315 * This function tests get/set service centre address |
|
316 */ |
|
317 { |
|
318 INFO_PRINTF1(_L("Check TSY's SMSP capabilities..")); |
|
319 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(iSmsCaps); |
|
320 TESTL(KErrNone == iSms.GetCaps(smsCapsPckg)); |
|
321 |
|
322 if ((iSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsGetSmspList) && |
|
323 (iSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsSetSmspList)) |
|
324 { |
|
325 INFO_PRINTF1(_L("Caps - KCapsGetSmspList supported")); |
|
326 INFO_PRINTF1(_L("Caps - KCapsSetSmspList supported")); |
|
327 |
|
328 RMobileSmsMessaging::TMobileSmspEntryV1 defaultSmspEntry; |
|
329 RMobileSmsMessaging::TMobileSmspEntryV1 newSmspEntry; |
|
330 RMobileSmsMessaging::TMobileSmspEntryV1 checkSmspEntry; |
|
331 |
|
332 INFO_PRINTF1(_L("Retrieve default SMSP list")); |
|
333 TRAPD(ret, GetSmspListL(defaultSmspEntry)); |
|
334 if(ret) |
|
335 return EFail; |
|
336 INFO_PRINTF1(_L("Store new SMSP list")); |
|
337 newSmspEntry.iValidParams = RMobileSmsMessaging::KSCAIncluded; |
|
338 newSmspEntry.iServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
339 newSmspEntry.iServiceCentre.iNumberPlan=RMobilePhone:: EIsdnNumberPlan; |
|
340 newSmspEntry.iServiceCentre.iTelNumber.Copy(_L("01632960000")); |
|
341 TRAP(ret, SetSmspListL(newSmspEntry)); |
|
342 if(ret) |
|
343 return EFail; |
|
344 INFO_PRINTF1(_L("Check SMSP list contains new entry")); |
|
345 TRAP(ret, GetSmspListL(checkSmspEntry)); |
|
346 if(ret) |
|
347 return EFail; |
|
348 |
|
349 INFO_PRINTF1(_L("Rewrite default SMSP list")); |
|
350 TRAP(ret, SetSmspListL(defaultSmspEntry)); |
|
351 if(ret) |
|
352 return(EFail); |
|
353 INFO_PRINTF1(_L("Check SMSP list contains default entry")); |
|
354 TRAP(ret, GetSmspListL(checkSmspEntry)); |
|
355 if(ret) |
|
356 return EFail; |
|
357 } |
|
358 return TestStepResult(); |
|
359 } |
|
360 |
|
361 void CTestSmspList::GetSmspListL(RMobileSmsMessaging::TMobileSmspEntryV1& aSmspEntry) |
|
362 /** |
|
363 * This function tests CRetrieveMobilePhoneSmspList |
|
364 */ |
|
365 { |
|
366 CTestGetSmspList* retrieveSmspList; |
|
367 CMobilePhoneSmspList* smspList; |
|
368 |
|
369 retrieveSmspList = CTestGetSmspList::NewLC(iSms); |
|
370 retrieveSmspList->Start(); |
|
371 CActiveScheduler::Start(); |
|
372 smspList = retrieveSmspList->RetrieveListL(); |
|
373 if(!smspList) |
|
374 return; // Ooooooooooooops ;-( |
|
375 |
|
376 |
|
377 TInt count = smspList->Enumerate(); |
|
378 INFO_PRINTF2(_L("SMSP list has %d entries"), count); |
|
379 |
|
380 TInt i; |
|
381 for (i=0; i<count; i++) |
|
382 { |
|
383 aSmspEntry = smspList->GetEntryL(i); |
|
384 INFO_PRINTF3(_L("Entry %d: Service Centre = >%S<"),i,&aSmspEntry.iServiceCentre.iTelNumber); |
|
385 } |
|
386 |
|
387 CleanupStack::PopAndDestroy(); // retrieveSmspList; |
|
388 delete smspList; |
|
389 User::After(1000000); // Give user time to see the test results |
|
390 } |
|
391 |
|
392 |
|
393 void CTestSmspList::SetSmspListL(RMobileSmsMessaging::TMobileSmspEntryV1& aSmspEntry) |
|
394 /** |
|
395 * This function tests writing service centre address |
|
396 */ |
|
397 { |
|
398 CMobilePhoneSmspList* smspList = CMobilePhoneSmspList::NewL(); |
|
399 CleanupStack::PushL(smspList); |
|
400 |
|
401 smspList->AddEntryL(aSmspEntry); |
|
402 |
|
403 TRequestStatus reqStatus; |
|
404 |
|
405 iSms.StoreSmspListL(reqStatus, smspList); |
|
406 User::WaitForRequest(reqStatus); |
|
407 TESTL(reqStatus.Int()==KErrNone); |
|
408 |
|
409 CleanupStack::PopAndDestroy(); // smspList; |
|
410 } |
|
411 |
|
412 //------------------------------------------------------------------ |
|
413 |
|
414 CMessageStoreInfo::CMessageStoreInfo() |
|
415 /** Each test step initialises it's own name |
|
416 */ |
|
417 { |
|
418 // store the name of this test case |
|
419 // this is the name that is used by the script file |
|
420 SetTestStepName(_L("MessageStoreInfo")); |
|
421 } |
|
422 //------------------------------------------------------------------ |
|
423 |
|
424 TVerdict CMessageStoreInfo::doTestStepL( void ) |
|
425 /** |
|
426 * This function retrieves the number of message stores supported by the iPhone. It |
|
427 * also gets the details of the supported message stores. It then gets and sets the |
|
428 * Default Service Center Address (SCA) and performs some Cancel Requests. |
|
429 */ |
|
430 { |
|
431 INFO_PRINTF1(_L("Test RMobileSmsMessaging::EnumerateMessageStores..")); |
|
432 |
|
433 TInt ret=KErrNone; |
|
434 TInt count=0; |
|
435 TInt i; |
|
436 |
|
437 ret=iSms.EnumerateMessageStores(count); |
|
438 if (!ret) |
|
439 { |
|
440 INFO_PRINTF2(_L("Error %d retrieving message store count"), ret); |
|
441 } |
|
442 else |
|
443 { |
|
444 INFO_PRINTF2(_L("There are %d SMS message stores"), count); |
|
445 } |
|
446 |
|
447 INFO_PRINTF1(_L("Test RMobileSmsMessaging::GetMessageStoreInfo...")); |
|
448 |
|
449 TRequestStatus reqStatus; |
|
450 RMobilePhoneStore::TMobilePhoneStoreInfoV1 smsInfo; |
|
451 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg smsInfoPckg(smsInfo); |
|
452 |
|
453 for (i=0; i<count; i++) |
|
454 { |
|
455 iSms.GetMessageStoreInfo(reqStatus, i, smsInfoPckg); |
|
456 User::WaitForRequest(reqStatus); |
|
457 |
|
458 if (reqStatus!=KErrNone) |
|
459 { |
|
460 INFO_PRINTF2(_L("Error %d retrieving message store info"), ret); |
|
461 break; |
|
462 } |
|
463 |
|
464 TESTL(smsInfo.iType==RMobilePhoneStore::EShortMessageStore); |
|
465 |
|
466 // Print the result |
|
467 INFO_PRINTF1(_L("Information retrieved about the message store")); |
|
468 INFO_PRINTF2(_L("Name : %S"), &smsInfo.iName); |
|
469 INFO_PRINTF2(_L("Total number of entries : %d"), smsInfo.iTotalEntries); |
|
470 INFO_PRINTF2(_L("Number of used entries : %d"), smsInfo.iUsedEntries); |
|
471 INFO_PRINTF2(_L("Capabilities(in hex) : %X"), smsInfo.iCaps); |
|
472 PrintMessageStoreCaps(smsInfo.iCaps); |
|
473 User::After(10000000); // Give user time to see the test results |
|
474 } |
|
475 |
|
476 // Test immediate cancelling of request |
|
477 INFO_PRINTF1(_L("Test cancelling of GetMessageStoreInfo request")); |
|
478 iSms.GetMessageStoreInfo(reqStatus, 0, smsInfoPckg); |
|
479 iSms.CancelAsyncRequest(EMobileSmsMessagingGetMessageStoreInfo); |
|
480 User::WaitForRequest(reqStatus); |
|
481 |
|
482 if (reqStatus==KErrCancel) |
|
483 { |
|
484 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
485 } |
|
486 else |
|
487 { |
|
488 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
489 } |
|
490 |
|
491 // Test delayed cancelling of request |
|
492 INFO_PRINTF1(_L("Test cancelling of GetMessageStoreInfo request")); |
|
493 iSms.GetMessageStoreInfo(reqStatus, 1, smsInfoPckg); |
|
494 // User::After(500000); |
|
495 iSms.CancelAsyncRequest(EMobileSmsMessagingGetMessageStoreInfo); |
|
496 User::WaitForRequest(reqStatus); |
|
497 |
|
498 if (reqStatus==KErrCancel) |
|
499 { |
|
500 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
501 } |
|
502 else |
|
503 { |
|
504 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
505 } |
|
506 |
|
507 return TestStepResult(); |
|
508 } |
|
509 //------------------------------------------------------------------ |
|
510 |
|
511 CMessageStoreOps::CMessageStoreOps() |
|
512 /** Each test step initialises it's own name |
|
513 */ |
|
514 { |
|
515 // store the name of this test case |
|
516 // this is the name that is used by the script file |
|
517 SetTestStepName(_L("MessageStoreOps")); |
|
518 } |
|
519 //------------------------------------------------------------------ |
|
520 |
|
521 TVerdict CMessageStoreOps::doTestStepL( void ) |
|
522 /** |
|
523 * This function performs Message Store Operations. |
|
524 * It opens the SIM and ME Stores, writes & reads sms' to these stores, performs |
|
525 * appropriate Cancel operations and gets information on the SIM and ME stores. |
|
526 */ |
|
527 { |
|
528 // Test open message store and get info |
|
529 |
|
530 RMobileSmsStore simStore; |
|
531 |
|
532 TInt ret=simStore.Open(iSms, KETelIccSmsStore); |
|
533 TESTL(ret==KErrNone); |
|
534 INFO_PRINTF1(_L("SIM message store opened...")); |
|
535 |
|
536 TRequestStatus reqStatus; |
|
537 RMobilePhoneStore::TMobilePhoneStoreInfoV1 simSmsInfo; |
|
538 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg simSmsInfoPckg(simSmsInfo); |
|
539 |
|
540 simStore.GetInfo(reqStatus, simSmsInfoPckg); |
|
541 User::WaitForRequest(reqStatus); |
|
542 if (reqStatus!=KErrNone) |
|
543 { |
|
544 INFO_PRINTF2(_L("Error %d retrieving SIM message store info"), ret); |
|
545 } |
|
546 else |
|
547 { |
|
548 TESTL(simSmsInfo.iType==RMobilePhoneStore::EShortMessageStore); |
|
549 |
|
550 // Print the result |
|
551 INFO_PRINTF1(_L("Information retrieved about the message store")); |
|
552 INFO_PRINTF2(_L("Name : %S"), &simSmsInfo.iName); |
|
553 INFO_PRINTF2(_L("Total number of entries : %d"), simSmsInfo.iTotalEntries); |
|
554 INFO_PRINTF2(_L("Number of used entries : %d"), simSmsInfo.iUsedEntries); |
|
555 INFO_PRINTF2(_L("Capabilities(in hex) : %X"), simSmsInfo.iCaps); |
|
556 PrintMessageStoreCaps(simSmsInfo.iCaps); |
|
557 User::After(10000000); // Give user time to see the test results |
|
558 } |
|
559 |
|
560 // Test immediate cancelling of request |
|
561 RMobilePhoneStore::TMobilePhoneStoreInfoV1 simSmsInfo2; |
|
562 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg simSmsInfoPckg2(simSmsInfo2); |
|
563 |
|
564 INFO_PRINTF1(_L("Test immediate cancelling of GetInfo request")); |
|
565 simStore.GetInfo(reqStatus, simSmsInfoPckg2); |
|
566 simStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo); |
|
567 User::WaitForRequest(reqStatus); |
|
568 |
|
569 if (reqStatus==KErrCancel) |
|
570 { |
|
571 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
572 } |
|
573 else |
|
574 { |
|
575 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
576 } |
|
577 |
|
578 // Test delayed cancelling of request |
|
579 INFO_PRINTF1(_L("Test delayed cancelling of GetInfo request")); |
|
580 simStore.GetInfo(reqStatus, simSmsInfoPckg2); |
|
581 User::After(500000); |
|
582 simStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo); |
|
583 User::WaitForRequest(reqStatus); |
|
584 |
|
585 if (reqStatus==KErrCancel) |
|
586 { |
|
587 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
588 } |
|
589 else |
|
590 { |
|
591 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
592 } |
|
593 |
|
594 // Test the same information retrieval for ME SMS store |
|
595 RMobileSmsStore meStore; |
|
596 RMobilePhoneStore::TMobilePhoneStoreInfoV1 meSmsInfo; |
|
597 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg meSmsInfoPckg(meSmsInfo); |
|
598 |
|
599 ret=meStore.Open(iSms, KETelMeSmsStore); |
|
600 if(ret != KErrNone) // If KETelMeSmsStore does not exist, re-open previous store (KETelIccSmsStore) |
|
601 ret=meStore.Open(iSms, KETelIccSmsStore); |
|
602 |
|
603 INFO_PRINTF1(_L("ME message store opened...")); |
|
604 |
|
605 meStore.GetInfo(reqStatus, meSmsInfoPckg); |
|
606 User::WaitForRequest(reqStatus); |
|
607 if (reqStatus!=KErrNone) |
|
608 { |
|
609 INFO_PRINTF2(_L("Error %d retrieving SIM message store info"), ret); |
|
610 } |
|
611 else |
|
612 { |
|
613 TESTL(meSmsInfo.iType==RMobilePhoneStore::EShortMessageStore); |
|
614 |
|
615 // Print the result |
|
616 INFO_PRINTF1(_L("Information retrieved about the message store")); |
|
617 INFO_PRINTF2(_L("Name : %S"), &meSmsInfo.iName); |
|
618 INFO_PRINTF2(_L("Total number of entries : %d"), meSmsInfo.iTotalEntries); |
|
619 INFO_PRINTF2(_L("Number of used entries : %d"), meSmsInfo.iUsedEntries); |
|
620 INFO_PRINTF2(_L("Capabilities(in hex) : %X"), meSmsInfo.iCaps); |
|
621 PrintMessageStoreCaps(meSmsInfo.iCaps); |
|
622 User::After(10000000); // Give user time to see the test results |
|
623 } |
|
624 |
|
625 // Test immediate cancelling of request |
|
626 RMobilePhoneStore::TMobilePhoneStoreInfoV1 meSmsInfo2; |
|
627 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg meSmsInfoPckg2(meSmsInfo2); |
|
628 INFO_PRINTF1(_L("Test immediate cancelling of GetInfo request")); |
|
629 meStore.GetInfo(reqStatus, meSmsInfoPckg2); |
|
630 meStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo); |
|
631 User::WaitForRequest(reqStatus); |
|
632 |
|
633 if (reqStatus==KErrCancel) |
|
634 { |
|
635 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
636 } |
|
637 else |
|
638 { |
|
639 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
640 } |
|
641 |
|
642 // Test delayed cancelling of request |
|
643 INFO_PRINTF1(_L("Test delayed cancelling of GetInfo request")); |
|
644 meStore.GetInfo(reqStatus, meSmsInfoPckg2); |
|
645 User::After(500000); |
|
646 meStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo); |
|
647 User::WaitForRequest(reqStatus); |
|
648 |
|
649 if (reqStatus==KErrCancel) |
|
650 { |
|
651 INFO_PRINTF1(_L("Request successfully cancelled")); |
|
652 } |
|
653 else |
|
654 { |
|
655 INFO_PRINTF1(_L("Request NOT cancelled")); |
|
656 } |
|
657 |
|
658 // Test reading all the messages in SIM store |
|
659 // Print details of each message |
|
660 INFO_PRINTF1(_L("Reading Message from SIM Store")); |
|
661 |
|
662 RMobileSmsStore::TMobileGsmSmsEntryV1 smsEntry; |
|
663 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsEntryPckg(smsEntry); |
|
664 |
|
665 for (TInt i=1; i<=simSmsInfo.iUsedEntries; i++) |
|
666 { |
|
667 smsEntry.iIndex=i; // Entry to read |
|
668 simStore.Read(reqStatus, smsEntryPckg); |
|
669 User::WaitForRequest(reqStatus); |
|
670 if (reqStatus == KErrNotFound) |
|
671 { |
|
672 INFO_PRINTF2((_L("The entry was not found, request status = %d")), reqStatus.Int()); |
|
673 } |
|
674 else |
|
675 { |
|
676 INFO_PRINTF2(_L("Entry %d: Successfully read"),smsEntry.iIndex); |
|
677 INFO_PRINTF2(_L("Status of entry = %d"),smsEntry.iMsgStatus); |
|
678 INFO_PRINTF2(_L("Length of PDU in octets = %d"),smsEntry.iMsgData.Size()); |
|
679 } |
|
680 } |
|
681 |
|
682 // Test reading and cancelling |
|
683 INFO_PRINTF1(_L("Test Cancel Read from SIM Store")); |
|
684 TRequestStatus cancelReqStatus; |
|
685 |
|
686 smsEntry.iIndex=simSmsInfo.iUsedEntries; |
|
687 simStore.Read(cancelReqStatus, smsEntryPckg); |
|
688 simStore.CancelAsyncRequest(EMobilePhoneStoreRead); |
|
689 User::WaitForRequest(cancelReqStatus); |
|
690 |
|
691 if (cancelReqStatus==KErrCancel) |
|
692 { |
|
693 INFO_PRINTF1(_L("Read Request successfully cancelled")); |
|
694 } |
|
695 else |
|
696 { |
|
697 INFO_PRINTF1(_L("Read Request NOT cancelled")); |
|
698 } |
|
699 |
|
700 // Test writing a dummy PDU to SIM store |
|
701 // And then test reading it out and comparing it |
|
702 INFO_PRINTF1(_L("Test Write to SIM Store")); |
|
703 |
|
704 const TText8 MyPdu[] = {0x24, 0x0c,0x91,0x44,0x97,0x10,0x91,0x06,0x25,0x00,0x00,0x10,0x70,0x92,0x40,0x83,0x50,0x40,0x37,0xD6,0x77,0x7A,0x5C,0x6E,0x87,0xD3,0x6C,0x10,0x3A,0x3C,0x07,0xCD,0x40,0xEE,0xF2,0x1D,0xD4,0x2E,0xCF,0xE7,0xE1,0x73,0x79,0xEE,0x02,0x41,0xD9,0xE5,0xF0,0xBC,0x0C,0x1A,0x87,0xD9,0x6C,0xD0,0x8A,0x46,0xBB,0xE5,0x60,0xB1,0x58,0xCE,0x06,0xAB,0xC9,0x00}; |
|
705 |
|
706 smsEntry.iMsgStatus=RMobileSmsStore::EStoredMessageUnsent; |
|
707 smsEntry.iMsgData.Copy(MyPdu, sizeof(MyPdu)); |
|
708 |
|
709 simStore.Write(reqStatus, smsEntryPckg); |
|
710 User::WaitForRequest(reqStatus); |
|
711 |
|
712 if (reqStatus==KErrNone) |
|
713 { |
|
714 INFO_PRINTF2(_L("Write request successfully completed to index %d"), smsEntry.iIndex); |
|
715 } |
|
716 else |
|
717 { |
|
718 INFO_PRINTF2(_L("Error %d writing message to SIM store"), reqStatus.Int()); |
|
719 } |
|
720 |
|
721 if (reqStatus==KErrNone) |
|
722 { |
|
723 INFO_PRINTF1(_L("Test Read of entry just written to SIM Store")); |
|
724 |
|
725 RMobileSmsStore::TMobileGsmSmsEntryV1 smsReadEntry; |
|
726 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsReadEntryPckg(smsReadEntry); |
|
727 |
|
728 smsReadEntry.iIndex=smsEntry.iIndex; |
|
729 simStore.Read(reqStatus, smsReadEntryPckg); |
|
730 User::WaitForRequest(reqStatus); |
|
731 |
|
732 if (reqStatus != KErrNone) |
|
733 { |
|
734 INFO_PRINTF2((_L("The entry was not found, request status = %d")), reqStatus.Int()); |
|
735 } |
|
736 else |
|
737 { |
|
738 INFO_PRINTF2(_L("Entry %d: Successfully read"),smsReadEntry.iIndex); |
|
739 INFO_PRINTF2(_L("Status of entry = %d"),smsReadEntry.iMsgStatus); |
|
740 INFO_PRINTF2(_L("Length of PDU in octets = %d"),smsReadEntry.iMsgData.Size()); |
|
741 |
|
742 if (smsReadEntry.iMsgData.Compare(smsEntry.iMsgData)==0) |
|
743 { |
|
744 INFO_PRINTF1(_L("Read entry successfully compared with Write entry")); |
|
745 } |
|
746 else |
|
747 { |
|
748 INFO_PRINTF1(_L("Read entry NOT matched with Write entry")); |
|
749 } |
|
750 } |
|
751 } |
|
752 |
|
753 // Test writing and cancelling to ME store first |
|
754 INFO_PRINTF1(_L("Test Cancel Write to ME Store")); |
|
755 meStore.Write(cancelReqStatus, smsEntryPckg); |
|
756 meStore.CancelAsyncRequest(EMobilePhoneStoreWrite); |
|
757 User::WaitForRequest(cancelReqStatus); |
|
758 |
|
759 if (cancelReqStatus==KErrCancel) |
|
760 { |
|
761 INFO_PRINTF1(_L("Write Request successfully cancelled")); |
|
762 } |
|
763 else |
|
764 { |
|
765 INFO_PRINTF1(_L("Write Request NOT cancelled")); |
|
766 } |
|
767 |
|
768 // Test writing the same PDU to ME store |
|
769 // And then test reading it out and comparing it again |
|
770 INFO_PRINTF1(_L("Test Write to ME Store")); |
|
771 |
|
772 meStore.Write(reqStatus, smsEntryPckg); |
|
773 User::WaitForRequest(reqStatus); |
|
774 |
|
775 if (reqStatus==KErrNone) |
|
776 { |
|
777 INFO_PRINTF2(_L("Write request successfully completed to index %d"), smsEntry.iIndex); |
|
778 } |
|
779 else |
|
780 { |
|
781 INFO_PRINTF2(_L("Error %d writing message to ME store"), reqStatus.Int()); |
|
782 } |
|
783 |
|
784 if (reqStatus==KErrNone) |
|
785 { |
|
786 INFO_PRINTF1(_L("Test Read of entry just written to ME Store")); |
|
787 |
|
788 RMobileSmsStore::TMobileGsmSmsEntryV1 smsReadEntry2; |
|
789 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsReadEntryPckg2(smsReadEntry2); |
|
790 |
|
791 smsReadEntry2.iIndex=smsEntry.iIndex; |
|
792 meStore.Read(reqStatus, smsReadEntryPckg2); |
|
793 User::WaitForRequest(reqStatus); |
|
794 if (reqStatus != KErrNone) |
|
795 { |
|
796 INFO_PRINTF2((_L("The entry was not found, request status = %d")), reqStatus.Int()); |
|
797 } |
|
798 else |
|
799 { |
|
800 INFO_PRINTF2(_L("Entry %d: Successfully read"), smsReadEntry2.iIndex); |
|
801 INFO_PRINTF2(_L("Status of entry = %d"),smsReadEntry2.iMsgStatus); |
|
802 INFO_PRINTF2(_L("Length of PDU in octets = %d"),smsReadEntry2.iMsgData.Size()); |
|
803 |
|
804 if (smsReadEntry2.iMsgData.Compare(smsEntry.iMsgData)==0) |
|
805 { |
|
806 INFO_PRINTF1(_L("Read entry successfully compared with Write entry")); |
|
807 } |
|
808 else |
|
809 { |
|
810 INFO_PRINTF1(_L("Read entry NOT matched with Write entry")); |
|
811 } |
|
812 } |
|
813 } |
|
814 |
|
815 // Now test deletion of entries - test deletion of last entry |
|
816 // Get info again in order to get up-to-date number of used entries |
|
817 |
|
818 simStore.GetInfo(reqStatus, simSmsInfoPckg); |
|
819 User::WaitForRequest(reqStatus); |
|
820 TESTL(reqStatus==KErrNone); |
|
821 |
|
822 if (simSmsInfo.iUsedEntries > 0) |
|
823 { |
|
824 simStore.Delete(reqStatus, simSmsInfo.iUsedEntries); |
|
825 User::WaitForRequest(reqStatus); |
|
826 if (reqStatus == KErrNotFound) |
|
827 { |
|
828 INFO_PRINTF2((_L("The entry was not found, request status = %d")), reqStatus.Int()); |
|
829 } |
|
830 else |
|
831 { |
|
832 INFO_PRINTF2(_L("Entry %d: Successfully deleted"), simSmsInfo.iUsedEntries); |
|
833 } |
|
834 } |
|
835 |
|
836 meStore.GetInfo(reqStatus, meSmsInfoPckg); |
|
837 User::WaitForRequest(reqStatus); |
|
838 TESTL(reqStatus==KErrNone); |
|
839 |
|
840 if (meSmsInfo.iUsedEntries > 0) |
|
841 { |
|
842 meStore.Delete(reqStatus, meSmsInfo.iUsedEntries); |
|
843 User::WaitForRequest(reqStatus); |
|
844 if (reqStatus == KErrNotFound) |
|
845 { |
|
846 INFO_PRINTF2((_L("The entry was not found, request status = %d")), reqStatus.Int()); |
|
847 } |
|
848 else |
|
849 { |
|
850 INFO_PRINTF2(_L("Entry %d: Successfully deleted"), meSmsInfo.iUsedEntries); |
|
851 } |
|
852 } |
|
853 |
|
854 // Test deleting and cancelling |
|
855 INFO_PRINTF1(_L("Test Cancel Delete from SIM Store")); |
|
856 |
|
857 // Write an entry to be deleted first |
|
858 simStore.Write(reqStatus, smsEntryPckg); |
|
859 User::WaitForRequest(reqStatus); |
|
860 if (reqStatus==KErrNone) |
|
861 { |
|
862 simStore.Delete(cancelReqStatus,smsEntry.iIndex); |
|
863 simStore.CancelAsyncRequest(EMobilePhoneStoreDelete); |
|
864 User::WaitForRequest(cancelReqStatus); |
|
865 |
|
866 if (cancelReqStatus==KErrCancel) |
|
867 { |
|
868 INFO_PRINTF1(_L("Delete Request successfully cancelled")); |
|
869 } |
|
870 else |
|
871 { |
|
872 INFO_PRINTF1(_L("Delete Request NOT cancelled")); |
|
873 } |
|
874 } |
|
875 |
|
876 simStore.Close(); |
|
877 meStore.Close(); |
|
878 return TestStepResult(); |
|
879 } |
|
880 //------------------------------------------------------------------ |
|
881 |
|
882 CSendSms::CSendSms() |
|
883 /** Each test step initialises it's own name |
|
884 */ |
|
885 { |
|
886 // store the name of this test case |
|
887 // this is the name that is used by the script file |
|
888 SetTestStepName(_L("SendSms")); |
|
889 } |
|
890 //------------------------------------------------------------------ |
|
891 |
|
892 TVerdict CSendSms::doTestStepL( void ) |
|
893 /** |
|
894 * SendSms test. |
|
895 */ |
|
896 { |
|
897 SendSms() ; |
|
898 return TestStepResult(); |
|
899 } |
|
900 //------------------------------------------------------------------ |
|
901 |
|
902 CReceiveUnstoredSms::CReceiveUnstoredSms() |
|
903 /** Each test step initialises it's own name |
|
904 */ |
|
905 { |
|
906 // store the name of this test case |
|
907 // this is the name that is used by the script file |
|
908 SetTestStepName(_L("ReceiveUnstoredSms")); |
|
909 } |
|
910 //------------------------------------------------------------------ |
|
911 |
|
912 TVerdict CReceiveUnstoredSms::doTestStepL( void ) |
|
913 /** |
|
914 * Receive an unstored Sms test. |
|
915 * Currently the MMTSY does not support receive unstored mode, so that is what this test |
|
916 * tests for. |
|
917 */ |
|
918 { |
|
919 |
|
920 // Added during port to test execute |
|
921 // Not part of original scheduletest test harness |
|
922 // Added because this test seems to rely upon previous test |
|
923 // Please review!!!! |
|
924 // The original code for this test step seems to rely on things that it should not! |
|
925 // vvvvvvvvvv |
|
926 CSimSmsTestStepBase::SendSms(); |
|
927 // ^^^^^^^^^^ |
|
928 |
|
929 TRequestStatus aStatus,stat0; |
|
930 |
|
931 INFO_PRINTF1(_L("Setting receive mode to EReceiveUnstoredClientAck.")); |
|
932 |
|
933 //User::After(2000000); // Gives a bit of time |
|
934 |
|
935 iSms.SetReceiveMode(aStatus, RMobileSmsMessaging::EReceiveUnstoredClientAck); |
|
936 User::WaitForRequest(aStatus); |
|
937 if(aStatus.Int()) return EFail; |
|
938 |
|
939 INFO_PRINTF1(_L("Calling Receive API ...")); |
|
940 |
|
941 RMobileSmsMessaging::TMobileSmsGsmTpdu gsmMsg; |
|
942 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 recAtt; |
|
943 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg recAttPckg(recAtt); |
|
944 |
|
945 iSms.ReceiveMessage(aStatus, gsmMsg, recAttPckg); |
|
946 |
|
947 //ack message |
|
948 TPtrC8 nullPtr(NULL,0); |
|
949 iSms.AckSmsStored(stat0,nullPtr,EFalse); |
|
950 iSms.CancelAsyncRequest(EMobileSmsMessagingAckSmsStored);//no implementation-does nothing |
|
951 User::WaitForRequest(stat0); |
|
952 TEST(stat0==KErrGeneral); |
|
953 INFO_PRINTF1(_L("Message 1 ack")); |
|
954 |
|
955 INFO_PRINTF1(_L("Sending out a SMS ...")); |
|
956 |
|
957 TRAPD(ret, SendSms()); |
|
958 if(ret) return EFail; |
|
959 |
|
960 // Wait for the sent SMS to return to this phone |
|
961 User::WaitForRequest(aStatus); |
|
962 if(aStatus.Int()) return(EFail); |
|
963 return TestStepResult(); |
|
964 } |
|
965 //------------------------------------------------------------------ |
|
966 |
|
967 CReceiveStoredSms::CReceiveStoredSms() |
|
968 /** Each test step initialises it's own name |
|
969 */ |
|
970 { |
|
971 // store the name of this test case |
|
972 // this is the name that is used by the script file |
|
973 SetTestStepName(_L("ReceiveStoredSms")); |
|
974 } |
|
975 //------------------------------------------------------------------ |
|
976 |
|
977 TVerdict CReceiveStoredSms::doTestStepL( void ) |
|
978 /** |
|
979 * Receive a stored Sms test. |
|
980 * Currently the MMTSY does not support receive unstored mode, so that is what this test |
|
981 * tests for. |
|
982 */ |
|
983 { |
|
984 |
|
985 // Added during port to test execute |
|
986 // Not part of original scheduletest test harness |
|
987 // Added because this test seems to rely upon previous test |
|
988 // Please review!!!! |
|
989 // The original code for this test step seems to rely on things that it should not! |
|
990 // vvvvvvvvvv |
|
991 CSimSmsTestStepBase::SendSms(); |
|
992 // ^^^^^^^^^^ |
|
993 |
|
994 TRequestStatus aStatus; |
|
995 |
|
996 INFO_PRINTF1(_L("Setting receive mode to EReceiveStored.")); |
|
997 |
|
998 User::After(2000000); // Gives a bit of time |
|
999 |
|
1000 iSms.SetReceiveMode(aStatus, RMobileSmsMessaging::EReceiveStored); |
|
1001 User::WaitForRequest(aStatus); |
|
1002 if(aStatus.Int()==KErrNotSupported) |
|
1003 return TestStepResult(); |
|
1004 |
|
1005 |
|
1006 INFO_PRINTF1(_L("Calling Receive API ...")); |
|
1007 |
|
1008 RMobileSmsMessaging::TMobileSmsGsmTpdu gsmMsg; |
|
1009 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 recAtt; |
|
1010 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg recAttPckg(recAtt); |
|
1011 |
|
1012 iSms.ReceiveMessage(aStatus, gsmMsg, recAttPckg); |
|
1013 |
|
1014 INFO_PRINTF1(_L("Sending out a SMS ...")); |
|
1015 TRAPD(ret, SendSms(ETrue,iSms)); |
|
1016 if(ret!=KErrNone) |
|
1017 return (EFail); |
|
1018 |
|
1019 // Wait for the sent SMS to return to this phone |
|
1020 User::WaitForRequest(aStatus); |
|
1021 if(aStatus.Int()!=KErrNone) |
|
1022 return(EFail); |
|
1023 return TestStepResult(); |
|
1024 } |
|
1025 //------------------------------------------------------------------ |
|
1026 |
|
1027 CReceiveStoredSmsAndCancel::CReceiveStoredSmsAndCancel() |
|
1028 /** Each test step initialises it's own name |
|
1029 */ |
|
1030 { |
|
1031 // store the name of this test case |
|
1032 // this is the name that is used by the script file |
|
1033 SetTestStepName(_L("ReceiveStoredSmsAndCancel")); |
|
1034 } |
|
1035 //------------------------------------------------------------------ |
|
1036 |
|
1037 TVerdict CReceiveStoredSmsAndCancel::doTestStepL( void ) |
|
1038 { |
|
1039 TRequestStatus aStatus; |
|
1040 |
|
1041 INFO_PRINTF1(_L("Setting receive mode to EReceiveStored.")); |
|
1042 |
|
1043 User::After(2000000); // Gives a bit of time |
|
1044 |
|
1045 iSms.SetReceiveMode(aStatus, RMobileSmsMessaging::EReceiveStored); |
|
1046 User::WaitForRequest(aStatus); |
|
1047 if(aStatus.Int()==KErrNotSupported) |
|
1048 return TestStepResult(); |
|
1049 |
|
1050 |
|
1051 INFO_PRINTF1(_L("Calling Receive API ...")); |
|
1052 |
|
1053 RMobileSmsMessaging::TMobileSmsGsmTpdu gsmMsg; |
|
1054 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 recAtt; |
|
1055 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg recAttPckg(recAtt); |
|
1056 |
|
1057 iSms.ReceiveMessage(aStatus, gsmMsg, recAttPckg); |
|
1058 |
|
1059 INFO_PRINTF1(_L("Sending out a SMS ...")); |
|
1060 TRAPD(ret, SendSms(ETrue,iSms)); |
|
1061 if(ret) |
|
1062 return EFail; |
|
1063 |
|
1064 iSms.CancelAsyncRequest(EMobileSmsMessagingReceiveMessage); // Cancels ... |
|
1065 |
|
1066 // Wait for the sent SMS to return to this phone |
|
1067 User::WaitForRequest(aStatus); |
|
1068 if((aStatus.Int() == KErrCancel) || (aStatus.Int() == KErrNone)) |
|
1069 return(EPass); |
|
1070 else |
|
1071 return(EFail); |
|
1072 } |
|
1073 //------------------------------------------------------------------ |
|
1074 |
|
1075 CSendSmsAndCancel::CSendSmsAndCancel() |
|
1076 /** Each test step initialises it's own name |
|
1077 */ |
|
1078 { |
|
1079 // store the name of this test case |
|
1080 // this is the name that is used by the script file |
|
1081 SetTestStepName(_L("SendSmsAndCancel")); |
|
1082 } |
|
1083 //------------------------------------------------------------------ |
|
1084 |
|
1085 TVerdict CSendSmsAndCancel::doTestStepL( void ) |
|
1086 { |
|
1087 TInt i; |
|
1088 TRequestStatus status; |
|
1089 INFO_PRINTF1(_L("Sending SMS and cancelling.")); |
|
1090 |
|
1091 // Create message PDU and convert to binary |
|
1092 _LIT8(KMsgDataBeforeTargetAddress,"1d00"); |
|
1093 _LIT8(KMsgDataAfterTargetAddress,"01A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A0"); |
|
1094 TBuf8<400> msgData; |
|
1095 TLex8 lex; |
|
1096 TUint8 val; |
|
1097 msgData.Zero(); |
|
1098 |
|
1099 const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1100 for(i=0;i<count_before;++i) |
|
1101 { |
|
1102 lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); |
|
1103 TESTL(KErrNone == lex.Val(val,EHex)); |
|
1104 msgData.Append(TChar(val)); |
|
1105 } |
|
1106 |
|
1107 TBuf8<20> targetAddressAscii; |
|
1108 targetAddressAscii.Zero(); |
|
1109 RMobilePhone::TMobileAddress targetAddress; |
|
1110 targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1111 targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1112 targetAddress.iTelNumber.Copy(iTelNumber); |
|
1113 TInt ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); |
|
1114 if(ret) return(EFail); |
|
1115 |
|
1116 const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even |
|
1117 for(i=0;i<count_address;++i) |
|
1118 { |
|
1119 lex=targetAddressAscii.Mid(i*2,2); |
|
1120 lex.Val(val,EHex); |
|
1121 msgData.Append(TChar(val)); |
|
1122 } |
|
1123 |
|
1124 const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1125 for(i=0;i<count_after;++i) |
|
1126 { |
|
1127 lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); |
|
1128 lex.Val(val,EHex); |
|
1129 msgData.Append(TChar(val)); |
|
1130 } |
|
1131 |
|
1132 // Create message attibutes |
|
1133 RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; |
|
1134 |
|
1135 msgAttr.iFlags=0x184; |
|
1136 msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; |
|
1137 msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1138 msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1139 msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); |
|
1140 |
|
1141 // Package up data ready for sending to etel |
|
1142 RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); |
|
1143 |
|
1144 // Send the message |
|
1145 INFO_PRINTF1(_L("..")); |
|
1146 |
|
1147 TSmsPdu smsPduSent; |
|
1148 |
|
1149 smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); |
|
1150 |
|
1151 |
|
1152 iSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1153 |
|
1154 // Wait for a bit |
|
1155 User::After(KOneSecond*2); |
|
1156 // Cancel sending, then wait for sending operation to complete |
|
1157 iSms.CancelAsyncRequest(EMobileSmsMessagingSendMessage); |
|
1158 //if(status==KRequestPending) |
|
1159 User::WaitForRequest(status); |
|
1160 |
|
1161 ret=KErrNone; |
|
1162 if(status!=KErrCancel && status!=KErrNone) |
|
1163 ret=status.Int(); |
|
1164 else |
|
1165 INFO_PRINTF1(_L("TESTL(s) passed")); // If we don't cause a panic or leave the test has passed |
|
1166 |
|
1167 /* iSms.Close(); |
|
1168 iPhone->Close(); |
|
1169 |
|
1170 User::After(500000L); |
|
1171 |
|
1172 iPhone.Open(iTelServer,GSM_NAME); |
|
1173 iSms.Open(iPhone); |
|
1174 */ |
|
1175 return TestStepResult(); |
|
1176 } |
|
1177 //------------------------------------------------------------------ |
|
1178 |
|
1179 CAckSmsStored::CAckSmsStored() |
|
1180 /** Each test step initialises it's own name |
|
1181 */ |
|
1182 { |
|
1183 // store the name of this test case |
|
1184 // this is the name that is used by the script file |
|
1185 SetTestStepName(_L("AckSmsStored")); |
|
1186 } |
|
1187 //------------------------------------------------------------------ |
|
1188 |
|
1189 TVerdict CAckSmsStored::doTestStepL( void ) |
|
1190 /** |
|
1191 * This function Tests an API that should return |
|
1192 * KErrNotSupported |
|
1193 */ |
|
1194 { |
|
1195 TRequestStatus aStatus; |
|
1196 |
|
1197 TPtrC8 nullPtr(NULL,0); |
|
1198 |
|
1199 //ack the pending one |
|
1200 iSms.AckSmsStored(aStatus, nullPtr); |
|
1201 User::WaitForRequest(aStatus); |
|
1202 //no more to ack |
|
1203 iSms.AckSmsStored(aStatus, nullPtr); |
|
1204 User::WaitForRequest(aStatus); |
|
1205 |
|
1206 if(aStatus.Int() == KErrGeneral) //There is no outstanding SMS to Ack, so KErrGeneral is the correct response. |
|
1207 return(EPass); |
|
1208 else |
|
1209 ERR_PRINTF1(_L("SIMTSY dehavior is diferent, but why?")); |
|
1210 return EFail ; |
|
1211 } |
|
1212 //------------------------------------------------------------------ |
|
1213 |
|
1214 CAckSmsStoredCancel::CAckSmsStoredCancel() |
|
1215 /** Each test step initialises it's own name |
|
1216 */ |
|
1217 { |
|
1218 // store the name of this test case |
|
1219 // this is the name that is used by the script file |
|
1220 SetTestStepName(_L("AckSmsStoredCancel")); |
|
1221 } |
|
1222 //------------------------------------------------------------------ |
|
1223 |
|
1224 TVerdict CAckSmsStoredCancel::doTestStepL( void ) |
|
1225 /** |
|
1226 * This function Tests an API that should return |
|
1227 * KErrNotSupported |
|
1228 */ |
|
1229 { |
|
1230 // iSms.AckSmsStoredCancel(); // This API doesn't exist anymore |
|
1231 return TestStepResult(); |
|
1232 } |
|
1233 //------------------------------------------------------------------ |
|
1234 |
|
1235 CNackSmsStored::CNackSmsStored() |
|
1236 /** Each test step initialises it's own name |
|
1237 */ |
|
1238 { |
|
1239 // store the name of this test case |
|
1240 // this is the name that is used by the script file |
|
1241 SetTestStepName(_L("NackSmsStored")); |
|
1242 } |
|
1243 //------------------------------------------------------------------ |
|
1244 |
|
1245 TVerdict CNackSmsStored::doTestStepL( void ) |
|
1246 /** |
|
1247 * This function Tests an API that should return |
|
1248 * KErrNotSupported |
|
1249 */ |
|
1250 { |
|
1251 TRequestStatus aStatus; |
|
1252 |
|
1253 TPtrC8 nullPtr(NULL,0); |
|
1254 |
|
1255 iSms.NackSmsStored(aStatus, nullPtr, KErrGsmRRInvalidMessage); |
|
1256 User::WaitForRequest(aStatus); // There is no sms to NACK, so KErrGeneral is the correct response. |
|
1257 if(aStatus.Int() == KErrGeneral) |
|
1258 return(EPass); |
|
1259 else |
|
1260 return(EFail); |
|
1261 } |
|
1262 //------------------------------------------------------------------ |
|
1263 |
|
1264 CNackSmsStoredCancel::CNackSmsStoredCancel() |
|
1265 /** Each test step initialises it's own name |
|
1266 */ |
|
1267 { |
|
1268 // store the name of this test case |
|
1269 // this is the name that is used by the script file |
|
1270 SetTestStepName(_L("NackSmsStoredCancel")); |
|
1271 } |
|
1272 //------------------------------------------------------------------ |
|
1273 |
|
1274 TVerdict CNackSmsStoredCancel::doTestStepL( void ) |
|
1275 /** |
|
1276 * This function Tests an API that should return |
|
1277 * KErrNotSupported |
|
1278 */ |
|
1279 { |
|
1280 // iSms.NackSmsStoredCancel(); // API doesn't exist anymore |
|
1281 return TestStepResult(); |
|
1282 } |
|
1283 //------------------------------------------------------------------ |
|
1284 |
|
1285 CAckSmsStoredWithResponse::CAckSmsStoredWithResponse() |
|
1286 /** Each test step initialises it's own name |
|
1287 */ |
|
1288 { |
|
1289 // store the name of this test case |
|
1290 // this is the name that is used by the script file |
|
1291 SetTestStepName(_L("AckSmsStoredWithResponse")); |
|
1292 } |
|
1293 //------------------------------------------------------------------ |
|
1294 |
|
1295 TVerdict CAckSmsStoredWithResponse::doTestStepL( void ) |
|
1296 /** |
|
1297 * This function Tests an API that should return |
|
1298 * KErrNotSupported |
|
1299 */ |
|
1300 { |
|
1301 // iSms.AckSmsStoredWithResponse(); // API doesn't exist anymore |
|
1302 return TestStepResult(); |
|
1303 } |
|
1304 //------------------------------------------------------------------ |
|
1305 |
|
1306 CAckSmsStoredWithResponseCancel::CAckSmsStoredWithResponseCancel() |
|
1307 /** Each test step initialises it's own name |
|
1308 */ |
|
1309 { |
|
1310 // store the name of this test case |
|
1311 // this is the name that is used by the script file |
|
1312 SetTestStepName(_L("AckSmsStoredWithResponseCancel")); |
|
1313 } |
|
1314 //------------------------------------------------------------------ |
|
1315 |
|
1316 TVerdict CAckSmsStoredWithResponseCancel::doTestStepL( void ) |
|
1317 /** |
|
1318 * This function Tests an API that should return |
|
1319 * KErrNotSupported |
|
1320 */ |
|
1321 { |
|
1322 // iSms.AckSmsStoredWithResponseCancel(); // API doesn't exist anymore |
|
1323 return TestStepResult(); |
|
1324 } |
|
1325 //------------------------------------------------------------------ |
|
1326 |
|
1327 CNackSmsStoredWithResponse::CNackSmsStoredWithResponse() |
|
1328 /** Each test step initialises it's own name |
|
1329 */ |
|
1330 { |
|
1331 // store the name of this test case |
|
1332 // this is the name that is used by the script file |
|
1333 SetTestStepName(_L("NackSmsStoredWithResponse")); |
|
1334 } |
|
1335 //------------------------------------------------------------------ |
|
1336 |
|
1337 TVerdict CNackSmsStoredWithResponse::doTestStepL( void ) |
|
1338 /** |
|
1339 * This function Tests an API that should return |
|
1340 * KErrNotSupported |
|
1341 */ |
|
1342 { |
|
1343 // iSms.NackSmsStoredWithResponse(); // API doesn't exist anymore |
|
1344 return TestStepResult(); |
|
1345 } |
|
1346 //------------------------------------------------------------------ |
|
1347 |
|
1348 CNackSmsStoredWithResponseCancel::CNackSmsStoredWithResponseCancel() |
|
1349 /** Each test step initialises it's own name |
|
1350 */ |
|
1351 { |
|
1352 // store the name of this test case |
|
1353 // this is the name that is used by the script file |
|
1354 SetTestStepName(_L("NackSmsStoredWithResponseCancel")); |
|
1355 } |
|
1356 //------------------------------------------------------------------ |
|
1357 |
|
1358 TVerdict CNackSmsStoredWithResponseCancel::doTestStepL( void ) |
|
1359 /** |
|
1360 * This function Tests an API that should return |
|
1361 * KErrNotSupported |
|
1362 */ |
|
1363 { |
|
1364 // iSms.NackSmsStoredWithResponse(); // API doesn't exist anymore |
|
1365 return TestStepResult(); |
|
1366 } |
|
1367 //------------------------------------------------------------------ |
|
1368 |
|
1369 CResumeSmsReception::CResumeSmsReception() |
|
1370 /** Each test step initialises it's own name |
|
1371 */ |
|
1372 { |
|
1373 // store the name of this test case |
|
1374 // this is the name that is used by the script file |
|
1375 SetTestStepName(_L("ResumeSmsReception")); |
|
1376 } |
|
1377 //------------------------------------------------------------------ |
|
1378 |
|
1379 TVerdict CResumeSmsReception::doTestStepL( void ) |
|
1380 /** |
|
1381 * This function Tests an API that should return |
|
1382 * KErrNotSupported |
|
1383 */ |
|
1384 { |
|
1385 TRequestStatus aStatus; |
|
1386 |
|
1387 iSms.ResumeSmsReception(aStatus); |
|
1388 User::WaitForRequest(aStatus); // There has been no SMS suspension, so KErrGeneral is the correct response. |
|
1389 if(aStatus.Int() == KErrGeneral) |
|
1390 return(EPass); |
|
1391 else |
|
1392 return(EFail); |
|
1393 } |
|
1394 //------------------------------------------------------------------ |
|
1395 |
|
1396 CNotifySmsEvent::CNotifySmsEvent() |
|
1397 /** Each test step initialises it's own name |
|
1398 */ |
|
1399 { |
|
1400 // store the name of this test case |
|
1401 // this is the name that is used by the script file |
|
1402 SetTestStepName(_L("NotifySmsEvent")); |
|
1403 } |
|
1404 //------------------------------------------------------------------ |
|
1405 |
|
1406 TVerdict CNotifySmsEvent::doTestStepL( void ) |
|
1407 /** |
|
1408 * This function Tests an API that should return |
|
1409 * KErrNotSupported |
|
1410 */ |
|
1411 { |
|
1412 // iSms.NotifySmsEvent(); // API doesn't exist anymore |
|
1413 return TestStepResult(); |
|
1414 } |
|
1415 //------------------------------------------------------------------ |
|
1416 |
|
1417 CNotifySmsEventCancel::CNotifySmsEventCancel() |
|
1418 /** Each test step initialises it's own name |
|
1419 */ |
|
1420 { |
|
1421 // store the name of this test case |
|
1422 // this is the name that is used by the script file |
|
1423 SetTestStepName(_L("NotifySmsEventCancel")); |
|
1424 } |
|
1425 //------------------------------------------------------------------ |
|
1426 |
|
1427 TVerdict CNotifySmsEventCancel::doTestStepL( void ) |
|
1428 /** |
|
1429 * This function Tests an API that should return |
|
1430 * KErrNotSupported |
|
1431 */ |
|
1432 { |
|
1433 // iSms.NotifySmsEventCancel(); // API doesn't exist anymore |
|
1434 return TestStepResult(); |
|
1435 } |
|
1436 |
|
1437 |
|
1438 /**************************************************************/ |
|
1439 // |
|
1440 // Testing asynchronous retrieve of SMSP list |
|
1441 // |
|
1442 /**************************************************************/ |
|
1443 |
|
1444 CTestGetSmspList* CTestGetSmspList::NewLC(RMobileSmsMessaging& aSmsMessaging) |
|
1445 { |
|
1446 CTestGetSmspList* r=new(ELeave) CTestGetSmspList(aSmsMessaging); |
|
1447 CleanupStack::PushL(r); |
|
1448 r->ConstructL(); |
|
1449 return r; |
|
1450 } |
|
1451 |
|
1452 CTestGetSmspList::CTestGetSmspList(RMobileSmsMessaging& aSmsMessaging) |
|
1453 : CActive(EPriorityNormal), iSmsMessaging(aSmsMessaging) |
|
1454 { |
|
1455 } |
|
1456 |
|
1457 void CTestGetSmspList::ConstructL() |
|
1458 { |
|
1459 CActiveScheduler::Add(this); |
|
1460 iRetrieve=CRetrieveMobilePhoneSmspList::NewL(iSmsMessaging); |
|
1461 } |
|
1462 |
|
1463 CTestGetSmspList::~CTestGetSmspList() |
|
1464 { |
|
1465 delete iRetrieve; |
|
1466 } |
|
1467 |
|
1468 void CTestGetSmspList::Start() |
|
1469 { |
|
1470 iRetrieve->Start(iStatus); |
|
1471 SetActive(); |
|
1472 } |
|
1473 |
|
1474 CMobilePhoneSmspList* CTestGetSmspList::RetrieveListL() |
|
1475 { |
|
1476 return(iRetrieve->RetrieveListL()); |
|
1477 } |
|
1478 |
|
1479 void CTestGetSmspList::RunL() |
|
1480 { |
|
1481 TInt ret=iStatus.Int(); |
|
1482 User::LeaveIfError(ret); |
|
1483 CActiveScheduler::Stop(); |
|
1484 } |
|
1485 |
|
1486 void CTestGetSmspList::DoCancel() |
|
1487 { |
|
1488 iRetrieve->Cancel(); |
|
1489 } |
|
1490 |
|
1491 TInt CReceiveStoredSmsAndCancel::SendSms(TBool aQuiet, RMobileSmsMessaging& aSms) |
|
1492 /** |
|
1493 * SendSms test. |
|
1494 */ |
|
1495 { |
|
1496 if(!aQuiet) |
|
1497 INFO_PRINTF1(_L("Sending SMS.")); |
|
1498 |
|
1499 // Create message PDU and convert to binary |
|
1500 TBuf8<400> msgData; |
|
1501 TLex8 lex; |
|
1502 TUint8 val; |
|
1503 TInt i; |
|
1504 |
|
1505 TInt ret; |
|
1506 msgData.Zero(); |
|
1507 |
|
1508 |
|
1509 |
|
1510 const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1511 for(i=0;i<count_before;++i) |
|
1512 { |
|
1513 lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); |
|
1514 ret = lex.Val(val,EHex); |
|
1515 |
|
1516 if(ret) return ret; |
|
1517 msgData.Append(TChar(val)); |
|
1518 } |
|
1519 |
|
1520 TBuf8<20> targetAddressAscii; |
|
1521 targetAddressAscii.Zero(); |
|
1522 RMobilePhone::TMobileAddress targetAddress; |
|
1523 targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1524 targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1525 targetAddress.iTelNumber.Copy(iTelNumber); |
|
1526 ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); |
|
1527 |
|
1528 if(ret) return ret; |
|
1529 |
|
1530 const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even |
|
1531 for(i=0;i<count_address;++i) |
|
1532 { |
|
1533 lex=targetAddressAscii.Mid(i*2,2); |
|
1534 ret = lex.Val(val,EHex); |
|
1535 |
|
1536 if(ret) return ret; |
|
1537 msgData.Append(TChar(val)); |
|
1538 } |
|
1539 |
|
1540 const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1541 for(i=0;i<count_after;++i) |
|
1542 { |
|
1543 lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); |
|
1544 ret = lex.Val(val,EHex); |
|
1545 |
|
1546 if(ret) return ret; |
|
1547 msgData.Append(TChar(val)); |
|
1548 } |
|
1549 |
|
1550 // Create message attibutes |
|
1551 RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; |
|
1552 |
|
1553 msgAttr.iFlags=0x184; |
|
1554 msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; |
|
1555 msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1556 msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1557 msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); |
|
1558 |
|
1559 // Package up data ready for sending to etel |
|
1560 RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); |
|
1561 |
|
1562 // Send the message, try upto 3 times if phone is not ready |
|
1563 TRequestStatus status; |
|
1564 INFO_PRINTF1(_L("..")); |
|
1565 TSmsPdu smsPduSent; |
|
1566 |
|
1567 smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); |
|
1568 |
|
1569 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1570 User::WaitForRequest(status); |
|
1571 if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) |
|
1572 { |
|
1573 INFO_PRINTF1(_L("..")); |
|
1574 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1575 User::WaitForRequest(status); |
|
1576 if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) |
|
1577 { |
|
1578 INFO_PRINTF1(_L("..")); |
|
1579 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1580 User::WaitForRequest(status); |
|
1581 } |
|
1582 } |
|
1583 |
|
1584 ret = status.Int(); |
|
1585 |
|
1586 if(ret) return ret; |
|
1587 |
|
1588 // Validate message reference number has changed |
|
1589 if(!(msgAttr.iFlags&RMobileSmsMessaging::KMessageReference)) |
|
1590 return(KErrCorrupt); |
|
1591 |
|
1592 if(!aQuiet) |
|
1593 INFO_PRINTF1(_L("test(s) passed")); |
|
1594 |
|
1595 return(KErrNone); |
|
1596 } |
|
1597 |
|
1598 |
|
1599 TInt CReceiveStoredSms::SendSms(TBool aQuiet, RMobileSmsMessaging& aSms) |
|
1600 /** |
|
1601 * SendSms test. |
|
1602 */ |
|
1603 { |
|
1604 if(!aQuiet) |
|
1605 INFO_PRINTF1(_L("Sending SMS.")); |
|
1606 |
|
1607 // Create message PDU and convert to binary |
|
1608 TBuf8<400> msgData; |
|
1609 TLex8 lex; |
|
1610 TUint8 val; |
|
1611 TInt i; |
|
1612 |
|
1613 TInt ret; |
|
1614 msgData.Zero(); |
|
1615 |
|
1616 |
|
1617 |
|
1618 const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1619 for(i=0;i<count_before;++i) |
|
1620 { |
|
1621 lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); |
|
1622 ret = lex.Val(val,EHex); |
|
1623 |
|
1624 if(ret) return ret; |
|
1625 msgData.Append(TChar(val)); |
|
1626 } |
|
1627 |
|
1628 TBuf8<20> targetAddressAscii; |
|
1629 targetAddressAscii.Zero(); |
|
1630 RMobilePhone::TMobileAddress targetAddress; |
|
1631 targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1632 targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1633 targetAddress.iTelNumber.Copy(iTelNumber); |
|
1634 ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); |
|
1635 |
|
1636 if(ret) return ret; |
|
1637 |
|
1638 const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even |
|
1639 for(i=0;i<count_address;++i) |
|
1640 { |
|
1641 lex=targetAddressAscii.Mid(i*2,2); |
|
1642 ret = lex.Val(val,EHex); |
|
1643 |
|
1644 if(ret) return ret; |
|
1645 msgData.Append(TChar(val)); |
|
1646 } |
|
1647 |
|
1648 const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even |
|
1649 for(i=0;i<count_after;++i) |
|
1650 { |
|
1651 lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); |
|
1652 ret = lex.Val(val,EHex); |
|
1653 |
|
1654 if(ret) return ret; |
|
1655 msgData.Append(TChar(val)); |
|
1656 } |
|
1657 |
|
1658 // Create message attibutes |
|
1659 RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; |
|
1660 |
|
1661 msgAttr.iFlags=0x184; |
|
1662 msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; |
|
1663 msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; |
|
1664 msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; |
|
1665 msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); |
|
1666 |
|
1667 // Package up data ready for sending to etel |
|
1668 RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); |
|
1669 |
|
1670 // Send the message, try upto 3 times if phone is not ready |
|
1671 TRequestStatus status; |
|
1672 INFO_PRINTF1(_L("..")); |
|
1673 TSmsPdu smsPduSent; |
|
1674 |
|
1675 smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); |
|
1676 |
|
1677 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1678 User::WaitForRequest(status); |
|
1679 if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) |
|
1680 { |
|
1681 INFO_PRINTF1(_L("..")); |
|
1682 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1683 User::WaitForRequest(status); |
|
1684 if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) |
|
1685 { |
|
1686 INFO_PRINTF1(_L("..")); |
|
1687 aSms.SendMessage(status,smsPduSent,msgAttrPkg); |
|
1688 User::WaitForRequest(status); |
|
1689 } |
|
1690 } |
|
1691 |
|
1692 ret = status.Int(); |
|
1693 |
|
1694 if(ret) return ret; |
|
1695 |
|
1696 // Validate message reference number has changed |
|
1697 if(!(msgAttr.iFlags&RMobileSmsMessaging::KMessageReference)) |
|
1698 { |
|
1699 return(KErrCorrupt); |
|
1700 } |
|
1701 |
|
1702 if(!aQuiet) |
|
1703 { |
|
1704 INFO_PRINTF1(_L("test(s) passed")); |
|
1705 } |
|
1706 |
|
1707 return(KErrNone); |
|
1708 } |