mediamgmt/src/MediaMgmtSmokeTestModuleBlocks.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-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 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <StifParser.h>
       
    21 #include <Stiftestinterface.h>
       
    22 #include <MGFetch.h>
       
    23 #include <mediafiletypes.hrh>
       
    24 #include "MediaMgmtSmokeTestModule.h"
       
    25 #include "MediaMgmtObserver.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 _LIT(KTypeImage, "Images");
       
    36 _LIT(KTypeAudio, "Audio");
       
    37 _LIT(KTypeVideo, "Video");
       
    38 _LIT(KTypeAny,	 "Any");
       
    39 
       
    40 // MACROS
       
    41 //#define ?macro ?macro_def
       
    42 
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 //const ?type ?constant_var = ?constant;
       
    45 //#define ?macro_name ?macro_def
       
    46 
       
    47 // MODULE DATA STRUCTURES
       
    48 //enum ?declaration
       
    49 //typedef ?declaration
       
    50 
       
    51 // LOCAL FUNCTION PROTOTYPES
       
    52 //?type ?function_name( ?arg_type, ?arg_type );
       
    53 
       
    54 // FORWARD DECLARATIONS
       
    55 //class ?FORWARD_CLASSNAME;
       
    56 
       
    57 // ============================= LOCAL FUNCTIONS ===============================
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // ?function_name ?description.
       
    61 // ?description
       
    62 // Returns: ?value_1: ?description
       
    63 //          ?value_n: ?description_line1
       
    64 //                    ?description_line2
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 /*
       
    68 ?type ?function_name(
       
    69     ?arg_type arg,  // ?description
       
    70     ?arg_type arg)  // ?description
       
    71     {
       
    72 
       
    73     ?code  // ?comment
       
    74 
       
    75     // ?comment
       
    76     ?code
       
    77     }
       
    78 */
       
    79 
       
    80 // ============================ MEMBER FUNCTIONS ===============================
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CMediaMgmtSmokeTestModule::Delete
       
    84 // Delete here all resources allocated and opened from test methods. 
       
    85 // Called from destructor. 
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMediaMgmtSmokeTestModule::Delete() 
       
    89     {
       
    90 
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CMediaMgmtSmokeTestModule::RunMethodL
       
    95 // Run specified method. Contains also table of test mothods and their names.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 TInt CMediaMgmtSmokeTestModule::RunMethodL( 
       
    99     CStifItemParser& aItem ) 
       
   100     {
       
   101 
       
   102     static TStifFunctionInfo const KFunctions[] =
       
   103         {  
       
   104         // Copy this line for every implemented function.
       
   105         // First string is the function name used in TestScripter script file.
       
   106         // Second is the actual implementation member function. 
       
   107         ENTRY( "ListMediaItems", CMediaMgmtSmokeTestModule::ListMediaItemsL ),
       
   108         //ADD NEW ENTRY HERE
       
   109         // [test cases entries] - Do not remove
       
   110 
       
   111         };
       
   112 
       
   113     const TInt count = sizeof( KFunctions ) / 
       
   114                         sizeof( TStifFunctionInfo );
       
   115 
       
   116     return RunInternalL( KFunctions, count, aItem );
       
   117 
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMediaMgmtSmokeTestModule::ExampleL
       
   122 // Example test method function.
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CMediaMgmtSmokeTestModule::ListMediaItemsL( CStifItemParser& aItem )
       
   127     {
       
   128     CPtrCArray* expectedItems = new (ELeave) CPtrCArray(5);
       
   129     CleanupArrayDeletePushL(expectedItems);
       
   130     
       
   131     // Print to UI
       
   132     _LIT( KMediaMgmtSmokeTestModule, "MediaMgmtSmokeTestModule" );
       
   133     _LIT( KListImages, "In ListMediaItemsL" );
       
   134     TestModuleIf().Printf( 0, KMediaMgmtSmokeTestModule, KListImages );
       
   135     // Print to log file
       
   136     iLog->Log( KListImages );
       
   137 
       
   138     TInt i = 0;
       
   139     TPtrC type;
       
   140     _LIT( KParam, "Param[%i]: %S" );
       
   141     if ( aItem.GetNextString( type ) == KErrNone )
       
   142     	{
       
   143     	TPtrC itemPath;
       
   144     	while ( aItem.GetNextString ( itemPath ) == KErrNone )
       
   145     		{
       
   146     		TestModuleIf().Printf( i, KMediaMgmtSmokeTestModule, 
       
   147 									KParam, i, &itemPath );
       
   148     		expectedItems->AppendL( itemPath );
       
   149     		i++;
       
   150     		}
       
   151     
       
   152     	CDesCArrayFlat* media = new (ELeave) CDesCArrayFlat(5);
       
   153     	CleanupArrayDeletePushL(media);
       
   154     	
       
   155     	// work out the file type we are looking for
       
   156     	TMediaFileType mediaType;
       
   157     	if (type == KTypeImage)
       
   158     		{
       
   159     		mediaType = EImageFile;
       
   160     		}
       
   161     	else if (type == KTypeAudio)
       
   162     		{
       
   163     		mediaType = EAudioFile;
       
   164     		}
       
   165     	else if (type == KTypeVideo)
       
   166     		{
       
   167     		mediaType = EVideoFile;
       
   168     		}
       
   169     	else
       
   170     		{
       
   171     		User::Leave(KErrArgument);
       
   172     		}
       
   173     	
       
   174     	MediaMgmtObserver* observer = new (ELeave) MediaMgmtObserver;
       
   175     
       
   176     	if (MGFetch::RunL(*media, mediaType, EFalse, observer))
       
   177     		{
       
   178     		//compare the two
       
   179     		TInt total = media->Count();
       
   180     		}
       
   181     
       
   182     	CleanupStack::PopAndDestroy(media);
       
   183     	}
       
   184     
       
   185     CleanupStack::PopAndDestroy(expectedItems);
       
   186     return KErrNone;
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CMediaMgmtSmokeTestModule::?member_function
       
   191 // ?implementation_description
       
   192 // (other items were commented in a header).
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 /*
       
   196 TInt CMediaMgmtSmokeTestModule::?member_function(
       
   197    CItemParser& aItem )
       
   198    {
       
   199 
       
   200    ?code
       
   201 
       
   202    }
       
   203 */
       
   204 
       
   205 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   206 // None
       
   207 
       
   208 //  [End of File] - Do not remove