|
1 // Copyright (c) 1997-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 file implements various receive message tests. |
|
15 // See CDataCall.cpp for fully documented test scenario. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 |
|
23 #include <e32test.h> |
|
24 #include <etelmm.h> |
|
25 #include "Te_LoopBackcrxmess.h" |
|
26 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint |
|
27 |
|
28 // |
|
29 // Test-side class |
|
30 // With the assistance of the base class, this class must start the emulator |
|
31 // and drive the ETel API. |
|
32 // |
|
33 CTestDriveRxMess* CTestDriveRxMess::NewL(const TScriptList aScriptListEntry) |
|
34 { |
|
35 CTestDriveRxMess* aA=new(ELeave) CTestDriveRxMess(aScriptListEntry); |
|
36 CleanupStack::PushL(aA); |
|
37 aA->ConstructL(); |
|
38 CleanupStack::Pop(); |
|
39 return aA; |
|
40 } |
|
41 |
|
42 CTestDriveRxMess::CTestDriveRxMess(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
43 { |
|
44 // NOP |
|
45 } |
|
46 |
|
47 TInt CTestDriveRxMess::RunTestL() |
|
48 { |
|
49 iCurrentScript=iScriptListEntry; |
|
50 return StartEmulatorL(); |
|
51 } |
|
52 |
|
53 TInt CTestDriveRxMess::DriveETelApiL() //1 |
|
54 // |
|
55 // This function contains the real meat of the Client-side test code |
|
56 // |
|
57 { |
|
58 TRequestStatus reqStatus; |
|
59 INFO_PRINTF1(_L("Initialising the Phone...")); |
|
60 |
|
61 RMobilePhone::TMMTableSettings tableSettings; |
|
62 tableSettings.iLocId=KInternetAccessPoint; |
|
63 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
64 iPhone.InitialiseMM(reqStatus , tableSettingsPckg); |
|
65 |
|
66 User::WaitForRequest(reqStatus); |
|
67 |
|
68 TESTL(reqStatus == KErrNone); |
|
69 |
|
70 RMobileSmsMessaging sms; |
|
71 |
|
72 INFO_PRINTF1(_L("Opening Sms Messaging")); |
|
73 |
|
74 TESTL(sms.Open(iPhone)==KErrNone); |
|
75 |
|
76 RMobileSmsMessaging::TMobileSmsCapsV1 smsCaps; |
|
77 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(smsCaps); |
|
78 |
|
79 sms.GetCaps(smsCapsPckg); |
|
80 smsCaps = smsCapsPckg(); |
|
81 DispCaps(smsCaps); |
|
82 |
|
83 TRequestStatus stat1, stat2; |
|
84 sms.SetReceiveMode (stat1, RMobileSmsMessaging::EReceiveStored); |
|
85 User::WaitForRequest(stat1); |
|
86 TESTL(stat1 == KErrNone); |
|
87 |
|
88 if(stat1 == KErrNone) |
|
89 { |
|
90 RMobileSmsMessaging::TMobileSmsGsmTpdu pdu; |
|
91 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
92 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPkg(attrib); |
|
93 sms.ReceiveMessage(stat2, pdu, attribPkg); |
|
94 User::WaitForRequest(stat2); |
|
95 TESTL(stat2 == KErrNone); |
|
96 attrib=attribPkg(); |
|
97 DispSmsAttributes(attrib); |
|
98 } |
|
99 |
|
100 INFO_PRINTF1(_L("Closing SMS Messaging...")); |
|
101 sms.Close(); |
|
102 return KErrNone; |
|
103 } |
|
104 |
|
105 // |
|
106 // Emulator-side class |
|
107 // With the assistance of the base class, this class must run the designated script |
|
108 // |
|
109 CTestRxMess* CTestRxMess::NewL(const TScript* aScript) |
|
110 { |
|
111 CTestRxMess* aA=new(ELeave) CTestRxMess(aScript); |
|
112 CleanupStack::PushL(aA); |
|
113 aA->ConstructL(); |
|
114 CleanupStack::Pop(); |
|
115 return aA; |
|
116 } |
|
117 |
|
118 CTestRxMess::CTestRxMess(const TScript* aScript) : iScript(aScript) |
|
119 { |
|
120 // NOP |
|
121 } |
|
122 |
|
123 void CTestRxMess::ConstructL() |
|
124 { |
|
125 CATScriptEng::ConstructL(); |
|
126 } |
|
127 |
|
128 TInt CTestRxMess::Start() |
|
129 { |
|
130 StartScript(iScript); |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 void CTestRxMess::SpecificAlgorithmL(TInt /* aParam */) |
|
135 { |
|
136 } |
|
137 |
|
138 void CTestRxMess::Complete(TInt aError) |
|
139 { |
|
140 iReturnValue=aError; |
|
141 CActiveScheduler::Stop(); |
|
142 } |
|
143 |
|
144 // |
|
145 // Test the SMS Notification Request |
|
146 // |
|
147 CTestDriveNotMess* CTestDriveNotMess::NewL(const TScriptList aScriptListEntry) |
|
148 { |
|
149 CTestDriveNotMess* aA=new(ELeave) CTestDriveNotMess(aScriptListEntry); |
|
150 CleanupStack::PushL(aA); |
|
151 aA->ConstructL(); |
|
152 CleanupStack::Pop(); |
|
153 return aA; |
|
154 } |
|
155 |
|
156 CTestDriveNotMess::CTestDriveNotMess(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
157 { |
|
158 // NOP |
|
159 } |
|
160 |
|
161 TInt CTestDriveNotMess::RunTestL() |
|
162 { |
|
163 iCurrentScript=iScriptListEntry; |
|
164 return StartEmulatorL(); |
|
165 } |
|
166 |
|
167 TInt CTestDriveNotMess::DriveETelApiL() //2 |
|
168 // |
|
169 // This function contains the real meat of the Client-side test code |
|
170 // |
|
171 { |
|
172 // Since NotifySmsMessageArrived is no more supported, we just have to |
|
173 // test with 1 script. We don't have to do post notify, read sim. and |
|
174 // then post notify, wait for complete, and post read. |
|
175 // Also SetReceiveMode requires a completed iPhone initialization. |
|
176 RMobileSmsMessaging sms; |
|
177 |
|
178 TRequestStatus reqStatus, stat1, stat2, stat3; |
|
179 INFO_PRINTF1(_L("Initialising the Phone...")); |
|
180 |
|
181 RMobilePhone::TMMTableSettings tableSettings; |
|
182 tableSettings.iLocId=KInternetAccessPoint; |
|
183 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
184 iPhone.InitialiseMM(reqStatus, tableSettingsPckg); |
|
185 |
|
186 User::WaitForRequest(reqStatus); |
|
187 TESTL(reqStatus == KErrNone); |
|
188 |
|
189 INFO_PRINTF1(_L("Opening Sms Messaging")); |
|
190 TESTL(sms.Open(iPhone) == KErrNone); |
|
191 |
|
192 RMobileSmsMessaging::TMobileSmsReceiveMode aReceiveMode; |
|
193 // KErrNotSupported is normal response as there can be only |
|
194 // one sms client who knows if the mode is changed. |
|
195 sms.NotifyReceiveModeChange(stat3, aReceiveMode); |
|
196 |
|
197 // set to CMTI mode (CNMI=0,1) |
|
198 sms.SetReceiveMode (stat1, RMobileSmsMessaging::EReceiveStored); |
|
199 User::WaitForRequest(stat1); |
|
200 TESTL(stat1==KErrNone); |
|
201 |
|
202 User::WaitForRequest(stat3); |
|
203 INFO_PRINTF2(_L("Sms Messaging: NotifyReceiveModeChange Not Supported = %d"), stat3.Int()); |
|
204 |
|
205 if(stat1==KErrNone) |
|
206 { |
|
207 RMobileSmsMessaging::TMobileSmsGsmTpdu rxPdu; |
|
208 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
209 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPkg(attrib); |
|
210 sms.ReceiveMessage(stat2, rxPdu, attribPkg); |
|
211 User::WaitForRequest(stat2); |
|
212 TESTL(stat2==KErrNone); |
|
213 attrib=attribPkg(); |
|
214 //TestDriveRxMess-> |
|
215 DispSmsAttributes(attrib); |
|
216 } |
|
217 |
|
218 INFO_PRINTF1(_L("Closing SMS Messaging...")); |
|
219 sms.Close(); |
|
220 return KErrNone; |
|
221 } |
|
222 |
|
223 // |
|
224 // Test-side class |
|
225 // Test CMT based incoming SMS messages |
|
226 // |
|
227 CTestDriveRxMessCmt* CTestDriveRxMessCmt::NewL(const TScriptList aScriptListEntry) |
|
228 { |
|
229 CTestDriveRxMessCmt* aA=new(ELeave) CTestDriveRxMessCmt(aScriptListEntry); |
|
230 CleanupStack::PushL(aA); |
|
231 aA->ConstructL(); |
|
232 CleanupStack::Pop(); |
|
233 return aA; |
|
234 } |
|
235 |
|
236 CTestDriveRxMessCmt::CTestDriveRxMessCmt(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
237 { |
|
238 // NOP |
|
239 } |
|
240 |
|
241 TInt CTestDriveRxMessCmt::RunTestL() |
|
242 { |
|
243 iCurrentScript=iScriptListEntry; |
|
244 return StartEmulatorL(); |
|
245 } |
|
246 |
|
247 TInt CTestDriveRxMessCmt::DriveETelApiL() //3 |
|
248 // |
|
249 // This function contains the real meat of the Client-side test code |
|
250 // |
|
251 { |
|
252 TRequestStatus reqStatus; |
|
253 |
|
254 INFO_PRINTF1(_L("Initialising the Phone...")); |
|
255 |
|
256 RMobilePhone::TMMTableSettings tableSettings; |
|
257 tableSettings.iLocId=KInternetAccessPoint; |
|
258 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
259 iPhone.InitialiseMM(reqStatus, tableSettingsPckg); |
|
260 |
|
261 User::WaitForRequest(reqStatus); |
|
262 TESTL(reqStatus == KErrNone); |
|
263 |
|
264 RMobileSmsMessaging sms; |
|
265 INFO_PRINTF1(_L("Opening Sms Messaging")); |
|
266 TESTL(sms.Open(iPhone)==KErrNone); |
|
267 |
|
268 TRequestStatus stat1,stat2; |
|
269 sms.SetReceiveMode(stat1, RMobileSmsMessaging::EReceiveUnstoredPhoneAck); |
|
270 User::WaitForRequest(stat1); |
|
271 TESTL(stat1 == KErrNone); |
|
272 |
|
273 RMobileSmsMessaging::TMobileSmsGsmTpdu pdu; |
|
274 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
275 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPkg(attrib); |
|
276 INFO_PRINTF1(_L("Closing SMS Messaging...")); |
|
277 sms.ReceiveMessage(stat2, pdu, attribPkg); |
|
278 User::WaitForRequest(stat2); |
|
279 TESTL(stat2 == KErrNone); |
|
280 attrib=attribPkg(); |
|
281 //aTestDriveRxMess-> |
|
282 DispSmsAttributes(attrib); |
|
283 |
|
284 INFO_PRINTF1(_L("Rx CMT type message")); |
|
285 sms.ReceiveMessage(stat2, pdu, attribPkg); |
|
286 User::WaitForRequest(stat2); |
|
287 TESTL(stat2 == KErrNone); |
|
288 attrib=attribPkg(); |
|
289 DispSmsAttributes(attrib); |
|
290 |
|
291 INFO_PRINTF1(_L("Closing SMS Messaging...")); |
|
292 sms.Close(); |
|
293 return KErrNone; |
|
294 } |
|
295 |
|
296 // |
|
297 // Test-side class |
|
298 // Test CMT based incoming SMS Notifications |
|
299 // |
|
300 CTestDriveNotMessCmt* CTestDriveNotMessCmt::NewL(const TScriptList aScriptListEntry) |
|
301 { |
|
302 CTestDriveNotMessCmt* aA=new(ELeave) CTestDriveNotMessCmt(aScriptListEntry); |
|
303 CleanupStack::PushL(aA); |
|
304 aA->ConstructL(); |
|
305 CleanupStack::Pop(); |
|
306 return aA; |
|
307 } |
|
308 |
|
309 CTestDriveNotMessCmt::CTestDriveNotMessCmt(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
310 { |
|
311 // NOP |
|
312 } |
|
313 |
|
314 TInt CTestDriveNotMessCmt::RunTestL() |
|
315 { |
|
316 iCurrentScript=iScriptListEntry; |
|
317 return StartEmulatorL(); |
|
318 } |
|
319 |
|
320 TInt CTestDriveNotMessCmt::DriveETelApiL() //4 |
|
321 // |
|
322 // This function contains the real meat of the Client-side test code |
|
323 // |
|
324 { |
|
325 RMobileSmsMessaging sms; |
|
326 |
|
327 TRequestStatus reqStatus, stat1, stat2, stat3; |
|
328 INFO_PRINTF1(_L("Initialising the Phone...")); |
|
329 |
|
330 RMobilePhone::TMMTableSettings tableSettings; |
|
331 tableSettings.iLocId=KInternetAccessPoint; |
|
332 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
333 iPhone.InitialiseMM(reqStatus, tableSettingsPckg); |
|
334 |
|
335 User::WaitForRequest(reqStatus); |
|
336 TESTL(reqStatus == KErrNone); |
|
337 |
|
338 INFO_PRINTF1(_L("Opening Sms Messaging")); |
|
339 TESTL(sms.Open(iPhone) == KErrNone); |
|
340 |
|
341 RMobileSmsMessaging::TMobileSmsReceiveMode aReceiveMode; |
|
342 sms.NotifyReceiveModeChange(stat3, aReceiveMode); |
|
343 |
|
344 sms.SetReceiveMode (stat1, RMobileSmsMessaging::EReceiveStored); |
|
345 User::WaitForRequest(stat1); |
|
346 TESTL(stat1 == KErrNone); |
|
347 |
|
348 User::WaitForRequest(stat3); |
|
349 INFO_PRINTF2(_L("Sms Messaging: NotifyReceiveModeChange Not Supported = %d"), stat3.Int()); |
|
350 |
|
351 if (stat1 == KErrNone) |
|
352 { |
|
353 RMobileSmsMessaging::TMobileSmsGsmTpdu rxPdu; |
|
354 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
355 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPkg(attrib); |
|
356 sms.ReceiveMessage(stat2, rxPdu, attribPkg); |
|
357 User::WaitForRequest(stat2); |
|
358 TESTL(stat2 == KErrNone); |
|
359 } |
|
360 |
|
361 INFO_PRINTF1(_L("Closing SMS Messaging...")); |
|
362 |
|
363 sms.Close(); |
|
364 return KErrNone; |
|
365 } |
|
366 |
|
367 |
|
368 void CTestDriveRxMess::DispSmsAttributes(RMobileSmsMessaging::TMobileSmsReceiveAttributesV1& aMobSmsAttr) |
|
369 { |
|
370 switch (aMobSmsAttr.iStatus) |
|
371 { |
|
372 case RMobileSmsMessaging::EMtMessageUnknownStatus: |
|
373 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnknownStatus.")); |
|
374 break; |
|
375 case RMobileSmsMessaging::EMtMessageUnstoredPhoneAck: |
|
376 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredPhoneAck.")); |
|
377 break; |
|
378 case RMobileSmsMessaging::EMtMessageUnstoredClientAck: |
|
379 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredClientAck.")); |
|
380 break; |
|
381 case RMobileSmsMessaging::EMtMessageStored: |
|
382 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageStored.")); |
|
383 break; |
|
384 default: |
|
385 break; |
|
386 } |
|
387 |
|
388 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Index = %d"), aMobSmsAttr.iStoreIndex); |
|
389 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Name = %S"), &aMobSmsAttr.iStore); |
|
390 INFO_PRINTF2(_L(" RMobileSmsMessaging iOriginator = %S"), &aMobSmsAttr.iOriginator.iTelNumber); |
|
391 } |
|
392 |
|
393 //it's bad, but I don't have any idea to redesing these tests |
|
394 void CTestDriveNotMess::DispSmsAttributes(RMobileSmsMessaging::TMobileSmsReceiveAttributesV1& aMobSmsAttr) |
|
395 { |
|
396 switch (aMobSmsAttr.iStatus) |
|
397 { |
|
398 case RMobileSmsMessaging::EMtMessageUnknownStatus: |
|
399 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnknownStatus.")); |
|
400 break; |
|
401 case RMobileSmsMessaging::EMtMessageUnstoredPhoneAck: |
|
402 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredPhoneAck.")); |
|
403 break; |
|
404 case RMobileSmsMessaging::EMtMessageUnstoredClientAck: |
|
405 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredClientAck.")); |
|
406 break; |
|
407 case RMobileSmsMessaging::EMtMessageStored: |
|
408 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageStored.")); |
|
409 break; |
|
410 default: |
|
411 break; |
|
412 } |
|
413 |
|
414 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Index = %d"), aMobSmsAttr.iStoreIndex); |
|
415 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Name = %S"), &aMobSmsAttr.iStore); |
|
416 INFO_PRINTF2(_L(" RMobileSmsMessaging iOriginator = %S"), &aMobSmsAttr.iOriginator.iTelNumber); |
|
417 } |
|
418 |
|
419 |
|
420 void CTestDriveRxMess::DispCaps(RMobileSmsMessaging::TMobileSmsCapsV1& aSmsCaps) |
|
421 { |
|
422 if ( aSmsCaps.iSmsMode & RMobileSmsMessaging::KCapsGsmSms) |
|
423 { |
|
424 INFO_PRINTF1(_L(" GSM SMS Supported")); |
|
425 } |
|
426 if (!( aSmsCaps.iSmsMode & RMobileSmsMessaging::KCapsGsmSms)) |
|
427 { |
|
428 INFO_PRINTF2(_L(" SMS Mode = 0x%x"), aSmsCaps.iSmsMode); |
|
429 } |
|
430 |
|
431 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsReceiveStored) |
|
432 { |
|
433 INFO_PRINTF1(_L(" ReceiveStored Caps Supported")); |
|
434 } |
|
435 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsReceiveUnstoredPhoneAck) |
|
436 { |
|
437 INFO_PRINTF1(_L(" ReceiveUnstoredPhoneAck Caps Supported")); |
|
438 } |
|
439 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsReceiveEither) |
|
440 { |
|
441 INFO_PRINTF1(_L(" ReceiveAny Caps Supported")); |
|
442 } |
|
443 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsCreateAck) |
|
444 { |
|
445 INFO_PRINTF1(_L(" CreateAck Caps Supported")); |
|
446 } |
|
447 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsSendNoAck) |
|
448 { |
|
449 INFO_PRINTF1(_L(" SendNoAck Caps Supported")); |
|
450 } |
|
451 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsSendWithAck) |
|
452 { |
|
453 INFO_PRINTF1(_L(" SendWithAck Caps Supported")); |
|
454 } |
|
455 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsGetSmspList) |
|
456 { |
|
457 INFO_PRINTF1(_L(" GetSmspList Caps Supported")); |
|
458 } |
|
459 if (aSmsCaps.iSmsControl & RMobileSmsMessaging::KCapsSetSmspList) |
|
460 { |
|
461 INFO_PRINTF1(_L(" SetSmspList Caps Supported")); |
|
462 } |
|
463 } |
|
464 |
|
465 void CTestDriveRxMessCmt::DispSmsAttributes(RMobileSmsMessaging::TMobileSmsReceiveAttributesV1& aMobSmsAttr) |
|
466 { |
|
467 switch (aMobSmsAttr.iStatus) |
|
468 { |
|
469 case RMobileSmsMessaging::EMtMessageUnknownStatus: |
|
470 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnknownStatus.")); |
|
471 break; |
|
472 case RMobileSmsMessaging::EMtMessageUnstoredPhoneAck: |
|
473 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredPhoneAck.")); |
|
474 break; |
|
475 case RMobileSmsMessaging::EMtMessageUnstoredClientAck: |
|
476 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageUnstoredClientAck.")); |
|
477 break; |
|
478 case RMobileSmsMessaging::EMtMessageStored: |
|
479 INFO_PRINTF1(_L(" RMobileSmsMessaging::EMtMessageStored.")); |
|
480 break; |
|
481 default: |
|
482 break; |
|
483 } |
|
484 |
|
485 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Index = %d"), aMobSmsAttr.iStoreIndex); |
|
486 INFO_PRINTF2(_L(" RMobileSmsMessaging Store Name = %S"), &aMobSmsAttr.iStore); |
|
487 INFO_PRINTF2(_L(" RMobileSmsMessaging iOriginator = %S"), &aMobSmsAttr.iOriginator.iTelNumber); |
|
488 } |