videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp
branchRCL_3
changeset 57 befca0ec475f
parent 56 839377eedc2b
--- a/videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp	Tue Aug 31 15:15:55 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTester.cpp	Wed Sep 01 12:30:28 2010 +0100
@@ -11,9 +11,10 @@
 *
 * Contributors:
 *
-* Description:
+* Description:   ?Description*
 */
 
+
 // INCLUDE FILES
 #include <e32svr.h>
 #include <e32std.h>
@@ -36,12 +37,14 @@
 #include <mpxcommandgeneraldefs.h>
 #include <mpxcollectioncommanddefs.h>
 
-#include "VCXMyVideosTestUtils.h"
+#include "VCXTestCommon.h"
 #include "VCXTestLog.h"
-#include "CVcxTestActiveWait.h"
+#include "CIptvTestTimer.h"
+#include "CIptvTestActiveWait.h"
+#include "VCXTestStatsKeeper.h"
 
 #include "VCXMyVideosCollectionPluginTester.h"
-#include "VCXMyVideosTestUtils.h"
+#include "VCXMyVideosTestDlWatcher.h"
 #include "VCXMyVideosTestCommon.h"
 
 #include "vcxmyvideoscollection.hrh"
@@ -58,11 +61,11 @@
 // -----------------------------------------------------------------------------
 //
 CVCXMyVideosCollectionPluginTester* CVCXMyVideosCollectionPluginTester::NewL(
-            MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXMyVideosTestUtils* aTestUtils )
+            MVCXMyVideosCollectionPluginTesterObserver* aObserver, CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
     {
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::NewL");
     CVCXMyVideosCollectionPluginTester* self = 
-        new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestUtils );
+        new (ELeave) CVCXMyVideosCollectionPluginTester( aObserver, aTestCommon, aStatsKeeper );
     CleanupStack::PushL(self);
     self->ConstructL();
     CleanupStack::Pop(self);
@@ -76,12 +79,8 @@
 //
 CVCXMyVideosCollectionPluginTester::CVCXMyVideosCollectionPluginTester( 
         MVCXMyVideosCollectionPluginTesterObserver* aObserver,
-        CVCXMyVideosTestUtils* aTestUtils ) :
-iObserver( aObserver ), 
-iTestUtils( aTestUtils ),
-iCurrentLevelName( NULL ),
-iAutomaticContentRefresh( ETrue),
-iCurrentOpenedLevelIndex( -1 )
+        CVCXTestCommon* aTestCommon, CVCXTestStatsKeeper* aStatsKeeper )
+ : iObserver( aObserver ), iTestCommon( aTestCommon ), iStats( aStatsKeeper )
     {
 
     }
@@ -94,6 +93,16 @@
     {
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
 
+    if( iProgressTimer )
+        {
+        iProgressTimer->CancelTimer();
+        delete iProgressTimer;
+        iProgressTimer = NULL;
+        }
+
+    delete iDlWatcher;
+    iDlWatcher = NULL;
+
     if( iCollectionUtility )
         {
         iCollectionUtility->Close();
@@ -112,19 +121,11 @@
 
     if( iMediaArray )
         {
-        PrintMediasL( iMediaArray, EFalse, _L("Items") );
         iMediaArray->Reset();
         delete iMediaArray;
         iMediaArray = NULL;
         }
 
-    if( iMediaArrayCopy )
-        {
-        iMediaArrayCopy->Reset();
-        delete iMediaArrayCopy;
-        iMediaArrayCopy = NULL;
-        }
-
     iFs.Close();
 
     if( iActiveWait )
@@ -152,9 +153,6 @@
     delete iTransactions;
     iTransactions = NULL;
     
-    iAlbumNames.ResetAndDestroy();
-    iAlbumNames.Close();
-    
     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::~CVCXMyVideosCollectionPluginTester");
     }
 
@@ -165,13 +163,18 @@
 void CVCXMyVideosCollectionPluginTester::ConstructL()
     {
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ConstructL");
-    
-
-    iActiveWait = CVcxTestActiveWait::NewL();
+    iAutomaticContentRefresh = ETrue;
+
+    iActiveWait = CIptvTestActiveWait::NewL();
     User::LeaveIfError( iFs.Connect() );
     
     iTransactions = CVCXMyVideosTestTransactions::NewL();
     iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated );
+    iDlWatcher = CVCXMyVideosTestDlWatcher::NewL( iObserver, iStats );
+    iUpdateDownloads = ETrue;
+    iCurrentOpenedLevelIndex = -1;
+    iProgressTimer = CIptvTestTimer::NewL( *this, 0 );
+    iProgressTimer->After( 1000000 );
     
     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ConstructL");
     }
@@ -189,12 +192,12 @@
     iCollectionUid = TUid::Uid( aCollectionUid );
     path->AppendL( aCollectionUid );
     
+    TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionActionId, _L("Open collection") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCurrentActionId = KOpenCollectionActionId;
     SetRefreshStatus( ETrue );
     
-    VCXLOGLO2("CVCXMyVideosCollectionPluginTester::OpenCollectionL: collectionId: 0x%x", aCollectionUid);
-    
     iCollectionUtility->Collection().OpenL( *path );
-    iCurrentOpenedLevelIndex = -1;
     
     CleanupStack::PopAndDestroy( path );
     
@@ -205,60 +208,6 @@
 // CVCXMyVideosCollectionPluginTester::OpenLevelL
 // -----------------------------------------------------------------------------
 //
-void CVCXMyVideosCollectionPluginTester::OpenLevelL( const TDesC& aLevelName )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL (by name)");
-
-    if( GetCurrentLevel() != 2 )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!");
-        User::Leave( KErrGeneral );
-        }
-
-    CMPXMedia* media;
-
-    int levelIndex(-1);
-    
-    // From last to first
-    for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
-        {
-        media = (*iMediaArray)[i];
-        
-        if( media->IsSupported( KMPXMediaGeneralTitle ) )
-            {
-            if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aLevelName ) == KErrNone )
-                {
-                TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
-                VCXLOGLO3("CVCXMyVideosCollectionPluginTester::OpenLevelL: mpx id1: %d, id2: %d", itemId.iId1, itemId.iId2);
-                
-                levelIndex = i;
-                delete iCurrentLevelName;
-                iCurrentLevelName = NULL;
-                iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
-                break;
-                }
-            }
-        }
-    
-    if( levelIndex == -1 )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:::OpenLevelL: Couldn't find the level!");
-        User::Leave( KErrNotFound );
-        }
-    
-    // Open the level
-    iCollectionUtility->Collection().OpenL( levelIndex );
-    
-    iCurrentOpenedLevelIndex = levelIndex;
-    SetRefreshStatus( ETrue );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:::OpenLevelL (by name)");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::OpenLevelL
-// -----------------------------------------------------------------------------
-//
 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex )
     {
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL");
@@ -269,24 +218,29 @@
         User::Leave( KErrGeneral );
         }
 
-    if( aIndex >= 0 || aIndex < iMediaArray->Count() )
+    if( aIndex < 0 || aIndex > iMediaArray->Count() )
         {
-        CMPXMedia* media(NULL);
-        media = (*iMediaArray)[aIndex];
-
-        if( media->IsSupported( KMPXMediaGeneralTitle ) )
-            {
-            delete iCurrentLevelName;
-            iCurrentLevelName = NULL;
-            iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
-            }
+        VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error. Index (%d) out of bounds!", aIndex);
+        User::Leave( KErrGeneral );
         }
-    else
+
+    // Save the name of level
+
+    CMPXMedia* media(NULL);
+    media = (*iMediaArray)[aIndex];
+
+    if( media->IsSupported( KMPXMediaGeneralTitle ) )
         {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester::OpenLevelL: level index is invalid. Opening..");
+        delete iCurrentLevelName;
+        iCurrentLevelName = NULL;
+        iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL();
         }
 
     // Open the level
+    TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionLevelActionId, _L("Open level") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCurrentActionId = KOpenCollectionLevelActionId;
+    
     iCollectionUtility->Collection().OpenL( aIndex );
     
     iCurrentOpenedLevelIndex = aIndex;
@@ -303,14 +257,12 @@
     {
     //VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RefreshContentsL");
 
-#if 0
     // No need to refresh if My Videos category is not open.
     if( GetCurrentLevel() != 3)
         {
         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level.");
         return;
         }
-#endif 
 
     // Wait previous refresh to complete.
     if( IsRefreshing() )
@@ -323,6 +275,9 @@
     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Refreshing video list ----->");
     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------");
 
+    TRAP_IGNORE( iStats->ActionStartL( KRefreshCollectionActionId, _L("Refreshing collection") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCurrentActionId = KRefreshCollectionActionId;
     iCollectionUtility->Collection().OpenL();
     SetRefreshStatus( ETrue );
 
@@ -364,7 +319,10 @@
         cmd->SetTObjectValueL( KMPXMediaArrayCount, requestedMediaObjects->Count() );
         }
 
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Doing request.");
     iActionCount++;
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Get medias by MPX ID") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     SetRefreshStatus( ETrue );
@@ -398,7 +356,8 @@
     CleanupStack::PushL( path );
     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selecting %d", realIndex);
     path->SelectL( realIndex );
-
+    TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
     CleanupStack::PopAndDestroy( path );
     CleanupStack::PopAndDestroy( &attrs );
@@ -428,8 +387,11 @@
 
     cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosGetMediaFullDetailsByMpxId, aSync );    
     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );    
