|
1 // Copyright (c) 2005-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 the data functionality of the Basic GsmTsy. |
|
15 // The files te_data and te_echo are designed as a Data and Echo server test and should |
|
16 // be run simultaneously on two EPOC machines. |
|
17 // The test scenario is outlined below: |
|
18 // Machine A (te_data.exe) Machine B (te_echo.exe) |
|
19 // 1. Dial |
|
20 // 2. Answer |
|
21 // 3. Transmit local tel. number |
|
22 // 4. Rx and log remote modem's tel. number |
|
23 // 5. Transmit Data |
|
24 // 6. Receive and then echo data |
|
25 // 7. Receive and Compare Data |
|
26 // 8. Hang up Hang up |
|
27 // 9. Pause Pause |
|
28 // 10. Dial remote modem's tel. number |
|
29 // 11. Answer |
|
30 // 13. Transmit Data |
|
31 // 14. Echo received data |
|
32 // 15. Receive and Compare Data |
|
33 // 16. Hang up Hang up |
|
34 // |
|
35 // |
|
36 |
|
37 /** |
|
38 @file |
|
39 */ |
|
40 |
|
41 #include "Te_EchoSingleTestStep.h" |
|
42 |
|
43 _LIT(KMmtsyName,"MM"); |
|
44 _LIT(KPhoneName,"GsmPhone1"); |
|
45 _LIT(KCsyName, "ECUART.CSY"); |
|
46 _LIT(KDataLineName,"Data"); |
|
47 _LIT8(KWriteTestData,"GSM TSY Data and Echo Server Test is still in progress..."); |
|
48 |
|
49 const TInt KTenSeconds=10000000; |
|
50 const TInt KTimeToWaitForRemoteEnd=2*KTenSeconds; // Twenty Seconds |
|
51 const TInt KTimeToWaitForRead=6*KTenSeconds; // Sixty Seconds |
|
52 |
|
53 CEchoTestStep::CEchoTestStep() |
|
54 { |
|
55 SetTestStepName(KEchoTestStepName); |
|
56 } |
|
57 |
|
58 TVerdict CEchoTestStep::doTestStepPreambleL() |
|
59 { |
|
60 __UHEAP_MARK; |
|
61 |
|
62 SetTestStepResult(EPass); |
|
63 |
|
64 TInt ret = iTelServer.Connect(); |
|
65 if (ret!=KErrNone) |
|
66 { |
|
67 INFO_PRINTF1(_L("Failed to connect to telephony server")); |
|
68 User::Leave(ret); |
|
69 } |
|
70 ret=iTelServer.LoadPhoneModule(KMmtsyName); |
|
71 if (ret!=KErrNone) |
|
72 { |
|
73 INFO_PRINTF1(_L("Failed to load phone module")); |
|
74 iTelServer.Close(); |
|
75 User::Leave(ret); |
|
76 } |
|
77 ret=iPhone.Open(iTelServer,KPhoneName) ; |
|
78 if (ret!=KErrNone) |
|
79 { |
|
80 INFO_PRINTF1(_L("Failed to open phone module")); |
|
81 iTelServer.UnloadPhoneModule(KMmtsyName); |
|
82 iTelServer.Close(); |
|
83 User::Leave(ret); |
|
84 } |
|
85 // |
|
86 // This test requires a mobile phone to be connected to the serial port |
|
87 // specified in the .cfg file for the initialise below to work |
|
88 // |
|
89 ret=iPhone.Initialise(); |
|
90 if (ret!=KErrNone) |
|
91 { |
|
92 INFO_PRINTF2(_L("Failed to initialise the phone (%d)"), ret); |
|
93 iPhone.Close(); |
|
94 iTelServer.UnloadPhoneModule(KMmtsyName); |
|
95 iTelServer.Close(); |
|
96 User::Leave(ret); |
|
97 } |
|
98 ret = iPhone.GetCaps(iPhoneCaps) ; |
|
99 if ((KErrNone != ret) || !(iPhoneCaps.iFlags & RPhone::KCapsData)) |
|
100 { |
|
101 INFO_PRINTF2(_L("This phone does not support data calls (caps=0x%x)"),iPhoneCaps.iFlags); |
|
102 iPhone.Close(); |
|
103 iTelServer.UnloadPhoneModule(KMmtsyName); |
|
104 iTelServer.Close(); |
|
105 User::Leave(ret); |
|
106 } |
|
107 |
|
108 return TestStepResult(); |
|
109 } |
|
110 |
|
111 TVerdict CEchoTestStep::doTestStepPostambleL() |
|
112 { |
|
113 iPhone.Close(); |
|
114 iTelServer.UnloadPhoneModule(KMmtsyName); |
|
115 iTelServer.Close(); |
|
116 |
|
117 __UHEAP_MARKEND; |
|
118 return TestStepResult(); |
|
119 } |
|
120 |
|
121 TVerdict CEchoTestStep::doTestStepL() |
|
122 { |
|
123 AnswerIncomingCallTestL(); |
|
124 User::After(KTimeToWaitForRemoteEnd); |
|
125 DialRemoteModemTestL(); |
|
126 |
|
127 return TestStepResult(); |
|
128 } |
|
129 |
|
130 void CEchoTestStep::AnswerIncomingCallTestL() |
|
131 /** |
|
132 * Answers an incoming data call. |
|
133 * This method opens a data line and call, and retrieves the status of the call. |
|
134 * It then answers an incoming call from a remote modem (initiated by t_data.exe), |
|
135 * loans the Comm port, connects to the Comms Server, opens a serial port and proceeds |
|
136 * to read data transmitted by the remote modem. It then echoes the received data |
|
137 * closes the serial port, its connection to the Comms Server, the data port, call and |
|
138 * line. |
|
139 * Leaves if test fails |
|
140 */ |
|
141 { |
|
142 const TInt KExpectedBytes=51; // Number of bytes expected from remote end |
|
143 |
|
144 RMobileLine line; |
|
145 INFO_PRINTF1(_L("Answer incomming call")); |
|
146 INFO_PRINTF1(_L("Opening Data Line")); |
|
147 TEST_FOR_ERROR_L(line.Open(iPhone,KDataLineName)); |
|
148 CleanupClosePushL(line); |
|
149 |
|
150 INFO_PRINTF1(_L("Opening New Data Call")); |
|
151 RMobileCall dataCall; |
|
152 TEST_FOR_ERROR_L(dataCall.OpenNewCall(line)); |
|
153 CleanupClosePushL(dataCall); |
|
154 |
|
155 INFO_PRINTF1(_L("Get call status")); |
|
156 RCall::TStatus callStatus; |
|
157 TEST_FOR_ERROR_L(dataCall.GetStatus(callStatus)); |
|
158 INFO_PRINTF2(_L("Call Status = %d"),callStatus); |
|
159 |
|
160 RMobileCall::TMobileDataCallParamsV1 callDataParams; |
|
161 RMobileCall::TMobileDataCallParamsV1Pckg callDataParamsPckg(callDataParams); |
|
162 |
|
163 callDataParams.iService = RMobileCall::EServiceDataCircuitAsync; |
|
164 callDataParams.iSpeed = RMobileCall::ESpeed9600; |
|
165 callDataParams.iProtocol = RMobileCall::EProtocolV32; |
|
166 callDataParams.iQoS = RMobileCall::EQoSNonTransparent; |
|
167 |
|
168 INFO_PRINTF1(_L("Answer incomming call")); |
|
169 dataCall.AnswerIncomingCall(iStatus, callDataParamsPckg); |
|
170 User::WaitForRequest(iStatus); |
|
171 TEST_FOR_ERROR_L(iStatus.Int()); |
|
172 |
|
173 INFO_PRINTF1(_L("Get call status")); |
|
174 TEST_FOR_ERROR_L(dataCall.GetStatus(callStatus)); |
|
175 INFO_PRINTF2(_L("Call Status = %d"),callStatus); |
|
176 |
|
177 INFO_PRINTF1(_L("Loan comm port")); |
|
178 RCall::TCommPort commPort; |
|
179 dataCall.LoanDataPort(iStatus,commPort); |
|
180 User::WaitForRequest(iStatus); |
|
181 if (iStatus==KErrCommsLineFail) |
|
182 { |
|
183 INFO_PRINTF1(_L("This error is currently known to only happen with the Motorola")); |
|
184 INFO_PRINTF1(_L("Time port. Please see the PhoneInfo.cpp file for more information.")); |
|
185 } |
|
186 TEST_FOR_ERROR_L(iStatus.Int()); |
|
187 |
|
188 INFO_PRINTF1(_L("Connect to the Comms Server and load the CSY")); |
|
189 RCommServ cs; |
|
190 TEST_FOR_ERROR_L(cs.Connect()); |
|
191 CleanupClosePushL(cs); |
|
192 |
|
193 TInt ret=cs.LoadCommModule(KCsyName); |
|
194 if (!(ret==KErrNone || ret==KErrAlreadyExists)) |
|
195 { |
|
196 FAIL_WITH_ERROR_L(ret); |
|
197 } |
|
198 |
|
199 INFO_PRINTF1(_L("Open a serial port")); |
|
200 RComm port; |
|
201 TEST_FOR_ERROR_L(port.Open(cs,commPort.iPort,ECommShared)); |
|
202 CleanupClosePushL(port); |
|
203 |
|
204 INFO_PRINTF1(_L("Read 1st stream of data from the serial port")); |
|
205 |
|
206 port.Read(iStatus,KTimeToWaitForRead,iRemoteNumber); |
|
207 User::WaitForRequest(iStatus); |
|
208 if (iStatus!=KErrNone) |
|
209 { |
|
210 if (iStatus==KErrTimedOut) |
|
211 { |
|
212 INFO_PRINTF1(_L("A Time out error occured during the read")); |
|
213 } |
|
214 FAIL_WITH_ERROR_L(iStatus.Int()); |
|
215 } |
|
216 TBuf<KRemoteNum> convertTel; // Convert the 8-bit data read from serial port to |
|
217 convertTel.Copy(iRemoteNumber); // 16-bit so that it can be displayed to the user |
|
218 INFO_PRINTF2(_L("Data stream 1 = %S"), &convertTel); |
|
219 |
|
220 INFO_PRINTF1(_L("Read 2nd stream of data from the serial port")); |
|
221 TBuf8<KExpectedBytes> readData; |
|
222 port.Read(iStatus,KTimeToWaitForRead,readData); |
|
223 User::WaitForRequest(iStatus); |
|
224 |
|
225 if (iStatus!=KErrNone) |
|
226 { |
|
227 if (iStatus==KErrTimedOut) |
|
228 { |
|
229 INFO_PRINTF1(_L("A Time out error occured during the read")); |
|
230 } |
|
231 FAIL_WITH_ERROR_L(iStatus.Int()); |
|
232 } |
|
233 TBuf<KExpectedBytes> convertData; // Convert the 8-bit data read from serial port to |
|
234 convertData.Copy(readData); // 16-bit so that it can be displayed to the screen |
|
235 INFO_PRINTF2(_L("Data stream 2 = %S"),&convertData); |
|
236 |
|
237 INFO_PRINTF1(_L("Echo the received data")); |
|
238 port.Write(iStatus,readData); |
|
239 User::WaitForRequest(iStatus); |
|
240 TEST_FOR_ERROR_L(iStatus.Int()); |
|
241 |
|
242 CleanupStack::PopAndDestroy(); // closes cs |
|
243 CleanupStack::PopAndDestroy(); // closes port |
|
244 |
|
245 INFO_PRINTF1(_L("Recover data port")); |
|
246 TEST_FOR_ERROR_L(dataCall.RecoverDataPort()); |
|
247 |
|
248 INFO_PRINTF1(_L("Hanging up the Data call")); |
|
249 TEST_FOR_ERROR_L(dataCall.HangUp()); |
|
250 |
|
251 CleanupStack::PopAndDestroy(); // closes dataCall |
|
252 CleanupStack::PopAndDestroy(); // closes line |
|
253 |
|
254 return; |
|
255 } |
|
256 |
|
257 void CEchoTestStep::DialRemoteModemTestL() |
|
258 /** |
|
259 * Dials a data call. |
|
260 * This method opens a data line and call, and retrieves the status of the call. |
|
261 * It then dials a remote modem (initiated by t_data.exe), loans the Comm port, |
|
262 * connects to the Comms Server, opens a serial port and proceeds to transmit data to |
|
263 * the remote modem. It subsequently reads the data echoed back by the remote modem and |
|
264 * compares the transmitted and received data. The serial port, the connection to the |
|
265 * Comms Server, the data port, call and line are then closed. |
|
266 * Leaves if test fails |
|
267 */ |
|
268 { |
|
269 const TInt KNumOfBytes=57; // Number of bytes to send to the remote end |
|
270 |
|
271 RMobileLine line; |
|
272 INFO_PRINTF1(_L("Dial remote modem")); |
|
273 INFO_PRINTF1(_L("Opening Data Line")); |
|
274 TEST_FOR_ERROR_L(line.Open(iPhone,KDataLineName)); |
|
275 CleanupClosePushL(line); |
|
276 |
|
277 INFO_PRINTF1(_L("Opening New Data Call")); |
|
278 RMobileCall dataCall; |
|
279 TEST_FOR_ERROR_L(dataCall.OpenNewCall(line)); |
|
280 CleanupClosePushL(dataCall); |
|
281 |
|
282 INFO_PRINTF1(_L("Get call status")); |
|
283 RCall::TStatus callStatus; |
|
284 TEST_FOR_ERROR_L(dataCall.GetStatus(callStatus)); |
|
285 INFO_PRINTF2(_L("Call Status = %d"),callStatus); |
|
286 |
|
287 TBuf16<KRemoteNum> phoneNum; // Convert remote tel. no. to 16-bit data |
|
288 phoneNum.Copy(iRemoteNumber); |
|
289 INFO_PRINTF2(_L("Dialling %S...."), &phoneNum); |
|
290 |
|
291 RMobileCall::TMobileDataCallParamsV1 callDataParams; |
|
292 RMobileCall::TMobileDataCallParamsV1Pckg callDataParamsPckg(callDataParams); |
|
293 |
|
294 callDataParams.iService = RMobileCall::EServiceDataCircuitAsync; |
|
295 callDataParams.iSpeed = RMobileCall::ESpeed9600; |
|
296 callDataParams.iProtocol = RMobileCall::EProtocolV32; |
|
297 callDataParams.iQoS = RMobileCall::EQoSNonTransparent; |
|
298 |
|
299 dataCall.Dial(iStatus, callDataParamsPckg, phoneNum); |
|
300 User::WaitForRequest(iStatus); |
|
301 TEST_FOR_ERROR_L(iStatus.Int()); |
|
302 |
|
303 INFO_PRINTF1(_L("Get call status")); |
|
304 TEST_FOR_ERROR_L(dataCall.GetStatus(callStatus)); |
|
305 INFO_PRINTF2(_L("Call Status = %d"),callStatus); |
|
306 |
|
307 INFO_PRINTF1(_L("Loan the Comm port")); |
|
308 RCall::TCommPort commPort; |
|
309 dataCall.LoanDataPort(iStatus,commPort); |
|
310 User::WaitForRequest(iStatus); |
|
311 |
|
312 if (iStatus==KErrCommsLineFail) |
|
313 { |
|
314 INFO_PRINTF1(_L("This error is currently known to only happen with the Motorola")); |
|
315 INFO_PRINTF1(_L("Time port. Please see the PhoneInfo.cpp file for more information.")); |
|
316 } |
|
317 TEST_FOR_ERROR_L(iStatus.Int()); |
|
318 |
|
319 INFO_PRINTF1(_L("Connect to the Comms Server and load the CSY")); |
|
320 RCommServ cs; |
|
321 TEST_FOR_ERROR_L(cs.Connect()); |
|
322 CleanupClosePushL(cs); |
|
323 |
|
324 TInt ret=cs.LoadCommModule(KCsyName); |
|
325 if (!(ret==KErrNone || ret==KErrAlreadyExists)) |
|
326 { |
|
327 FAIL_WITH_ERROR_L(ret); |
|
328 } |
|
329 |
|
330 INFO_PRINTF1(_L("Open a serial port")); |
|
331 RComm port; |
|
332 TEST_FOR_ERROR_L(port.Open(cs,commPort.iPort,ECommShared)); |
|
333 CleanupClosePushL(port); |
|
334 |
|
335 User::After(KTimeToWaitForRemoteEnd); |
|
336 |
|
337 INFO_PRINTF1(_L("Write data stream")); |
|
338 port.Write(iStatus,KWriteTestData); |
|
339 User::WaitForRequest(iStatus); |
|
340 TEST_FOR_ERROR_L(iStatus.Int()); |
|
341 |
|
342 |
|
343 INFO_PRINTF1(_L("Read Echoed data")); |
|
344 TBuf8<KNumOfBytes> echoedData; |
|
345 port.Read(iStatus,KTimeToWaitForRead,echoedData); |
|
346 User::WaitForRequest(iStatus); |
|
347 if (iStatus!=KErrNone) |
|
348 { |
|
349 if (iStatus==KErrTimedOut) |
|
350 { |
|
351 INFO_PRINTF1(_L("A Time out error occured during the read")); |
|
352 } |
|
353 FAIL_WITH_ERROR_L(iStatus.Int()); |
|
354 } |
|
355 |
|
356 if (echoedData!=KWriteTestData) |
|
357 { |
|
358 INFO_PRINTF1(_L("Data does not match error")); |
|
359 FAIL_WITH_ERROR_L(KErrCorrupt); |
|
360 } |
|
361 |
|
362 TBuf<KNumOfBytes> convertData; // Convert the 8-bit data read from serial port to 16-bit |
|
363 convertData.Copy(echoedData); // so that it can be displayed to the user. |
|
364 INFO_PRINTF2(_L("Echoed data stream = %S\n"),&convertData); |
|
365 |
|
366 // Close the serial port, connection to Comms Server and recover the data port |
|
367 CleanupStack::PopAndDestroy(); // closes cs |
|
368 CleanupStack::PopAndDestroy(); // closes port |
|
369 |
|
370 INFO_PRINTF1(_L("Recover data port")); |
|
371 TEST_FOR_ERROR_L(dataCall.RecoverDataPort()); |
|
372 |
|
373 INFO_PRINTF1(_L("Hanging up the Data call")); |
|
374 TEST_FOR_ERROR_L(dataCall.HangUp()); |
|
375 |
|
376 CleanupStack::PopAndDestroy(); // closes dataCall |
|
377 CleanupStack::PopAndDestroy(); // closes line |
|
378 } |