|
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 cancelling of SMS operations test scenarios. |
|
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_LoopBackcsmscancel.h" |
|
26 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint |
|
27 |
|
28 |
|
29 // |
|
30 // Test-side class |
|
31 // With the assistance of the base class, this class must start the emulator |
|
32 // and drive the ETel API. |
|
33 // |
|
34 CTestDriveSmsCancel* CTestDriveSmsCancel::NewL(const TScriptList aScriptListEntry) |
|
35 { |
|
36 CTestDriveSmsCancel* aA=new(ELeave) CTestDriveSmsCancel(aScriptListEntry); |
|
37 CleanupStack::PushL(aA); |
|
38 aA->ConstructL(); |
|
39 CleanupStack::Pop(); |
|
40 return aA; |
|
41 } |
|
42 |
|
43 CTestDriveSmsCancel::CTestDriveSmsCancel(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
44 {} |
|
45 |
|
46 TInt CTestDriveSmsCancel::RunTestL() |
|
47 { |
|
48 iCurrentScript=iScriptListEntry; |
|
49 return StartEmulatorL(); |
|
50 } |
|
51 |
|
52 TInt CTestDriveSmsCancel::DriveETelApiL() |
|
53 // |
|
54 // This function contains the real meat of the Client-side test code |
|
55 // |
|
56 { |
|
57 RMobileSmsMessaging sms; |
|
58 TRequestStatus stat0, stat1; |
|
59 |
|
60 RMobilePhone::TMMTableSettings tableSettings; |
|
61 tableSettings.iLocId=KInternetAccessPoint; |
|
62 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
63 iPhone.InitialiseMM(stat0, tableSettingsPckg); |
|
64 User::WaitForRequest(stat0); |
|
65 TESTL(stat0 == KErrNone); |
|
66 |
|
67 INFO_PRINTF1(_L("Opening Sms Messaging\n")); |
|
68 TESTL(sms.Open(iPhone)==KErrNone); |
|
69 |
|
70 |
|
71 if (iScriptListEntry == ESmsCancelScript) |
|
72 { |
|
73 INFO_PRINTF1(_L("Set receive mode to EReceiveUnstoredPhoneAck.\n")); |
|
74 sms.SetReceiveMode (stat0, RMobileSmsMessaging::EReceiveUnstoredPhoneAck); |
|
75 } |
|
76 else if (iScriptListEntry == ESmsCancelCmtiScript) |
|
77 { |
|
78 INFO_PRINTF1(_L("Set receive mode to EReceiveStored.\n")); |
|
79 sms.SetReceiveMode (stat0, RMobileSmsMessaging::EReceiveStored); |
|
80 } |
|
81 else |
|
82 { |
|
83 ERR_PRINTF1(_L("Error: Unknown script id.\n")); |
|
84 User::Leave(KErrGeneral) ; |
|
85 } |
|
86 User::WaitForRequest(stat0); |
|
87 TESTL(stat0 == KErrNone); |
|
88 |
|
89 // Which pdu size to use? Find out from caps of iPhone - GSM/WCDMA |
|
90 RMobileSmsMessaging::TMobileSmsCapsV1 caps; |
|
91 RMobileSmsMessaging::TMobileSmsCapsV1Pckg capsPkg(caps); |
|
92 sms.GetCaps (capsPkg); |
|
93 caps = capsPkg(); |
|
94 if (caps.iSmsMode & RMobileSmsMessaging::KCapsGsmSms) |
|
95 { |
|
96 INFO_PRINTF1(_L("Phone supports GSM/WCDMA mode.\n")); |
|
97 } |
|
98 RMobileSmsMessaging::TMobileSmsGsmTpdu pdu; |
|
99 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
100 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPkg(attrib); |
|
101 |
|
102 sms.ReceiveMessage(stat1, pdu, attribPkg); |
|
103 |
|
104 // A request that will fail and force a re-initialisation |
|
105 TInt32 signalStrength=0; |
|
106 TInt8 bar=0; |
|
107 iPhone.GetSignalStrength(stat0,signalStrength,bar); |
|
108 User::WaitForRequest(stat0); |
|
109 TESTL(stat0==KErrTimedOut); |
|
110 |
|
111 sms.CancelAsyncRequest(EMobileSmsMessagingReceiveMessage); |
|
112 User::WaitForRequest(stat1); |
|
113 TESTL((stat1.Int()==KErrCancel)||(stat1.Int()==KErrNone)); // check that ReceiveMessage is cancelled |
|
114 |
|
115 // Re-post a read request and re-initialise |
|
116 sms.ReceiveMessage(stat1, pdu, attribPkg); |
|
117 iPhone.InitialiseMM(stat0, tableSettingsPckg); |
|
118 |
|
119 User::After(1000000L); |
|
120 |
|
121 sms.CancelAsyncRequest(EMobileSmsMessagingReceiveMessage); |
|
122 User::WaitForRequest(stat1); |
|
123 TESTL((stat1.Int()==KErrCancel)||(stat1.Int()==KErrNone)); // check that ReceiveMessage is cancelled |
|
124 |
|
125 User::WaitForRequest(stat0); |
|
126 TESTL(stat0.Int()==KErrNone); // check that iPhone init ok |
|
127 |
|
128 sms.Close(); |
|
129 return KErrNone; |
|
130 } |
|
131 |
|
132 // |
|
133 // Emulator-side class |
|
134 // With the assistance of the base class, this class must run the designated script |
|
135 // |
|
136 CTestSmsCancel* CTestSmsCancel::NewL(const TScript* aScript) |
|
137 { |
|
138 CTestSmsCancel* aA=new(ELeave) CTestSmsCancel(aScript); |
|
139 CleanupStack::PushL(aA); |
|
140 aA->ConstructL(); |
|
141 CleanupStack::Pop(); |
|
142 return aA; |
|
143 } |
|
144 |
|
145 CTestSmsCancel::CTestSmsCancel(const TScript* aScript) : iScript(aScript) |
|
146 {} |
|
147 |
|
148 void CTestSmsCancel::ConstructL() |
|
149 { |
|
150 CATScriptEng::ConstructL(); |
|
151 } |
|
152 |
|
153 TInt CTestSmsCancel::Start() |
|
154 { |
|
155 StartScript(iScript); |
|
156 return KErrNone; |
|
157 } |
|
158 |
|
159 void CTestSmsCancel::SpecificAlgorithmL(TInt /* aParam */) |
|
160 { |
|
161 } |
|
162 |
|
163 void CTestSmsCancel::Complete(TInt aError) |
|
164 { |
|
165 iReturnValue=aError; |
|
166 CActiveScheduler::Stop(); |
|
167 } |
|
168 |