+    TRAP_IGNORE( iStats->ActionStartL( KGetMediaFullDetailsActionId, _L("Get media full details by MPX ID") ) );
     iCollectionUtility->Collection().CommandL( *cmd );
     
+    iCurrentActionHasResponse = EFalse;
+    
     CleanupStack::PopAndDestroy( cmd );
 
     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetMediaFullDetailsByMpxIdL");
@@ -481,8 +443,12 @@
                     PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName );
                     }
                 }
-            
-            UpdateAlbumsListL();
+
+            // Update download states and info
+            if( GetCurrentLevel() == 3 && iUpdateDownloads && iDownloadsStarted )
+                {
+                UpdateDownloadsL( iQuietMode );
+                }
             }
         else
             {
@@ -494,7 +460,643 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::PrintMediasL
+// CVcxMyVideosCollectionTester::UpdateDownloadsL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::UpdateDownloadsL( TBool aQuietMode )
+    {
+    if( !iMediaArray || !iDlWatcher )
+        {
+        return;
+        }
+
+    if( !aQuietMode )
+        VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateDownloadsL ---------->");
+
+    iDlWatcher->PrepareCheck();
+
+    // Print short info about downloads
+    CMPXMedia* media( NULL );
+
+    for( TInt i = 0; i < iMediaArray->Count(); i++ )
+        {
+        media = (*iMediaArray)[i];
+
+        // If it's download then get info about it and update download watcher.
+        if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
+            {
+            TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
+
+            TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
+
+            HBufC* titleBuff = NULL;
+            HBufC* urlBuff = NULL;
+            HBufC* pathBuff = NULL;
+
+            if( media->IsSupported( KMPXMediaGeneralUri ) )
+                {
+                const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
+                pathBuff = url.AllocL();
+                CleanupStack::PushL( pathBuff );
+                }
+
+            if( media->IsSupported( KMPXMediaGeneralTitle ) )
+                {
+                const TDesC& title = media->ValueText( KMPXMediaGeneralTitle );
+                titleBuff = title.AllocL();
+                CleanupStack::PushL( titleBuff );
+                }
+
+            if( media->IsSupported( KVcxMediaMyVideosRemoteUrl ) )
+                {
+                const TDesC& url = media->ValueText( KVcxMediaMyVideosRemoteUrl );
+                urlBuff = url.AllocL();
+                CleanupStack::PushL( urlBuff );
+                }
+
+            TInt progress = 0;
+            if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
+                {
+                progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
+                }
+
+            TUint32 downloadId = 0;
+            if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
+                {
+                downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
+                }
+
+            TInt downloadError = 0;
+            if( media->IsSupported( KVcxMediaMyVideosDownloadError ) )
+                {
+                downloadError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError );
+                }
+
+            TInt globalError = 0;
+            if( media->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) )
+                {
+                globalError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError );
+                }
+
+            CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
+
+            if( !dl )
+                {
+                // Tell dl watcher that dl has started. 
+                if( state != EVcxMyVideosDlStateNone )
+                    {
+                    iDlWatcher->StartDownloadL( *urlBuff, *pathBuff, downloadId, itemId.iId1, *titleBuff,
+                            static_cast<TVcxMyVideosDownloadState>( state ), progress );
+                    }
+                }
+            else
+                {
+                // Update download. 
+                    iDlWatcher->UpdateDownloadStateL( itemId.iId1, downloadId, 
+                            static_cast<TVcxMyVideosDownloadState>( state ), progress, 
+                            downloadError, globalError );
+                    
+                }
+            
+            if( state == EVcxMyVideosDlStatePaused && iAutoResume )
+                {
+                if( dl && !dl->iWaitingResume )
+                    {
+                    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Autoresuming the paused download. ---------->");
+                    ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
+                    iDlWatcher->SetDownloadResumedFlagL( itemId.iId1, downloadId );
+                    dl->iWaitingPause = EFalse;
+                    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Resume ok ---------->");
+                    }
+                }
+
+            if( urlBuff )
+                {
+                CleanupStack::PopAndDestroy( urlBuff );
+                }
+            if( titleBuff )
+                {                
+                CleanupStack::PopAndDestroy( titleBuff );
+                }
+            if( pathBuff )
+                {                       
+                CleanupStack::PopAndDestroy( pathBuff );
+                }
+            }
+        }
+
+    if( !aQuietMode )
+        {
+        iDlWatcher->PrintDownloads();
+        }
+
+    iDlWatcher->FinishCheckL();
+    if( !aQuietMode )
+        VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateDownloadsL <----------");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::CreateMpxCommandLC
+// -----------------------------------------------------------------------------
+//
+CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync )
+    {
+    CMPXCommand* cmd = CMPXCommand::NewL();
+    CleanupStack::PushL( cmd );
+
+    cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
+    if( aCommandGeneralId == KVcxCommandIdMyVideos )
+        {
+        cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
+        }
+
+    cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync );
+
+    if( !aSync )
+        {
+        // Transaction id is used also tracking stats, so increment for every command.
+        iTransactions->NextTransactionId();
+
+        if( aCommandGeneralId == KVcxCommandIdMyVideos )
+            {
+            cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
+            iTransactions->AddTransactionId( aMyVideosCommandId );
+            }
+        }
+
+    cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
+
+    return cmd;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::SelectMediasL
+// -----------------------------------------------------------------------------
+//
+CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex )
+    {
+    if( aStartIndex == -4 )
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL");
+        return NULL;
+        }
+
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL");
+    VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex);
+
+    if( !iMediaArray )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    iRequestedMediaIds.Reset();
+
+    CMPXMediaArray* medias = CMPXMediaArray::NewL();
+
+    // None
+    if( aStartIndex > aEndIndex )
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos.");
+        VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
+        return medias;
+        }
+
+    CleanupStack::PushL( medias );
+
+    if( aStartIndex >= 0 )
+        {
+        if( aEndIndex > iMediaArray->Count() )
+            {
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
+            User::Leave( KErrArgument );
+            }
+
+        TInt countToSelect = aEndIndex - aStartIndex;
+        TInt indexOfVideoOnDrive = 0;
+        
+        for( TInt i = 0; i < iMediaArray->Count(); i++ )
+            {
+            CMPXMedia* media = (*iMediaArray)[i];
+
+            if( media )
+                {
+                TBool selectThis( EFalse );
+                
+                if( aDriveFilter != -1 )
+                    {
+                    // Drive specified, check path and index of video on the drive.
+                    const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
+                    TInt drive( 0 );
+                    User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
+
+                    if( drive == aDriveFilter )
+                        {
+                        if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex )
+                            {
+                            selectThis = ETrue;
+                            }
+                        indexOfVideoOnDrive++;                        
+                        }
+                    }
+                else
+                    {
+                    // No drive specified, just index check.
+                    if( i >= aStartIndex && i < aEndIndex )
+                        {
+                        selectThis = ETrue;
+                        }
+                    }
+
+                if( selectThis )
+                    {
+                    TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+                    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
+                    iRequestedMediaIds.Append( mpxId.iId1 );
+                    CMPXMedia* newMedia = CMPXMedia::NewL();
+                    CleanupStack::PushL( newMedia );
+                    newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
+                    newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
+                    medias->AppendL( *newMedia );
+                    CleanupStack::PopAndDestroy( newMedia );
+    
+                    if( medias->Count() >= countToSelect )
+                        {
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+
+    // Invalid IDs
+    if( aStartIndex == -1 )
+        {
+        for( TInt i = 0; i < aEndIndex; i++ )
+            {
+            TMPXItemId mpxId;
+            mpxId.iId1 = i+66666;
+            mpxId.iId2 = 0;
+
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1);
+
+            CMPXMedia* newMedia = CMPXMedia::NewL();
+            CleanupStack::PushL( newMedia );
+            newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
+            newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
+            medias->AppendL( *newMedia );
+            CleanupStack::PopAndDestroy( newMedia );
+            }
+        }
+
+    // Duplicate IDs
+    if( aStartIndex == -2 )
+        {
+        if( aEndIndex > iMediaArray->Count() )
+            {
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
+            User::Leave( KErrArgument );
+            }
+
+        for( TInt i = 0; i < aEndIndex; i++ )
+            {
+            CMPXMedia* media = (*iMediaArray)[i];
+
+            if( media )
+                {
+                TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+
+                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1);
+                iRequestedMediaIds.Append( mpxId.iId1 );
+                iRequestedMediaIds.Append( mpxId.iId1 );
+                CMPXMedia* newMedia = CMPXMedia::NewL();
+                CleanupStack::PushL( newMedia );
+                newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
+                newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
+                medias->AppendL( *newMedia );
+                medias->AppendL( *newMedia );
+                CleanupStack::PopAndDestroy( newMedia );
+                }
+            }
+        }
+
+    // Every second ID
+    if( aStartIndex == -3 )
+        {
+        if( aEndIndex > iMediaArray->Count() )
+            {
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
+            User::Leave( KErrArgument );
+            }
+
+        for( TInt i = 0; i < aEndIndex; i+=2 )
+            {
+            CMPXMedia* media = (*iMediaArray)[i];
+
+            if( media )
+                {
+                TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+
+                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
+                iRequestedMediaIds.Append( mpxId.iId1 );
+                CMPXMedia* newMedia = CMPXMedia::NewL();
+                CleanupStack::PushL( newMedia );
+                newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
+                newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
+                medias->AppendL( *newMedia );
+                CleanupStack::PopAndDestroy( newMedia );
+                }
+            }
+        }
+
+    CleanupStack::Pop( medias );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
+    return medias;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::UpdateOwnedMediaArray
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL()
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
+
+    if ( !iCollectionEntries )
+        {
+        return;
+        }
+
+    if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) )
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!");
+        User::Leave( KErrNotSupported );
+        }
+
+    // Get up to date list of all medias in collection.
+    CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
+    
+    // Delete array of old medias
+    if( iOldMediaArray )
+        {
+        iOldMediaArray->Reset();
+        delete iOldMediaArray;
+        }
+
+    // Update the old array and create new
+    iOldMediaArray = iMediaArray;
+    iMediaArray = CMPXMediaArray::NewL();
+
+    TBool categories( EFalse );
+    
+    // Make copies of the medias.
+    for( TInt i=0; i<medias->Count(); i++ )
+        {
+        CMPXMedia* media = (*medias)[i];
+        
+        TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
+        if( itemId.iId2 != 0 )
+             {
+             categories = ETrue;
+             }
+        
+        // Ignore medias on ROM.
+        TBool isOnRom( EFalse );
+        
+        if( media->IsSupported( KMPXMediaGeneralUri ) )
+            {
+            const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
+            if( url.FindC( _L("z:" ) ) != KErrNotFound )
+                {
+                isOnRom = ETrue;
+                }
+            }
+        
+        if( !isOnRom )
+            {
+            iMediaArray->AppendL( *media );
+            }
+        }
+    
+    iMediaCount = iMediaArray->Count();
+    
+    // Update count of videos on ROM.
+    if( !categories )
+        {
+        iVideosOnRomCount = 0;
+
+        for( TInt i=0; i<medias->Count(); i++ )
+            {
+            CMPXMedia* media = (*medias)[i];            
+            
+            if( media->IsSupported( KMPXMediaGeneralUri ) )
+                {
+                const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
+                if( url.FindC( _L("z:" ) ) != KErrNotFound )
+                    {
+                    iVideosOnRomCount++;
+                    }
+                }
+            }
+
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount);
+        }
+    
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::GetChangedMedias
+// -----------------------------------------------------------------------------
+//
+CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias");
+
+    CMPXMediaArray* changedMedias = CMPXMediaArray::NewL();
+
+    if( !aNewMedias )
+        {
+        VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
+        return changedMedias;
+        }
+
+    CleanupStack::PushL( changedMedias );
+
+    for( TInt i=0; i<aNewMedias->Count(); i++ )
+        {
+        CMPXMedia* media(NULL);
+        media = (*aNewMedias)[i];
+        
+        if( !media )
+            {
+            continue;
+            }
+        
+        TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+
+        CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId );
+
+        TBool add( EFalse );
+
+        // It's a new.
+        if( !oldMedia )
+            {
+            add = ETrue;
+            }
+        // Check changes
+        else
+            {
+            const TArray<TMPXAttribute> newAttributes = media->Attributes();
+            const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
+            if( newAttributes.Count() != oldAttributes.Count() )
+                {
+                add = ETrue;
+                }
+            else
+                {
+                for( TInt e=0; e<newAttributes.Count(); e++ )
+                    {
+                    if( !oldMedia->Match( *media, newAttributes[e] ) )
+                        {
+                        add = ETrue;
+                        break;
+                        }
+                    }
+                }
+            }
+
+        // Add a copy of the media.
+        if( add )
+            {
+            changedMedias->AppendL( *media );
+            }
+        }
+
+    CleanupStack::Pop( changedMedias );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
+    return changedMedias;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::GetMediaByMpxId
+// -----------------------------------------------------------------------------
+//
+CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId )
+    {
+    if( !aMedias )
+        {
+        return NULL;
+        }
+
+    for( TInt i=0; i<aMedias->Count(); i++ )
+        {
+        CMPXMedia* media = (*aMedias)[i];
+        TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+
+        if( mpxId == aMpxId )
+            {
+            return media;
+            }
+        }
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::SetRefreshStatus
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection )
+    {
+    iRefreshingCollection = aRefreshingCollection;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::CheckRequestMediaArrayL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
+
+    // Print requested ids
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:");
+    for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
+        {
+        VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] );
+        }
+
+    // Print actual result ids and check for errors
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:");
+    for( TInt i = 0; i < aRequestResultMedias.Count(); i++ )
+        {
+        VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i);
+        CMPXMedia* media = aRequestResultMedias[i];
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media");
+        if( media )
+            {
+            TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
+            VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 );
+            if( media->IsSupported( KVcxMediaMyVideosInt32Value ) )
+                {
+                TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
+                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result);
+                if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) )
+                    {
+                    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result);
+                    User::Leave( result );
+                    }
+                }
+            }
+        else
+            {
+            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i);
+            }
+        }
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks");
+    
+    // First check the counts match
+    if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() )
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!");
+        User::Leave( KErrCorrupt );
+        }
+    else
+    // Check that all requested ids are in the results
+    for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
+        {
+        TMPXItemId mpxId;
+        mpxId.iId1 = aRequestedMediaIds[i];
+        mpxId.iId2 = 0;
+
+        TBool found( EFalse );
+        for( TInt e = 0; e < aRequestResultMedias.Count(); e++ )
+            {
+            CMPXMedia* media2 = aRequestResultMedias[e];
+            if( media2 )
+                {
+                TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId );
+
+                if( mpxId == mpxId2 )
+                    {
+                    found = ETrue;
+                    }
+                }
+            }
+
+        if( !found )
+            {
+            VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!");
+            User::Leave( KErrCorrupt );
+            }
+        }
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::PrintMediasL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle )
@@ -535,7 +1137,7 @@
         VCXLOGLO4("CVCXMyVideosCollectionPluginTester:: <----------- %S - %d Entries, %d has changed ----------->", &aTitle, count, changedCount );
         }
 
