|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: ?Description* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef VCXMYVIDEOSCOLLECTIONPLUGINTESTER_H |
|
20 #define VCXMYVIDEOSCOLLECTIONPLUGINTESTER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <StifLogger.h> |
|
24 #include <TestScripterInternal.h> |
|
25 #include <StifTestModule.h> |
|
26 #include <mpxcollectionobserver.h> |
|
27 #include "MVCXMyVideosCollectionPluginTesterObserver.h" |
|
28 #include <mpxmediabase.h> |
|
29 #include <f32file.h> |
|
30 #include "MIptvTestTimerObserver.h" |
|
31 #include "VCXMyVideosTestTransactions.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TUint KOpenCollectionActionId = 10000001; |
|
35 const TUint KOpenCollectionLevelActionId = 10000002; |
|
36 const TUint KRefreshCollectionActionId = 10000003; |
|
37 const TUint KGetMediaFullDetailsActionId = 10000004; |
|
38 const TUint KSideloadVideoActionId = 10000005; |
|
39 const TUint KRemoveMediaActionId = 10000006; |
|
40 |
|
41 // MACROS |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class MMPXCollectionUtility; |
|
45 class CVCXTestCommon; |
|
46 class CVCXMyVideosTestDlWatcher; |
|
47 class CIptvTestActiveWait; |
|
48 class CVCXMyVideosTestDownload; |
|
49 class CIptvTestTimer; |
|
50 class CVCXTestStatsKeeper; |
|
51 |
|
52 // DATA TYPES |
|
53 |
|
54 // CLASS DECLARATION |
|
55 |
|
56 /** |
|
57 * CVCXMyVideosCollectionPluginTester test class |
|
58 * |
|
59 * @lib ?library |
|
60 * @since ?Series60_version |
|
61 */ |
|
62 class CVCXMyVideosCollectionPluginTester : public CBase, |
|
63 public MMPXCollectionObserver, |
|
64 public MIptvTestTimerObserver |
|
65 { |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 static CVCXMyVideosCollectionPluginTester* NewL( MVCXMyVideosCollectionPluginTesterObserver* aObserver, |
|
72 CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper ); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 virtual ~CVCXMyVideosCollectionPluginTester(); |
|
78 |
|
79 public: // New functions |
|
80 |
|
81 /** |
|
82 * Opens MPX collection. |
|
83 * Observer gets message when action is finished. |
|
84 */ |
|
85 void OpenCollectionL( TUint32 aCollectionUid ); |
|
86 |
|
87 /** |
|
88 * Opens MPX collection level. |
|
89 * Observer gets message when action is finished. |
|
90 */ |
|
91 void OpenLevelL( TInt aIndex ); |
|
92 |
|
93 /** |
|
94 * Gets medias by their MPX IDs. A collection must be opened before calling this. |
|
95 * The returned medias are handled as when opening collection. |
|
96 * @param aStartIndex, start index in iMediaArray, first media to get. |
|
97 * @param aEndIndex, end index in iMediaArray, last media to get. |
|
98 */ |
|
99 void GetMediasByMpxIdL( TInt aStartIndex, TInt aEndIndex, TBool aSync ); |
|
100 |
|
101 /** |
|
102 * Opens MPX collection level. |
|
103 * Observer gets message when action is finished. |
|
104 */ |
|
105 void RefreshContentsL(); |
|
106 |
|
107 /** |
|
108 * Closes MPX collection level or collection. |
|
109 * Observer gets message when action is finished. |
|
110 */ |
|
111 void CloseLevelL(); |
|
112 |
|
113 /** |
|
114 * Gets item from MPX and prints details for it. Copy of the media is |
|
115 * stored to member variable and can be fetched with GetLastFullMedia. |
|
116 * Observer gets message when action is finished. |
|
117 */ |
|
118 void GetMediaFullDetailsL( TInt aDrive, TInt aIndex ); |
|
119 |
|
120 /** |
|
121 * Gets item from MPX and prints details for it. Copy of the media is |
|
122 * stored to member variable and can be fetched with GetLastFullMedia. |
|
123 * Observer gets message when action is finished. |
|
124 */ |
|
125 void GetMediaFullDetailsByMpxIdL( TInt aDrive, TInt aIndex, TBool aSync ); |
|
126 |
|
127 /** |
|
128 * Gets the full details for all of the medias and prints them to debug output. |
|
129 */ |
|
130 void GetAllMediaFullDetailsL(); |
|
131 |
|
132 /** |
|
133 * Prints details for items in the current MPX level and |
|
134 * updates the downloads. This is done when collection or collection |
|
135 * level is opened. |
|
136 */ |
|
137 void ProcessCurrentEntriesL(); |
|
138 |
|
139 /** |
|
140 * Prints MPX media object properties. |
|
141 */ |
|
142 void PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle ); |
|
143 |
|
144 /** |
|
145 * Prints MPX media object properties to debug output. |
|
146 */ |
|
147 void PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails ); |
|
148 |
|
149 /** |
|
150 * Returns count of items of the open MPX level. |
|
151 */ |
|
152 TInt GetMediaCount(); |
|
153 |
|
154 /** |
|
155 * Adds media to the collection. |
|
156 * Observer gets message when action is finished. |
|
157 */ |
|
158 void AddMediaL( CMPXMedia* aMedia, TBool aSync ); |
|
159 |
|
160 /** |
|
161 * Updates media in the collection. |
|
162 * Observer gets message when action is finished. |
|
163 */ |
|
164 void SetMediaL( CMPXMedia* aMedia, TBool aSync ); |
|
165 |
|
166 /** |
|
167 * Removes media item with command KMPXCommandIdCollectionRemoveMedia to MV MPX plugin. |
|
168 */ |
|
169 void RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync ); |
|
170 |
|
171 /** |
|
172 * Removes media item with command KMPXCommandIdCollectionRemoveMedia to MV MPX plugin. |
|
173 */ |
|
174 void RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync ); |
|
175 |
|
176 /** |
|
177 * Deletes files of the current media entries. |
|
178 */ |
|
179 void DeleteAllMediaFilesL(); |
|
180 |
|
181 /** |
|
182 * Deletes a file of a media in current entries. |
|
183 */ |
|
184 void DeleteFileOfMediaL( TInt aDrive, TInt aIndex ); |
|
185 |
|
186 /** |
|
187 * Gets MPX media from current entries. Contains only brief details of the item. |
|
188 */ |
|
189 CMPXMedia* GetMediaL( TInt aDrive, TInt aIndex ); |
|
190 |
|
191 /** |
|
192 * Moves multiple medias to specified drive. |
|
193 * |
|
194 * @param aSourceDrive, -1 is all drives |
|
195 * @param aStartIndex |
|
196 * @param aEndIndex |
|
197 * @param aDestDrive |
|
198 * @param aSync |
|
199 */ |
|
200 void MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync ); |
|
201 |
|
202 /** |
|
203 * Cancels move or copy request. |
|
204 */ |
|
205 void CancelMoveOrCopyL( TBool aSync ); |
|
206 |
|
207 /** |
|
208 * Copies multiple medias to specified drive. |
|
209 * |
|
210 * @param aSourceDrive, -1 is all drives |
|
211 * @param aStartIndex |
|
212 * @param aEndIndex |
|
213 * @param aDestDrive |
|
214 * @param aSync |
|
215 */ |
|
216 void CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync ); |
|
217 |
|
218 /** |
|
219 * Deletes multiple medias on specified drive. |
|
220 * |
|
221 * @param aSourceDrive, -1 is all drives |
|
222 * @param aStartIndex |
|
223 * @param aEndIndex |
|
224 * @param aSync |
|
225 */ |
|
226 void DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync ); |
|
227 |
|
228 void DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync ); |
|
229 |
|
230 void DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync ); |
|
231 |
|
232 /** |
|
233 * Cancels move request. |
|
234 */ |
|
235 void CancelDeleteL( TBool aSync ); |
|
236 |
|
237 /** |
|
238 * Use to toggle automatic refresh of contents when open collection changes. |
|
239 */ |
|
240 void SetAutomaticRefresh( TBool aValue ); |
|
241 |
|
242 /** |
|
243 * Returns true if refresh is ongoing. |
|
244 */ |
|
245 TBool IsRefreshing(); |
|
246 |
|
247 /** |
|
248 * Use to disable some of the logging. |
|
249 */ |
|
250 void SetQuietMode( TBool aValue ); |
|
251 |
|
252 /** |
|
253 * Starts MPX My Videos download. |
|
254 * @param aTitle |
|
255 * @param aIapId |
|
256 * @param aServiceId |
|
257 * @param aContentId |
|
258 * @param aUrl |
|
259 * @param aSync |
|
260 * @param aUserName |
|
261 * @param aPassword |
|
262 * @param aMedia |
|
263 */ |
|
264 void StartDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId, TInt aContentId, |
|
265 const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword, |
|
266 CMPXMedia* aMedia ); |
|
267 |
|
268 /** |
|
269 * Resumes MPX My Videos download. |
|
270 * If download is not found from cache then fake download ID is used. |
|
271 * |
|
272 * @param aTitle |
|
273 * @param aIapId |
|
274 * @param aServiceId |
|
275 * @param aContentId |
|
276 * @param aUrl |
|
277 * @param aSync |
|
278 * @param aUserName |
|
279 * @param aPassword |
|
280 * @param aMedia |
|
281 */ |
|
282 void ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId, TInt aContentId, |
|
283 const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword, |
|
284 CMPXMedia* aMedia ); |
|
285 |
|
286 /** |
|
287 * Resumes MPX My Videos downloads. |
|
288 */ |
|
289 void ResumeAllDownloadsL(); |
|
290 |
|
291 /** |
|
292 * Cancels MPX My Videos download. |
|
293 */ |
|
294 void CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync ); |
|
295 |
|
296 /** |
|
297 * Cancels MPX My Videos download. |
|
298 */ |
|
299 void CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync ); |
|
300 |
|
301 /** |
|
302 * Pauses MPX My Videos download. |
|
303 */ |
|
304 void PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync ); |
|
305 |
|
306 /** |
|
307 * Pauses MPX My Videos download. |
|
308 */ |
|
309 void PauseDownloadL( const TDesC& aUrl, TBool aSync ); |
|
310 |
|
311 /** |
|
312 * Returns instance of the download watcher. |
|
313 */ |
|
314 CVCXMyVideosTestDlWatcher* GetDownloadWatcher(); |
|
315 |
|
316 /** |
|
317 * Returns number of active downloads. |
|
318 */ |
|
319 TInt GetActiveDownloadCountL(); |
|
320 |
|
321 /** |
|
322 * Sets automatic resuming of paused download. |
|
323 */ |
|
324 void SetAutoResume( TBool aValue ); |
|
325 |
|
326 /** |
|
327 * Returns the index of current collection level. |
|
328 */ |
|
329 TInt GetCurrentLevel(); |
|
330 |
|
331 /** |
|
332 * Returns the currently opened level index (category). |
|
333 */ |
|
334 TInt GetCurrentOpenLevelIndex(); |
|
335 |
|
336 /** |
|
337 * Returns the media from last call to GetMediaDetailsL. |
|
338 */ |
|
339 CMPXMedia* GetLastFullMedia(); |
|
340 |
|
341 /** |
|
342 * Gets index of media in collection side array. |
|
343 */ |
|
344 TInt GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex ); |
|
345 |
|
346 /** |
|
347 * Returns the video count on specified drive. |
|
348 */ |
|
349 TInt GetVideoCountForDrive( TInt aDrive ); |
|
350 |
|
351 /** |
|
352 * Returns all medias from collection side. |
|
353 */ |
|
354 const CMPXMediaArray* GetAllCollectionMedia(); |
|
355 |
|
356 /** |
|
357 * Ensures that files are not in use. |
|
358 */ |
|
359 void EnsureMediaFilesAreNotInUseL(); |
|
360 |
|
361 /** |
|
362 * Creates media array with following rules: |
|
363 * If startIndex is > 0 and < endIndex then these files will be selected from specified drive. |
|
364 * If startIndex is -1 then invalid IDs will be used and end index is count. |
|
365 * If startIndex is -2 then duplicate MPX IDs are requested starting from 0. |
|
366 * If startIndex is -3 then only every second MPX item is used in request and starting from 0. |
|
367 * If startIndex > endIndex then empty array is returned. |
|
368 * |
|
369 * @param aDriveFilter, -1 is all files. This is ignored for all other rules but the first. |
|
370 * When drive is specified selection starts from index 0. |
|
371 * @param aStartIndex index at current entries. |
|
372 * @param aEndIndex, index at current entries. |
|
373 */ |
|
374 CMPXMediaArray* SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex ); |
|
375 |
|
376 private: |
|
377 /** |
|
378 * Updates the downloads using current MPX entries. |
|
379 */ |
|
380 void UpdateDownloadsL( TBool aQuietMode ); |
|
381 |
|
382 /** |
|
383 * Creates a MPX command. |
|
384 * |
|
385 * @param aCommandGeneralId |
|
386 * @param aMyVideosCommandId ( this is used only if aCommandGeneralId is My Videos collection specific. |
|
387 * @param aAsync |
|
388 */ |
|
389 CMPXCommand* CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aAsync ); |
|
390 |
|
391 /** |
|
392 * Ensures that result medias array has all the medias of requested array. |
|
393 */ |
|
394 void CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds ); |
|
395 |
|
396 /** |
|
397 * Creates copies of medias in iCollectionEntries to iMediaArray and old media array is moved to |
|
398 * iOldMediaArray. |
|
399 */ |
|
400 void UpdateOwnedMediaArrayL(); |
|
401 |
|
402 /** |
|
403 * Compares iMediaArray to iOldMediaArray and returns copies if any of the medias are different. |
|
404 */ |
|
405 CMPXMediaArray* GetChangedMedias( const CMPXMediaArray* aNewMedias ); |
|
406 |
|
407 /** |
|
408 * Returns media from the aMedias array for specified mpx id. |
|
409 */ |
|
410 CMPXMedia* GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId ); |
|
411 |
|
412 /** |
|
413 * Sets status of refresh. |
|
414 */ |
|
415 void SetRefreshStatus( TBool aRefreshingCollection ); |
|
416 |
|
417 public: // Functions from base classes |
|
418 |
|
419 /** |
|
420 * From MMPXCollectionObserver->MMPXCollectionMediaObserver |
|
421 * Handle extended media properties |
|
422 * |
|
423 * @param aMedia media |
|
424 * @param aError error code |
|
425 */ |
|
426 virtual void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError ); |
|
427 |
|
428 /** |
|
429 * From MMPXCollectionUtilityObserver. |
|
430 * Handle collection message |
|
431 * NOTE: only one of HandleCollectionMessage callback can be implemented |
|
432 * |
|
433 * @param aMessage collection message, ownership not transferred. |
|
434 * Please check aMsg is not NULL before using it. If aErr is not |
|
435 * KErrNone, plugin might still call back with more info in the aMsg. |
|
436 * @param aErr system error code. |
|
437 */ |
|
438 void HandleCollectionMessage( CMPXMessage* aMsg, TInt /*aErr*/ ); |
|
439 |
|
440 void HandleSingleCollectionMessageL( CMPXMessage* aMessage ); |
|
441 |
|
442 /** |
|
443 * From MMPXCollectionUtilityObserver. |
|
444 * Handles the collection entries being opened. Typically called |
|
445 * when client has Open()'d a folder |
|
446 * |
|
447 * @param aEntries collection entries opened |
|
448 * @param aIndex focused entry |
|
449 * @param aComplete ETrue no more entries. EFalse more entries |
|
450 * expected |
|
451 * @param aError error code |
|
452 */ |
|
453 void HandleOpenL( const CMPXMedia& aEntries, |
|
454 TInt aIndex,TBool aComplete,TInt aError ); |
|
455 |
|
456 /** |
|
457 * From MMPXCollectionUtilityObserver. |
|
458 * Handles the item being opened. Typically called |
|
459 * when client has Open()'d an item. Client typically responds by |
|
460 * 'playing' the item via the playlist |
|
461 * |
|
462 * @param aPlaylist collection playlist |
|
463 * @param aError error code |
|
464 */ |
|
465 void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,TInt aError ); |
|
466 |
|
467 /** |
|
468 * From MMPXCollectionUtilityObserver. |
|
469 * Handle completion of a asynchronous command |
|
470 * @param aCommandResult result of the command, NULL if error |
|
471 * @param aError error code |
|
472 */ |
|
473 void HandleCommandComplete( CMPXCommand* aCommandResult, |
|
474 TInt aError); |
|
475 |
|
476 /** |
|
477 * From MIptvTestTimerObserver Handles timer completion |
|
478 * @since |
|
479 * @param aTimerId |
|
480 * @param aError |
|
481 */ |
|
482 void TimerComplete(TInt aTimerId, TInt aError); |
|
483 |
|
484 private: |
|
485 |
|
486 /** |
|
487 * C++ default constructor. |
|
488 */ |
|
489 CVCXMyVideosCollectionPluginTester( MVCXMyVideosCollectionPluginTesterObserver* aObserver, |
|
490 CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper ); |
|
491 |
|
492 /** |
|
493 * By default Symbian 2nd phase constructor is private. |
|
494 */ |
|
495 void ConstructL(); |
|
496 |
|
497 private: // Data |
|
498 |
|
499 // MVCXMyVideosCollectionPluginTesterObserver |
|
500 MVCXMyVideosCollectionPluginTesterObserver* iObserver; |
|
501 |
|
502 // UID of currently open collection. |
|
503 TUid iCollectionUid; |
|
504 |
|
505 // The index of last level which was opened. |
|
506 TInt iCurrentOpenedLevelIndex; |
|
507 |
|
508 HBufC* iCurrentLevelName; |
|
509 |
|
510 // MMPXCollectionUtility. |
|
511 MMPXCollectionUtility* iCollectionUtility; |
|
512 |
|
513 // Entries from collection. |
|
514 CMPXMedia* iCollectionEntries; |
|
515 |
|
516 // Media array of videos on collection side. |
|
517 CMPXMediaArray* iCollectionMediaArray; |
|
518 |
|
519 // Media array of videos tests uses. |
|
520 CMPXMediaArray* iMediaArray; |
|
521 |
|
522 // Media array of previous videos. |
|
523 CMPXMediaArray* iOldMediaArray; |
|
524 |
|
525 // Count of current medias in iMediaArray. |
|
526 TUint32 iMediaCount; |
|
527 |
|
528 // CVCXTestCommon. |
|
529 CVCXTestCommon* iTestCommon; |
|
530 |
|
531 // RFs. |
|
532 RFs iFs; |
|
533 |
|
534 // Refresh is already ongoing. |
|
535 TBool iRefreshingCollection; |
|
536 |
|
537 // Member to keep track of downnloads. |
|
538 CVCXMyVideosTestDlWatcher* iDlWatcher; |
|
539 |
|
540 // Active wait |
|
541 CIptvTestActiveWait* iActiveWait; |
|
542 |
|
543 // Refresh contents of open collection when they change |
|
544 TBool iAutomaticContentRefresh; |
|
545 |
|
546 // Tester is waiting for item change. |
|
547 TBool iWaitingForItemChange; |
|
548 |
|
549 // Autoresume downloads |
|
550 TBool iAutoResume; |
|
551 |
|
552 // Downloads do not start updating before we get DL related commands from script. |
|
553 TBool iUpdateDownloads; |
|
554 |
|
555 TUint32 iCurrentMyVideosMessageId; |
|
556 |
|
557 RArray<TInt32> iRequestedMediaIds; |
|
558 |
|
559 // Full details of media got from GetMediaDetailsL |
|
560 CMPXMedia* iFullMedia; |
|
561 |
|
562 TBool iGettingFullDetailsForAllMedia; |
|
563 |
|
564 // Item ids which have been deleted in change event. |
|
565 RArray<TUint32> iDeletedItemIds; |
|
566 |
|
567 // Item ids which have been inserted in change event. |
|
568 RArray<TUint32> iInsertedItemIds; |
|
569 |
|
570 CVCXMyVideosTestTransactions* iTransactions; |
|
571 |
|
572 TBool iQuietMode; |
|
573 |
|
574 // Canceling Move, Copy or Delete cause commmand completion with error KErrCancel |
|
575 TBool iCancelRequested; |
|
576 |
|
577 // Update downloads only after first one is started. |
|
578 TBool iDownloadsStarted; |
|
579 |
|
580 TInt iActionCount; |
|
581 |
|
582 // Download progress update timer. |
|
583 CIptvTestTimer* iProgressTimer; |
|
584 |
|
585 TInt iVideosOnRomCount; |
|
586 |
|
587 // Variable to follow what kind of collection opening is going on. |
|
588 TInt iCurrentActionId; |
|
589 |
|
590 // Variable to follow where action ending should be handled. |
|
591 TBool iCurrentActionHasResponse; |
|
592 |
|
593 // Class to hold robustness and performance data. |
|
594 CVCXTestStatsKeeper* iStats; |
|
595 }; |
|
596 |
|
597 #endif // VCXMYVIDEOSCOLLECTIONPLUGINTESTER_H |
|
598 |
|
599 // End of File |