videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp
branchRCL_3
changeset 26 67eb01668b0e
parent 23 8f0df5c82986
child 45 baf439b22ddd
--- a/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp	Tue May 25 12:44:54 2010 +0300
+++ b/videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp	Wed Jun 09 09:44:23 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 1 %
+// Version : %version: 6 %
 
 // [INCLUDE FILES] - do not remove
 #include <e32svr.h>
@@ -35,7 +35,20 @@
 #include <mpxmediavideodefs.h>
 #include <centralrepository.h>
 
+#include <mdesession.h>
+#include <mdequery.h>
+#include <harvesterclient.h>
+#include <mpxcollectionmessagedefs.h>
+#include <vcxmyvideosdefs.h>
+#include <e32property.h>
+#include "vcxmyvideosalbum.h"
+
+#define protected public
+#define private public
 #include "vcxmyvideosmdsdb.h"
+#undef private
+#undef protected
+
 #include "vcxmyvideoscollectionutil.h"
 
 
@@ -103,7 +116,7 @@
 //
 void CVcxMyVideosMdsDbTest::Delete() 
     {
-
+    delete iVideoList;
     }
 
 // -----------------------------------------------------------------------------
@@ -124,7 +137,16 @@
         ENTRY( "RemoveVideoL", CVcxMyVideosMdsDbTest::RemoveVideoL ),
         ENTRY( "UpdateVideoL", CVcxMyVideosMdsDbTest::UpdateVideoL ),
         ENTRY( "CreateVideoListL", CVcxMyVideosMdsDbTest::CreateVideoListL ),
-        ENTRY( "CreateVideoL", CVcxMyVideosMdsDbTest::CreateVideoL )
+        ENTRY( "DoCreateVideoListL", CVcxMyVideosMdsDbTest::DoCreateVideoListL ),
+        ENTRY( "CreateVideoL", CVcxMyVideosMdsDbTest::CreateVideoL ),
+        ENTRY( "HandleQueryNewResultsL", CVcxMyVideosMdsDbTest::HandleQueryNewResultsL ),
+        ENTRY( "HandleQueryCompletedL", CVcxMyVideosMdsDbTest::HandleQueryCompletedL ),
+        ENTRY( "AsyncHandleQueryCompletedL", CVcxMyVideosMdsDbTest::AsyncHandleQueryCompletedL ),
+        ENTRY( "HandleSessionErrorL", CVcxMyVideosMdsDbTest::HandleSessionErrorL ),
+        ENTRY( "HandleObjectNotificationL", CVcxMyVideosMdsDbTest::HandleObjectNotificationL ),
+        ENTRY( "HandleObjectPresentNotification", CVcxMyVideosMdsDbTest::HandleObjectPresentNotification ),
+        ENTRY( "ShutdownNotificationL", CVcxMyVideosMdsDbTest::ShutdownNotificationL ),
+
         };
 
     const TInt count = sizeof( KFunctions ) / 
@@ -153,7 +175,7 @@
     return KErrNone;
     }
 
-TInt CVcxMyVideosMdsDbTest::DeleteL( CStifItemParser& aItem )
+TInt CVcxMyVideosMdsDbTest::DeleteL( CStifItemParser& )
     {
     delete iMdsDb;
     return KErrNone;
@@ -161,82 +183,80 @@
 
 TInt CVcxMyVideosMdsDbTest::CancelL( CStifItemParser& aItem )
     {
-    iMdsDb->Cancel();
+    TInt type = NextIntOrZero( aItem );
+    iMdsDb->Cancel( ( CVcxMyVideosMdsDb::TRequestType ) type );
     return KErrNone;
     }
 
 TInt CVcxMyVideosMdsDbTest::AddVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TBool setMimeType   = NextIntOrZero( aItem ) ;
+    propertynotdefined  = NextIntOrZero( aItem );
+    propertyisnull      = NextIntOrZero( aItem );
+    TBool setAttrs      = NextIntOrZero( aItem ) ;
     
     CMPXMedia* media  = CMPXMedia::NewL();
-    
+    CleanupStack::PushL( media );
     TUint32 mdsId;
     
-    //1. MPX ID, set by collection
-    //2
-    media->SetTextValueL( KMPXMediaGeneralTitle, _L("KMPXMediaGeneralTitle") );
-    //3
-    media->SetTextValueL( KMPXMediaGeneralComment, _L("KMPXMediaGeneralComment") );
-    //4
     media->SetTextValueL( KMPXMediaGeneralUri, _L("c:\\data\\videos\\addtest1.mp4") );
-    //5
-    media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
-    //6 Creation date
-    TTime time;
-    time.HomeTime();
-    media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, time.Int64() );
-    //7
-    TUint32 flags = EVcxMyVideosVideoDrmProtected || EVcxMyVideosVideoNew;
-    media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags );
-    //8
-    media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") ); 
-    //9
-    media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );
     