-    CMPXMedia* media;
+    CMPXMedia* media(NULL);
     for( TInt i = 0; i < medias->Count(); i++ )
         {
         media = (*medias)[i];
@@ -551,7 +1153,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::PrintMPXMediaL
+// CVcxMyVideosCollectionTester::PrintMPXMediaL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::PrintMPXMediaL( const CMPXMedia& aMedia, TBool aPrintAllDetails )
@@ -567,7 +1169,7 @@
             }
 
         // Category
-        if( itemId.iId2 != KVcxMvcMediaTypeVideo )
+        if( itemId.iId2 != 0 )
             {
             TInt itemCount(0);
             TInt newItemCount(0);
@@ -621,21 +1223,13 @@
 
     // Print all details
 
-    if( itemId.iId2 == KVcxMvcMediaTypeCategory )
+    if( itemId.iId2 != 0 )
         {
-        VCXLOGLO1("--------------------------- CATEGORY -------------------------------");
-        }
-    else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
-        {
-        VCXLOGLO1("--------------------------- Album ----------------------------------");
+        VCXLOGLO1("--------------------------- MEDIA CATEGORY -------------------------------");
         }
-    else if( itemId.iId2 == KVcxMvcMediaTypeVideo )
+    else
         {
-        VCXLOGLO1("--------------------------- VIDEO -------------------------------");
-        }
-    else 
-        {
-        VCXLOGLO1("--------------------------- UNKNOWN! -------------------------------");
+        VCXLOGLO1("--------------------------- MEDIA OBJECT -------------------------------");
         }
 
     VCXLOGLO3("iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 );
@@ -865,653 +1459,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL()
-    {
-    CMPXMedia* media;
-    
-    for( TInt i = 0; i < iMediaArray->Count(); i++ )
-        {
-        media = (*iMediaArray)[i];
-        
-        if( media )
-            {
-            TMPXItemId itemId = *media->Value<TMPXItemId>( KMPXMediaGeneralId );
-                        
-            if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
-                {
-                int albumIndex(-1);
-                for( TInt e = 0; e < iAlbumIds.Count(); e++ )
-                    {
-                    if( iAlbumIds[e] == itemId )
-                        {
-                        albumIndex = e;
-                        }
-                    }
-                
-                TBuf<256> title;
-                if( media->IsSupported( KMPXMediaGeneralTitle ) )
-                    {
-                    title = media->ValueText( KMPXMediaGeneralTitle );
-                    
-                    if( albumIndex == -1 )
-                        {
-                        HBufC* titleBuff = title.AllocL();
-                        iAlbumNames.Append( titleBuff );
-                        iAlbumIds.Append( itemId );
-                        }
-                    else
-                        {
-                        if( iAlbumNames[albumIndex]->Compare( title )!= KErrNone )
-                            {
-                            iAlbumNames[albumIndex]->Des().SetLength( 0 );
-                            iAlbumNames[albumIndex]->ReAlloc( title.Length() );
-                            iAlbumNames[albumIndex]->Des().Copy( title );
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetAlbumIdL
-// -----------------------------------------------------------------------------
-//
-TMPXItemId CVCXMyVideosCollectionPluginTester::GetAlbumIdL( const TDesC& aAlbumName )
-    {
-    // Get the last album with the name.
-    for( TInt i = iAlbumNames.Count()-1; i >= 0; i-- )
-        {
-        if( iAlbumNames[i]->Des() == aAlbumName && i < iAlbumIds.Count() )
-            {
-            VCXLOGLO3("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: returning album id1: %d, id2: %d", iAlbumIds[i].iId1, iAlbumIds[i].iId2);
-            return iAlbumIds[i];
-            }
-        }
-    
-    VCXLOGLO2("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: could not find album '%S'", &aAlbumName);
-    User::Leave( KErrNotFound );
-    
-    return TMPXItemId::InvalidId();
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC
-// -----------------------------------------------------------------------------
-//
-CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync )
-    {
-    CMPXCommand* cmd = CMPXCommand::NewL();
-    CleanupStack::PushL( cmd );
-
-    cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId );
-    if( aCommandGeneralId == KVcxCommandIdMyVideos )
-        {
-        cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId );
-        }
-
-    cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync );
-
-    if( !aSync )
-        {
-        iTransactions->NextTransactionId();
-
-        if( aCommandGeneralId == KVcxCommandIdMyVideos )
-            {
-            cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() );
-            iTransactions->AddTransactionId( aMyVideosCommandId );
-            }
-        }
-
-    VCXLOGLO2("CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC: collectionId: 0x%x", iCollectionUid.iUid);
-    cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid );
-
-    return cmd;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::SelectMediasL
-// -----------------------------------------------------------------------------
-//
-CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex )
-    {
-    if( aStartIndex == -4 )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL");
-        return NULL;
-        }
-
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL");
-    VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex);
-
-    CMPXMediaArray* iSourceMedias;
-    
-    if( !iUseCopiedMedias )
-        {
-        if( !iMediaArray )
-            {
-            User::Leave( KErrNotReady );
-            }
-        iSourceMedias = iMediaArray;
-        }
-    else
-        {
-        if( !iMediaArrayCopy )
-            {
-            User::Leave( KErrNotReady );
-            }
-        iSourceMedias = iMediaArrayCopy;
-        }
-
-    iRequestedMediaIds.Reset();
-
-    CMPXMediaArray* medias = CMPXMediaArray::NewL();
-
-    // None
-    if( aStartIndex > aEndIndex )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos.");
-        VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
-        return medias;
-        }
-
-    CleanupStack::PushL( medias );
-
-    if( aStartIndex >= 0 )
-        {
-        if( aEndIndex > iSourceMedias->Count() )
-            {
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
-            User::Leave( KErrArgument );
-            }
-
-        TInt countToSelect = aEndIndex - aStartIndex;
-        TInt indexOfVideoOnDrive = 0;
-        
-        for( TInt i = 0; i < iSourceMedias->Count(); i++ )
-            {
-            CMPXMedia* media = (*iSourceMedias)[i];
-
-            if( media )
-                {
-                TBool selectThis( EFalse );
-                
-                if( aDriveFilter != -1 )
-                    {
-                    // Drive specified, check path and index of video on the drive.
-                    const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
-                    TInt drive( 0 );
-                    User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) );
-
-                    if( drive == aDriveFilter )
-                        {
-                        if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex )
-                            {
-                            selectThis = ETrue;
-                            }
-                        indexOfVideoOnDrive++;                        
-                        }
-                    }
-                else
-                    {
-                    // No drive specified, just index check.
-                    if( i >= aStartIndex && i < aEndIndex )
-                        {
-                        selectThis = ETrue;
-                        }
-                    }
-
-                if( selectThis )
-                    {
-                    TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-                    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
-                    iRequestedMediaIds.Append( mpxId.iId1 );
-                    CMPXMedia* newMedia = CMPXMedia::NewL();
-                    CleanupStack::PushL( newMedia );
-                    newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
-                    newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
-                    medias->AppendL( *newMedia );
-                    CleanupStack::PopAndDestroy( newMedia );
-    
-                    if( medias->Count() >= countToSelect )
-                        {
-                        break;
-                        }
-                    }
-                }
-            }
-        }
-
-    // Invalid IDs
-    if( aStartIndex == -1 )
-        {
-        for( TInt i = 0; i < aEndIndex; i++ )
-            {
-            TMPXItemId mpxId;
-            mpxId.iId1 = i+66666;
-            mpxId.iId2 = 0;
-
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1);
-
-            CMPXMedia* newMedia = CMPXMedia::NewL();
-            CleanupStack::PushL( newMedia );
-            newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
-            newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
-            medias->AppendL( *newMedia );
-            CleanupStack::PopAndDestroy( newMedia );
-            }
-        }
-
-    // Duplicate IDs
-    if( aStartIndex == -2 )
-        {
-        if( aEndIndex > iSourceMedias->Count() )
-            {
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
-            User::Leave( KErrArgument );
-            }
-
-        for( TInt i = 0; i < aEndIndex; i++ )
-            {
-            CMPXMedia* media = (*iSourceMedias)[i];
-
-            if( media )
-                {
-                TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1);
-                iRequestedMediaIds.Append( mpxId.iId1 );
-                iRequestedMediaIds.Append( mpxId.iId1 );
-                CMPXMedia* newMedia = CMPXMedia::NewL();
-                CleanupStack::PushL( newMedia );
-                newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
-                newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
-                medias->AppendL( *newMedia );
-                medias->AppendL( *newMedia );
-                CleanupStack::PopAndDestroy( newMedia );
-                }
-            }
-        }
-
-    // Every second ID
-    if( aStartIndex == -3 )
-        {
-        if( aEndIndex > iSourceMedias->Count() )
-            {
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex);
-            User::Leave( KErrArgument );
-            }
-
-        for( TInt i = 0; i < aEndIndex; i+=2 )
-            {
-            CMPXMedia* media = (*iSourceMedias)[i];
-
-            if( media )
-                {
-                TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1);
-                iRequestedMediaIds.Append( mpxId.iId1 );
-                CMPXMedia* newMedia = CMPXMedia::NewL();
-                CleanupStack::PushL( newMedia );
-                newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
-                newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
-                medias->AppendL( *newMedia );
-                CleanupStack::PopAndDestroy( newMedia );
-                }
-            }
-        }
-
-    CleanupStack::Pop( medias );
-
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL");
-    return medias;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL( TBool aUseCopiedMedias )
-    {
-    if( aUseCopiedMedias )
-        {
-        CreateCopyOfCurrentMediasL();
-        }
-    
-    iUseCopiedMedias = aUseCopiedMedias;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL()
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL");
-    
-    if( !iMediaArray )
-        {
-        User::Leave( KErrNotReady );
-        }
-    
-    if( iMediaArrayCopy )
-        {
-        iMediaArrayCopy->Reset();
-        delete iMediaArrayCopy;
-        iMediaArrayCopy = NULL;
-        }
-    
-    iMediaArrayCopy = CMPXMediaArray::NewL();
-    
-    for( TInt i = 0; i < iMediaArray->Count(); i++ )
-        {
-        CMPXMedia* media = (*iMediaArray)[i];
-
-        if( media )
-            {
-            TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-            CMPXMedia* newMedia = CMPXMedia::NewL();
-            CleanupStack::PushL( newMedia );
-            newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId );
-            newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId );
-            iMediaArrayCopy->AppendL( *newMedia );
-            CleanupStack::PopAndDestroy( newMedia );
-            }
-        }
-
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArray
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL()
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
-
-    if ( !iCollectionEntries )
-        {
-        return;
-        }
-
-    if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!");
-        User::Leave( KErrNotSupported );
-        }
-
-    // Get up to date list of all medias in collection.
-    CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
-    
-    // Delete array of old medias
-    if( iOldMediaArray )
-        {
-        iOldMediaArray->Reset();
-        delete iOldMediaArray;
-        }
-
-    // Update the old array and create new
-    iOldMediaArray = iMediaArray;
-    iMediaArray = CMPXMediaArray::NewL();
-
-    TBool categories( EFalse );
-    
-    // Make copies of the medias.
-    for( TInt i=0; i<medias->Count(); i++ )
-        {
-        CMPXMedia* media = (*medias)[i];
-        
-        TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
-
-        if( itemId.iId2 != KVcxMvcMediaTypeVideo )
-             {
-             categories = ETrue;
-             }
-        
-        // Ignore medias on ROM.
-        TBool isOnRom( EFalse );
-        
-        if( media->IsSupported( KMPXMediaGeneralUri ) )
-            {
-            const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
-            if( url.FindC( _L("z:" ) ) != KErrNotFound )
-                {
-                isOnRom = ETrue;
-                }
-            }
-        
-        if( !isOnRom )
-            {
-            iMediaArray->AppendL( *media );
-            }
-        }
-    
-    iMediaCount = iMediaArray->Count();
-    
-    // Update count of videos on ROM.
-    if( !categories )
-        {
-        iVideosOnRomCount = 0;
-
-        for( TInt i=0; i<medias->Count(); i++ )
-            {
-            CMPXMedia* media = (*medias)[i];            
-            
-            if( media->IsSupported( KMPXMediaGeneralUri ) )
-                {
-                const TDesC& url = media->ValueText( KMPXMediaGeneralUri );
-                if( url.FindC( _L("z:" ) ) != KErrNotFound )
-                    {
-                    iVideosOnRomCount++;
-                    }
-                }
-            }
-
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount);
-        }
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetChangedMedias
-// -----------------------------------------------------------------------------
-//
-CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias");
-
-    CMPXMediaArray* changedMedias = CMPXMediaArray::NewL();
-
-    if( !aNewMedias )
-        {
-        VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
-        return changedMedias;
-        }
-
-    CleanupStack::PushL( changedMedias );
-
-    for( TInt i=0; i<aNewMedias->Count(); i++ )
-        {
-        CMPXMedia* media(NULL);
-        media = (*aNewMedias)[i];
-        
-        if( !media )
-            {
-            continue;
-            }
-        
-        TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-        CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId );
-
-        TBool add( EFalse );
-
-        // It's a new.
-        if( !oldMedia )
-            {
-            add = ETrue;
-            }
-        // Check changes
-        else
-            {
-            const TArray<TMPXAttribute> newAttributes = media->Attributes();
-            const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes();
-            if( newAttributes.Count() != oldAttributes.Count() )
-                {
-                add = ETrue;
-                }
-            else
-                {
-                for( TInt e=0; e<newAttributes.Count(); e++ )
-                    {
-                    if( !oldMedia->Match( *media, newAttributes[e] ) )
-                        {
-                        add = ETrue;
-                        break;
-                        }
-                    }
-                }
-            }
-
-        // Add a copy of the media.
-        if( add )
-            {
-            changedMedias->AppendL( *media );
-            }
-        }
-
-    CleanupStack::Pop( changedMedias );
-
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias");
-    return changedMedias;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetMediaByMpxId
-// -----------------------------------------------------------------------------
-//
-CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId )
-    {
-    if( !aMedias )
-        {
-        return NULL;
-        }
-
-    for( TInt i=0; i<aMedias->Count(); i++ )
-        {
-        CMPXMedia* media = (*aMedias)[i];
-        TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-        if( mpxId == aMpxId )
-            {
-            return media;
-            }
-        }
-    return NULL;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::SetRefreshStatus
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection )
-    {
-    iRefreshingCollection = aRefreshingCollection;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
-
-    // Print requested ids
-    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:");
-    for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
-        {
-        VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] );
-        }
-
-    // Print actual result ids and check for errors
-    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:");
-    for( TInt i = 0; i < aRequestResultMedias.Count(); i++ )
-        {
-        VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i);
-        CMPXMedia* media = aRequestResultMedias[i];
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media");
-        if( media )
-            {
-            TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
-            VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 );
-            if( media->IsSupported( KVcxMediaMyVideosInt32Value ) )
-                {
-                TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
-                VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result);
-                if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) )
-                    {
-                    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result);
-                    User::Leave( result );
-                    }
-                }
-            }
-        else
-            {
-            VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i);
-            }
-        }
-
-    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks");
-    
-    // First check the counts match
-    if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() )
-        {
-        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!");
-        User::Leave( KErrCorrupt );
-        }
-    else
-    // Check that all requested ids are in the results
-    for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ )
-        {
-        TMPXItemId mpxId;
-        mpxId.iId1 = aRequestedMediaIds[i];
-        mpxId.iId2 = 0;
-
-        TBool found( EFalse );
-        for( TInt e = 0; e < aRequestResultMedias.Count(); e++ )
-            {
-            CMPXMedia* media2 = aRequestResultMedias[e];
-            if( media2 )
-                {
-                TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId );
-
-                if( mpxId == mpxId2 )
-                    {
-                    found = ETrue;
-                    }
-                }
-            }
-
-        if( !found )
-            {
-            VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!");
-            User::Leave( KErrCorrupt );
-            }
-        }
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleCollectionMessage
+// CVcxMyVideosCollectionTester::HandleCollectionMessage
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
@@ -1584,7 +1532,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessage
+// CVcxMyVideosCollectionTester::HandleSingleCollectionMessage
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleSingleCollectionMessageL( CMPXMessage* aMessage )
@@ -1644,13 +1592,16 @@
                         delete iCollectionEntries;
                         iCollectionEntries = NULL;
                         iCollectionEntries = CMPXMedia::NewL( *aMessage );
