44
|
1 |
/*
|
58
|
2 |
* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
44
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
46
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
44
|
6 |
* which accompanies this distribution, and is available
|
46
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
44
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// [INCLUDE FILES] - do not remove
|
|
19 |
#include <e32svr.h>
|
|
20 |
#include <StifParser.h>
|
|
21 |
#include <ecom/ecom.h>
|
87
|
22 |
#include <StifTestInterface.h>
|
52
|
23 |
#include "usbuinotifapitest.h"
|
44
|
24 |
|
|
25 |
// EXTERNAL DATA STRUCTURES
|
|
26 |
|
|
27 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
28 |
|
|
29 |
// CONSTANTS
|
52
|
30 |
#ifdef __WINS__
|
|
31 |
_LIT( KUsbAppProcPattern, "usb[*" );
|
|
32 |
#else
|
|
33 |
_LIT( KUsbAppProcPattern, "#USBSettingsApp*" );
|
|
34 |
#endif
|
44
|
35 |
|
|
36 |
// MACROS
|
|
37 |
|
|
38 |
// LOCAL CONSTANTS AND MACROS
|
|
39 |
|
|
40 |
// MODULE DATA STRUCTURES
|
|
41 |
|
|
42 |
// LOCAL FUNCTION PROTOTYPES
|
|
43 |
|
|
44 |
// FORWARD DECLARATIONS
|
|
45 |
|
|
46 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
47 |
|
|
48 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
52
|
51 |
// CUSBUiNotifApiTest::Delete
|
44
|
52 |
// Delete here all resources allocated and opened from test methods.
|
|
53 |
// Called from destructor.
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
52
|
56 |
void CUSBUiNotifApiTest::Delete()
|
|
57 |
{
|
44
|
58 |
iNotifier -> Close();
|
|
59 |
delete iNotifier;
|
|
60 |
iNotifier = NULL;
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
52
|
64 |
// CUSBUiNotifApiTest::RunMethodL
|
44
|
65 |
// Run specified method. Contains also table of test mothods and their names.
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
52
|
68 |
TInt CUSBUiNotifApiTest::RunMethodL(
|
44
|
69 |
CStifItemParser& aItem )
|
|
70 |
{
|
|
71 |
|
|
72 |
static TStifFunctionInfo const KFunctions[] =
|
|
73 |
{
|
52
|
74 |
// Copy this line for every implemented function.
|
|
75 |
// First string is the function name used in TestScripter script file.
|
|
76 |
// Second is the actual implementation member function.
|
|
77 |
ENTRY( "CableConnectedNotifierTest", CUSBUiNotifApiTest::CableConnectedNotifierTest ),
|
|
78 |
ENTRY( "FinishCableConnectedQuery", CUSBUiNotifApiTest::FinishCableConnectedQuery ),
|
|
79 |
ENTRY( "UsbQueriesNotifierTest", CUSBUiNotifApiTest::UsbQueriesNotifierTest ),
|
|
80 |
ENTRY( "FinishQuery", CUSBUiNotifApiTest::FinishQuery ),
|
|
81 |
ENTRY( "UsbOTGErrorNotifierTests", CUSBUiNotifApiTest::UsbOTGErrorNotifierTests ),
|
|
82 |
ENTRY( "UsbOTGWarningNotifierTests", CUSBUiNotifApiTest::UsbOTGWarningNotifierTests ),
|
|
83 |
ENTRY( "LoadNotifiers", CUSBUiNotifApiTest::LoadNotifiersL ),
|
|
84 |
ENTRY( "UnLoadNotifiers", CUSBUiNotifApiTest::UnLoadNotifiers ),
|
|
85 |
ENTRY( "UsbMSMMNotifierTests", CUSBUiNotifApiTest::UsbMSMMNotifierTests ),
|
|
86 |
ENTRY( "CancelMsmmNotifier", CUSBUiNotifApiTest::CancelMsmmNotifier ),
|
|
87 |
ENTRY( "CancelQueryNotifier", CUSBUiNotifApiTest::CancelQueryNotifier ),
|
|
88 |
ENTRY( "CancelOtgErrorNotifier", CUSBUiNotifApiTest::CancelOtgErrorNotifier ),
|
|
89 |
ENTRY( "CancelOtgWarningNotifier", CUSBUiNotifApiTest::CancelOtgWarningNotifier ),
|
|
90 |
ENTRY( "CancelCableConnectedNotifier", CUSBUiNotifApiTest::CancelCableConnectedNotifier ),
|
|
91 |
ENTRY( "WaitForRequest", CUSBUiNotifApiTest::WaitForRequest ),
|
|
92 |
ENTRY( "SynchStart", CUSBUiNotifApiTest::SynchStart ),
|
|
93 |
ENTRY( "Update", CUSBUiNotifApiTest::Update )
|
44
|
94 |
//ADD NEW ENTRY HERE
|
|
95 |
// [test cases entries] - Do not remove
|
52
|
96 |
|
44
|
97 |
};
|
|
98 |
|
|
99 |
const TInt count = sizeof( KFunctions ) /
|
|
100 |
sizeof( TStifFunctionInfo );
|
|
101 |
|
|
102 |
return RunInternalL( KFunctions, count, aItem );
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
52
|
107 |
// CUSBUiNotifApiTest::CableConnectedNotifierTests
|
44
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
|
52
|
110 |
TInt CUSBUiNotifApiTest::CableConnectedNotifierTest( CStifItemParser& /*aItem*/ )
|
44
|
111 |
{
|
|
112 |
TInt res;
|
52
|
113 |
TPtrC8 dummyPckg; //no parameters used
|
44
|
114 |
|
|
115 |
res = iNotifier -> Connect();
|
|
116 |
if ( res != KErrNone )
|
|
117 |
{
|
52
|
118 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
119 |
return res;
|
44
|
120 |
}
|
52
|
121 |
iLog -> Log( _L("RNotifier connected") );
|
|
122 |
|
|
123 |
//kill the possibly running usb application
|
|
124 |
FindAndKillProcess(KUsbAppProcPattern);
|
|
125 |
|
|
126 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid,
|
|
127 |
dummyPckg, iConnectionNotifierResponseParamsPckg );
|
|
128 |
|
|
129 |
return KErrNone;
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
TInt CUSBUiNotifApiTest::FinishCableConnectedQuery( CStifItemParser& aItem )
|
|
135 |
{
|
|
136 |
//give time for application to start, in microseconds
|
|
137 |
const TInt KAppLaunchDelay = 5000000;
|
|
138 |
TInt res;
|
|
139 |
TPtrC optionName( KNullDesC );
|
|
140 |
TTestOption option;
|
|
141 |
TPtrC expectedUsbPersonalityName( KNullDesC );
|
|
142 |
TInt expectedErrorCode;
|
44
|
143 |
|
52
|
144 |
iLog -> Log( _L("FinishCableConnectedQuery") );
|
|
145 |
|
|
146 |
res = aItem.GetString( _L( "FinishCableConnectedQuery" ), optionName );
|
|
147 |
|
|
148 |
if ( res != KErrNone )
|
|
149 |
{
|
|
150 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
151 |
iNotifier -> Close();
|
|
152 |
return res;
|
|
153 |
}
|
|
154 |
|
|
155 |
iLog -> Log( _L("FinishCableConnectedQuery getting option") );
|
|
156 |
res = GetTestOption( optionName, option );
|
|
157 |
if ( res != KErrNone )
|
|
158 |
{
|
|
159 |
iLog -> Log( _L("GetTestOption failed with value: %d"), res );
|
|
160 |
iUsbWatcher -> Close();
|
|
161 |
iNotifier -> Close();
|
|
162 |
return res;
|
|
163 |
}
|
|
164 |
|
|
165 |
iLog -> Log( _L("FinishCableConnectedQuery wait for request") );
|
44
|
166 |
User::WaitForRequest( iReqStatus );
|
52
|
167 |
expectedErrorCode = iReqStatus.Int();
|
|
168 |
|
|
169 |
iLog -> Log( _L("FinishCableConnectedQuery request complete") );
|
44
|
170 |
|
52
|
171 |
iNotifier -> Close();
|
|
172 |
|
|
173 |
iLog -> Log( _L("FinishCableConnectedQuery close") );
|
44
|
174 |
|
52
|
175 |
TInt ret = KErrNone;
|
|
176 |
switch( option )
|
|
177 |
{
|
|
178 |
case EQueryAccepted:
|
|
179 |
iLog -> Log( _L("EQueryAccepted"));
|
|
180 |
User::After(KAppLaunchDelay); //let the app start and let the tester person to see that
|
|
181 |
ret = FindAndKillProcess(KUsbAppProcPattern);
|
|
182 |
if (ret != KErrNone)
|
|
183 |
{
|
|
184 |
iLog -> Log( _L("Process start failed: %d"), ret );
|
|
185 |
return ret;
|
|
186 |
}
|
|
187 |
iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel );
|
|
188 |
//the notifier returns KErrCancel when clicked
|
|
189 |
STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode );
|
|
190 |
break;
|
|
191 |
case EQueryCanceled:
|
|
192 |
iLog -> Log( _L("FinishCableConnectedQuery canceled") );
|
|
193 |
iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel );
|
|
194 |
STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode );
|
|
195 |
break;
|
|
196 |
default:
|
|
197 |
iLog -> Log( _L("FinishCableConnectedQuery default - not found") );
|
|
198 |
return KErrNotFound;
|
|
199 |
}
|
|
200 |
|
|
201 |
iLog -> Log( _L("Test case passed!") );
|
|
202 |
return KErrNone;
|
44
|
203 |
}
|
|
204 |
|
|
205 |
|
|
206 |
// -----------------------------------------------------------------------------
|
52
|
207 |
// CBtNotifApiTest::UsbQueriesNotifierTests
|
44
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
|
52
|
210 |
TInt CUSBUiNotifApiTest::UsbQueriesNotifierTest( CStifItemParser& aItem )
|
44
|
211 |
{
|
|
212 |
TInt res;
|
52
|
213 |
TPtrC usbQueryName( KNullDesC );
|
44
|
214 |
TUSBUIQueries usbQueryType;
|
|
215 |
|
52
|
216 |
res = aItem.GetString( _L( "UsbQueriesNotifierTest" ), usbQueryName );
|
44
|
217 |
if ( res != KErrNone )
|
|
218 |
{
|
52
|
219 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
220 |
iNotifier -> Close();
|
|
221 |
return res;
|
|
222 |
}
|
|
223 |
|
|
224 |
res = GetQueryType( usbQueryName, usbQueryType );
|
|
225 |
if ( res != KErrNone )
|
|
226 |
{
|
|
227 |
iLog -> Log( _L("GetQueryType failed with value: %d"), res );
|
|
228 |
return res;
|
44
|
229 |
}
|
|
230 |
|
|
231 |
TUSBQueriesNotiferParams notifierParams;
|
|
232 |
notifierParams.iDrive = 'c';
|
|
233 |
notifierParams.iQuery = usbQueryType;
|
|
234 |
TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams );
|
|
235 |
TPckgBuf<TBool> output;
|
|
236 |
|
52
|
237 |
if (!iNotifierConnected)
|
|
238 |
{
|
|
239 |
res = iNotifier -> Connect();
|
|
240 |
iNotifierConnected = ETrue;
|
|
241 |
}
|
44
|
242 |
if ( res != KErrNone )
|
|
243 |
{
|
52
|
244 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
245 |
return res;
|
44
|
246 |
}
|
52
|
247 |
iLog -> Log( _L("RNotifier connected") );
|
44
|
248 |
|
|
249 |
switch( usbQueryType )
|
|
250 |
{
|
|
251 |
case EUSBNoMemoryCard:
|
|
252 |
iCompleteQuery = ETrue;
|
|
253 |
break;
|
|
254 |
case EUSBStorageMediaFailure:
|
|
255 |
case EUSBChangeFromMassStorage:
|
|
256 |
iCompleteQuery = EFalse;
|
|
257 |
break;
|
|
258 |
default:
|
|
259 |
break;
|
|
260 |
}
|
|
261 |
|
52
|
262 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier,
|
|
263 |
notifierParamsPckg, output );
|
|
264 |
iLog -> Log( _L("StartNotifierAndGetResponse ready") );
|
44
|
265 |
|
52
|
266 |
return KErrNone;
|
44
|
267 |
}
|
52
|
268 |
|
44
|
269 |
// -----------------------------------------------------------------------------
|
52
|
270 |
// CBtNotifApiTest::UsbOTGErrorNotifierTests
|
44
|
271 |
// -----------------------------------------------------------------------------
|
|
272 |
|
52
|
273 |
TInt CUSBUiNotifApiTest::UsbOTGErrorNotifierTests( CStifItemParser& aItem )
|
44
|
274 |
{
|
52
|
275 |
TInt res;
|
|
276 |
TPtrC usbQueryName( KNullDesC );
|
|
277 |
TUsbUiNotifOtgError usbOTGErrorType;
|
44
|
278 |
|
52
|
279 |
res = aItem.GetString( _L( "UsbOTGErrorNotifierTests" ), usbQueryName );
|
44
|
280 |
if ( res != KErrNone )
|
|
281 |
{
|
52
|
282 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
283 |
iNotifier -> Close();
|
|
284 |
return res;
|
|
285 |
}
|
|
286 |
|
|
287 |
res = GetOTGErrorType( usbQueryName, usbOTGErrorType );
|
|
288 |
if ( res != KErrNone )
|
|
289 |
{
|
|
290 |
iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
|
|
291 |
return res;
|
44
|
292 |
}
|
|
293 |
|
52
|
294 |
if (!iNotifierConnected)
|
|
295 |
{
|
|
296 |
res = iNotifier -> Connect();
|
|
297 |
iNotifierConnected = ETrue;
|
|
298 |
}
|
44
|
299 |
if ( res != KErrNone )
|
|
300 |
{
|
52
|
301 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
302 |
return res;
|
44
|
303 |
}
|
52
|
304 |
iLog -> Log( _L("RNotifier connected") );
|
44
|
305 |
|
|
306 |
TPckgBuf<TInt> notifierParamsPckg;
|
|
307 |
notifierParamsPckg() = usbOTGErrorType;
|
|
308 |
iCompleteQuery = EFalse;
|
|
309 |
|
52
|
310 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus,
|
|
311 |
KUsbUiNotifOtgError, notifierParamsPckg, iRes );
|
44
|
312 |
|
52
|
313 |
return KErrNone;
|
44
|
314 |
}
|
|
315 |
|
|
316 |
// -----------------------------------------------------------------------------
|
52
|
317 |
// CBtNotifApiTest::UsbOTGErrorNotifierTests
|
44
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
|
52
|
320 |
TInt CUSBUiNotifApiTest::UsbOTGWarningNotifierTests( CStifItemParser& aItem )
|
44
|
321 |
{
|
|
322 |
TInt res;
|
52
|
323 |
TPtrC usbQueryName( KNullDesC );
|
44
|
324 |
TUsbUiNotifOtgWarning usbOTGWarningType;
|
|
325 |
|
52
|
326 |
res = aItem.GetString( _L( "UsbOTGWarningNotifierTests" ), usbQueryName );
|
44
|
327 |
if ( res != KErrNone )
|
|
328 |
{
|
52
|
329 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
330 |
iNotifier -> Close();
|
|
331 |
return res;
|
|
332 |
}
|
|
333 |
|
|
334 |
res = GetOTGWarningType( usbQueryName, usbOTGWarningType );
|
|
335 |
if ( res != KErrNone )
|
|
336 |
{
|
|
337 |
iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
|
|
338 |
return res;
|
44
|
339 |
}
|
|
340 |
|
52
|
341 |
if (!iNotifierConnected)
|
|
342 |
{
|
|
343 |
res = iNotifier -> Connect();
|
|
344 |
iNotifierConnected = ETrue;
|
|
345 |
}
|
44
|
346 |
if ( res != KErrNone )
|
|
347 |
{
|
52
|
348 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
349 |
return res;
|
44
|
350 |
}
|
52
|
351 |
iLog -> Log( _L("RNotifier connected") );
|
44
|
352 |
|
|
353 |
TPckgBuf<TInt> notifierParamsPckg;
|
|
354 |
notifierParamsPckg() = usbOTGWarningType;
|
|
355 |
iCompleteQuery = EFalse;
|
|
356 |
|
52
|
357 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus,
|
|
358 |
KUsbUiNotifOtgWarning, notifierParamsPckg, iRes );
|
44
|
359 |
|
52
|
360 |
return KErrNone;
|
44
|
361 |
}
|
|
362 |
|
|
363 |
// -----------------------------------------------------------------------------
|
52
|
364 |
// CBtNotifApiTest::UsbMSMMNotifierTests
|
44
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
|
52
|
367 |
TInt CUSBUiNotifApiTest::UsbMSMMNotifierTests( CStifItemParser& aItem )
|
44
|
368 |
{
|
|
369 |
TInt res;
|
52
|
370 |
TPtrC usbQueryName( KNullDesC );
|
44
|
371 |
THostMsErrCode usbMSMMNErrorType;
|
|
372 |
|
52
|
373 |
iLog -> Log( _L("------msmm------") );
|
|
374 |
|
|
375 |
res = aItem.GetString( _L( "UsbMSMMNotifierTests" ), usbQueryName );
|
44
|
376 |
if ( res != KErrNone )
|
|
377 |
{
|
52
|
378 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
379 |
iNotifier -> Close();
|
|
380 |
return res;
|
|
381 |
}
|
|
382 |
|
|
383 |
res = GetMSMMrrorType( usbQueryName, usbMSMMNErrorType );
|
|
384 |
if ( res != KErrNone )
|
|
385 |
{
|
|
386 |
iLog -> Log( _L("MSMMrrorType failed with value: %d"), res );
|
|
387 |
return res;
|
44
|
388 |
}
|
|
389 |
iErrData.iError=usbMSMMNErrorType;
|
|
390 |
iErrPckg = iErrData;
|
52
|
391 |
if (!iNotifierConnected)
|
|
392 |
{
|
|
393 |
res = iNotifier -> Connect();
|
|
394 |
iNotifierConnected = ETrue;
|
|
395 |
}
|
44
|
396 |
if ( res != KErrNone )
|
|
397 |
{
|
52
|
398 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
399 |
return res;
|
44
|
400 |
}
|
52
|
401 |
iLog -> Log( _L("RNotifier connected") );
|
44
|
402 |
|
|
403 |
TPckgBuf<TInt> notifierParamsPckg;
|
|
404 |
notifierParamsPckg() = usbMSMMNErrorType;
|
|
405 |
iCompleteQuery = EFalse;
|
|
406 |
|
|
407 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes );
|
52
|
408 |
|
|
409 |
return KErrNone;
|
|
410 |
}
|
44
|
411 |
|
52
|
412 |
|
|
413 |
TInt CUSBUiNotifApiTest::CancelMsmmNotifier( CStifItemParser& /*aItem*/ )
|
|
414 |
{
|
|
415 |
return ( iNotifier->CancelNotifier(KUsbUiNotifMsmmError) );
|
|
416 |
}
|
|
417 |
|
|
418 |
|
|
419 |
TInt CUSBUiNotifApiTest::CancelQueryNotifier( CStifItemParser& /*aItem*/ )
|
|
420 |
{
|
|
421 |
iLog -> Log( _L("CancelQueryNotifier") );
|
|
422 |
return ( iNotifier->CancelNotifier(KQueriesNotifier) );
|
44
|
423 |
}
|
|
424 |
|
|
425 |
|
52
|
426 |
TInt CUSBUiNotifApiTest::CancelOtgErrorNotifier( CStifItemParser& /*aItem*/ )
|
|
427 |
{
|
|
428 |
return ( iNotifier->CancelNotifier(KUsbUiNotifOtgError) );
|
|
429 |
}
|
|
430 |
|
|
431 |
TInt CUSBUiNotifApiTest::CancelOtgWarningNotifier( CStifItemParser& /*aItem*/ )
|
|
432 |
{
|
|
433 |
return ( iNotifier->CancelNotifier(KUsbUiNotifOtgWarning) );
|
|
434 |
}
|
|
435 |
|
|
436 |
TInt CUSBUiNotifApiTest::CancelCableConnectedNotifier( CStifItemParser& /*aItem*/ )
|
|
437 |
{
|
|
438 |
return ( iNotifier->CancelNotifier(KCableConnectedNotifierUid) );
|
|
439 |
}
|
|
440 |
|
|
441 |
TInt CUSBUiNotifApiTest::WaitForRequest( CStifItemParser& /*aItem*/ )
|
|
442 |
{
|
|
443 |
User::WaitForRequest( iReqStatus );
|
|
444 |
return KErrNone;
|
|
445 |
}
|
44
|
446 |
|
52
|
447 |
TInt CUSBUiNotifApiTest::SynchStart(CStifItemParser& aItem )
|
|
448 |
{
|
|
449 |
TInt res;
|
|
450 |
TPtrC usbQueryName( KNullDesC );
|
|
451 |
TUsbUiNotifOtgWarning usbOTGWarningType;
|
|
452 |
|
|
453 |
res = aItem.GetString( _L( "SynchStart" ), usbQueryName );
|
|
454 |
if ( res != KErrNone )
|
|
455 |
{
|
|
456 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
|
457 |
iNotifier -> Close();
|
|
458 |
return res;
|
|
459 |
}
|
|
460 |
|
|
461 |
res = GetOTGWarningType( usbQueryName, usbOTGWarningType );
|
|
462 |
if ( res != KErrNone )
|
|
463 |
{
|
|
464 |
iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
|
|
465 |
return res;
|
|
466 |
}
|
|
467 |
|
|
468 |
|
|
469 |
res = iNotifier -> Connect();
|
|
470 |
if ( res != KErrNone )
|
|
471 |
{
|
|
472 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
473 |
return res;
|
|
474 |
}
|
|
475 |
iLog -> Log( _L("RNotifier connected") );
|
|
476 |
|
|
477 |
TPckgBuf<TInt> notifierParamsPckg;
|
|
478 |
notifierParamsPckg() = usbOTGWarningType;
|
|
479 |
iCompleteQuery = EFalse;
|
|
480 |
|
|
481 |
TInt retVal = iNotifier -> StartNotifier( KUsbUiNotifOtgWarning, notifierParamsPckg );
|
|
482 |
iLog -> Log( _L("StartNotifier returned with value: %d"), retVal );
|
|
483 |
|
|
484 |
iNotifier->Close();
|
|
485 |
return retVal;
|
|
486 |
}
|
|
487 |
|
|
488 |
TInt CUSBUiNotifApiTest::Update(CStifItemParser& /*aItem*/ )
|
|
489 |
{
|
|
490 |
//delay in microseconds before updating the notifier
|
|
491 |
const TInt KUpdateDelay = 2000000;
|
|
492 |
TInt res;
|
|
493 |
TPtrC usbQueryName( KNullDesC );
|
|
494 |
|
|
495 |
res = iNotifier -> Connect();
|
|
496 |
if ( res != KErrNone )
|
|
497 |
{
|
|
498 |
iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
|
|
499 |
return res;
|
|
500 |
}
|
|
501 |
iLog -> Log( _L("RNotifier connected") );
|
|
502 |
|
|
503 |
TPckgBuf<TInt> notifierParamsPckg;
|
|
504 |
notifierParamsPckg() = EUsbOtgUnsupportedDevice;
|
|
505 |
iCompleteQuery = EFalse;
|
|
506 |
TPckgBuf<TInt> response ;
|
|
507 |
iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError,
|
|
508 |
notifierParamsPckg, iRes );
|
|
509 |
|
|
510 |
User::After(KUpdateDelay); //simulate update after a delay
|
|
511 |
TPckgBuf<TInt> notifierParamsPckgUpdate;
|
|
512 |
notifierParamsPckgUpdate() = EUsbOtgErrorNoMemory;
|
|
513 |
TInt retVal = iNotifier -> UpdateNotifier( KUsbUiNotifOtgError,
|
|
514 |
notifierParamsPckgUpdate, response);
|
|
515 |
|
|
516 |
iNotifier->Close();
|
|
517 |
return retVal;
|
|
518 |
}
|
|
519 |
|
|
520 |
|
|
521 |
TInt CUSBUiNotifApiTest::FinishQuery( CStifItemParser& aItem )
|
44
|
522 |
{
|
52
|
523 |
iLog -> Log( _L("FinishQuery") );
|
44
|
524 |
TInt res;
|
52
|
525 |
TPtrC optionName( KNullDesC );
|
44
|
526 |
TTestOption option;
|
|
527 |
|
|
528 |
if ( iCompleteQuery )
|
|
529 |
{
|
52
|
530 |
iLog -> Log( _L("FinishQuery completing request") );
|
44
|
531 |
TRequestStatus* statPtr = &iReqStatus;
|
|
532 |
User::RequestComplete( statPtr, KErrNone );
|
52
|
533 |
}
|
44
|
534 |
|
52
|
535 |
iLog -> Log( _L("FinishQuery getting options") );
|
|
536 |
res = aItem.GetString( _L( "FinishQuery" ), optionName );
|
44
|
537 |
if ( res != KErrNone )
|
|
538 |
{
|
52
|
539 |
iLog -> Log( _L("GetString failed with value: %d"), res );
|
44
|
540 |
iNotifier -> Close();
|
|
541 |
return res;
|
|
542 |
}
|
|
543 |
|
52
|
544 |
res = GetTestOption( optionName, option );
|
|
545 |
if ( res != KErrNone )
|
|
546 |
{
|
|
547 |
iLog -> Log( _L("GetTestOption failed with value: %d"), res );
|
|
548 |
iNotifier -> Close();
|
|
549 |
return res;
|
|
550 |
}
|
|
551 |
|
|
552 |
iLog -> Log( _L("FinishQuery waiting for request") );
|
|
553 |
User::WaitForRequest( iReqStatus );
|
|
554 |
iLog -> Log( _L("FinishQuery closing notifier") );
|
44
|
555 |
iNotifier -> Close();
|
52
|
556 |
iNotifierConnected = EFalse;
|
44
|
557 |
|
|
558 |
switch( option )
|
|
559 |
{
|
|
560 |
case EQueryAccepted:
|
52
|
561 |
iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
|
44
|
562 |
STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
|
|
563 |
break;
|
|
564 |
case EQueryCanceled:
|
52
|
565 |
iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
|
44
|
566 |
STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
|
|
567 |
break;
|
|
568 |
default:
|
|
569 |
return KErrNotFound;
|
|
570 |
}
|
|
571 |
|
52
|
572 |
iLog -> Log( _L("Test case passed!") );
|
44
|
573 |
return KErrNone;
|
|
574 |
}
|
|
575 |
|
52
|
576 |
TInt CUSBUiNotifApiTest::LoadNotifiersL( CStifItemParser& /*aItem*/ )
|
44
|
577 |
{
|
|
578 |
iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>(
|
|
579 |
REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid));
|
52
|
580 |
return KErrNone;
|
44
|
581 |
}
|
52
|
582 |
|
|
583 |
TInt CUSBUiNotifApiTest::UnLoadNotifiers ( CStifItemParser& /*aItem*/ )
|
44
|
584 |
{
|
|
585 |
TInt count = iNotifierArray->Count();
|
|
586 |
TInt i=0;
|
|
587 |
for (i=0; i<count; i++)
|
|
588 |
{
|
|
589 |
iNotifierArray->At(i)->Release();
|
|
590 |
}
|
|
591 |
iNotifierArray->Reset();
|
|
592 |
delete iNotifierArray;
|
52
|
593 |
iNotifierArray = NULL;
|
44
|
594 |
REComSession::DestroyedImplementation(iInstanceUid);
|
52
|
595 |
return KErrNone;
|
44
|
596 |
}
|
52
|
597 |
|
|
598 |
TInt CUSBUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType )
|
44
|
599 |
{
|
|
600 |
if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) )
|
|
601 |
{
|
|
602 |
aQueryType = EUSBNoMemoryCard;
|
52
|
603 |
iLog -> Log( _L("Query type: EUSBNoMemoryCard") );
|
44
|
604 |
}
|
|
605 |
else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) )
|
|
606 |
{
|
|
607 |
aQueryType = EUSBStorageMediaFailure;
|
52
|
608 |
iLog -> Log( _L("Query type: EUSBStorageMediaFailure") );
|
44
|
609 |
}
|
52
|
610 |
else if ( !aTypeString.Compare( _L( "EUSBDiskFull" ) ) )
|
44
|
611 |
{
|
52
|
612 |
aQueryType = EUSBDiskFull;
|
|
613 |
iLog -> Log( _L("Query type: EUSBDiskFull") );
|
|
614 |
}
|
|
615 |
else if ( !aTypeString.Compare( _L( "EUSBNotEnoughRam" ) ) )
|
|
616 |
{
|
|
617 |
aQueryType = EUSBNotEnoughRam;
|
|
618 |
iLog -> Log( _L("Query type: EUSBNotEnoughRam") );
|
44
|
619 |
}
|
|
620 |
else
|
|
621 |
{
|
52
|
622 |
iLog -> Log( _L("Query type: not supported") );
|
44
|
623 |
return KErrNotFound;
|
|
624 |
}
|
52
|
625 |
|
44
|
626 |
return KErrNone;
|
|
627 |
}
|
|
628 |
|
52
|
629 |
TInt CUSBUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType )
|
44
|
630 |
{
|
|
631 |
if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) )
|
|
632 |
{
|
|
633 |
aQueryType = EUsbOtgTooMuchPower;
|
52
|
634 |
iLog -> Log( _L("Query type: EUsbOtgTooMuchPower") );
|
44
|
635 |
}
|
|
636 |
else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) )
|
|
637 |
{
|
|
638 |
aQueryType = EUsbOtgTooMuchPowerRequired;
|
52
|
639 |
iLog -> Log( _L("Query type: EUsbOtgTooMuchPowerRequired") );
|
44
|
640 |
}
|
|
641 |
else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) )
|
|
642 |
{
|
|
643 |
aQueryType = EUsbOtgUnsupportedDevice;
|
52
|
644 |
iLog -> Log( _L("Query type: EUsbOtgUnsupportedDevice") );
|
44
|
645 |
}
|
|
646 |
else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) )
|
|
647 |
{
|
|
648 |
aQueryType = EUsbOtgHubUnsupported;
|
52
|
649 |
iLog -> Log( _L("Query type: EUsbOtgHubUnsupported") );
|
44
|
650 |
}
|
|
651 |
else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) )
|
|
652 |
{
|
|
653 |
aQueryType = EUsbOtgErrorInConnection;
|
52
|
654 |
iLog -> Log( _L("Query type: EUsbOtgErrorInConnection") );
|
44
|
655 |
}
|
|
656 |
else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) )
|
|
657 |
{
|
|
658 |
aQueryType = EUsbOtgErrorAttachTimedOut;
|
52
|
659 |
iLog -> Log( _L("Query type: EUsbOtgErrorAttachTimedOut") );
|
|
660 |
}
|
|
661 |
else if ( !aTypeString.Compare( _L( "EUsbOtgErrorNoMemory" ) ) )
|
|
662 |
{
|
|
663 |
aQueryType = EUsbOtgErrorNoMemory;
|
|
664 |
iLog -> Log( _L("Query type: EUsbOtgErrorNoMemory") );
|
44
|
665 |
}
|
|
666 |
else
|
|
667 |
{
|
52
|
668 |
iLog -> Log( _L("Query type: not supported") );
|
44
|
669 |
return KErrNotFound;
|
|
670 |
}
|
|
671 |
return KErrNone;
|
|
672 |
}
|
|
673 |
|
|
674 |
|
52
|
675 |
TInt CUSBUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType )
|
44
|
676 |
{
|
|
677 |
if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) )
|
|
678 |
{
|
|
679 |
aQueryType = EUsbOtgPartiallySupportedDevice;
|
52
|
680 |
iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") );
|
44
|
681 |
}
|
|
682 |
else
|
|
683 |
{
|
52
|
684 |
iLog -> Log( _L("Query type: not supported") );
|
44
|
685 |
return KErrNotFound;
|
|
686 |
}
|
52
|
687 |
|
44
|
688 |
return KErrNone;
|
|
689 |
}
|
|
690 |
|
52
|
691 |
TInt CUSBUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType )
|
44
|
692 |
{
|
|
693 |
if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) )
|
|
694 |
{
|
|
695 |
aQueryType = EHostMsErrGeneral;
|
52
|
696 |
iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") );
|
44
|
697 |
}
|
|
698 |
else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) )
|
|
699 |
{
|
|
700 |
aQueryType = EHostMsErrUnknownFileSystem;
|
52
|
701 |
iLog -> Log( _L("Query type: EUsbMSMMUnknownFileSystem") );
|
44
|
702 |
}
|
|
703 |
else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) )
|
|
704 |
{
|
|
705 |
aQueryType = EHostMsErrOutOfMemory;
|
52
|
706 |
iLog -> Log( _L("Query type: EUsbMSMMOutOfMemory") );
|
44
|
707 |
}
|
58
|
708 |
else if ( !aTypeString.Compare( _L( "EUsbMSMMSafeToRemove" ) ) )
|
|
709 |
{
|
|
710 |
aQueryType = EHostMsErrNone;
|
|
711 |
iLog -> Log( _L("Query type: EUsbMSMMSafeToRemove") );
|
|
712 |
}
|
|
713 |
else if ( !aTypeString.Compare( _L( "EUsbMSMMUnableToEject" ) ) )
|
|
714 |
{
|
|
715 |
aQueryType = EHostMsErrInUse;
|
|
716 |
iLog -> Log( _L("Query type: EUsbMSMMUnableToEject") );
|
|
717 |
}
|
44
|
718 |
else
|
|
719 |
{
|
52
|
720 |
iLog -> Log( _L("Query type: not supported") );
|
44
|
721 |
return KErrNotFound;
|
|
722 |
}
|
52
|
723 |
|
44
|
724 |
return KErrNone;
|
|
725 |
}
|
52
|
726 |
|
44
|
727 |
// -----------------------------------------------------------------------------
|
52
|
728 |
// CBtNotifApiTest::GetTestOption
|
44
|
729 |
// -----------------------------------------------------------------------------
|
|
730 |
|
52
|
731 |
TInt CUSBUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption )
|
44
|
732 |
{
|
|
733 |
if ( !aOptionString.Compare( _L( "DISCARD" ) ) )
|
|
734 |
{
|
|
735 |
aOption = EQueryDiscarded;
|
52
|
736 |
iLog -> Log( _L("Test type: EQueryDiscarded") );
|
44
|
737 |
}
|
|
738 |
else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) )
|
|
739 |
{
|
|
740 |
aOption = EQueryAccepted;
|
52
|
741 |
iLog -> Log( _L("Test type: EQueryAccepted") );
|
44
|
742 |
}
|
|
743 |
else if ( !aOptionString.Compare( _L( "CANCEL" ) ) )
|
|
744 |
{
|
|
745 |
aOption = EQueryCanceled;
|
52
|
746 |
iLog -> Log( _L("Test type: EQueryCanceled") );
|
44
|
747 |
}
|
|
748 |
else
|
|
749 |
{
|
52
|
750 |
iLog -> Log( _L("Test type: not supported") );
|
44
|
751 |
return KErrNotFound;
|
|
752 |
}
|
|
753 |
|
|
754 |
return KErrNone;
|
|
755 |
}
|
|
756 |
|
|
757 |
// -----------------------------------------------------------------------------
|
52
|
758 |
// CBtNotifApiTest::GetPersonalityIdFromString
|
44
|
759 |
// -----------------------------------------------------------------------------
|
|
760 |
|
52
|
761 |
TInt CUSBUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId )
|
44
|
762 |
{
|
|
763 |
if ( !aOptionString.Compare( _L( "MS" ) ) )
|
|
764 |
{
|
|
765 |
aPersonalityId = KUsbPersonalityIdMS;
|
52
|
766 |
iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMS") );
|
44
|
767 |
}
|
52
|
768 |
else if ( !aOptionString.Compare( _L( "PTP" ) ) )
|
44
|
769 |
{
|
52
|
770 |
aPersonalityId = KUsbPersonalityIdPTP;
|
|
771 |
iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPTP") );
|
44
|
772 |
}
|
|
773 |
else if ( !aOptionString.Compare( _L( "MTP" ) ) )
|
|
774 |
{
|
|
775 |
aPersonalityId = KUsbPersonalityIdMTP;
|
52
|
776 |
iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMTP") );
|
44
|
777 |
}
|
|
778 |
else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) )
|
|
779 |
{
|
|
780 |
aPersonalityId = KUsbPersonalityIdPCSuiteMTP;
|
52
|
781 |
iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") );
|
44
|
782 |
}
|
|
783 |
else
|
|
784 |
{
|
52
|
785 |
iLog -> Log( _L("Usb personality type: not found") );
|
44
|
786 |
return KErrNotFound;
|
|
787 |
}
|
|
788 |
|
|
789 |
return KErrNone;
|
|
790 |
}
|
|
791 |
|
52
|
792 |
|
|
793 |
TInt CUSBUiNotifApiTest::FindAndKillProcess(const TDesC& aProcessName)
|
|
794 |
{
|
|
795 |
iLog -> Log( _L("FindAndKillProcess") );
|
|
796 |
TInt ret = KErrNotFound;
|
|
797 |
RProcess process;
|
|
798 |
TFindProcess findProc;
|
|
799 |
findProc.Find(aProcessName);
|
|
800 |
TFullName procName;
|
|
801 |
ret = findProc.Next(procName);
|
|
802 |
iLog -> Log( _L("FindAndKillProcess findProc returned: %d"), ret );
|
|
803 |
if (ret == KErrNone)
|
|
804 |
{
|
|
805 |
ret = process.Open(procName, EOwnerThread);
|
|
806 |
iLog -> Log( _L("FindAndKillProcess process open returned: %d"), ret );
|
|
807 |
if (ret == KErrNone)
|
|
808 |
{
|
|
809 |
process.Terminate(KErrNone);
|
|
810 |
process.Close();
|
|
811 |
}
|
|
812 |
}
|
|
813 |
return ret;
|
|
814 |
}
|
|
815 |
|
44
|
816 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
817 |
// None
|
|
818 |
|
|
819 |
// [End of File] - Do not remove
|