-    //10
-    TInt lastPlaybackPos( 13232 );
-    media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, lastPlaybackPos );
-    //11
-    media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, time.Int64() );    
-    //12
-    media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
-    //13
-    media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
-    //14
-    media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
-    //15
-    media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
-    //16
-    TReal32 duration( 1212 );
-    media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, duration );
-    //17
-    media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
-    //18
-    media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
+    if ( setAttrs )
+        {
+        media->SetTextValueL( KMPXMediaGeneralTitle, _L("KMPXMediaGeneralTitle") );
+        media->SetTextValueL( KMPXMediaGeneralComment, _L("KMPXMediaGeneralComment") );
+        media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
+        media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, 1465324313154 );
+        media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, 10 );
+        media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") );    
+        media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, 13232 );
+        media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, 1465324313154 );
+        media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
+        media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
+        media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
+        media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
+        media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, 1212 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
+        media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
+        media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
+        media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoBitRate, 1235 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoWidth, 15 );
+        media->SetTObjectValueL<TUint16>( KMPXMediaVideoHeight, 12 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc, 0 );
+        media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosAudioFourCc, 0 );
+        media->SetTextValueL( KMPXMediaVideoArtist, _L("artist") );
+        media->SetTObjectValueL<TInt64>( KMPXMediaGeneralExtSizeInt64, 123456 );
+        }
 
-    media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
-    
-    media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
+    if ( setMimeType )
+        {
+        media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );    
+        }
     
     iMdsDb->AddVideoL( *media, mdsId );
     
-    delete media;
+    CleanupStack::PopAndDestroy( media );
+    
     return KErrNone;
     }
 
 TInt CVcxMyVideosMdsDbTest::RemoveVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
-    
-    TInt id;
-    aItem.GetNextInt( id );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TInt id             = NextIntOrZero( aItem );
+
     return iMdsDb->RemoveVideo( id );
     }
 
 TInt CVcxMyVideosMdsDbTest::UpdateVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem  );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    mdeobjectopenresult = NextIntOrZero( aItem );
     
     CMPXMedia* media  = CMPXMedia::NewL();
     CleanupStack::PushL(media);
@@ -292,30 +312,63 @@
     return KErrNone;
     }
 
-TInt CVcxMyVideosMdsDbTest::CreateVideoListL( CStifItemParser& aItem )
+TInt CVcxMyVideosMdsDbTest::CreateVideoListL( CStifItemParser& )
+    {    
+    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) 0;
+
+    CMPXMedia* videoList( NULL );
+    CMPXMedia* localvideoList( NULL );
+    CMPXMediaArray* mediaArray( NULL );
+                        
+   
+    iMdsDb->CreateVideoListL( sortingorder, 0, 0, videoList );
+    
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::DoCreateVideoListL( CStifItemParser& aItem )
     {
-    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) NextIntOrZero( aItem );
-    TBool ascending                       = NextIntOrZero( aItem );
-    TBool fullDetails                     = NextIntOrZero( aItem );
-    TBool docreate                        = NextIntOrZero( aItem );
+    TBool bitmask = NextIntOrZero( aItem );
+    TBool storelist = NextIntOrZero( aItem );
     
+    TBool ascending                       = bitmask & 0x01;
+    TBool fullDetails                     = bitmask & 0x02;
+    TBool docreate                        = bitmask & 0x04;
+    TBool fetchongoing                    = bitmask & 0x08;
+    
+    TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) ( bitmask >> 4 );
+
     CMPXMedia* videoList( NULL );
+    CMPXMedia* localvideoList( NULL );
     CMPXMediaArray* mediaArray( NULL );
                         
     if ( docreate )
         {
-        videoList = CMPXMedia::NewL();
-        CleanupStack::PushL( videoList );
+        localvideoList = CMPXMedia::NewL();
+        CleanupStack::PushL( localvideoList );
         mediaArray = CMPXMediaArray::NewL();
-        videoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
         CleanupStack::PushL( mediaArray );
+        localvideoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
+        CleanupStack::PopAndDestroy( mediaArray );
+        
+        videoList = localvideoList;
         }
     