-                        iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );
 
                         UpdateOwnedMediaArrayL();
 
                         SetRefreshStatus( EFalse );
 
+                        // add downloads to the requested ID array always and update downloads too.
+                        TBool backup = iUpdateDownloads;
+                        iUpdateDownloads = EFalse;
                         ProcessCurrentEntriesL();
+                        iUpdateDownloads = backup;
 
                         // Check
                         TRAPD( err, CheckRequestMediaArrayL( *iMediaArray, iRequestedMediaIds ) );
@@ -1662,6 +1613,10 @@
                         // Inform observer
                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageGotMediasByKMpxId, KErrNone );
                         
+                        TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
+                        if( actionErr == KErrAbort )
+                            iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+                        
                         }
                         break;
 
@@ -1698,7 +1653,7 @@
                     case KVcxMessageMyVideosListComplete:
                         {
                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
-                        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete ------>");
+                        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: KVcxMediaMyVideosCommandId: KVcxMessageMyVideosListComplete");
                         VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: ----------------------------------------------------------------");
                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageListComplete, KErrNone );
                         }
@@ -1717,6 +1672,8 @@
                         iActionCount--;
 
                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCopyOrMoveStarted, KErrNone );
+                        
+                        TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Move/Copy started.") ) );
                         }
                         break;
 
