62
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
87
|
19 |
#include <StifTestInterface.h>
|
62
|
20 |
#include <SettingServerClient.h>
|
|
21 |
#include "UsbOtgWatcherTest.h"
|
|
22 |
#include "testdebug.h"
|
|
23 |
|
|
24 |
// EXTERNAL DATA STRUCTURES
|
|
25 |
|
|
26 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
27 |
|
|
28 |
// CONSTANTS
|
|
29 |
|
|
30 |
// MACROS
|
|
31 |
|
|
32 |
// LOCAL CONSTANTS AND MACROS
|
|
33 |
|
|
34 |
// MODULE DATA STRUCTURES
|
|
35 |
|
|
36 |
// LOCAL FUNCTION PROTOTYPES
|
|
37 |
|
|
38 |
// FORWARD DECLARATIONS
|
|
39 |
|
|
40 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
|
|
45 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
46 |
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
// CUsbOtgWatcherTest::CUsbOtgWatcherTest
|
|
49 |
// C++ default constructor can NOT contain any code, that
|
|
50 |
// might leave.
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CtUsbOtgWatcher::CtUsbOtgWatcher(
|
|
54 |
CTestModuleIf& aTestModuleIf ):
|
|
55 |
CScriptBase( aTestModuleIf )
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CtUsbOtgWatcher::ConstructL
|
|
61 |
// Symbian 2nd phase constructor can leave.
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CtUsbOtgWatcher::ConstructL()
|
|
65 |
{
|
|
66 |
//Read logger settings to check whether test case name is to be
|
|
67 |
//appended to log file name.
|
|
68 |
RSettingServer settingServer;
|
|
69 |
TInt ret = settingServer.Connect();
|
|
70 |
if(ret != KErrNone)
|
|
71 |
{
|
|
72 |
User::Leave(ret);
|
|
73 |
}
|
|
74 |
// Struct to StifLogger settigs.
|
|
75 |
TLoggerSettings loggerSettings;
|
|
76 |
// Parse StifLogger defaults from STIF initialization file.
|
|
77 |
ret = settingServer.GetLoggerSettings( loggerSettings );
|
|
78 |
if( ret != KErrNone )
|
|
79 |
{
|
|
80 |
User::Leave( ret );
|
|
81 |
}
|
|
82 |
// Close Setting server session
|
|
83 |
settingServer.Close();
|
|
84 |
|
|
85 |
TFileName logFileName;
|
|
86 |
|
|
87 |
if( loggerSettings.iAddTestCaseTitle )
|
|
88 |
{
|
|
89 |
TName title;
|
|
90 |
TestModuleIf().GetTestCaseTitleL( title );
|
|
91 |
logFileName.Format( KUsbOtgWatcherTestLogFileWithTitle, &title );
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
|
95 |
logFileName.Copy( KUsbOtgWatcherTestLogFile );
|
|
96 |
}
|
|
97 |
|
|
98 |
iLog = CStifLogger::NewL( KUsbOtgWatcherTestLogPath,
|
|
99 |
logFileName,
|
|
100 |
CStifLogger::ETxt,
|
|
101 |
CStifLogger::EFile,
|
|
102 |
EFalse );
|
|
103 |
|
|
104 |
SendTestClassVersion();
|
|
105 |
TestConstructL();
|
|
106 |
}
|
|
107 |
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
// CtUsbOtgWatcher::NewL
|
|
110 |
// Two-phased constructor.
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
CtUsbOtgWatcher* CtUsbOtgWatcher::NewL(
|
|
114 |
CTestModuleIf& aTestModuleIf )
|
|
115 |
{
|
|
116 |
CtUsbOtgWatcher* self = new (ELeave) CtUsbOtgWatcher( aTestModuleIf );
|
|
117 |
CleanupStack::PushL( self );
|
|
118 |
self->ConstructL();
|
|
119 |
CleanupStack::Pop();
|
|
120 |
return self;
|
|
121 |
}
|
|
122 |
|
|
123 |
// Destructor
|
|
124 |
CtUsbOtgWatcher::~CtUsbOtgWatcher()
|
|
125 |
{
|
|
126 |
|
|
127 |
// Delete resources allocated from test methods
|
|
128 |
TestDelete();
|
|
129 |
|
|
130 |
// Delete logger
|
|
131 |
delete iLog;
|
|
132 |
|
|
133 |
}
|
|
134 |
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
// CtUsbOtgWatcher::RunMethodL
|
|
137 |
// Run specified method. Contains also table of test mothods and their names.
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
|
|
140 |
TInt CtUsbOtgWatcher::RunMethodL(
|
|
141 |
CStifItemParser& aItem )
|
|
142 |
{
|
|
143 |
return ExecuteTestBlock( aItem );
|
|
144 |
}
|
|
145 |
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
// CtUsbOtgWatcher::ExecuteTestBlock
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
|
|
150 |
TInt CtUsbOtgWatcher::ExecuteTestBlock( CStifItemParser& aItem )
|
|
151 |
{
|
|
152 |
TRACE_FUNC_ENTRY
|
|
153 |
iItem = &aItem;
|
|
154 |
TInt res;
|
|
155 |
TUsbOtgWatcherTestResult testResult = ETestCaseFailed;
|
|
156 |
|
|
157 |
res = iItem -> GetString( _L( "tester" ), iTestBlockParams.iTestBlockName );
|
|
158 |
if ( res != KErrNone )
|
|
159 |
{
|
|
160 |
TRACE_INFO( "Getting test block name failed with: %d", res )
|
|
161 |
TRACE_FUNC_EXIT
|
|
162 |
return res;
|
|
163 |
}
|
|
164 |
TRACE_INFO( "Test block name: %S", &iTestBlockParams.iTestBlockName )
|
|
165 |
|
|
166 |
TRACE( "Extracting test block parameters..." )
|
|
167 |
TRAP( res, TestBlocksInfoL() );
|
|
168 |
if ( res != KErrNone )
|
|
169 |
{
|
|
170 |
TRACE_INFO( "Extracting parameters failed: %d", res )
|
|
171 |
TRACE_FUNC_EXIT
|
|
172 |
return res;
|
|
173 |
}
|
|
174 |
if ( !iTestBlockFound )
|
|
175 |
{
|
|
176 |
TRACE( "Test block not found!" )
|
|
177 |
TRACE_FUNC_EXIT
|
|
178 |
return KErrNotFound;
|
|
179 |
}
|
|
180 |
TRACE( "Extracting parameters successful" )
|
|
181 |
|
|
182 |
TRAP( res, ( this ->*iTestBlockFunction )( iTestBlockParams, testResult ) );
|
|
183 |
if ( res != KErrNone )
|
|
184 |
{
|
|
185 |
TRACE_INFO( "ExecuteTestBlockL error: %d", res )
|
|
186 |
TRACE_FUNC_EXIT
|
|
187 |
return res;
|
|
188 |
}
|
|
189 |
|
|
190 |
if (ETestCasePassed != testResult)
|
|
191 |
{
|
|
192 |
return KErrGeneral;
|
|
193 |
}
|
|
194 |
TRACE( "Test block passed!" );
|
|
195 |
TRACE_FUNC_EXIT
|
|
196 |
return KErrNone;
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CtUsbOtgWatcher::GetTestBlockParamL
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
|
|
203 |
void CtUsbOtgWatcher::GetTestBlockParamL( TGetTestBlockParamOperation aOperation, TTestBlockParamName aParamName )
|
|
204 |
{
|
|
205 |
switch( aOperation )
|
|
206 |
{
|
|
207 |
case eGetString:
|
|
208 |
{
|
|
209 |
switch ( aParamName )
|
|
210 |
{
|
|
211 |
case eTestOption1:
|
|
212 |
{
|
|
213 |
User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption1 ) );
|
|
214 |
break;
|
|
215 |
}
|
|
216 |
case eTestOption2:
|
|
217 |
{
|
|
218 |
User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption2 ) );
|
|
219 |
break;
|
|
220 |
}
|
|
221 |
case eTestOption3:
|
|
222 |
{
|
|
223 |
User::LeaveIfError( iItem -> GetNextString( iTestBlockParams.iTestOption3 ) );
|
|
224 |
break;
|
|
225 |
}
|
|
226 |
default:
|
|
227 |
{
|
|
228 |
User::Leave( KErrArgument );
|
|
229 |
break;
|
|
230 |
}
|
|
231 |
}
|
|
232 |
break;
|
|
233 |
}
|
|
234 |
case eGetInt:
|
|
235 |
{
|
|
236 |
switch ( aParamName )
|
|
237 |
{
|
|
238 |
case eTestIntOption1:
|
|
239 |
{
|
|
240 |
User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption1 ) );
|
|
241 |
break;
|
|
242 |
}
|
|
243 |
case eTestIntOption2:
|
|
244 |
{
|
|
245 |
User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption2 ) );
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
case eTestIntOption3:
|
|
249 |
{
|
|
250 |
User::LeaveIfError( iItem -> GetNextInt( iTestBlockParams.iTestIntOption3 ) );
|
|
251 |
break;
|
|
252 |
}
|
|
253 |
default:
|
|
254 |
{
|
|
255 |
User::Leave( KErrArgument );
|
|
256 |
break;
|
|
257 |
}
|
|
258 |
}
|
|
259 |
break;
|
|
260 |
}
|
|
261 |
case eGetChar:
|
|
262 |
{
|
|
263 |
switch ( aParamName )
|
|
264 |
{
|
|
265 |
case eTestCharOption1:
|
|
266 |
{
|
|
267 |
User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption1 ) );
|
|
268 |
break;
|
|
269 |
}
|
|
270 |
case eTestCharOption2:
|
|
271 |
{
|
|
272 |
User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption2 ) );
|
|
273 |
break;
|
|
274 |
}
|
|
275 |
case eTestCharOption3:
|
|
276 |
{
|
|
277 |
User::LeaveIfError( iItem -> GetNextChar( iTestBlockParams.iTestCharOption3 ) );
|
|
278 |
break;
|
|
279 |
}
|
|
280 |
default:
|
|
281 |
{
|
|
282 |
User::Leave( KErrArgument );
|
|
283 |
}
|
|
284 |
}
|
|
285 |
break;
|
|
286 |
}
|
|
287 |
default:
|
|
288 |
{
|
|
289 |
User::Leave( KErrArgument );
|
|
290 |
}
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
//-----------------------------------------------------------------------------
|
|
295 |
// CtUsbOtgWatcher::SendTestClassVersion
|
|
296 |
// Method used to send version of test class
|
|
297 |
//-----------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
void CtUsbOtgWatcher::SendTestClassVersion()
|
|
300 |
{
|
|
301 |
TVersion moduleVersion;
|
|
302 |
moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
|
|
303 |
moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
|
|
304 |
moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
|
|
305 |
|
|
306 |
TFileName moduleName;
|
|
307 |
moduleName = _L("UsbOtgWatcherTest.dll");
|
|
308 |
|
|
309 |
TBool newVersionOfMethod = ETrue;
|
|
310 |
TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
|
|
311 |
}
|
|
312 |
|
|
313 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
314 |
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
// LibEntryL is a polymorphic Dll entry point.
|
|
317 |
// Returns: CScriptBase: New CScriptBase derived object
|
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
//
|
|
320 |
EXPORT_C CScriptBase* LibEntryL(
|
|
321 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
|
|
322 |
{
|
|
323 |
|
|
324 |
return ( CScriptBase* ) CtUsbOtgWatcher::NewL( aTestModuleIf );
|
|
325 |
|
|
326 |
}
|
|
327 |
|
|
328 |
|
|
329 |
// End of File
|