|
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 #ifndef USBPERSONALITYPLUGINTEST_H |
|
18 #define USBPERSONALITYPLUGINTEST_H |
|
19 // INCLUDES |
|
20 #include <StifLogger.h> |
|
21 #include <TestScripterInternal.h> |
|
22 #include <StifTestModule.h> |
|
23 #include <TestclassAssert.h> |
|
24 #include <usbman.h> |
|
25 #include <cusbpersonalitynotifier.h> |
|
26 #include <cusbpersonalityplugin.h> |
|
27 #include <tusbpersonalityparams.h> |
|
28 #include <usbuinotif.h> |
|
29 #include "UsbPersonalityPluginActiveObject.h" |
|
30 |
|
31 // CONSTANTS |
|
32 // Logging path |
|
33 _LIT( KUsbPersonalityPluginTestLogPath, "\\logs\\testframework\\UsbPersonalityPluginTest\\" ); |
|
34 // Logging path for ATS - for phone builds comment this line |
|
35 //_LIT( KUsbPersonalityPluginTestLogPath, "e:\\testing\\stiflogs\\" ); |
|
36 // Log file |
|
37 _LIT( KUsbPersonalityPluginTestLogFile, "UsbPersonalityPluginTest.txt" ); |
|
38 _LIT( KUsbPersonalityPluginTestLogFileWithTitle, "UsbPersonalityPluginTest_[%S].txt" ); |
|
39 |
|
40 // MACROS |
|
41 #define TEST_CLASS_VERSION_MAJOR 0 |
|
42 #define TEST_CLASS_VERSION_MINOR 0 |
|
43 #define TEST_CLASS_VERSION_BUILD 0 |
|
44 |
|
45 // Macros used to extract test block parameters |
|
46 #define TESTENTRY( A, B )\ |
|
47 if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) )\ |
|
48 { iTestBlockFunction = &B; iTestBlockFound = ETrue; }\ |
|
49 if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) ) |
|
50 |
|
51 #define TESTPARAM( A, B )\ |
|
52 GetTestBlockParamL( ( TGetTestBlockParamOperation ) A, ( TTestBlockParamName ) B ); |
|
53 |
|
54 // FUNCTION PROTOTYPES |
|
55 |
|
56 // FORWARD DECLARATIONS |
|
57 |
|
58 // DATA TYPES |
|
59 |
|
60 // Enum type used to determine test block execution result |
|
61 enum TUsbPersonalityPluginTestResult |
|
62 { |
|
63 ETestCasePassed, ETestCaseFailed |
|
64 }; |
|
65 |
|
66 // Enum type indicating test block parameter which should be used to store |
|
67 // data extracted from test script |
|
68 enum TTestBlockParamName |
|
69 { |
|
70 eTestOption1, |
|
71 eTestOption2, |
|
72 eTestOption3, |
|
73 eTestIntOption1, |
|
74 eTestIntOption2, |
|
75 eTestIntOption3, |
|
76 eTestCharOption1, |
|
77 eTestCharOption2, |
|
78 eTestCharOption3 |
|
79 }; |
|
80 |
|
81 // Enum type used to indicate which get parameter function should be used |
|
82 enum TGetTestBlockParamOperation |
|
83 { |
|
84 eGetString, eGetInt, eGetChar |
|
85 }; |
|
86 |
|
87 enum TUsbPersonalityIds |
|
88 { |
|
89 EMassStorage = 2, EMediaTransfer = 4, EPCSuite = 5 |
|
90 }; |
|
91 // CLASS DECLARATION |
|
92 /** |
|
93 * TUsbPersonalityPluginTestBlockParams test class for storing test block parameters. |
|
94 */ |
|
95 NONSHARABLE_CLASS( TUsbPersonalityPluginTestBlockParams ) |
|
96 { |
|
97 public: |
|
98 TPtrC iTestBlockName; |
|
99 |
|
100 TPtrC iTestOption1; |
|
101 TPtrC iTestOption2; |
|
102 TPtrC iTestOption3; |
|
103 |
|
104 TInt iTestIntOption1; |
|
105 TInt iTestIntOption2; |
|
106 TInt iTestIntOption3; |
|
107 |
|
108 TChar iTestCharOption1; |
|
109 TChar iTestCharOption2; |
|
110 TChar iTestCharOption3; |
|
111 }; |
|
112 |
|
113 /** |
|
114 * CUsbPersonalityPluginTest test class for STIF Test Framework TestScripter. |
|
115 */ |
|
116 NONSHARABLE_CLASS( CUsbPersonalityPluginTest ) : public CScriptBase |
|
117 { |
|
118 public: |
|
119 // Constructors and destructor |
|
120 |
|
121 /** |
|
122 * Two-phased constructor. |
|
123 */ |
|
124 static CUsbPersonalityPluginTest* NewL(CTestModuleIf& aTestModuleIf); |
|
125 |
|
126 /** |
|
127 * Destructor. |
|
128 */ |
|
129 virtual ~CUsbPersonalityPluginTest(); |
|
130 |
|
131 public: |
|
132 // New functions |
|
133 public: |
|
134 // Functions from base classes |
|
135 |
|
136 /** |
|
137 * From CScriptBase Runs a script line. |
|
138 * @since ?Series60_version |
|
139 * @param aItem Script line containing method name and parameters |
|
140 * @return Symbian OS error code |
|
141 */ |
|
142 virtual TInt RunMethodL(CStifItemParser& aItem); |
|
143 |
|
144 protected: |
|
145 // New functions |
|
146 protected: |
|
147 // Functions from base classes |
|
148 private: |
|
149 |
|
150 /** |
|
151 * C++ default constructor. |
|
152 */ |
|
153 CUsbPersonalityPluginTest(CTestModuleIf& aTestModuleIf); |
|
154 |
|
155 /** |
|
156 * By default Symbian 2nd phase constructor is private. |
|
157 */ |
|
158 void ConstructL(); |
|
159 |
|
160 /** |
|
161 * Frees all resources allocated from test methods. |
|
162 * @since ?Series60_version |
|
163 */ |
|
164 void TestDelete(); |
|
165 |
|
166 /** |
|
167 * Constructs all test resources for test methods. |
|
168 */ |
|
169 void TestConstructL(); |
|
170 |
|
171 /** |
|
172 * Extracts test block parameters from script file |
|
173 */ |
|
174 void TestBlocksInfoL(); |
|
175 |
|
176 /** |
|
177 * Executes test block |
|
178 */ |
|
179 TInt ExecuteTestBlock(CStifItemParser& aItem); |
|
180 |
|
181 /** |
|
182 * Executes proper get parameter function indicated by its arguments |
|
183 */ |
|
184 void GetTestBlockParamL(TGetTestBlockParamOperation aOperation, |
|
185 TTestBlockParamName aParamName); |
|
186 |
|
187 /** |
|
188 * Method used to log version of test class |
|
189 */ |
|
190 void SendTestClassVersion(); |
|
191 |
|
192 // ADD NEW METHOD DEC HERE |
|
193 // [TestMethods] - Do not remove |
|
194 void ExampleTestL(TUsbPersonalityPluginTestBlockParams& aParams, |
|
195 TUsbPersonalityPluginTestResult& aTestResult); |
|
196 void InitializationTestL(TUsbPersonalityPluginTestBlockParams& aParams, |
|
197 TUsbPersonalityPluginTestResult& aTestResult); |
|
198 void SetPersonalityTestL(TUsbPersonalityPluginTestBlockParams& aParams, |
|
199 TUsbPersonalityPluginTestResult& aTestResult); |
|
200 void ShowNoteTestL(TUsbPersonalityPluginTestBlockParams& aParams, |
|
201 TUsbPersonalityPluginTestResult& aTestResult); |
|
202 void ShowQueryTestL(TUsbPersonalityPluginTestBlockParams& aParams, |
|
203 TUsbPersonalityPluginTestResult& aTestResult); |
|
204 void ShowConnectionNoteTestL( |
|
205 TUsbPersonalityPluginTestBlockParams& aParams, |
|
206 TUsbPersonalityPluginTestResult& aTestResult); |
|
207 void CreatePersonalityPluginTestL( |
|
208 TUsbPersonalityPluginTestBlockParams& aParams, |
|
209 TUsbPersonalityPluginTestResult& aTestResult); |
|
210 void PreparePersonalityStartTestL( |
|
211 TUsbPersonalityPluginTestBlockParams& aParams, |
|
212 TUsbPersonalityPluginTestResult& aTestResult); |
|
213 void FinishPersonalityStartTestL( |
|
214 TUsbPersonalityPluginTestBlockParams& aParams, |
|
215 TUsbPersonalityPluginTestResult& aTestResult); |
|
216 void PreparePersonalityStopTestL( |
|
217 TUsbPersonalityPluginTestBlockParams& aParams, |
|
218 TUsbPersonalityPluginTestResult& aTestResult); |
|
219 void FinishPersonalityStopTestL( |
|
220 TUsbPersonalityPluginTestBlockParams& aParams, |
|
221 TUsbPersonalityPluginTestResult& aTestResult); |
|
222 |
|
223 TInt GetIdFromString(TPtrC aBuffer); |
|
224 TUid GetUidFromId(TInt aId); |
|
225 |
|
226 void InitializeTestObjectsL(); |
|
227 void DeleteTestObjects(); |
|
228 |
|
229 public: |
|
230 // Data |
|
231 protected: |
|
232 // Data |
|
233 private: |
|
234 // Data |
|
235 |
|
236 // Member object used to store test block parameters |
|
237 TUsbPersonalityPluginTestBlockParams iTestBlockParams; |
|
238 |
|
239 // Used to indicate if test block with specified parameters exist |
|
240 TBool iTestBlockFound; |
|
241 |
|
242 // Function pointer used to call proper test block methods |
|
243 void (CUsbPersonalityPluginTest::*iTestBlockFunction)( |
|
244 TUsbPersonalityPluginTestBlockParams&, |
|
245 TUsbPersonalityPluginTestResult&); |
|
246 |
|
247 // Not own |
|
248 CStifItemParser* iItem; |
|
249 |
|
250 RUsb* iUsbMan; |
|
251 CUsbPersonalityNotifier* iNotifier; |
|
252 TUsbPersonalityParams* iParams; |
|
253 CUsbPersonalityPlugin* iPlugin; |
|
254 CUsbPersonalityPluginActiveObject* iActive; |
|
255 TRequestStatus iRequestStatus; |
|
256 // Reserved pointer for future extension |
|
257 //TAny* iReserved; |
|
258 |
|
259 // ADD NEW DATA DEC HERE |
|
260 |
|
261 |
|
262 public: |
|
263 // Friend classes |
|
264 protected: |
|
265 // Friend classes |
|
266 private: |
|
267 // Friend classes |
|
268 |
|
269 }; |
|
270 #endif // USBPERSONALITYPLUGINTEST_H |
|
271 // End of File |