@@ -1752,6 +1709,10 @@
                             TRAP_IGNORE( iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCommandCanceled, KErrNone ) );
                             iCancelRequested = EFalse;
                             }                        
+
+                        TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
+                        if( actionErr == KErrAbort )
+                            iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
                         
                         CleanupStack::PopAndDestroy( medias );
                         }
@@ -1789,6 +1750,10 @@
                             iCancelRequested = EFalse;
                             }                        
                         
+                        TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
+                        if( actionErr == KErrAbort )
+                            iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+                        
                         CleanupStack::PopAndDestroy( medias );
                         }
                         break;
@@ -1806,6 +1771,8 @@
                         iActionCount--;
 
                         iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageDeleteStarted, KErrNone );
+                        
+                        TRAP_IGNORE( iStats->ActionProgressL( transactionId, _L("Delete started.") ) );
                         }
                         break;
 
@@ -1842,6 +1809,10 @@
                             iCancelRequested = EFalse;
                             }
                         
+                        TRAPD( actionErr, iStats->ActionEndL( transactionId, err ) );
+                        if( actionErr == KErrAbort )
+                            iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+                        
                         CleanupStack::PopAndDestroy( medias );
                         }
                         break;
@@ -1909,8 +1880,28 @@
 
             TMPXItemId itemId = *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId);
             VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2);
-       
-            if( iWaitingForItemChange && itemId.iId2 == KVcxMvcMediaTypeVideo )
+
+#if 1
+            // Check the IDs for categories
+            if( itemId.iId2 != 0 && ( itemId.iId1 != KVcxMvcCategoryIdAll &&
+                    itemId.iId1 != KVcxMvcCategoryIdDownloads &&
+                    itemId.iId1 != KVcxMvcCategoryIdTvRecordings &&
+                    itemId.iId1 != KVcxMvcCategoryIdCaptured &&
+                    itemId.iId1 != KVcxMvcCategoryIdOther ) )
+                {
+                iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrCorrupt );
+                VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. INVALID ITEM ID.");
+                break;
+                }
+#endif
+            // If event if for category, skip it if it's not for the open category.
+            if( iCurrentOpenedLevelIndex != -1 && itemId.iId2 > 0 && itemId.iId1 != iCurrentOpenedLevelIndex )
+                {
+                VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Not for open category. Skip.");
+                break;
+                }
+
+            if( iWaitingForItemChange && itemId.iId2 == 0 )
                 {
                 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Stop wait for item change");
                 iWaitingForItemChange = EFalse;
@@ -1926,20 +1917,14 @@
                     {
                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemInserted");
                     iInsertedItemIds.Append( itemId.iId1 );
+
                     refreshNeeded = ETrue;
+                    iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemInserted, KErrNone );
                     
-                    if( itemId.iId2 == KVcxMvcMediaTypeVideo)
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoInserted, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryInserted, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumInserted, KErrNone );
-                        }
+                    TRAPD( actionErr, iStats->ActionEndL( KSideloadVideoActionId, KErrNone ) );
+                    if( actionErr == KErrAbort )
+                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+                    
                     }
                     break;
 
@@ -1948,19 +1933,11 @@
                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemDeleted");
                     iDeletedItemIds.Append( itemId.iId1 );
                     refreshNeeded = ETrue;
+                    iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemDeleted, KErrNone );
                     
-                    if( itemId.iId2 == KVcxMvcMediaTypeVideo)
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoDeleted, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryDeleted, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumDeleted, KErrNone );
-                        }
+                    TRAPD( actionErr, iStats->ActionEndL( KRemoveMediaActionId, KErrNone ) );
+                    if( actionErr == KErrAbort )
+                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
                     }
                     break;
 
