mpx/tsrc/public/basic/playbackplugintest/src/playbackplugintestBlocks.cpp
changeset 62 b276843a15ba
equal deleted inserted replaced
58:c76ea6caa649 62:b276843a15ba
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  Scripted Tests for MPX Playback Plugin
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <StifParser.h>
       
    21 #include <Stiftestinterface.h>
       
    22 #include <mpxplaybackutility.h>
       
    23 #include <mpxplaybackmessagedefs.h> 
       
    24 #include <mpxmessagegeneraldefs.h> 
       
    25 #include <mpxplaybackmessage.h>
       
    26 #include "testcommonpluginuids.h"
       
    27 #include "playbackplugintest.h"
       
    28 
       
    29 const TUid KPbTestPlugin = {KPlaybackTestPluginImpId};
       
    30 const TUid KPbFusionVideoHelixPlugin = {0x10282551};
       
    31 const TUid KPbLocalAudioPlugin = {0x101FFC06};
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // From MMPXPlaybackObserver
       
    37 // Handle playback message.
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CPlaybackPluginTest::HandlePlaybackMessage( 
       
    41         CMPXMessage* aMessage, TInt aError )
       
    42     {
       
    43     iLog->Log(_L("Cmpxharvestertest::HandlePlaybackMessage: %d"), KTextHandlePlaybackMessage2);
       
    44     TMPXMessageId id( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
       
    45     TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ));
       
    46     TInt type( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
       
    47     TInt data( *aMessage->Value<TInt>( KMPXMessageGeneralData ) );
       
    48     iLog->Log(_L("CPlaybackPluginTest::HandlePlaybackMessage: %d, %d, %d"), event, type, data);
       
    49    
       
    50     iLog->Log(_L("CPlaybackPluginTest::HandlePlaybackMessage: %d"), aError); 
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CPlaybackPluginTest::Delete
       
    55 // Delete here all resources allocated and opened from test methods. 
       
    56 // Called from destructor. 
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CPlaybackPluginTest::Delete() 
       
    60     {
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CPlaybackPluginTest::RunMethodL
       
    65 // Run specified method. Contains also table of test mothods and their names.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 TInt CPlaybackPluginTest::RunMethodL( CStifItemParser& aItem ) 
       
    69     {
       
    70 
       
    71     static TStifFunctionInfo const KFunctions[] =
       
    72         {  
       
    73         // Copy this line for every implemented function.
       
    74         // First string is the function name used in TestScripter script file.
       
    75         // Second is the actual implementation member function. 
       
    76                              
       
    77         ENTRY( "MMPXPlaybackUtilityNewL", CPlaybackPluginTest::MMPXPlaybackUtilityNewL ),
       
    78         ENTRY( "MMPXPlaybackUtilityNewLHelixVideoPlugin", CPlaybackPluginTest::MMPXPlaybackUtilityNewLHelixVideoPlugin ),           
       
    79         ENTRY( "MMPXPlaybackUtilityNewLLocalAudioPlugin", CPlaybackPluginTest::MMPXPlaybackUtilityNewLLocalAudioPlugin ),
       
    80         ENTRY( "MMPXPlaybackUtilityUtilityL", CPlaybackPluginTest::MMPXPlaybackUtilityUtilityL ),
       
    81         ENTRY( "InitStreamingL", CPlaybackPluginTest::InitStreamingL ),
       
    82         ENTRY( "Close", CPlaybackPluginTest::Close ),
       
    83         ENTRY( "InitStreaming2L", CPlaybackPluginTest::InitStreaming2L ),
       
    84         ENTRY( "InitRFileL", CPlaybackPluginTest::InitRFileL ),
       
    85         ENTRY( "InitURIL", CPlaybackPluginTest::InitURIL ),
       
    86         //ADD NEW ENTRY HERE
       
    87         // [test cases entries] - Do not remove
       
    88         };
       
    89 
       
    90     const TInt count = sizeof( KFunctions ) / 
       
    91                         sizeof( TStifFunctionInfo );
       
    92 
       
    93     return RunInternalL( KFunctions, count, aItem );
       
    94 
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CPlaybackPluginTest::MMPXPlaybackUtilityNewL
       
    99 // NewL test method function.
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TInt CPlaybackPluginTest::MMPXPlaybackUtilityNewL(CStifItemParser& /*aItem*/)
       
   104     {
       
   105     TInt err = KErrNone;    
       
   106     TRAP(err, 
       
   107          iPlaybackUtility = MMPXPlaybackUtility::NewL(KPbModeNewPlayer, this));
       
   108     if (err == KErrNone)
       
   109         {
       
   110         TRAP(err, 
       
   111              iPlaybackUtility->PlayerManager().SelectPlayerL(KPbTestPlugin));
       
   112         }
       
   113     if (err!= KErrNone)
       
   114         {
       
   115         iLog->Log(_L("CPlaybackPluginTest::MMPXPlaybackUtilityNewL: %d"), err);
       
   116         }   
       
   117     return err;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CPlaybackPluginTest::MMPXPlaybackUtilityNewLHelixVideoPlugin
       
   122 // NewL test method function.
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CPlaybackPluginTest::MMPXPlaybackUtilityNewLHelixVideoPlugin(CStifItemParser& /*aItem*/)
       
   127     {
       
   128     TInt err = KErrNone;    
       
   129     TRAP(err, 
       
   130          iPlaybackUtility = MMPXPlaybackUtility::NewL(KPbModeNewPlayer, this));
       
   131     
       
   132     if (err == KErrNone)
       
   133         {
       
   134         TRAP(err, 
       
   135              iPlaybackUtility->PlayerManager().
       
   136                                  SelectPlayerL(KPbFusionVideoHelixPlugin));
       
   137         }
       
   138     
       
   139     if (err!= KErrNone)
       
   140         {
       
   141         iLog->Log(_L("CPlaybackPluginTest::MMPXPlaybackUtilityNewLHelixVideoPlugin: %d"), err);
       
   142         } 
       
   143     
       
   144     return err;
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CPlaybackPluginTest::MMPXPlaybackUtilityNewLLocalAudioPlugin
       
   149 // NewL test method function.
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CPlaybackPluginTest::MMPXPlaybackUtilityNewLLocalAudioPlugin(CStifItemParser& /*aItem*/)
       
   154     {
       
   155     TInt err = KErrNone;    
       
   156     TRAP(err, 
       
   157          iPlaybackUtility = MMPXPlaybackUtility::NewL(KPbModeNewPlayer, this));
       
   158     
       
   159     if (err == KErrNone)
       
   160         {
       
   161         TRAP(err, 
       
   162              iPlaybackUtility->PlayerManager().
       
   163                                  SelectPlayerL(KPbLocalAudioPlugin));
       
   164         }
       
   165     
       
   166     if (err!= KErrNone)
       
   167         {
       
   168         iLog->Log(_L("CPlaybackPluginTest::MMPXPlaybackUtilityNewLLocalAudioPlugin: %d"), err);
       
   169         } 
       
   170     
       
   171     return err;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CPlaybackPluginTest::Close
       
   176 // NewL test method function.
       
   177 // (other items were commented in a header).
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 TInt CPlaybackPluginTest::Close(CStifItemParser& /*aItem*/)
       
   181     {
       
   182     TInt err = KErrNone;
       
   183     iLog->Log( _L("Entering Close::Starting closing MMPXPlaybackUtility...") );
       
   184     if ( iPlaybackUtility )
       
   185         {
       
   186         iPlaybackUtility->Close();
       
   187         iPlaybackUtility = NULL;
       
   188         }
       
   189     iLog->Log( _L("Getting out of Close.") );
       
   190     return err;
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CPlaybackPluginTest::MMPXPlaybackUtilityUtilityL
       
   195 // UtilityL test method function.
       
   196 // (other items were commented in a header).
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 TInt CPlaybackPluginTest::MMPXPlaybackUtilityUtilityL(CStifItemParser& /*aItem*/)
       
   200     {
       
   201     TInt err = KErrNone;    
       
   202     TRAP(err,iPlaybackUtility = MMPXPlaybackUtility::UtilityL());
       
   203     if (err!= KErrNone)
       
   204         {
       
   205         iLog->Log(_L("CPlaybackPluginTest::MMPXPlaybackUtilityUtilityL: %d"), err);
       
   206         }   
       
   207     return err;
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CPlaybackPluginTest::InitStreamingL
       
   212 // InitStreamingL test method function.
       
   213 // (other items were commented in a header).
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 TInt CPlaybackPluginTest::InitStreamingL( CStifItemParser& aItem )
       
   217     {       
       
   218     _LIT8(KTextType, "audio/mpeg");
       
   219     TInt err = KErrNone;
       
   220     iLog->Log( _L("Entering InitStreamingL---->") );
       
   221     TPtrC uri;
       
   222     TPtrC FileNamePtr;
       
   223     TInt accesspoint = 2;
       
   224     while ( aItem.GetNextString( uri ) == KErrNone )
       
   225            {
       
   226             TBuf<120> KFrom;
       
   227             KFrom.Append(KPlaybackPluginTest_digitalPath);
       
   228             KFrom.Append(uri);
       
   229             TFileName FileName = KFrom;
       
   230             iLog->Log( _L("Input file [%S]"), &FileNamePtr );          
       
   231             TRAP(err, iPlaybackUtility->InitStreamingL( FileName, &KTextType, accesspoint));
       
   232             if( err == KErrNone )
       
   233                 {
       
   234                 iLog->Log( _L("Succeeded in initialising streaming.") );
       
   235                 }
       
   236             else
       
   237                 {
       
   238                 iLog->Log( _L("Failed to initialise streaming.Error %d returns."),err );
       
   239                 }
       
   240            }
       
   241     iLog->Log( _L("<----Ending InitStreamingL") );
       
   242     return err;
       
   243 
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CPlaybackPluginTest::InitStreaming2L
       
   248 // InitStreamingL test method function.
       
   249 // (other items were commented in a header).
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TInt CPlaybackPluginTest::InitStreaming2L(CStifItemParser& aItem)
       
   253     {
       
   254     TInt err = KErrNone;
       
   255     iLog->Log( _L("Entering InitStreaming2L---->") );
       
   256     TInt accessPoint = 2;
       
   257     TPtrC fileFullName; 
       
   258     if( aItem.GetNextString( fileFullName ) == KErrNone )
       
   259         {
       
   260         TBuf<120> KFrom;
       
   261         KFrom.Append(KPlaybackPluginTest_digitalPath);
       
   262         KFrom.Append(fileFullName);
       
   263         TFileName FileName = KFrom;
       
   264         RFs   fs;
       
   265         RFile file;        
       
   266         User::LeaveIfError(fs.Connect());
       
   267         fs.ShareProtected();
       
   268         User::LeaveIfError(file.Open( fs, FileName, EFileShareReadersOrWriters));
       
   269         iLog->Log( _L("Starting initialising streaming...") );
       
   270         TRAP(err,iPlaybackUtility->InitStreamingL( file, accessPoint));
       
   271         fs.Close();
       
   272         if( err == KErrNone )
       
   273             {
       
   274             iLog->Log( _L("Succeeded in initialising streaming.") );
       
   275             }
       
   276         else
       
   277             {
       
   278             iLog->Log( _L("Failed to initialise streaming.Error %d returns."),err );
       
   279             }
       
   280         }
       
   281     else
       
   282         {
       
   283         err = KErrArgument;
       
   284         iLog->Log( _L("Pass in bad parameter.User leaves here.") );
       
   285         User::LeaveIfError( err );
       
   286         }
       
   287     
       
   288     iLog->Log( _L("<----Getting out of InitStreaming2L\r\n.") );
       
   289     return err;
       
   290     }
       
   291 
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CPlaybackPluginTest::InitRFileL
       
   295 // InitL test method function.
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 TInt CPlaybackPluginTest::InitRFileL(CStifItemParser& aItem)
       
   300     {
       
   301     TInt err = KErrNone;
       
   302     iLog->Log( _L("Entering InitRFileL---->") );
       
   303     TPtrC fileFullName; 
       
   304     
       
   305     if( aItem.GetNextString( fileFullName ) == KErrNone )
       
   306         {
       
   307         TBuf<120> KFrom;
       
   308         KFrom.Append(KPlaybackPluginTest_digitalPath);
       
   309         KFrom.Append(fileFullName);
       
   310         TFileName FileName = KFrom;
       
   311         RFs   fs;
       
   312         RFile file;        
       
   313         User::LeaveIfError(fs.Connect());
       
   314         fs.ShareProtected();
       
   315         User::LeaveIfError(file.Open( fs, FileName, EFileShareReadersOrWriters));
       
   316         iLog->Log( _L("Starting InitRFileL...") );
       
   317         TRAP(err, iPlaybackUtility->InitL( file));
       
   318         fs.Close(); 
       
   319         if( err == KErrNone )
       
   320             {
       
   321             iLog->Log( _L("Succeeded InitRFileL.") );
       
   322             }
       
   323         else
       
   324             {
       
   325             iLog->Log( _L("Failed to InitRFileL. Error %d returns."),err );
       
   326             }
       
   327         }
       
   328     else
       
   329         {
       
   330         err = KErrArgument;
       
   331         iLog->Log( _L("Pass in bad parameter.User leaves here.") );
       
   332         User::LeaveIfError( err );
       
   333         }
       
   334     
       
   335     iLog->Log( _L("<----Getting out of InitRFileL\r\n.") );
       
   336     return err;
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CPlaybackPluginTest::InitURIL
       
   341 // InitL test method function.
       
   342 // (other items were commented in a header).
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 TInt CPlaybackPluginTest::InitURIL(CStifItemParser& aItem)
       
   346     {
       
   347     TInt err = KErrNone;
       
   348     _LIT8(KTextType, "audio/mpeg");
       
   349     iLog->Log( _L("Entering InitURIL---->") );
       
   350     TPtrC uri;
       
   351     TPtrC FileNamePtr;
       
   352     while ( aItem.GetNextString( uri ) == KErrNone )
       
   353            {
       
   354             TBuf<120> KFrom;
       
   355             KFrom.Append(KPlaybackPluginTest_digitalPath);
       
   356             KFrom.Append(uri);
       
   357             TFileName FileName = KFrom;
       
   358             iLog->Log( _L("Input file [%S]"), &FileNamePtr );          
       
   359             TRAP(err, iPlaybackUtility->InitL( FileName, &KTextType));
       
   360             if( err == KErrNone )
       
   361                 {
       
   362                 iLog->Log( _L("Succeeded in InitURIL.") );
       
   363                 }
       
   364             else
       
   365                 {
       
   366                 iLog->Log( _L("Failed to InitURIL. Error %d returns."),err );
       
   367                 }
       
   368            }
       
   369     iLog->Log( _L("<----Getting out of InitURIL\r\n.") );
       
   370     return err;
       
   371     }
       
   372 
       
   373 //  [End of File] - Do not remove