|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: CCollectionHelperTestClass heder for STIF Test Framework TestScripter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef COLLECTIONHELPERTESTCLASS_H |
|
21 #define COLLECTIONHELPERTESTCLASS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <StifLogger.h> |
|
25 #include <TestScripterInternal.h> |
|
26 #include <StifTestModule.h> |
|
27 #include <mpxcollectionutility.h> |
|
28 #include <mpxcollectionpath.h> |
|
29 #include <mpxcollectionplaylist.h> |
|
30 #include <mpxcollectionmessage.h> |
|
31 #include <mpxcollectionframeworkdefs.h> |
|
32 #include "mpxcollectionhelper.h" |
|
33 #include "mpxcollectionhelperfactory.h" |
|
34 #include "mpxcollectionhelperobserver.h" |
|
35 #include "mpxcollectionuihelper.h" |
|
36 #include "mpxcollectionuihelperobserver.h" |
|
37 |
|
38 #include "TimeoutController.h" |
|
39 |
|
40 |
|
41 // CONSTANTS |
|
42 const TInt KErrBadTestParameter= -1000; // Error on configuration file |
|
43 |
|
44 const TInt KErrEventPending =-2000; // Timeout and not callback |
|
45 const TInt KErrCallbackErrorCode = -2001; // Callback return error code |
|
46 const TInt KErrUnexpectedValue =-2002; // Unexpected value at setting |
|
47 const TInt KExpectedFrequencyChange = -2003; // Is not finding more than one station |
|
48 const TInt KErrTimeoutController = -2007; // Unexpected notification |
|
49 |
|
50 const TInt KSmallTimeout = 1000; |
|
51 const TInt KMediumTimeout = 4000; |
|
52 const TInt KLargeTimeout = 100000; |
|
53 |
|
54 |
|
55 _LIT( KMsgBadTestParameters, "[Error] No valid test case parameters"); |
|
56 |
|
57 |
|
58 // MACROS |
|
59 //#define ?macro ?macro_def |
|
60 // Logging path |
|
61 #ifdef __WINSCW__ |
|
62 _LIT( KCollectionHelperTestClassLogPath, "\\logs\\testframework\\CollectionHelperTestClass\\" ); |
|
63 #else |
|
64 _LIT( KCollectionHelperTestClassLogPath, "e:\\logs\\testframework\\CollectionHelperTestClass\\" ); |
|
65 #endif |
|
66 |
|
67 // Log file |
|
68 _LIT( KCollectionHelperTestClassLogFile, "CollectionHelperTestClass.txt" ); |
|
69 |
|
70 |
|
71 _LIT( KTestFile, "c:\\Blackbird.aac"); |
|
72 _LIT( KTestFileMimeType, "audio/aac" ); |
|
73 _LIT( KRenameOldUri, "c:\\Blackbird.aac"); |
|
74 _LIT( KRenameNewUri, "c:\\data\\Blackbird.aac"); |
|
75 |
|
76 |
|
77 // FORWARD DECLARATIONS |
|
78 class CCollectionHelperTestClass; |
|
79 |
|
80 |
|
81 /** |
|
82 * CCollectionHelperTestClass test class for STIF Test Framework TestScripter. |
|
83 * ?other_description_lines |
|
84 * |
|
85 * @lib ?library |
|
86 * @since ?Series60_version |
|
87 */ |
|
88 NONSHARABLE_CLASS(CCollectionHelperTestClass) : public CScriptBase, |
|
89 public MTimeoutObserver, |
|
90 public MMPXCollectionHelperObserver, |
|
91 public MMPXCHelperObserver, |
|
92 public MMPXCHelperEmbeddedOpenObserver, public MMPXCollectionObserver, |
|
93 public MMPXCollectionRemoveObserver, |
|
94 public MMPXCollectionFindObserver |
|
95 |
|
96 { |
|
97 public: // Constructors and destructor |
|
98 |
|
99 /** |
|
100 * Two-phased constructor. |
|
101 */ |
|
102 static CCollectionHelperTestClass* NewL( CTestModuleIf& aTestModuleIf ); |
|
103 |
|
104 /** |
|
105 * Destructor. |
|
106 */ |
|
107 virtual ~CCollectionHelperTestClass(); |
|
108 |
|
109 enum TCollectionHelperExpectedEvent |
|
110 { |
|
111 EHandleCollectionMessage, |
|
112 EHandleOpen, |
|
113 EHandleAddFileComplete, |
|
114 EHandleRemove, |
|
115 EHandleFindAllComplete |
|
116 }; |
|
117 |
|
118 public: // New functions |
|
119 |
|
120 /** |
|
121 * Callback function to signal that adding a file is complete |
|
122 * @param aErr, error of the operation |
|
123 */ |
|
124 virtual void HandleAddFileCompleteL( TInt aErr ); |
|
125 |
|
126 /** |
|
127 * Generic Observer class for the ui helper |
|
128 * A single callback function, but usable for all collection helper callbacks |
|
129 */ |
|
130 virtual void HandleOperationCompleteL( TCHelperOperation aOperation, |
|
131 TInt aErr, |
|
132 void* aArgument ); |
|
133 |
|
134 /** |
|
135 * Callback to the observer for embedded OpenL() result |
|
136 * @param aErr, error for the operation, KErrNone if successful |
|
137 * @param aCategory, category of the file opened |
|
138 */ |
|
139 virtual void HandleEmbeddedOpenL( TInt aErr, TMPXGeneralCategory aCategory ); |
|
140 |
|
141 /** |
|
142 * From MMPXCollectionObserver |
|
143 * Handle extended media properties |
|
144 * @param aMedia media |
|
145 * @param aError error code |
|
146 */ |
|
147 void HandleCollectionMediaL( |
|
148 const CMPXMedia& aMedia, |
|
149 TInt aError); |
|
150 |
|
151 /** |
|
152 * From MMPXCollectionObserver |
|
153 * Handle collection message |
|
154 * @param aMessage collection message |
|
155 */ |
|
156 void HandleCollectionMessageL(const CMPXMessage& aMsg); |
|
157 |
|
158 /** |
|
159 * From MMPXCollectionObserver |
|
160 * Handles the collection entries being opened. Typically called |
|
161 * when client has Open()'d a folder |
|
162 * |
|
163 * @param aEntries collection entries opened |
|
164 * @param aIndex focused entry |
|
165 * @param aComplete ETrue no more entries. EFalse more entries |
|
166 * expected |
|
167 * @param aError error code |
|
168 */ |
|
169 void HandleOpenL(const CMPXMedia& aEntries, |
|
170 TInt aIndex,TBool aComplete,TInt aError); |
|
171 |
|
172 /** |
|
173 * From MMPXCollectionObserver |
|
174 * Handles the item being opened. Typically called |
|
175 * when client has Open()'d an item. Client typically responds by |
|
176 * 'playing' the item via the playlist |
|
177 * |
|
178 * @param aPlaylist collection playlist, owner ship is transfered |
|
179 * @param aError error code |
|
180 */ |
|
181 void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError); |
|
182 |
|
183 |
|
184 void HandleCommandComplete(CMPXCommand* aCommandResult, TInt aError); |
|
185 |
|
186 public: // Functions from base classes |
|
187 |
|
188 /** |
|
189 * From CScriptBase Runs a script line. |
|
190 * @since ?Series60_version |
|
191 * @param aItem Script line containing method name and parameters |
|
192 * @return Symbian OS error code |
|
193 */ |
|
194 virtual TInt RunMethodL( CStifItemParser& aItem ); |
|
195 |
|
196 |
|
197 // From MTimeoutObserver |
|
198 |
|
199 /** |
|
200 * @since 3.2 |
|
201 * @param none |
|
202 * Review if all the expected events have ocurred once the time is over |
|
203 */ |
|
204 void HandleTimeout(TInt error); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * C++ default constructor. |
|
210 */ |
|
211 CCollectionHelperTestClass( CTestModuleIf& aTestModuleIf ); |
|
212 |
|
213 /** |
|
214 * By default Symbian 2nd phase constructor is private. |
|
215 */ |
|
216 void ConstructL(); |
|
217 |
|
218 // Prohibit copy constructor if not deriving from CBase. |
|
219 // ?classname( const ?classname& ); |
|
220 // Prohibit assigment operator if not deriving from CBase. |
|
221 // ?classname& operator=( const ?classname& ); |
|
222 |
|
223 /** |
|
224 * Frees all resources allocated from test methods. |
|
225 * @since ?Series60_version |
|
226 */ |
|
227 void Delete(); |
|
228 |
|
229 /** |
|
230 * Test methods are listed below. |
|
231 */ |
|
232 |
|
233 /** |
|
234 * Example test method. |
|
235 * @since S60 3.2 |
|
236 * @param aItem Script line containing parameters. |
|
237 * @return Symbian OS error code. |
|
238 */ |
|
239 |
|
240 /** |
|
241 * Set an event as expected and set default timeout |
|
242 * @since S60 3.2 |
|
243 */ |
|
244 void AddExpectedEvent(TCollectionHelperExpectedEvent event, TInt ms); |
|
245 |
|
246 |
|
247 /** |
|
248 * Unset an event as expected |
|
249 * @since S60 3.2 |
|
250 */ |
|
251 TBool RemoveExpectedEvent(TCollectionHelperExpectedEvent event); |
|
252 |
|
253 |
|
254 /** |
|
255 * @since S60 3.2 |
|
256 * @param none |
|
257 * Removes all expected events |
|
258 */ |
|
259 void RemoveAllExpectedEvents(); |
|
260 |
|
261 /** |
|
262 * Verify that the event was expected, removes it from the list |
|
263 * Signal the TestScripter with the returned error code |
|
264 * @since S60 3.2 |
|
265 */ |
|
266 void ProcessEvent(TCollectionHelperExpectedEvent aEvent, TInt aError); |
|
267 |
|
268 /** |
|
269 * Maps a event with a descriptor with its name |
|
270 * @since S60 3.2 |
|
271 */ |
|
272 TPtrC EventName( TInt aKey ); |
|
273 |
|
274 /* |
|
275 * Test methods are listed below. |
|
276 */ |
|
277 |
|
278 /** |
|
279 * Sets a timeout different since the default |
|
280 * @since S60 3.2 |
|
281 * @param aItem Script line containing parameters. |
|
282 * @return Symbian OS error code. |
|
283 */ |
|
284 TInt SetTimeout( CStifItemParser& aItem ); |
|
285 |
|
286 /** |
|
287 * |
|
288 * @since S60 3.2 |
|
289 * @param aItem Script line containing parameters. |
|
290 * @return Symbian OS error code. |
|
291 */ |
|
292 TInt SetExpectedEvents( CStifItemParser& aItem ); |
|
293 |
|
294 /** |
|
295 * |
|
296 * @since S60 3.2 |
|
297 * @param aItem Script line containing parameters. |
|
298 * @return Symbian OS error code. |
|
299 */ |
|
300 TInt SetAllowedPanic( CStifItemParser& aItem ); |
|
301 |
|
302 void CreateTestMediaL( CMPXMedia*& aNewProperty ); |
|
303 |
|
304 /** |
|
305 * Connect to the default client to the server |
|
306 * @since S60 3.2 |
|
307 * @param aItem Script line containing parameters. |
|
308 * @return Symbian OS error code. |
|
309 */ |
|
310 |
|
311 virtual TInt ExampleL( CStifItemParser& aItem ); |
|
312 virtual TInt OpenCollectionUtilityL(CStifItemParser& aItem); |
|
313 virtual TInt NewUiHelperL(CStifItemParser& aItem); |
|
314 virtual TInt NewHelperL(CStifItemParser& aItem); |
|
315 virtual TInt NewCachedHelperL(CStifItemParser& aItem); |
|
316 virtual TInt CloseUiHelperL(CStifItemParser& aItem); |
|
317 virtual TInt CloseHelperL(CStifItemParser& aItem); |
|
318 virtual TInt CloseCachedHelperL(CStifItemParser& aItem); |
|
319 |
|
320 |
|
321 /** |
|
322 * From MMPXCollectionRemoveObserver |
|
323 * Handles removing a collection path |
|
324 * calls back with the list of file paths that were deleted |
|
325 * This callback is only applicable for local file storage plugins. |
|
326 * |
|
327 * @param aUriArray, list of files that were deleted |
|
328 */ |
|
329 void HandleRemoveL(MDesCArray& aUriArray, TInt aError); |
|
330 |
|
331 //*********************************************************************** |
|
332 |
|
333 /** |
|
334 * From MMPXCollectionFindObserver |
|
335 * Handle callback for "find" operation |
|
336 * @param aEntries, CMPXMedia to be returned |
|
337 * @param aComplete ETrue no more entries. EFalse more entries |
|
338 * expected |
|
339 * @param aError error code |
|
340 */ |
|
341 void HandleFindAllL(const CMPXMedia& aResults, TBool aComplete,TInt aError); |
|
342 |
|
343 public: // Data |
|
344 |
|
345 protected: // Data |
|
346 |
|
347 private: // Data |
|
348 |
|
349 // reference to TestModuleIf |
|
350 CTestModuleIf& iTestModuleIf; |
|
351 |
|
352 MMPXCollectionUtility* iCollectionUtility; |
|
353 |
|
354 //NewUiHelperL() |
|
355 MMPXCollectionUiHelper* iUIHelper; |
|
356 |
|
357 //NewHelperL() |
|
358 MMPXCollectionHelper* iHelper; |
|
359 |
|
360 //NewCachedHelperL() |
|
361 MMPXCollectionHelper* iCachedHelper; |
|
362 |
|
363 // Active object with a timer to timeout the test case |
|
364 CSimpleTimeout * iTimeoutController; |
|
365 |
|
366 // Indicates if the test case use a normal exit reason |
|
367 TBool iNormalExitReason; |
|
368 |
|
369 // List of expected events |
|
370 RArray<TCollectionHelperExpectedEvent> iExpectedEvents; |
|
371 |
|
372 // List of notification event (by the callback) |
|
373 RArray<TCollectionHelperExpectedEvent> iOcurredEvents; |
|
374 |
|
375 public: // Friend classes |
|
376 //?friend_class_declaration; |
|
377 protected: // Friend classes |
|
378 //?friend_class_declaration; |
|
379 private: // Friend classes |
|
380 //?friend_class_declaration; |
|
381 |
|
382 }; |
|
383 |
|
384 #endif // COLLECTIONHELPERTESTCLASS_H |
|
385 |
|
386 // End of File |