@@ -1968,29 +1945,17 @@
                     {
                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: changeEvent EMPXItemModified");
                     refreshNeeded = EFalse;
-                    
                     if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) )
                         {
                         TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value );
                         if ( extraInfo == EVcxMyVideosVideoListOrderChanged )
                             {
-                            VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
+                            VCXLOGLO1("CVcxMyVideosCollectionTester:: Received EVcxMyVideosVideoListOrderChanged ------->");
                             iObserver->HandleVcxMvTesterMessageL( KVCXMyVideosTestMessageVideoListOrderChanged, KErrNone );
                             refreshNeeded = ETrue;
                             }
                         }
-                    if( itemId.iId2 == KVcxMvcMediaTypeVideo)
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxVideoModified, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeCategory )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxCategoryModified, KErrNone );
-                        }
-                    else if( itemId.iId2 == KVcxMvcMediaTypeAlbum )
-                        {
-                        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxAlbumModified, KErrNone );
-                        }
+                    iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageMpxItemModified, KErrNone );
                     }
                     break;
 
@@ -2002,6 +1967,15 @@
                     break;
                 }
 
+            if( itemId.iId2 == 0 )
+                {
+                iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionItemChanged, KErrNone );
+                }
+            else
+                {
+                iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionCategoryChanged, KErrNone );
+                }
+
             // Refresh if there's need and it's possible.
             if( refreshNeeded  )
                 {
@@ -2017,14 +1991,13 @@
                      VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Auto refresh disabled");
                      refreshNeeded = EFalse;
                      }
-#if 0
+
                 // No need to refresh if My Videos category is not open.
                 if( GetCurrentLevel() != 3 )
                     {
                     VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No refresh because level");
                     refreshNeeded = EFalse;
                     }
-#endif
 
                 if( refreshNeeded )
                     {
@@ -2051,7 +2024,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleOpenL
+// CVcxMyVideosCollectionTester::HandleOpenL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXMedia& aEntries,
@@ -2065,6 +2038,12 @@
     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
     
     SetRefreshStatus( EFalse );
+
+    TRAPD( actionErr, iStats->ActionEndL( iCurrentActionId, aError ) );
+    if( actionErr == KErrAbort )
+        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+    
+    iCurrentActionId = -1;
     
     if( aError == KErrNone )
         {
@@ -2074,7 +2053,7 @@
         iCollectionEntries = CMPXMedia::NewL( aEntries );
         
         iCollectionMediaArray = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents );        
-        
+
         UpdateOwnedMediaArrayL();
 
         // There could have been changes to the content during update.
@@ -2084,7 +2063,7 @@
 
         TInt foundInsertedItemCount(0);
 
-        for( TInt e = 0; e < iMediaCount; e++ )
+        for( TInt e=0; e<iMediaCount; e++ )
             {
             CMPXMedia* media = (*iMediaArray)[e];
             TMPXItemId itemId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId );
@@ -2142,7 +2121,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleOpenL
+// CVcxMyVideosCollectionTester::HandleOpenL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/,
@@ -2155,7 +2134,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL
+// CVcxMyVideosCollectionTester::HandleCollectionMediaL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL(const CMPXMedia& aMedia,
@@ -2164,6 +2143,10 @@
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMediaL");
     VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: aError: %d", aError);
 
+    TRAPD( actionErr, iStats->ActionEndL( KGetMediaFullDetailsActionId, aError ) );
+    if( actionErr == KErrAbort )
+        iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+
     if( iGettingFullDetailsForAllMedia )
         {
         iActiveWait->Stop();
@@ -2179,7 +2162,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::HandleCommandComplete
+// CVcxMyVideosCollectionTester::HandleCommandComplete
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::HandleCommandComplete( CMPXCommand* aCommandResult,
@@ -2206,6 +2189,12 @@
             {
             transactionId = *aCommandResult->Value<TUint32>( KVcxMediaMyVideosTransactionId );
             iTransactions->TransactionResponse( transactionId );
+            if( !iCurrentActionHasResponse )
+                {
+                TRAPD( actionErr, iStats->ActionEndL( transactionId, aError ) );
+                if( actionErr == KErrAbort )
+                    iObserver->HandleVcxMvTesterMessageL( KVCXMYVideosTestMessageCollectionGeneral, actionErr );
+                }
             }
         
         if( aCommandResult->IsSupported( KMPXCommandGeneralId ) )
@@ -2272,7 +2261,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetMediaCount
+// CVcxMyVideosCollectionTester::GetMediaCount
 // -----------------------------------------------------------------------------
 //
 TInt CVCXMyVideosCollectionPluginTester::GetMediaCount()
@@ -2307,7 +2296,8 @@
 
     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionAdd, 0, aSync );
     cmd->SetCObjectValueL(KMPXCommandColAddMedia, aMedia );
-
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Add media") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().CommandL(*cmd);
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2334,13 +2324,14 @@
     PrintMPXMediaL( *aMedia, ETrue );
 
     iCollectionUtility->Collection().CommandL( *cmd );
-    
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Set media") ) );
+    iCurrentActionHasResponse = EFalse;
     CleanupStack::PopAndDestroy( cmd );
     VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SetMediaL");
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::RemoveMediaL
+// CVcxMyVideosCollectionTester::RemoveMediaL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::RemoveMediaL( TInt aDrive, TInt aIndex, TBool aSync )
@@ -2354,13 +2345,15 @@
     media = (*iCollectionMediaArray)[realIndex];
     
     const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
-    iTestUtils->EnsureFileIsNotInUse( localFilePath );
+    iTestCommon->EnsureFileIsNotInUse( localFilePath );
     
     TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
 
     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
     cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId );
 
+    TRAP_IGNORE( iStats->ActionStartL( KRemoveMediaActionId, _L("Remove media") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2369,7 +2362,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL
+// CVcxMyVideosCollectionTester::RemoveMediaByMpxIdL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::RemoveMediaByMpxIdL( TInt aMpxId, TBool aSync )
@@ -2381,6 +2374,8 @@
     CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, aSync );
     cmd->SetTObjectValueL( KMPXMediaGeneralId, aMpxId );
 
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Remove media") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().CommandL( *cmd );
     CleanupStack::PopAndDestroy( cmd );
 
@@ -2388,7 +2383,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL
+// CVcxMyVideosCollectionTester::GetAllMediaFullDetailsL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::GetAllMediaFullDetailsL()
@@ -2442,7 +2437,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL
+// CVcxMyVideosCollectionTester::DeleteAllMediaFilesL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::DeleteAllMediaFilesL( )
@@ -2482,7 +2477,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL
+// CVcxMyVideosCollectionTester::DeleteFileOfMediaL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::DeleteFileOfMediaL( TInt aDrive, TInt aIndex )
@@ -2499,7 +2494,7 @@
         const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
         VCXLOGLO2("Local file path: %S", &localFilePath);
 
-        iTestUtils->EnsureFileIsNotInUse( localFilePath );
+        iTestCommon->EnsureFileIsNotInUse( localFilePath );
         TInt err = iFs.Delete( localFilePath );
         if( err != KErrNone )
             {
@@ -2515,7 +2510,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetMediaL
+// CVcxMyVideosCollectionTester::GetMediaL
 // -----------------------------------------------------------------------------
 //
 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaL( TInt aDrive, TInt aIndex )
@@ -2525,46 +2520,11 @@
     TInt realIndex = GetMediaIndexInCollectionL( aDrive, aIndex );
 
     media = (*iCollectionMediaArray)[realIndex];
-
     return media;
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL
-// -----------------------------------------------------------------------------
-//
-TInt CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL( const TDesC& aName )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
-    CMPXMedia* media = NULL;
-    
-    TInt index = -1;
-    
-    if( !iMediaArray )
-        {
-        User::Leave( KErrNotReady );
-        }
-    
-    // From last to first
-    for( TInt i = iMediaArray->Count()-1; i >= 0; i-- )
-        {
-        media = (*iMediaArray)[i];
-        
-        if( media->IsSupported( KMPXMediaGeneralTitle ) )
-            {
-            if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aName ) == KErrNone )
-                {
-                index = i;
-                break;
-                }
-            }
-        }
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetIndexOfMediaWithNameL");
-    return index;
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::MoveMediasL
+// CVcxMyVideosCollectionTester::MoveMediasL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::MoveMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
@@ -2581,6 +2541,8 @@
         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
         }
     
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Move medias") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2592,7 +2554,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CancelMoveL
+// CVcxMyVideosCollectionTester::CancelMoveL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL( TBool aSync )
@@ -2600,7 +2562,8 @@
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelMoveOrCopyL");
 
     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelMoveOrCopy, aSync );
-
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel move or copy") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().CommandL( *cmd );
     CleanupStack::PopAndDestroy( cmd );
     
@@ -2610,7 +2573,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CopyMediasL
+// CVcxMyVideosCollectionTester::CopyMediasL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::CopyMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TInt aDestDrive, TBool aSync )
@@ -2627,6 +2590,8 @@
         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
         }
     
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Copy medias") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2638,7 +2603,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteMediasL
+// CVcxMyVideosCollectionTester::DeleteMediasL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::DeleteMediasL( TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex, TBool aSync )
@@ -2653,7 +2618,8 @@
         {
         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
         }
