|
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 initiates the "Data Call set-up, data transfer and remote termination" |
|
15 // scenario for the MultiMode Test Harness. This test is setup to make an outgoing |
|
16 // data-call and transfer data to the remote end. After the data transfer, the call |
|
17 // is terminated by the remote end. The client (application) side must start the |
|
18 // emulator and drive the ETel API. The emulator side runs the designated script. |
|
19 // |
|
20 // |
|
21 |
|
22 /** |
|
23 @file |
|
24 @note There are mulitple classes implemented in this file. |
|
25 @note These classes are CTestDriveDataCallRemoteTerm and CTestDataCallRemoteTerm. |
|
26 */ |
|
27 |
|
28 #include <e32test.h> |
|
29 #include "Te_LoopBackCDataCallRemoteTerm.h" |
|
30 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint |
|
31 |
|
32 // |
|
33 // Test-side class |
|
34 // With the assistance of the base class, this class must start the emulator |
|
35 // and drive the ETel API. |
|
36 // |
|
37 CTestDriveDataCallRemoteTerm* CTestDriveDataCallRemoteTerm::NewL(const TScriptList aScriptListEntry) |
|
38 /** |
|
39 * 2 Phase Constructor |
|
40 * |
|
41 * This method creates an instance of CTestDriveDataCallRemoteTerm. The ConstructL for |
|
42 * for CTestDriveDataCallRemoteTerm is inherited from and implemented in CTestBase. The |
|
43 * ConstructL uses the CTestDriveDataCallRemoteTerm object to load ond open the two iPhone |
|
44 * objects, one from each server. |
|
45 * |
|
46 * @param aScriptListEntry: enum indicating which script to use for this test. |
|
47 * @leave Leaves if a failure occurs during connect or open of the iPhone by ConstructL. |
|
48 * @return pointer to the instance of CTestDriveDataCallRemoteTerm. |
|
49 */ |
|
50 { |
|
51 CTestDriveDataCallRemoteTerm* aA=new(ELeave) CTestDriveDataCallRemoteTerm(aScriptListEntry); |
|
52 CleanupStack::PushL(aA); |
|
53 aA->ConstructL(); |
|
54 CleanupStack::Pop(); |
|
55 return aA; |
|
56 } |
|
57 |
|
58 CTestDriveDataCallRemoteTerm::CTestDriveDataCallRemoteTerm(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry) |
|
59 /** |
|
60 * This method is the constructor for CTestDriveDataCallRemoteTerm. |
|
61 * |
|
62 * @param aScriptListEntry: enum indicating which script to use for this test. |
|
63 * @note Initializes private data "aScriptListEntry" to received parameter. |
|
64 */ |
|
65 {} |
|
66 |
|
67 TInt CTestDriveDataCallRemoteTerm::RunTestL() |
|
68 /** |
|
69 * This method is invoked to start a "Data Call set-up, data transfer and remote |
|
70 * termination" test. This method starts the modem emulator side of the test. |
|
71 * |
|
72 * @return KErrNone when no error exists. |
|
73 * @return KErrAlreadyExists is returned if modem emulator exists and retry limit expires. |
|
74 * @return Variable depending on return value from test's DriveETelApiL method and thread monitoring. |
|
75 */ |
|
76 { |
|
77 iCurrentScript=iScriptListEntry; |
|
78 return StartEmulatorL(); |
|
79 } |
|
80 |
|
81 TInt CTestDriveDataCallRemoteTerm::DriveETelApiL() |
|
82 /** |
|
83 * This method contains the real meat of the Client-side the "Data Call set-up, data |
|
84 * transfer and remote termination" test code. This method sets up to make a data-call |
|
85 * and then transfer data. After the data transfer, the call is terminated by the remote end. |
|
86 * |
|
87 * @return KErrNone. |
|
88 */ |
|
89 { |
|
90 _LIT(KMmPhoneName,"GsmPhone1"); |
|
91 _LIT(KDataLineName,"Data"); |
|
92 |
|
93 INFO_PRINTF1(_L("Opening Mobile Phone\n")); |
|
94 RMobilePhone mmPhone; |
|
95 TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone); |
|
96 |
|
97 RLine line; |
|
98 INFO_PRINTF1(_L("Opening Data Line\n")); |
|
99 TESTL(line.Open(iPhone,KDataLineName)==KErrNone); |
|
100 |
|
101 INFO_PRINTF1(_L("Opening New Data Call\n")); |
|
102 RCall call; |
|
103 TESTL(call.OpenNewCall(line)==KErrNone); |
|
104 |
|
105 TRequestStatus reqStatus; |
|
106 RMobilePhone::TMMTableSettings tableSettings; |
|
107 tableSettings.iLocId=KInternetAccessPoint; |
|
108 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
109 iPhone.InitialiseMM(reqStatus , tableSettingsPckg); |
|
110 User::WaitForRequest(reqStatus); |
|
111 TESTL(reqStatus == KErrNone); |
|
112 |
|
113 // dial |
|
114 _LIT(KDialString,"+1234"); |
|
115 TESTL(call.Dial(KDialString)==KErrNone); |
|
116 |
|
117 INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n")); |
|
118 RCall::TCommPort commPort; |
|
119 TESTL(call.LoanDataPort(commPort)==KErrNone); |
|
120 |
|
121 RCommServ cs; |
|
122 TESTL(cs.Connect()==KErrNone); |
|
123 |
|
124 RComm port; |
|
125 TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone); |
|
126 |
|
127 // Transfer data |
|
128 TRequestStatus stat; |
|
129 port.Write(stat,KWriteTestRemoteData); |
|
130 User::WaitForRequest(stat); |
|
131 TESTL(stat.Int()==KErrNone); |
|
132 |
|
133 //-- a small delay between successive writes to the COM port |
|
134 //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem |
|
135 User::After(500000); |
|
136 |
|
137 port.Write(stat,KWriteTestRemoteData); |
|
138 User::WaitForRequest(stat); |
|
139 TESTL(stat.Int()==KErrNone); |
|
140 |
|
141 // Remote termination of call should have occurred in scripts, |
|
142 // close port and comm server |
|
143 port.Close(); |
|
144 cs.Close(); |
|
145 INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n")); |
|
146 TESTL(call.RecoverDataPort()==KErrNone); |
|
147 |
|
148 TInt32 ss; |
|
149 TInt8 bar=0; |
|
150 mmPhone.GetSignalStrength(stat,ss,bar); |
|
151 User::WaitForRequest(stat); |
|
152 TESTL(stat==KErrNone); |
|
153 |
|
154 // close iPhone, line and call |
|
155 mmPhone.Close(); |
|
156 line.Close(); |
|
157 call.Close(); |
|
158 return KErrNone; |
|
159 } |
|
160 |
|
161 // |
|
162 // Emulator-side class |
|
163 // With the assistance of the base class, this class must run the designated script |
|
164 // |
|
165 CTestDataCallRemoteTerm* CTestDataCallRemoteTerm::NewL(const TScript* aScript) |
|
166 /** |
|
167 * 2 Phase Constructor |
|
168 * |
|
169 * This method creates an instance of CTestDataCallRemoteTerm. |
|
170 * |
|
171 * @param aScript: pointer to the specifics of the script to run. |
|
172 * @leave Leaves if out of memory when attempting to create. |
|
173 * @return pointer to the instance of CTestDataCallRemoteTerm. |
|
174 */ |
|
175 { |
|
176 CTestDataCallRemoteTerm* aA=new(ELeave) CTestDataCallRemoteTerm(aScript); |
|
177 CleanupStack::PushL(aA); |
|
178 aA->ConstructL(); |
|
179 CleanupStack::Pop(); |
|
180 return aA; |
|
181 } |
|
182 |
|
183 CTestDataCallRemoteTerm::CTestDataCallRemoteTerm(const TScript* aScript) : iScript(aScript) |
|
184 /** |
|
185 * This method is the constructor for CTestDataCallRemoteTerm. |
|
186 * |
|
187 * @param aScript: pointer to the specifics of the script to run. |
|
188 * @note Initializes private data "aScript" to received parameter. |
|
189 */ |
|
190 {} |
|
191 |
|
192 void CTestDataCallRemoteTerm::ConstructL() |
|
193 /** |
|
194 * This method is used to implement the 2 Phase Constructor for CTestDataCallRemoteTerm. |
|
195 * This method uses the CATBase ConstructL to configure the port to be used. |
|
196 * |
|
197 * @leave Leaves if CATBase leaves. |
|
198 */ |
|
199 { |
|
200 CATScriptEng::ConstructL(); |
|
201 } |
|
202 |
|
203 TInt CTestDataCallRemoteTerm::Start() |
|
204 /** |
|
205 * This method is defined as a pure virtual function that must be implemented. |
|
206 * This method is currently not used by the Etel regression test harness. |
|
207 * Instead of using this method to start the scripts, the CTestTxMess::Start() |
|
208 * method is used to start the scripts. The CTestTxMess::Start() is called by |
|
209 * the responder thread of the scripting engine to start the execution of the script. |
|
210 * |
|
211 * @return KErrNone. |
|
212 */ |
|
213 { |
|
214 StartScript(iScript); |
|
215 return KErrNone; |
|
216 } |
|
217 |
|
218 void CTestDataCallRemoteTerm::SpecificAlgorithmL(TInt /* aParam */) |
|
219 /** |
|
220 * This method is defined as a pure virtual function that must be implemented. |
|
221 * This method is currently not used by the Etel regression test harness. |
|
222 * Instead of using this method to perform an algorithm specific to this test, |
|
223 * the CTestTxMess::SpecificAlgorithm() method is used. The CTestTxMess::SpecificAlgorithm() |
|
224 * is called by the scripting engine to perform the test specific algorithm. |
|
225 */ |
|
226 { |
|
227 } |
|
228 |
|
229 void CTestDataCallRemoteTerm::Complete(TInt aError) |
|
230 /** |
|
231 * This method is defined as a pure virtual function that must be implemented. |
|
232 * This method is currently not used by the Etel regression test harness. |
|
233 * Instead of using this method to end the scripts, the CTestTxMess::Complete() |
|
234 * method is used to end the scripts. The CTestTxMess::Complete() is called by |
|
235 * the scripting engine to end the execution of the script. |
|
236 */ |
|
237 { |
|
238 iReturnValue=aError; |
|
239 CActiveScheduler::Stop(); |
|
240 } |