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