-
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2666,7 +2632,7 @@
 
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL
+// CVcxMyVideosCollectionTester::DeleteMediasByMpxIdsL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::DeleteMediasByMpxIdsL( CMPXMediaArray* aMedias, TBool aSync )
@@ -2686,7 +2652,8 @@
         {
         cmd->SetCObjectValueL( KMPXMediaArrayContents, aMedias );
         }
-
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2697,7 +2664,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL
+// CVcxMyVideosCollectionTester::DeleteMediaByMpxIdL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL( TMPXItemId& aMpxId, TBool aSync )
@@ -2722,7 +2689,8 @@
         {
         cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
         }
-    
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Delete media") ) );
+    iCurrentActionHasResponse = ETrue;
     iCollectionUtility->Collection().CommandL( *cmd );
 
     CleanupStack::PopAndDestroy( cmd );
@@ -2734,7 +2702,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CancelDeleteL
+// CVcxMyVideosCollectionTester::CancelDeleteL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync )
@@ -2742,7 +2710,8 @@
     VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL");
 
     CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync );
-
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel delete") ) );
+    iCurrentActionHasResponse = EFalse;
     iCollectionUtility->Collection().CommandL( *cmd );
     CleanupStack::PopAndDestroy( cmd );
 
@@ -2752,179 +2721,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::CreateAlbumL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::CreateAlbumL( const TDesC& aName, TBool aSync, TBool aInvalidCmd )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateAlbumL");
-
-    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddAlbum, aSync );
-
-    if( !aInvalidCmd )
-        {
-        cmd->SetTextValueL( KMPXMediaGeneralTitle, aName );
-        }
-
-    iCollectionUtility->Collection().CommandL( *cmd );
-    CleanupStack::PopAndDestroy( cmd );
-
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateAlbumL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteAlbumsL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::DeleteAlbumsL( RArray<TPtrC>& aAlbumNames )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
-
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL( array );
-    
-    for( int i = 0; i < aAlbumNames.Count(); i++ )
-        {
-        TMPXItemId albumId;
-        TRAPD(err, albumId = GetAlbumIdL( aAlbumNames[i] ));
-        if( err == KErrNone )
-            {
-            CMPXMedia* album = CMPXMedia::NewL();
-            CleanupStack::PushL( album );
-            album->SetTObjectValueL( KMPXMediaGeneralId, albumId );
-            array->AppendL( *album );
-            CleanupStack::PopAndDestroy( album );
-            }
-        }
-    
-    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
-    
-    cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
-
-    iCollectionUtility->Collection().CommandL( *cmd );
-    
-    CleanupStack::PopAndDestroy( cmd );
-    CleanupStack::PopAndDestroy( array );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAlbumsL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::DeleteAllAlbumL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL()
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
-
-    CMPXMediaArray* array = CMPXMediaArray::NewL();
-    CleanupStack::PushL( array );
-    CMPXMedia* album;
-    
-    for( TInt i = 0; i < iAlbumIds.Count(); i++ )
-        {
-        // don't remove photos albums
-        if( iAlbumIds[i].iId1 > 2 )
-            {
-            album = CMPXMedia::NewL();
-            CleanupStack::PushL( album );
-            album->SetTObjectValueL( KMPXMediaGeneralId, iAlbumIds[i] );
-            array->AppendL( *album );
-            CleanupStack::PopAndDestroy( album );
-            }
-        }
-    
-    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse );
-    
-    cmd->SetCObjectValueL( KMPXMediaArrayContents, array );
-
-    iCollectionUtility->Collection().CommandL( *cmd );
-    
-    CleanupStack::PopAndDestroy( cmd );
-    CleanupStack::PopAndDestroy( array );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
-    
-    TMPXItemId albumId = GetAlbumIdL( aAlbumName );
-    
-    CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
-    CleanupStack::PushL( medias );
-
-    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddToAlbum, EFalse );
-    if( medias )
-        {
-        cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
-        }
-
-    cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
-    
-    iCollectionUtility->Collection().CommandL( *cmd );
-
-    CleanupStack::PopAndDestroy( cmd );
-    CleanupStack::PopAndDestroy( medias );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
-    
-    TMPXItemId albumId = GetAlbumIdL( aAlbumName );
-    
-    CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex );
-    CleanupStack::PushL( medias );
-
-    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveFromAlbum, EFalse );
-    if( medias )
-        {
-        cmd->SetCObjectValueL( KMPXMediaArrayContents, medias );
-        }
-
-    cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId );
-    
-    iCollectionUtility->Collection().CommandL( *cmd );
-
-    CleanupStack::PopAndDestroy( cmd );
-    CleanupStack::PopAndDestroy( medias );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::RenameAlbumL
-// -----------------------------------------------------------------------------
-//
-void CVCXMyVideosCollectionPluginTester::RenameAlbumL( const TDesC& aAlbumName, const TDesC& aNewAlbumName )
-    {
-    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RenameAlbumL");
-    
-    TMPXItemId itemId = GetAlbumIdL( aAlbumName );
-    CMPXMedia *media = CMPXMedia::NewL();
-    CleanupStack::PushL( media );
-    media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId );
-    media->SetTextValueL( KMPXMediaGeneralTitle, aNewAlbumName );
-    SetMediaL( media, ETrue );
-    CleanupStack::PopAndDestroy( media );
-    
-    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RenameAlbumL");
-    }
-
-// -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh
+// CVcxMyVideosCollectionTester::SetAutomaticRefresh
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue )
@@ -2933,16 +2730,15 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::IsRefreshing
+// CVcxMyVideosCollectionTester::IsRefreshing
 // -----------------------------------------------------------------------------
 //
 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing()
     {
     return iRefreshingCollection;
     }
