videocollection/mpxmyvideoscollection/tsrc/ut_vcxmyvideosmdsdb/src/VcxMyVideosMdsDbTestBlocks.cpp
branchRCL_3
changeset 23 8f0df5c82986
child 26 67eb01668b0e
equal deleted inserted replaced
21:55fa1ec415c6 23:8f0df5c82986
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 1 %
       
    19 
       
    20 // [INCLUDE FILES] - do not remove
       
    21 #include <e32svr.h>
       
    22 #include <StifParser.h>
       
    23 #include <StifTestInterface.h>
       
    24 
       
    25 #include <mpxlog.h>
       
    26 #include <mdeconstants.h>
       
    27 #include <mdequery.h>
       
    28 #include <bautils.h>
       
    29 #include <mpxmedia.h>
       
    30 #include <vcxmyvideosdefs.h>
       
    31 #include <mpxmediacontainerdefs.h>
       
    32 #include <mpxmediageneraldefs.h>
       
    33 #include <mpxmediageneralextdefs.h>
       
    34 #include <mpxmediaarray.h>
       
    35 #include <mpxmediavideodefs.h>
       
    36 #include <centralrepository.h>
       
    37 
       
    38 #include "vcxmyvideosmdsdb.h"
       
    39 #include "vcxmyvideoscollectionutil.h"
       
    40 
       
    41 
       
    42 #include "VcxMyVideosMdsDbTest.h"
       
    43 
       
    44 
       
    45         
       
    46 // EXTERNAL DATA STRUCTURES
       
    47 //extern  ?external_data;
       
    48 
       
    49 // EXTERNAL FUNCTION PROTOTYPES  
       
    50 //extern ?external_function( ?arg_type,?arg_type );
       
    51 
       
    52 // CONSTANTS
       
    53 //const ?type ?constant_var = ?constant;
       
    54 
       
    55 // MACROS
       
    56 //#define ?macro ?macro_def
       
    57 
       
    58 // LOCAL CONSTANTS AND MACROS
       
    59 //const ?type ?constant_var = ?constant;
       
    60 //#define ?macro_name ?macro_def
       
    61 
       
    62 // MODULE DATA STRUCTURES
       
    63 //enum ?declaration
       
    64 //typedef ?declaration
       
    65 
       
    66 // LOCAL FUNCTION PROTOTYPES
       
    67 //?type ?function_name( ?arg_type, ?arg_type );
       
    68 
       
    69 // FORWARD DECLARATIONS
       
    70 //class ?FORWARD_CLASSNAME;
       
    71 
       
    72 // ============================= LOCAL FUNCTIONS ===============================
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // ?function_name ?description.
       
    76 // ?description
       
    77 // Returns: ?value_1: ?description
       
    78 //          ?value_n: ?description_line1
       
    79 //                    ?description_line2
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 
       
    83 TInt NextIntOrZero( CStifItemParser& aItem ) 
       
    84     {
       
    85     TInt a ( 0 );
       
    86     if ( !aItem.GetNextInt( a ) )
       
    87         {
       
    88         return a;
       
    89         }
       
    90     else
       
    91         {
       
    92         return 0;
       
    93         }
       
    94     }
       
    95 
       
    96 // ============================ MEMBER FUNCTIONS ===============================
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CVcxMyVideosMdsDbTest::Delete
       
   100 // Delete here all resources allocated and opened from test methods. 
       
   101 // Called from destructor. 
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CVcxMyVideosMdsDbTest::Delete() 
       
   105     {
       
   106 
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CVcxMyVideosMdsDbTest::RunMethodL
       
   111 // Run specified method. Contains also table of test mothods and their names.
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 TInt CVcxMyVideosMdsDbTest::RunMethodL( 
       
   115     CStifItemParser& aItem ) 
       
   116     {
       
   117 
       
   118     static TStifFunctionInfo const KFunctions[] =
       
   119         {  
       
   120         ENTRY( "CreateL", CVcxMyVideosMdsDbTest::CreateL ),
       
   121         ENTRY( "DeleteL", CVcxMyVideosMdsDbTest::DeleteL ),
       
   122         ENTRY( "CancelL", CVcxMyVideosMdsDbTest::CancelL ),
       
   123         ENTRY( "AddVideoL", CVcxMyVideosMdsDbTest::AddVideoL ),
       
   124         ENTRY( "RemoveVideoL", CVcxMyVideosMdsDbTest::RemoveVideoL ),
       
   125         ENTRY( "UpdateVideoL", CVcxMyVideosMdsDbTest::UpdateVideoL ),
       
   126         ENTRY( "CreateVideoListL", CVcxMyVideosMdsDbTest::CreateVideoListL ),
       
   127         ENTRY( "CreateVideoL", CVcxMyVideosMdsDbTest::CreateVideoL )
       
   128         };
       
   129 
       
   130     const TInt count = sizeof( KFunctions ) / 
       
   131                         sizeof( TStifFunctionInfo );
       
   132 
       
   133     return RunInternalL( KFunctions, count, aItem );
       
   134 
       
   135     }
       
   136 
       
   137 TInt CVcxMyVideosMdsDbTest::CreateL( CStifItemParser& aItem )
       
   138     {
       
   139     int a ( 0 );
       
   140     
       
   141     if ( !aItem.GetNextInt( a ) )
       
   142         {
       
   143         mdssessionerror = a;
       
   144         }
       
   145     
       
   146     if ( !aItem.GetNextInt( a ) )
       
   147         {
       
   148         mdssessionasyncerror = a;
       
   149         }
       
   150     
       
   151     iMdsDb = CVcxMyVideosMdsDb::NewL( this, iFs );
       
   152     
       
   153     return KErrNone;
       
   154     }
       
   155 
       
   156 TInt CVcxMyVideosMdsDbTest::DeleteL( CStifItemParser& aItem )
       
   157     {
       
   158     delete iMdsDb;
       
   159     return KErrNone;
       
   160     }
       
   161 
       
   162 TInt CVcxMyVideosMdsDbTest::CancelL( CStifItemParser& aItem )
       
   163     {
       
   164     iMdsDb->Cancel();
       
   165     return KErrNone;
       
   166     }
       
   167 
       
   168 TInt CVcxMyVideosMdsDbTest::AddVideoL( CStifItemParser& aItem )
       
   169     {
       
   170     PrepareMdsL( aItem  );
       
   171     
       
   172     CMPXMedia* media  = CMPXMedia::NewL();
       
   173     
       
   174     TUint32 mdsId;
       
   175     
       
   176     //1. MPX ID, set by collection
       
   177     //2
       
   178     media->SetTextValueL( KMPXMediaGeneralTitle, _L("KMPXMediaGeneralTitle") );
       
   179     //3
       
   180     media->SetTextValueL( KMPXMediaGeneralComment, _L("KMPXMediaGeneralComment") );
       
   181     //4
       
   182     media->SetTextValueL( KMPXMediaGeneralUri, _L("c:\\data\\videos\\addtest1.mp4") );
       
   183     //5
       
   184     media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
       
   185     //6 Creation date
       
   186     TTime time;
       
   187     time.HomeTime();
       
   188     media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, time.Int64() );
       
   189     //7
       
   190     TUint32 flags = EVcxMyVideosVideoDrmProtected || EVcxMyVideosVideoNew;
       
   191     media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags );
       
   192     //8
       
   193     media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") ); 
       
   194     //9
       
   195     media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );
       
   196     
       
   197     //10
       
   198     TInt lastPlaybackPos( 13232 );
       
   199     media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, lastPlaybackPos );
       
   200     //11
       
   201     media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, time.Int64() );    
       
   202     //12
       
   203     media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
       
   204     //13
       
   205     media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
       
   206     //14
       
   207     media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
       
   208     //15
       
   209     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
       
   210     //16
       
   211     TReal32 duration( 1212 );
       
   212     media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, duration );
       
   213     //17
       
   214     media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
       
   215     //18
       
   216     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
       
   217 
       
   218     media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
       
   219     
       
   220     media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
       
   221     
       
   222     iMdsDb->AddVideoL( *media, mdsId );
       
   223     
       
   224     delete media;
       
   225     return KErrNone;
       
   226     }
       
   227 
       
   228 TInt CVcxMyVideosMdsDbTest::RemoveVideoL( CStifItemParser& aItem )
       
   229     {
       
   230     PrepareMdsL( aItem  );
       
   231     
       
   232     TInt id;
       
   233     aItem.GetNextInt( id );
       
   234     return iMdsDb->RemoveVideo( id );
       
   235     }
       
   236 
       
   237 TInt CVcxMyVideosMdsDbTest::UpdateVideoL( CStifItemParser& aItem )
       
   238     {
       
   239     PrepareMdsL( aItem  );
       
   240     
       
   241     CMPXMedia* media  = CMPXMedia::NewL();
       
   242     CleanupStack::PushL(media);
       
   243     //1. MPX ID, set by collection
       
   244     //2
       
   245     media->SetTextValueL( KMPXMediaGeneralTitle, _L("Titteli") );
       
   246     //3
       
   247     media->SetTextValueL( KMPXMediaGeneralComment, _L("Desciä") );
       
   248     //4
       
   249     media->SetTextValueL( KMPXMediaGeneralUri, _L("c:\\data\\videos\\addtest1.mp4") );
       
   250     //5
       
   251     media->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, 100 );
       
   252     //6 Creation date
       
   253     TTime time;
       
   254     time.HomeTime();
       
   255     media->SetTObjectValueL<TInt64>( KMPXMediaGeneralDate, time.Int64() );
       
   256     //7
       
   257     TUint32 flags = EVcxMyVideosVideoDrmProtected || EVcxMyVideosVideoNew;
       
   258     media->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, flags );
       
   259     //8
       
   260     media->SetTextValueL( KMPXMediaGeneralCopyright, _L("Copyright info") );    
       
   261     //9
       
   262     media->SetTextValueL( KMPXMediaGeneralMimeType, _L("Mime type") );    
       
   263     //10
       
   264     TInt lastPlaybackPos( 13232 );
       
   265     media->SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, lastPlaybackPos );
       
   266     //11
       
   267     media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate, time.Int64() );    
       
   268     //12
       
   269     media->SetTObjectValueL<TInt64>( KVcxMediaMyVideosAgeProfile, 18 );
       
   270     //13
       
   271     media->SetTextValueL( KVcxMediaMyVideosAudioLanguage, _L("Audio language") );
       
   272     //14
       
   273     media->SetTextValueL( KVcxMediaMyVideosAuthor, _L("Author") );
       
   274     //15
       
   275     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosOrigin, 1 );
       
   276     //16
       
   277     TReal32 duration( 1212 );
       
   278     media->SetTObjectValueL<TReal32>( KVcxMediaMyVideosDuration, duration );
       
   279     //17
       
   280     media->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 );
       
   281     //18
       
   282     media->SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, 1 );
       
   283 
       
   284     media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadError, -1 );
       
   285     
       
   286     media->SetTObjectValueL<TInt>( KVcxMediaMyVideosDownloadGlobalError, -2 );
       
   287     
       
   288     iMdsDb->UpdateVideoL( *media );
       
   289     
       
   290     CleanupStack::PopAndDestroy( media );
       
   291     
       
   292     return KErrNone;
       
   293     }
       
   294 
       
   295 TInt CVcxMyVideosMdsDbTest::CreateVideoListL( CStifItemParser& aItem )
       
   296     {
       
   297     TVcxMyVideosSortingOrder sortingorder = ( TVcxMyVideosSortingOrder ) NextIntOrZero( aItem );
       
   298     TBool ascending                       = NextIntOrZero( aItem );
       
   299     TBool fullDetails                     = NextIntOrZero( aItem );
       
   300     TBool docreate                        = NextIntOrZero( aItem );
       
   301     
       
   302     CMPXMedia* videoList( NULL );
       
   303     CMPXMediaArray* mediaArray( NULL );
       
   304                         
       
   305     if ( docreate )
       
   306         {
       
   307         videoList = CMPXMedia::NewL();
       
   308         CleanupStack::PushL( videoList );
       
   309         mediaArray = CMPXMediaArray::NewL();
       
   310         videoList->SetCObjectValueL<CMPXMediaArray>( KMPXMediaArrayContents, mediaArray );
       
   311         CleanupStack::PushL( mediaArray );
       
   312         }
       
   313     
       
   314     iMdsDb->CreateVideoListL( sortingorder, ascending, fullDetails, videoList );
       
   315     
       
   316     if ( docreate )
       
   317         {
       
   318         CleanupStack::PopAndDestroy( videoList );
       
   319         }
       
   320     else
       
   321         {
       
   322         delete videoList;
       
   323         }
       
   324     
       
   325     return KErrNone;
       
   326     }
       
   327 
       
   328 TInt CVcxMyVideosMdsDbTest::CreateVideoL( CStifItemParser& aItem )
       
   329     {
       
   330     PrepareMdsL( aItem );
       
   331     
       
   332     TUint32 aId;
       
   333     TBool aFullDetails = ETrue;
       
   334     CMPXMedia* media = iMdsDb->CreateVideoL( aId, aFullDetails );
       
   335     delete media;
       
   336     return KErrNone;
       
   337     }
       
   338 
       
   339 
       
   340 void CVcxMyVideosMdsDbTest::PrepareMdsL(  CStifItemParser& aItem  ) 
       
   341     {
       
   342     mdsoperationreturns = NextIntOrZero( aItem );
       
   343     
       
   344     mdsoperationleaves = NextIntOrZero( aItem );
       
   345     }
       
   346