|
1 /* |
|
2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * This contains Usb Test Section 2 |
|
16 * |
|
17 */ |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 |
|
22 // Usb Test system includes |
|
23 #include <networking/log.h> |
|
24 #include "UsbStep.h" |
|
25 #include "UsbSuite.h" |
|
26 #include "UsbTest2.h" |
|
27 |
|
28 _LIT(KSignalSection, "Signal"); |
|
29 _LIT(KSignalMark, "Mark"); |
|
30 _LIT(KSignalSpace, "Space"); |
|
31 _LIT(KSignalCheckValue, "CheckValue"); |
|
32 _LIT(KSignalCheckValueMask, "CheckValueMask"); |
|
33 |
|
34 _LIT(KConfigSection, "Config"); |
|
35 _LIT(KConfigRate, "Rate"); |
|
36 _LIT(KConfigStopBits, "StopBits"); |
|
37 _LIT(KConfigDataBits, "DataBits"); |
|
38 _LIT(KConfigParity, "Parity"); |
|
39 |
|
40 _LIT(KWriteSection, "Write"); |
|
41 _LIT(KWriteFailureValue, "FailureValue"); |
|
42 |
|
43 _LIT(KReadSection, "Read"); |
|
44 _LIT(KReadFailureValue, "FailureValue"); |
|
45 |
|
46 _LIT(KPortSection, "Port"); |
|
47 _LIT(KPortOpenMode, "OpenMode"); |
|
48 _LIT(KPortOpenRole, "OpenRole"); |
|
49 _LIT(KPortOpenReturnValue, "OpenReturnValue"); |
|
50 |
|
51 _LIT(KStateSection, "State"); |
|
52 _LIT(KStateTarget, "Target"); |
|
53 |
|
54 //////////////////////////////////////////////////////////////////////////////////// |
|
55 //////////////////////////////////////////////////////////////////////////////////// |
|
56 // Test 2.1 |
|
57 CTestSetSignalsToMark::CTestSetSignalsToMark() |
|
58 { |
|
59 // store the name of this test case |
|
60 iTestStepName = _L("SetSignalsToMarkC"); |
|
61 } |
|
62 |
|
63 // Test 2.1 Destructor |
|
64 CTestSetSignalsToMark::~CTestSetSignalsToMark() |
|
65 { |
|
66 } |
|
67 |
|
68 // Test 2.1 Main Code |
|
69 enum TVerdict CTestSetSignalsToMark::doTestStepL() |
|
70 { |
|
71 TUint mask; |
|
72 TESTL(GetIntFromConfig(KSignalSection, KSignalMark, (TInt&) mask)); |
|
73 iUsbSuite->iCommPort.SetSignalsToMark(mask); |
|
74 Log(_L("CTestSetSignalsToMark::doTestStepL() - Signal to mark set to 0x%x"), mask); |
|
75 TEST(ETrue); |
|
76 return iTestStepResult; |
|
77 } |
|
78 |
|
79 //////////////////////////////////////////////////////////////////////////////////// |
|
80 //////////////////////////////////////////////////////////////////////////////////// |
|
81 // Test 2.2 |
|
82 CTestSetSignalsToSpace::CTestSetSignalsToSpace() |
|
83 { |
|
84 // store the name of this test case |
|
85 iTestStepName = _L("SetSignalsToSpaceC"); |
|
86 } |
|
87 |
|
88 // Test 2.2 Destructor |
|
89 CTestSetSignalsToSpace::~CTestSetSignalsToSpace() |
|
90 { |
|
91 } |
|
92 |
|
93 // Test 2.2 Main Code |
|
94 enum TVerdict CTestSetSignalsToSpace::doTestStepL() |
|
95 { |
|
96 TUint mask; |
|
97 TESTL(GetIntFromConfig(KSignalSection, KSignalSpace, (TInt&) mask)); |
|
98 iUsbSuite->iCommPort.SetSignalsToSpace(mask); |
|
99 Log(_L("CTestSetSignalsToSpace::doTestStepL() - Signal to space set to 0x%x"), mask); |
|
100 TEST(ETrue); |
|
101 return iTestStepResult; |
|
102 } |
|
103 |
|
104 //////////////////////////////////////////////////////////////////////////////////// |
|
105 //////////////////////////////////////////////////////////////////////////////////// |
|
106 // Test 2.3 |
|
107 CTestCheckSignals::CTestCheckSignals() |
|
108 { |
|
109 // store the name of this test case |
|
110 iTestStepName = _L("CheckSignalsC"); |
|
111 } |
|
112 |
|
113 // Test 2.3 Destructor |
|
114 CTestCheckSignals::~CTestCheckSignals() |
|
115 { |
|
116 } |
|
117 |
|
118 // Test 2.3 Main Code |
|
119 enum TVerdict CTestCheckSignals::doTestStepL() |
|
120 { |
|
121 TUint checkValue; |
|
122 TUint checkValueMask; |
|
123 TUint currentValue; |
|
124 |
|
125 TESTL(GetIntFromConfig(KSignalSection, KSignalCheckValue, (TInt&) checkValue)); |
|
126 |
|
127 if (GetIntFromConfig(KSignalSection, KSignalCheckValueMask, (TInt&) checkValueMask)) |
|
128 currentValue = iUsbSuite->iCommPort.Signals(checkValueMask); |
|
129 else |
|
130 currentValue = iUsbSuite->iCommPort.Signals(); |
|
131 |
|
132 Log(_L("CTestCheckSignals::doTestStepL() - Current signals set to 0x%x with mask 0x%x"), currentValue, checkValueMask); |
|
133 TEST(currentValue == checkValue); |
|
134 return iTestStepResult; |
|
135 } |
|
136 |
|
137 //////////////////////////////////////////////////////////////////////////////////// |
|
138 //////////////////////////////////////////////////////////////////////////////////// |
|
139 // Test 2.4 |
|
140 CTestWaitForReadFailure::CTestWaitForReadFailure() |
|
141 { |
|
142 // store the name of this test case |
|
143 iTestStepName = _L("WaitForReadFailureC"); |
|
144 } |
|
145 |
|
146 // Test 2.4 Destructor |
|
147 CTestWaitForReadFailure::~CTestWaitForReadFailure() |
|
148 { |
|
149 } |
|
150 |
|
151 // Test 2.4 Main Code |
|
152 enum TVerdict CTestWaitForReadFailure::doTestStepL() |
|
153 { |
|
154 TInt failureValue; |
|
155 |
|
156 TESTL(GetIntFromConfig(KReadSection, KReadFailureValue, failureValue)); |
|
157 |
|
158 Log(_L("CTestWaitForReadFailure::doTestStepL() - Waiting for read status to be complete with error")); |
|
159 User::WaitForRequest(iUsbSuite->iReadStatus); |
|
160 Log(_L("CTestWaitForReadFailure::doTestStepL() - Read status completed with %d"), iUsbSuite->iReadStatus.Int()); |
|
161 TEST(iUsbSuite->iReadStatus.Int() == failureValue); |
|
162 |
|
163 return iTestStepResult; |
|
164 } |
|
165 |
|
166 //////////////////////////////////////////////////////////////////////////////////// |
|
167 //////////////////////////////////////////////////////////////////////////////////// |
|
168 // Test 2.5 |
|
169 CTestWaitForWriteFailure::CTestWaitForWriteFailure() |
|
170 { |
|
171 // store the name of this test case |
|
172 iTestStepName = _L("WaitForWriteFailureC"); |
|
173 } |
|
174 |
|
175 // Test 2.5 Destructor |
|
176 CTestWaitForWriteFailure::~CTestWaitForWriteFailure() |
|
177 { |
|
178 } |
|
179 |
|
180 // Test 2.5 Main Code |
|
181 enum TVerdict CTestWaitForWriteFailure::doTestStepL() |
|
182 { |
|
183 TInt failureValue; |
|
184 |
|
185 TESTL(GetIntFromConfig(KWriteSection, KWriteFailureValue, failureValue)); |
|
186 |
|
187 Log(_L("CTestWaitForWriteFailure::doTestStepL() - Waiting for write status to be complete with error")); |
|
188 User::WaitForRequest(iUsbSuite->iWriteStatus); |
|
189 Log(_L("CTestWaitForWriteFailure::doTestStepL() - Read status completed with %d"), iUsbSuite->iWriteStatus.Int()); |
|
190 TEST(iUsbSuite->iWriteStatus.Int() == failureValue); |
|
191 |
|
192 return iTestStepResult; |
|
193 } |
|
194 |
|
195 //////////////////////////////////////////////////////////////////////////////////// |
|
196 //////////////////////////////////////////////////////////////////////////////////// |
|
197 // Test 2.6 |
|
198 CTestOpenPort::CTestOpenPort() |
|
199 { |
|
200 // store the name of this test case |
|
201 iTestStepName = _L("OpenPortC"); |
|
202 } |
|
203 |
|
204 // Test 2.6 Destructor |
|
205 CTestOpenPort::~CTestOpenPort() |
|
206 { |
|
207 } |
|
208 |
|
209 // Test 2.6 Main Code |
|
210 enum TVerdict CTestOpenPort::doTestStepL() |
|
211 { |
|
212 TCommAccess openMode; |
|
213 TCommRole role; |
|
214 TInt returnValue; |
|
215 |
|
216 TESTL(GetIntFromConfig(KPortSection, KPortOpenMode, (TInt&) openMode)); |
|
217 TESTL(GetIntFromConfig(KPortSection, KPortOpenRole, (TInt&) role)); |
|
218 TESTL(GetIntFromConfig(KPortSection, KPortOpenReturnValue, returnValue)); |
|
219 |
|
220 OpenCommServerL(); |
|
221 |
|
222 if (!iUsbSuite->iPortOpen) |
|
223 { |
|
224 Log(_L("CTestOpenPort::doTestStepL() - Attempting to open ACM comm port with mode %d and role %d"), openMode, role); |
|
225 TInt err = iUsbSuite->iCommPort.Open(iUsbSuite->iCommServer, PORT_NAME, openMode, role); |
|
226 |
|
227 if (err == KErrNone) |
|
228 { |
|
229 iUsbSuite->iPortOpen = ETrue; |
|
230 Log(_L("CTestOpenPort::doTestStepL() - Opened ACM comm port, mode %d, role %d"), openMode, role); |
|
231 } |
|
232 TESTL(err == returnValue); |
|
233 } |
|
234 else |
|
235 { |
|
236 TEST(ETrue); |
|
237 } |
|
238 |
|
239 return iTestStepResult; |
|
240 } |
|
241 |
|
242 //////////////////////////////////////////////////////////////////////////////////// |
|
243 //////////////////////////////////////////////////////////////////////////////////// |
|
244 // Test 2.7 |
|
245 CTestWaitForConfigChange::CTestWaitForConfigChange() |
|
246 { |
|
247 // store the name of this test case |
|
248 iTestStepName = _L("WaitForConfigChangeC"); |
|
249 } |
|
250 |
|
251 // Test 2.7 Destructor |
|
252 CTestWaitForConfigChange::~CTestWaitForConfigChange() |
|
253 { |
|
254 } |
|
255 |
|
256 // Test 2.7 Main Code |
|
257 enum TVerdict CTestWaitForConfigChange::doTestStepL() |
|
258 { |
|
259 TCommConfigV01 config; |
|
260 |
|
261 TESTL(GetIntFromConfig(KConfigSection, KConfigRate, (TInt&) config.iRate)); |
|
262 TESTL(GetIntFromConfig(KConfigSection, KConfigStopBits, (TInt&) config.iStopBits)); |
|
263 TESTL(GetIntFromConfig(KConfigSection, KConfigDataBits, (TInt&) config.iDataBits)); |
|
264 TESTL(GetIntFromConfig(KConfigSection, KConfigParity, (TInt&) config.iParity)); |
|
265 |
|
266 Log(_L("CTestWaitForConfigChange::doTestStepL() - Waiting for config change")); |
|
267 User::WaitForRequest(iUsbSuite->iNotifyConfigChangeStatus); |
|
268 Log(_L("CTestWaitForConfigChange::doTestStepL() - Config status completed with %d"), iUsbSuite->iNotifyConfigChangeStatus.Int()); |
|
269 TESTL(iUsbSuite->iNotifyConfigChangeStatus.Int() == KErrNone); |
|
270 |
|
271 Log(_L("iRate=%d iStopBits=%d iDataBits=%d iParity=%d"), iUsbSuite->iConfig().iRate, iUsbSuite->iConfig().iStopBits, iUsbSuite->iConfig().iDataBits, iUsbSuite->iConfig().iParity); |
|
272 |
|
273 TESTL(iUsbSuite->iConfig().iRate == config.iRate); |
|
274 TESTL(iUsbSuite->iConfig().iStopBits == config.iStopBits); |
|
275 TESTL(iUsbSuite->iConfig().iDataBits == config.iDataBits); |
|
276 TESTL(iUsbSuite->iConfig().iParity == config.iParity); |
|
277 |
|
278 return iTestStepResult; |
|
279 } |
|
280 |
|
281 //////////////////////////////////////////////////////////////////////////////////// |
|
282 //////////////////////////////////////////////////////////////////////////////////// |
|
283 // Test 2.8 |
|
284 CTestNotifyStateChange::CTestNotifyStateChange() |
|
285 { |
|
286 // store the name of this test case |
|
287 iTestStepName = _L("NotifyStateChange"); |
|
288 } |
|
289 |
|
290 // Test 2.8 Destructor |
|
291 CTestNotifyStateChange::~CTestNotifyStateChange() |
|
292 { |
|
293 } |
|
294 |
|
295 // Test 2.8 Main Code |
|
296 enum TVerdict CTestNotifyStateChange::doTestStepL() |
|
297 { |
|
298 TESTL(OpenLdd() == KErrNone); |
|
299 iUsbSuite->iLdd.AlternateDeviceStatusNotify(iUsbSuite->iNotifyStateStatus, iUsbSuite->iUsbState); |
|
300 TEST(ETrue); |
|
301 return iTestStepResult; |
|
302 } |
|
303 |
|
304 //////////////////////////////////////////////////////////////////////////////////// |
|
305 //////////////////////////////////////////////////////////////////////////////////// |
|
306 // Test 2.9 |
|
307 CTestWaitForStateChange::CTestWaitForStateChange() |
|
308 { |
|
309 // store the name of this test case |
|
310 iTestStepName = _L("WaitForStateChangeC"); |
|
311 } |
|
312 |
|
313 // Test 2.9 Destructor |
|
314 CTestWaitForStateChange::~CTestWaitForStateChange() |
|
315 { |
|
316 } |
|
317 |
|
318 // Test 2.9 Main Code |
|
319 enum TVerdict CTestWaitForStateChange::doTestStepL() |
|
320 { |
|
321 Log(_L("CTestWaitForConfigChange::doTestStepL() - Waiting for state change...")); |
|
322 User::WaitForRequest(iUsbSuite->iNotifyStateStatus); |
|
323 |
|
324 if (iUsbSuite->iNotifyStateStatus.Int() != KErrNone) |
|
325 { |
|
326 Log(_L("CTestWaitForConfigChange::doTestStepL() - Error = %d"), iUsbSuite->iNotifyStateStatus.Int()); |
|
327 TESTL(EFalse); |
|
328 return iTestStepResult; |
|
329 } |
|
330 |
|
331 TUint targetState; |
|
332 |
|
333 TESTL(GetIntFromConfig(KStateSection, KStateTarget, (TInt&) targetState)); |
|
334 |
|
335 if (!(iUsbSuite->iUsbState & KUsbAlternateSetting)) |
|
336 { |
|
337 Log(_L("CTestWaitForStateChange::doTestStepL() - State Changed to %d"), iUsbSuite->iUsbState); |
|
338 TESTL(iUsbSuite->iUsbState == targetState); |
|
339 } |
|
340 else |
|
341 { |
|
342 // Repost notify as state hasn't changed yet |
|
343 Log(_L("CTestWaitForStateChange::doTestStepL() - State hasn't changed, reposting notify")); |
|
344 iUsbSuite->iLdd.AlternateDeviceStatusNotify(iUsbSuite->iNotifyStateStatus, iUsbSuite->iUsbState); |
|
345 doTestStepL(); |
|
346 return iTestStepResult; |
|
347 } |
|
348 |
|
349 return iTestStepResult; |
|
350 } |
|
351 |
|
352 |
|
353 |