-
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::SetQuietMode
+// CVcxMyVideosCollectionTester::SetQuietMode
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue )
@@ -2951,7 +2747,376 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetCurrentLevel
+// CVcxMyVideosCollectionTester::StartDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::StartDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
+        TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
+        CMPXMedia* aMedia )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::StartDownloadL");
+
+    iUpdateDownloads = ETrue;
+    iDownloadsStarted = ETrue;
+
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
+
+    CMPXMedia* startDownloadReq(NULL);
+    if( !aMedia )
+        {
+        startDownloadReq = CMPXMedia::NewL();
+        CleanupStack::PushL( startDownloadReq );
+        }
+    else
+        {
+        startDownloadReq = aMedia;
+        }
+
+    //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
+    startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
+
+    // read only iap needed?
+    TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
+
+    startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
+
+    VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: UserName: %S, Password: %S.", &aUserName, &aPassword);
+    
+    startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
+    
+    cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
+
+    iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    if( !aMedia )
+        {
+        CleanupStack::PopAndDestroy( startDownloadReq );
+        }
+
+    CleanupStack::PopAndDestroy( cmd );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::StartDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::ResumeDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId,
+        TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword,
+        CMPXMedia* aMedia
+        )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
+
+    iUpdateDownloads = ETrue;
+    iDownloadsStarted = ETrue;
+
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync );
+
+    CMPXMedia* startDownloadReq(NULL);
+    if( !aMedia )
+        {
+        startDownloadReq = CMPXMedia::NewL();
+        CleanupStack::PushL( startDownloadReq );
+        }
+    else
+        {
+        startDownloadReq = aMedia;
+        }
+
+    //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId );
+    startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 );
+
+    // read only iap needed?
+    TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent;
+
+    startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags );
+
+    startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle );
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl );
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName);
+    startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword);
+
+    cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq );
+
+    CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
+    if( dl )
+        {
+        startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
+
+        TMPXItemId itemId;
+        itemId.iId1 = dl->iMpxId;
+        itemId.iId2 = 0;
+        startDownloadReq->SetTObjectValueL( KMPXMediaGeneralId, itemId );
+        
+        dl->iInformed = EFalse;
+        dl->iWaitingPause = EFalse;
+        }
+    else
+        {
+        startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, 6666 );
+        iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword );
+        }
+
+    EnsureMediaFilesAreNotInUseL();
+    
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Resume download") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    if( !aMedia )
+        {
+        CleanupStack::PopAndDestroy( startDownloadReq );
+        }
+
+    CleanupStack::PopAndDestroy( cmd );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::ResumeAllDownloadsL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL()
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
+
+    iUpdateDownloads = ETrue;
+    iDownloadsStarted = ETrue;
+
+    for( TInt i = 0; i < iDlWatcher->GetDownloadCount(); i++ )
+        {
+        CVCXMyVideosTestDownload* dl;
+        dl = iDlWatcher->GetDownloadByIndex( i );
+        if( dl && dl->iState == EVcxMyVideosDlStatePaused )
+            {
+            ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL );
+            }
+        }
+     
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::CancelDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL");
+
+    if( !aDownload )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iUpdateDownloads = ETrue;
+
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
+
+    CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
+    CleanupStack::PushL( cancelDownloadReq );
+
+    cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aDownload->iMpxId, 0 ) );
+    cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownload->iDownloadId );
+    cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, aDownload->iPath->Des() );
+
+    cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
+    
+    iDlWatcher->CancelDownloadL( aDownload->iServiceId, aDownload->iContentId, *aDownload->iUrl );
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    CleanupStack::PopAndDestroy( cancelDownloadReq );
+    CleanupStack::PopAndDestroy( cmd );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::CancelDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL (by IDs)");
+
+    iUpdateDownloads = ETrue;
+
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync );
+
+    CMPXMedia* cancelDownloadReq = CMPXMedia::NewL();
+    CleanupStack::PushL( cancelDownloadReq );
+
+    CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByIndex(0);
+
+    TPtrC downloadPath( aDownloadPath );
+
+    if( aMpxId == -1 && dl )
+        {
+        aMpxId = dl->iMpxId;
+        }
+
+    if( aDownloadId == -1 && dl )
+        {
+        aDownloadId = dl->iDownloadId;
+        }
+
+    if( aDownloadPath == _L("NULL") && dl )
+        {
+        downloadPath.Set( *dl->iPath );
+        }
+
+    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpxId: %d", aMpxId);
+    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadId: %d", aDownloadId);
+    VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadPath: %S", &aDownloadPath);
+
+    cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aMpxId, 0 ) );
+    cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownloadId );
+    cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, downloadPath );
+
+    cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq );
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    CleanupStack::PopAndDestroy( cancelDownloadReq );
+    CleanupStack::PopAndDestroy( cmd );
+
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::PauseDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
+
+    iUpdateDownloads = ETrue;
+
+    CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl );
+    if( dl )
+        {
+        dl->iWaitingPause = ETrue;
+        }
+    else
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
+        User::Leave( KErrNotFound );
+        }
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
+
+    cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    CleanupStack::PopAndDestroy( cmd );
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::PauseDownloadL
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::PauseDownloadL( const TDesC& aUrl, TBool aSync )
+    {
+    VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL");
+
+    iUpdateDownloads = ETrue;
+
+    CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync );
+
+    CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aUrl );
+    if( !dl )
+        {
+        VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!");
+        User::Leave( KErrNotFound );
+        }
+    else
+        {
+        dl->iWaitingPause = ETrue;
+        }
+    
+
+    cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId );
+
+    VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command.");
+    TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) );
+    iCurrentActionHasResponse = EFalse;
+    iCollectionUtility->Collection().CommandL( *cmd );
+
+    CleanupStack::PopAndDestroy( cmd );
+    VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL");
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::GetDownloadWatcher
+// -----------------------------------------------------------------------------
+//
+CVCXMyVideosTestDlWatcher* CVCXMyVideosCollectionPluginTester::GetDownloadWatcher()
+    {
+    return iDlWatcher;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::GetActiveDownloadCountL
+// -----------------------------------------------------------------------------
+//
+TInt CVCXMyVideosCollectionPluginTester::GetActiveDownloadCountL()
+    {
+    TInt count = 0;
+
+    CMPXMedia* media ( NULL );
+    for( TInt i = 0; i < iMediaArray->Count(); i++ )
+        {
+        media = (*iMediaArray)[i];
+
+        if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
+            {
+            TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
+
+            if( state == EVcxMyVideosDlStateDownloading || ( state == EVcxMyVideosDlStatePaused && iAutoResume ) )
+                {
+                count++;
+                }
+            }
+        }
+
+    VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester:: Active downloads: %d", count);
+
+    return count;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::SetAutoResume
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::SetAutoResume( TBool aValue )
+    {
+    iAutoResume = aValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcxMyVideosCollectionTester::GetCurrentLevel
 // -----------------------------------------------------------------------------
 //
 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel()
@@ -2968,7 +3133,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex
+// CVcxMyVideosCollectionTester::GetCurrentOpenLevelIndex
 // -----------------------------------------------------------------------------
 //
 TInt CVCXMyVideosCollectionPluginTester::GetCurrentOpenLevelIndex()
@@ -2977,7 +3142,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetLastFullMedia
+// CVcxMyVideosCollectionTester::GetLastFullMedia
 // -----------------------------------------------------------------------------
 //
 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetLastFullMedia()
@@ -2986,7 +3151,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL
+// CVcxMyVideosCollectionTester::GetMediaIndexInCollectionL
 // -----------------------------------------------------------------------------
 //
 TInt CVCXMyVideosCollectionPluginTester::GetMediaIndexInCollectionL( TInt aDrive, TInt aIndex )
@@ -3028,7 +3193,7 @@
                         break;
                         }
                     indexOfMediaWithDrive++;
-                    }
+                    }            
                 }
             }
         }
@@ -3066,7 +3231,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive
+// CVcxMyVideosCollectionTester::GetVideoCountForDrive
 // -----------------------------------------------------------------------------
 //
 TInt CVCXMyVideosCollectionPluginTester::GetVideoCountForDrive( TInt aDrive )
@@ -3095,7 +3260,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia
+// CVcxMyVideosCollectionTester::GetAllCollectionMedia
 // -----------------------------------------------------------------------------
 //
 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia()
@@ -3104,35 +3269,20 @@
     }
 
 // -----------------------------------------------------------------------------
-// CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL
+// CVcxMyVideosCollectionTester::EnsureMediaFilesAreNotInUseL
 // -----------------------------------------------------------------------------
 //
 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL()
     {
-    CMPXMediaArray* iSourceMedias;
-    
-    if( !iUseCopiedMedias )
-        {
-        if( !iMediaArray )
-            {
-            User::Leave( KErrNotReady );
-            }
-        iSourceMedias = iMediaArray;
-        }
-    else
-        {
-        if( !iMediaArrayCopy )
-            {
-            User::Leave( KErrNotReady );
-            }
-        iSourceMedias = iMediaArrayCopy;
-        }
-    
-    if( iSourceMedias->Count() <= 0 ) return; 
+    if( iMediaArray->Count() <= 0 ) return; 
     
     TInt retries = 200;
     RFile64 file;
-    TInt error( KErrNone );
+    TInt error( KErrInUse );
+    
+    const TInt KEnsureMediasNotInUseID = 1234567;
+    
+    TRAP_IGNORE( iStats->ActionStartL( KEnsureMediasNotInUseID, _L("Ensure files.") ) );
     
     TBool filesLocked( ETrue );
     // Check all files that they are not in use, retry few times.
@@ -3140,18 +3290,17 @@
         {
         filesLocked = EFalse;
         
-        for( TInt i=0; i<iSourceMedias->Count(); i++ )
+        for( TInt i=0; i<iMediaArray->Count(); i++ )
             {
-            CMPXMedia* media = (*iSourceMedias)[i];
+            CMPXMedia* media = (*iMediaArray)[i];
             
             if( media->IsSupported( KMPXMediaGeneralUri ) )
                 {
                 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri );
 
-                TInt err = file.Open( iFs, localFilePath, EFileShareExclusive );
-                if( err == KErrInUse || err == KErrLocked )
+                error = file.Open( iFs, localFilePath, EFileShareExclusive );
+                if( error == KErrInUse || error == KErrLocked )
                     {
-                    error = err;
                     filesLocked = ETrue;
                     User::After( 1000000 * 5 ); // Wait
                     break;
@@ -3159,20 +3308,76 @@
                 file.Close();
                 }
             }
-        
-            if(!filesLocked)
-                {
-                error = KErrNone;
-                }
         }
 
     if( error != KErrNone && error != KErrNotFound && error != KErrBadName )
         {
+        TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, error ) );
         VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error);
         User::Leave( error );
         }
+    else
+        {
+        TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, KErrNone ) );
+        }
     
     VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok.");
     }
-
+    
+// -----------------------------------------------------------------------------
+// CVCXMyVideosCollectionPluginTester::TimerComplete
+// -----------------------------------------------------------------------------
+//
+void CVCXMyVideosCollectionPluginTester::TimerComplete( TInt /* aTimerId */, TInt /* aError */ )
+    {
+    if( iProgressTimer )
+        {
+        iProgressTimer->After( 1000000 );
+        }
+
+    if( !iMediaArray || !iDlWatcher )
+       {
+       return;
+       }
+
+    if( iDownloadsStarted && iUpdateDownloads && GetCurrentLevel() == 3 )
+        {
+       // Print short info about downloads
+       CMPXMedia* media( NULL );
+
+       VCXLOGLO2("CVCXMyVideosCollectionPluginTester::TimerComplete: medias: %d", iMediaArray->Count());
+       for( TInt i = 0; i < iMediaArray->Count(); i++ )
+           {
+           media = (*iMediaArray)[i];
+
+           if( media->IsSupported( KVcxMediaMyVideosDownloadState ) )
+               {
+               TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState );
+
+               TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId ));
+
+               TInt progress = -1;
+               if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) )
+                   {
+                   progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress );
+                   }
+
+               TUint32 downloadId = 0;
+               if( media->IsSupported( KVcxMediaMyVideosDownloadId ) )
+                   {
+                   downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
+                   }
+
+               CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 );
+
+               if( dl )
+                   {
+//                   VCXLOGLO5("CVCXMyVideosCollectionPluginTester:: DL ID: %d, MPX ID: %d, state: %d, progress: %d", downloadId, itemId.iId1, state, progress );
+//                   VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: serviceId: %d, contentId: %d", dl->iServiceId, dl->iContentId );
+                   iDlWatcher->UpdateDownloadProgressL( itemId.iId1, downloadId, progress );
+                   }
+               }
+           }
+        }
+    }
 //  End of File