-    iMdsDb->CreateVideoListL( sortingorder, ascending, fullDetails, videoList );
+    if ( fetchongoing )
+        {
+        iMdsDb->DoCreateVideoListL( sortingorder, ascending, fullDetails, videoList );
+        iMdsDb->iVideoListFetchingIsOngoing = fetchongoing;
+        }
+    
+    iMdsDb->DoCreateVideoListL( sortingorder, ascending, fullDetails, videoList );
     
     if ( docreate )
         {
-        CleanupStack::PopAndDestroy( videoList );
+        CleanupStack::PopAndDestroy( localvideoList );
+        }
+    else if ( storelist )
+        {
+        iVideoList = videoList;
         }
     else
         {
@@ -327,20 +380,110 @@
 
 TInt CVcxMyVideosMdsDbTest::CreateVideoL( CStifItemParser& aItem )
     {
-    PrepareMdsL( aItem );
+    mdsoperationreturns = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
+    TBool fulldetails   = NextIntOrZero( aItem );
+    TUint32 id          = NextIntOrZero( aItem );
     
-    TUint32 aId;
-    TBool aFullDetails = ETrue;
-    CMPXMedia* media = iMdsDb->CreateVideoL( aId, aFullDetails );
+    CMPXMedia* media ( NULL );
+    media = iMdsDb->CreateVideoL( id, fulldetails );
     delete media;
     return KErrNone;
     }
 
+TInt CVcxMyVideosMdsDbTest::HandleQueryNewResultsL( CStifItemParser& aItem )
+    {
+    querycountresult        = NextIntOrZero( aItem );
+    propertyisnull          = NextIntOrZero( aItem );
+    propertynotdefined      = NextIntOrZero( aItem );
+    handledbeventleave      = NextIntOrZero( aItem );
+    
+    TInt firstnewitemindex  = NextIntOrZero( aItem );
+    TInt newitemcount       = NextIntOrZero( aItem );
+
+    
+    iMdsDb->HandleQueryNewResults( *(CMdEQuery*) NULL, firstnewitemindex, newitemcount );
+
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleQueryCompletedL( CStifItemParser&  )
+    {
+    CMdEQuery* query ( NULL );
+    iMdsDb->HandleQueryCompleted( *query, 0 );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::AsyncHandleQueryCompletedL( CStifItemParser&  aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    TInt b = NextIntOrZero( aItem );
+    TInt ret = CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( iMdsDb );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleSessionErrorL( CStifItemParser& aItem )
+    {
+    iMdsDb->iVideoListFetchingIsOngoing = NextIntOrZero( aItem );
+    TUint32 err = NextIntOrZero( aItem );
+    
+    CMdESession* cmdesession ( NULL );
+    iMdsDb->HandleSessionError( *cmdesession, err );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleObjectNotificationL( CStifItemParser& aItem )
+    {
+    TInt notificationtype = NextIntOrZero( aItem );
+    handledbeventleave    = NextIntOrZero( aItem );
+    
+    RArray<TItemId> ids;
+    ids.Append( 0 );
+    ids.Append( 1 );
+    ids.Append( 2 );
+    
+    iMdsDb->HandleObjectNotification( *(CMdESession*)0, ( TObserverNotificationType )notificationtype, ids );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::HandleObjectPresentNotification( CStifItemParser& aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    CMdESession* cmdesession ( NULL );
+    RArray<TItemId> ids;
+    ids.Append( 0 );
+    ids.Append( 1 );
+    ids.Append( 2 );
+    handledbeventleave = NextIntOrZero(aItem);
+    iMdsDb->HandleObjectPresentNotification( *cmdesession, a, ids );
+    return KErrNone;
+    }
+
+TInt CVcxMyVideosMdsDbTest::ShutdownNotificationL( CStifItemParser& aItem )
+    {
+    TInt a = NextIntOrZero( aItem );
+    iMdsDb->ShutdownNotification( a );
+    return KErrNone;
+    }
 
 void CVcxMyVideosMdsDbTest::PrepareMdsL(  CStifItemParser& aItem  ) 
     {
     mdsoperationreturns = NextIntOrZero( aItem );
-    
-    mdsoperationleaves = NextIntOrZero( aItem );
+    mdsoperationleaves  = NextIntOrZero( aItem );
     }
 
+void CVcxMyVideosMdsDbTest::HandleMyVideosDbEvent( TMPXChangeEventType , RArray<TUint32>&  )
+    {
+    if ( handledbeventleave )
+        {
+        User::Leave( handledbeventleave );
+        }
+    }
+
+void CVcxMyVideosMdsDbTest::HandleCreateVideoListResp( CMPXMedia* aVideoList, TInt aNewItemsStartIndex, TBool aComplete )
+    {
+    if ( handledbeventleave )
+        {
+        User::Leave( handledbeventleave );
+        }
+    }