author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "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 |
// @file PBASE-T_USBDI-0486.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "PBASE-T_USBDI-0486.h" |
|
20 |
#include "testpolicy.h" |
|
21 |
#include "testdebug.h" |
|
22 |
#include "modelleddevices.h" |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include "OstTraceDefinitions.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#include "PBASE-T_USBDI-0486Traces.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#endif |
0 | 27 |
|
28 |
namespace NUnitTesting_USBDI |
|
29 |
{ |
|
30 |
||
31 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0486"); |
|
32 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0486,TBool> CUT_PBASE_T_USBDI_0486::iFunctor(KTestCaseId); |
|
33 |
const TInt KBulkTranferId = 2; |
|
34 |
const TInt KExpectedDataSize = 26; |
|
35 |
||
36 |
CUT_PBASE_T_USBDI_0486* CUT_PBASE_T_USBDI_0486::NewL(TBool aHostRole) |
|
37 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_NEWL_ENTRY, aHostRole ); |
0 | 39 |
CUT_PBASE_T_USBDI_0486* self = new (ELeave) CUT_PBASE_T_USBDI_0486(aHostRole); |
40 |
CleanupStack::PushL(self); |
|
41 |
self->ConstructL(); |
|
42 |
CleanupStack::Pop(self); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_NEWL_EXIT, ( TUint )( self ) ); |
0 | 44 |
return self; |
45 |
} |
|
46 |
||
47 |
||
48 |
CUT_PBASE_T_USBDI_0486::CUT_PBASE_T_USBDI_0486(TBool aHostRole) |
|
49 |
: CBaseBulkTestCase(KTestCaseId,aHostRole), |
|
50 |
iCaseStep(EWaitForDeviceCConnection) |
|
51 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_EXIT, this ); |
0 | 54 |
} |
55 |
||
56 |
||
57 |
void CUT_PBASE_T_USBDI_0486::ConstructL() |
|
58 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_CONSTRUCTL_ENTRY, this ); |
0 | 60 |
BaseBulkConstructL(); |
61 |
iTestDeviceC = new RUsbDeviceC(this); // TODO check tree for device C, once inserted |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CONSTRUCTL_EXIT, this ); |
0 | 63 |
} |
64 |
||
65 |
CUT_PBASE_T_USBDI_0486::~CUT_PBASE_T_USBDI_0486() |
|
66 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_ENTRY_DUP01, this ); |
0 | 68 |
|
69 |
delete iTestDeviceC; |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_EXIT_DUP01, this ); |
0 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
Called when the device has reported any kind of error in its operation |
|
75 |
or when the device has been informed by the host to report success |
|
76 |
*/ |
|
77 |
void CUT_PBASE_T_USBDI_0486::DeviceRunL() |
|
78 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_DEVICERUNL_ENTRY, this ); |
0 | 80 |
// Complete the test case request |
81 |
TestPolicy().SignalTestComplete(iStatus.Int()); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICERUNL_EXIT, this ); |
0 | 83 |
} |
84 |
||
85 |
void CUT_PBASE_T_USBDI_0486::DeviceDoCancel() |
|
86 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_DEVICEDOCANCEL_ENTRY, this ); |
0 | 88 |
iTestDeviceC->CancelSubscriptionToReports(); |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEDOCANCEL_EXIT, this ); |
0 | 90 |
} |
91 |
||
92 |
TBool CUT_PBASE_T_USBDI_0486::CheckSN(const TDesC16& aSerialNumberGot, const TDesC& aExpectedSerialNumber) |
|
93 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_CHECKSN_ENTRY, this ); |
0 | 95 |
TBool areSNsIdenticals = (aSerialNumberGot.Compare(aExpectedSerialNumber) == 0); |
96 |
||
97 |
if(!areSNsIdenticals) |
|
98 |
{ |
|
99 |
// Incorrect device for this test case |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_CHECKSN, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
KErrNotFound,aSerialNumberGot, aExpectedSerialNumber); |
0 | 102 |
} |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
103 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_CHECKSN_EXIT, this, areSNsIdenticals ); |
0 | 104 |
return areSNsIdenticals; |
105 |
} |
|
106 |
||
107 |
||
108 |
void CUT_PBASE_T_USBDI_0486::Ep0TransferCompleteL(TInt aCompletionCode) |
|
109 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_ENTRY, this ); |
0 | 111 |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_DUP01, "--->Ep0TransferCompleteL, case step = %d", iCaseStep); |
0 | 114 |
|
115 |
switch(iCaseStep) |
|
116 |
{ |
|
117 |
case EDeviceCConnected: |
|
118 |
{ |
|
119 |
if(aCompletionCode != KErrNone) |
|
120 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_DUP02, "<Error %d> aCompletionCode != KErrNone",aCompletionCode); |
0 | 122 |
return TestFailed(aCompletionCode); |
123 |
} |
|
124 |
// close interface 0 |
|
125 |
iUsbInterface0.Close(); |
|
126 |
iCaseStep = EWaitForDeviceCDisconnection; |
|
127 |
} |
|
128 |
break; |
|
129 |
||
130 |
case EPassed: |
|
131 |
TestPassed(); |
|
132 |
break; |
|
133 |
||
134 |
default: |
|
135 |
TestFailed(KErrCompletion); |
|
136 |
break; |
|
137 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_EXIT, this ); |
0 | 139 |
} |
140 |
||
141 |
void CUT_PBASE_T_USBDI_0486::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
|
142 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_ENTRY, this ); |
0 | 144 |
Cancel(); |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL, "--->TransferCompleteL, case step = %d", iCaseStep); |
0 | 146 |
|
147 |
if(aTransferId == KBulkTranferId) |
|
148 |
{ |
|
149 |
if(aCompletionCode != KErrCancel && aCompletionCode != KErrUsbIOError) |
|
150 |
{ |
|
151 |
TBuf<256> msg; |
|
152 |
msg.Format(_L("<Error %d> The transfer completed with no errors but should have done so"),aCompletionCode); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP01, msg); |
0 | 154 |
TTestCaseFailed request(KErrCorrupt,msg); |
155 |
return iControlEp0->SendRequest(request,this); |
|
156 |
} |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP02, "<Error> a transfer completed (id=%d) that was not expected",aTransferId); |
0 | 161 |
return TestFailed(KErrCorrupt); |
162 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_EXIT, this ); |
0 | 164 |
} |
165 |
||
166 |
||
167 |
void CUT_PBASE_T_USBDI_0486::DeviceInsertedL(TUint aDeviceHandle) |
|
168 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL, "--->DeviceInsertedL, case step = %d", iCaseStep); |
0 | 171 |
|
172 |
// Cancel the timeout timer |
|
173 |
Cancel(); |
|
174 |
TInt err(KErrNone); |
|
175 |
||
176 |
// Validate that device is as expected |
|
177 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
|
178 |
||
179 |
// Perform the correct test step |
|
180 |
switch(iCaseStep) |
|
181 |
{ |
|
182 |
case EWaitForDeviceCConnection: |
|
183 |
{ |
|
184 |
if(!CheckSN(testDevice.SerialNumber(), KTestDeviceC_SN())) |
|
185 |
{ |
|
186 |
return TestFailed(KErrNotFound); |
|
187 |
} |
|
188 |
iCaseStep = EDeviceCConnected; |
|
189 |
||
190 |
err = testDevice.Device().GetTokenForInterface(0,iToken0DeviceC); |
|
191 |
if(err != KErrNone) |
|
192 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP01, "<Error %d> Unable to retrieve token for interface 0",err); |
0 | 194 |
TestFailed(err); |
195 |
} |
|
196 |
// Open the interface |
|
197 |
err = iUsbInterface0.Open(iToken0DeviceC); |
|
198 |
if(err != KErrNone) |
|
199 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0", err); |
0 | 201 |
TestFailed(err); |
202 |
} |
|
203 |
||
204 |
TUint32 token1; |
|
205 |
err = testDevice.Device().GetTokenForInterface(1,token1); |
|
206 |
if(err != KErrNone) |
|
207 |
{ |
|
208 |
TBuf<256> msg; |
|
209 |
msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP03, msg); |
0 | 211 |
iCaseStep = EFailed; |
212 |
TTestCaseFailed request(err,msg); |
|
213 |
return iControlEp0->SendRequest(request,this); |
|
214 |
} |
|
215 |
||
216 |
||
217 |
err = iUsbInterface1.Open(token1); // Default interface setting 0 |
|
218 |
if(err != KErrNone) |
|
219 |
{ |
|
220 |
TBuf<256> msg; |
|
221 |
msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP04, msg); |
0 | 223 |
iCaseStep = EFailed; |
224 |
TTestCaseFailed request(err,msg); |
|
225 |
return iControlEp0->SendRequest(request,this); |
|
226 |
} |
|
227 |
||
228 |
TInt endpointAddress; |
|
229 |
// Queue a bulk in transfer on endpoint 2 |
|
230 |
err = GetEndpointAddress(iUsbInterface1,0,KTransferTypeBulk,KEpDirectionIn,endpointAddress); |
|
231 |
if(err != KErrNone) |
|
232 |
{ |
|
233 |
TBuf<256> msg; |
|
234 |
msg.Format(_L("<Error %d> Address for bulk in endpoint could not be obtained"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP05, msg); |
0 | 236 |
iCaseStep = EFailed; |
237 |
TTestCaseFailed request(err,msg); |
|
238 |
return iControlEp0->SendRequest(request,this); |
|
239 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP06, "Endpoint adress %08x",endpointAddress); |
0 | 241 |
|
242 |
err = iUsbInterface1.OpenPipeForEndpoint(iTestPipeInterface1BulkIn,endpointAddress,ETrue); |
|
243 |
if(err != KErrNone) |
|
244 |
{ |
|
245 |
TBuf<256> msg; |
|
246 |
msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP07, msg); |
0 | 248 |
iCaseStep = EFailed; |
249 |
TTestCaseFailed request(err,msg); |
|
250 |
return iControlEp0->SendRequest(request,this); |
|
251 |
} |
|
252 |
||
253 |
// Create the bulk transfers |
|
254 |
iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,256,*this, KBulkTranferId); |
|
255 |
||
256 |
// Initialise the descriptors for transfer |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP08, "Initialising the transfer descriptors"); |
0 | 258 |
err = iUsbInterface1.InitialiseTransferDescriptors(); |
259 |
if(err != KErrNone) |
|
260 |
{ |
|
261 |
TBuf<256> msg; |
|
262 |
msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP09, msg); |
0 | 264 |
iCaseStep = EFailed; |
265 |
TTestCaseFailed request(err,msg); |
|
266 |
return iControlEp0->SendRequest(request,this); |
|
267 |
} |
|
268 |
iInTransfer[0]->TransferIn(KExpectedDataSize); |
|
269 |
||
270 |
// disconnect device C and connect device A |
|
271 |
TDisconnectDeviceCThenConnectDeviceARequest request; |
|
272 |
iControlEp0->SendRequest(request,this); |
|
273 |
||
274 |
// Monitor for the reconnection from the client |
|
275 |
iActorFDF->Monitor(); |
|
276 |
TimeoutIn(30); |
|
277 |
||
278 |
} |
|
279 |
break; |
|
280 |
||
281 |
case EWaitForDeviceAConnection: |
|
282 |
{ |
|
283 |
if(!CheckSN(testDevice.SerialNumber(), TestCaseId())) |
|
284 |
{ |
|
285 |
return TestFailed(KErrNotFound); |
|
286 |
} |
|
287 |
// try to open interface 0 |
|
288 |
err = iUsbInterface0.Open(iToken0DeviceC); |
|
289 |
if(err != KErrNotFound) // invalid token |
|
290 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP10, "iUsbInterface0.Open(iToken0DeviceC) === %d", err); |
0 | 292 |
TestFailed(err); |
293 |
} |
|
294 |
||
295 |
// get token now |
|
296 |
TUint32 token0DeviceA; |
|
297 |
err = testDevice.Device().GetTokenForInterface(0,token0DeviceA); |
|
298 |
if(err != KErrNone) |
|
299 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP11, "<Error %d> Unable to retrieve token(device A) for interface 0",err); |
0 | 301 |
TestFailed(err); |
302 |
} |
|
303 |
// Open the interface |
|
304 |
err = iUsbInterface0.Open(token0DeviceA); |
|
305 |
if(err != KErrNone) |
|
306 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP12, "<Error %d> Unable to open interface 0(device A)", err); |
0 | 308 |
TestFailed(err); |
309 |
} |
|
310 |
||
311 |
// ok, send EPassed request |
|
312 |
iCaseStep = EPassed; |
|
313 |
// Send test case passed request to client |
|
314 |
User::After(2000000); |
|
315 |
TTestCasePassed request; |
|
316 |
iControlEp0->SendRequest(request,this); |
|
317 |
} |
|
318 |
break; |
|
319 |
||
320 |
default: |
|
321 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP13, "<Error> Test case actions out of sync"); |
0 | 323 |
TestFailed(KErrCorrupt); |
324 |
} |
|
325 |
break; |
|
326 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_EXIT, this ); |
0 | 328 |
} |
329 |
||
330 |
void CUT_PBASE_T_USBDI_0486::DeviceRemovedL(TUint aDeviceHandle) |
|
331 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_ENTRY, this ); |
0 | 333 |
Cancel(); |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL, "--->DeviceRemovedL, case step = %d", iCaseStep); |
0 | 335 |
|
336 |
switch(iCaseStep) |
|
337 |
{ |
|
338 |
case EWaitForDeviceCDisconnection: // device C is disconnected now, interface 0 has been closed before |
|
339 |
{ |
|
340 |
iCaseStep = EWaitForDeviceAConnection; |
|
341 |
iActorFDF->Monitor(); |
|
342 |
} |
|
343 |
break; |
|
344 |
||
345 |
default: |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_DUP01, "<Error> Test case actions out of sync"); |
0 | 347 |
TestFailed(KErrCorrupt); |
348 |
break; |
|
349 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_EXIT, this ); |
0 | 351 |
} |
352 |
||
353 |
void CUT_PBASE_T_USBDI_0486::HandleDeviceDConnection() |
|
354 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_HANDLEDEVICEDCONNECTION_ENTRY, this ); |
0 | 356 |
|
357 |
iTestDevice->SubscribeToReports(iStatus); |
|
358 |
SetActive(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_HANDLEDEVICEDCONNECTION_EXIT, this ); |
0 | 360 |
} |
361 |
||
362 |
void CUT_PBASE_T_USBDI_0486::ExecuteDeviceTestCaseL() |
|
363 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_EXECUTEDEVICETESTCASEL_ENTRY, this ); |
0 | 365 |
|
366 |
// Create the test device |
|
367 |
iTestDeviceC->OpenL(KTestDeviceC_SN()); |
|
368 |
iTestDeviceC->SubscribeToReports(iStatus); |
|
369 |
SetActive(); |
|
370 |
||
371 |
// Connect the device to the host |
|
372 |
iTestDeviceC->SoftwareConnect(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_EXECUTEDEVICETESTCASEL_EXIT, this ); |
0 | 374 |
} |
375 |
||
376 |
RUsbDeviceC* CUT_PBASE_T_USBDI_0486::TestDeviceC() |
|
377 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_TESTDEVICEC_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_TESTDEVICEC_EXIT, this, ( TUint )( iTestDeviceC ) ); |
0 | 380 |
return iTestDeviceC; |
381 |
} |
|
382 |
||
383 |
RUsbDeviceD* CUT_PBASE_T_USBDI_0486::TestDeviceD() |
|
384 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_TESTDEVICED_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_TESTDEVICED_EXIT, this, ( TUint )( iTestDevice ) ); |
0 | 387 |
return iTestDevice; //from CBaseBulkTestCase |
388 |
} |
|
389 |
||
390 |
} |