camerasrv_plat/media_recorder_api/tsrc/src/camcTest_8.cpp
changeset 0 9b3e960ffc8a
child 42 605672cc2a86
equal deleted inserted replaced
-1:000000000000 0:9b3e960ffc8a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Camcorder MMF API Test DLL
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "camcTest_8.h"
       
    22 #include "camcTest.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES 
       
    27  
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // LOCAL CONSTANTS AND MACROS
       
    33 
       
    34 // MODULE DATA STRUCTURES
       
    35 
       
    36 // LOCAL FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 ///////////////////////////////////////////////////////////////////
       
    41 // Tests for Cooperation with Camera API
       
    42 //
       
    43 ///////////////////////////////////////////////////////////////////
       
    44 
       
    45 CCamcTest_8::CCamcTest_8 ()
       
    46     {
       
    47     }
       
    48 
       
    49 
       
    50 
       
    51 CCamcTest_8::~CCamcTest_8 ()
       
    52     {
       
    53     delete iCamcTestClient1; // To mute PCLINT
       
    54     iCamcTestClient1 = NULL;
       
    55     delete iCamcTestClient2; // To mute PCLINT
       
    56     iCamcTestClient2 = NULL;
       
    57     }
       
    58 
       
    59 
       
    60 void CCamcTest_8::setUpL ()
       
    61     {
       
    62     iWaitScheduler = new (ELeave) CActiveSchedulerWait;	
       
    63     // Create a new Camera API implementation object, if supported
       
    64     TRAPD( err, iUiLevelCamera = CCamera::New2L( static_cast<MCameraObserver2&>(*this), 0 /*index*/, 0 /*Priority*/ ) );
       
    65     if ( err )
       
    66         {
       
    67         PRINT( ( _L( "CCamcTest_8::setUpL CCamera::New2L return code=%d" ), err ) ); 
       
    68         // Create old Camera API implementation object.
       
    69         iUiLevelCamera = CCamera::NewL( static_cast<MCameraObserver&>(*this), 0 /*Index*/ );
       
    70         }
       
    71     else 
       
    72        {
       
    73        PRINT( ( _L( "CCamcTest_8::setUp() using new MCameraObserver2" )) ); 
       
    74        }
       
    75 
       
    76 	iUiLevelCameraHandle = iUiLevelCamera->Handle();
       
    77 	iUiLevelCamera->Reserve();
       
    78 	iWaitScheduler->Start();        
       
    79     }
       
    80 
       
    81 
       
    82 void CCamcTest_8::tearDown ()
       
    83     {   
       
    84     delete iWaitScheduler;
       
    85     delete iUiLevelCamera;    
       
    86         
       
    87 	REComSession::FinalClose();
       
    88     }
       
    89 
       
    90 
       
    91 //
       
    92 // Own test functions.
       
    93 //
       
    94 
       
    95 void CCamcTest_8::MultipleInstance_001_L()
       
    96     {
       
    97     
       
    98     ///////////////////////////////////////
       
    99     //  ID: CAMC_API.MULTIPLEINSTANCE_001
       
   100     //
       
   101     //   Action :
       
   102     //      1 Camcorder is in Prepared state
       
   103     //      A 2nd Camcorder is instanciated with same file name.
       
   104 	//   Output : 
       
   105     //      Leave with KErrInUse
       
   106     /////////////////////////////////////// 
       
   107     TInt numberOfCamcOpen = 0;
       
   108 
       
   109     TFileName file;
       
   110     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   111 
       
   112     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   113         &iError,&numberOfCamcOpen, iUiLevelCameraHandle);
       
   114     iCamcTestClient2 = CCamcTestClient_8::NewL( file,
       
   115         &iError,&numberOfCamcOpen, iUiLevelCameraHandle);
       
   116 
       
   117 
       
   118     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance001_AO1 ,
       
   119         iCamcTestClient2);    
       
   120     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance001_AO2 ,
       
   121         iCamcTestClient1); 
       
   122 
       
   123     // Start the active scheduler
       
   124     CActiveScheduler::Start();
       
   125 
       
   126     delete iCamcTestClient1;      
       
   127     iCamcTestClient1 = NULL;
       
   128     delete iCamcTestClient2; 
       
   129     iCamcTestClient2 = NULL;
       
   130     assertTIntsEqualL( KErrInUse, iError );
       
   131 
       
   132     }
       
   133 
       
   134 
       
   135 void CCamcTest_8::MultipleInstance_002_L()
       
   136     {
       
   137     
       
   138     ///////////////////////////////////////
       
   139     //  ID: CAMC_API.MULTIPLEINSTANCE_002
       
   140     //
       
   141     //   Action :
       
   142     //      1 Camcorder is in Prepared state
       
   143     //      A 2nd Camcorder is instanciated with different file name.
       
   144     //   Output : 
       
   145     //      OK
       
   146     /////////////////////////////////////// 
       
   147     TInt numberOfCamcOpen = 0;
       
   148 
       
   149     TFileName file;
       
   150     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   151     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   152         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   153 
       
   154     AddDriveLetterToPath(_L("recordQCIF2.3gp"),file);
       
   155     iCamcTestClient2 = CCamcTestClient_8::NewL( file ,
       
   156         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   157 
       
   158 
       
   159     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance002_AO1 ,
       
   160         iCamcTestClient2);    
       
   161     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance002_AO2 ,
       
   162         iCamcTestClient1); 
       
   163 
       
   164     // Start the active scheduler
       
   165     CActiveScheduler::Start();
       
   166     assertTIntsEqualL( KErrNone, iError );
       
   167     delete iCamcTestClient1;      
       
   168     iCamcTestClient1 = NULL;
       
   169     delete iCamcTestClient2;   
       
   170     iCamcTestClient2 = NULL;
       
   171     }
       
   172 
       
   173 void CCamcTest_8::MultipleInstance_003_L()
       
   174     {
       
   175     
       
   176     ///////////////////////////////////////
       
   177     //  ID: CAMC_API.MULTIPLEINSTANCE_003
       
   178     //
       
   179     //   Action :
       
   180     //      1 Camcorder is in Prepared state
       
   181     //      A 2nd Camcorder calls prepare.
       
   182     //   Output : 
       
   183     //      Leave with KErrInUse
       
   184     /////////////////////////////////////// 
       
   185     TInt numberOfCamcOpen = 0;
       
   186 
       
   187     TFileName file;
       
   188     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   189     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   190         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   191     
       
   192     AddDriveLetterToPath(_L("recordQCIF2.3gp"),file);
       
   193     iCamcTestClient2 = CCamcTestClient_8::NewL( file,
       
   194         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   195 
       
   196 
       
   197     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance003_AO1 ,
       
   198         iCamcTestClient2);    
       
   199     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance003_AO2 ,
       
   200         iCamcTestClient1); 
       
   201 
       
   202     // Start the active scheduler
       
   203     CActiveScheduler::Start();
       
   204 
       
   205     delete iCamcTestClient1;       
       
   206     iCamcTestClient1 = NULL;
       
   207     delete iCamcTestClient2;   
       
   208     iCamcTestClient2 = NULL;
       
   209     assertTIntsEqualL( KErrInUse, iError );
       
   210     }
       
   211 
       
   212 
       
   213 
       
   214 void CCamcTest_8::MultipleInstance_004_L()
       
   215     {
       
   216     
       
   217     ///////////////////////////////////////
       
   218     //  ID: CAMC_API.MULTIPLEINSTANCE_004
       
   219     //
       
   220     //   Action :
       
   221     //      1 Camcorder is Recording
       
   222     //      A 2nd Camcorder calls prepare.
       
   223     //   Output : 
       
   224     //      Leave with KErrInUse
       
   225     /////////////////////////////////////// 
       
   226     TInt numberOfCamcOpen = 0;
       
   227 
       
   228     TFileName file;
       
   229     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   230     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   231         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   232     
       
   233     AddDriveLetterToPath(_L("recordQCIF2.3gp"),file);
       
   234     iCamcTestClient2 = CCamcTestClient_8::NewL( file,
       
   235         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   236 
       
   237 
       
   238     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance004_AO1 ,
       
   239         iCamcTestClient2);    
       
   240     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance004_AO2 ,
       
   241         iCamcTestClient1); 
       
   242 
       
   243     // Start the active scheduler
       
   244     CActiveScheduler::Start();
       
   245 
       
   246     delete iCamcTestClient1; 
       
   247     iCamcTestClient1 = NULL;
       
   248     delete iCamcTestClient2; 
       
   249     iCamcTestClient2 = NULL;
       
   250     assertTIntsEqualL( KErrInUse, iError );
       
   251     }
       
   252 
       
   253 
       
   254 
       
   255 void CCamcTest_8::MultipleInstance_005_L()
       
   256     {
       
   257     
       
   258     ///////////////////////////////////////
       
   259     //  ID: CAMC_API.MULTIPLEINSTANCE_005
       
   260     //
       
   261     //   Action :
       
   262     //      1 Camcorder has finished Recording
       
   263     //      A 2nd Camcorder calls prepare.
       
   264     //   Output : 
       
   265     //      Leaves with KErrInUse
       
   266     /////////////////////////////////////// 
       
   267     TInt numberOfCamcOpen = 0;
       
   268 
       
   269     TFileName file;
       
   270     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   271     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   272         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   273 
       
   274     AddDriveLetterToPath(_L("recordQCIF2.3gp"),file);
       
   275     iCamcTestClient2 = CCamcTestClient_8::NewL( file ,
       
   276         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   277 
       
   278     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance005_AO1 ,
       
   279         iCamcTestClient2);    
       
   280     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance005_AO2 ,
       
   281         iCamcTestClient1); 
       
   282 
       
   283     // Start the active scheduler
       
   284     CActiveScheduler::Start();
       
   285     
       
   286     delete iCamcTestClient1; 
       
   287     iCamcTestClient1 = NULL;
       
   288     delete iCamcTestClient2; 
       
   289     iCamcTestClient2 = NULL;
       
   290     assertTIntsEqualL( KErrInUse, iError );
       
   291     assertTIntsEqualL( KErrHardwareNotAvailable, iError );
       
   292     }
       
   293 
       
   294 
       
   295 void CCamcTest_8::MultipleInstance_006_L()
       
   296     {
       
   297     
       
   298     ///////////////////////////////////////
       
   299     //  ID: CAMC_API.MULTIPLEINSTANCE_006
       
   300     //
       
   301     //   Action :
       
   302     //      1 Camcorder is Recording
       
   303     //      A 2nd Camcorder calls prepare.
       
   304     //   Output : 
       
   305     //      Leave with KErrInUse
       
   306     /////////////////////////////////////// 
       
   307     TInt numberOfCamcOpen = 0;
       
   308 
       
   309     
       
   310     TFileName file;
       
   311     AddDriveLetterToPath(_L("recordQCIF1.3gp"),file);
       
   312 
       
   313     iCamcTestClient1 = CCamcTestClient_8::NewL( file,
       
   314         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   315 
       
   316     AddDriveLetterToPath(_L("recordQCIF2.3gp"),file);
       
   317     iCamcTestClient2 = CCamcTestClient_8::NewL( file,
       
   318         &iError, &numberOfCamcOpen, iUiLevelCameraHandle);
       
   319 
       
   320 
       
   321     iCamcTestClient1->Start_Active_Object( K_Tc8_MultipleInstance006_AO1 ,
       
   322         iCamcTestClient2);    
       
   323     iCamcTestClient2->Start_Active_Object( K_Tc8_MultipleInstance006_AO2 ,
       
   324         iCamcTestClient1); 
       
   325 
       
   326     // Start the active scheduler
       
   327     CActiveScheduler::Start();
       
   328 
       
   329     delete iCamcTestClient1;  
       
   330     iCamcTestClient1 = NULL;      
       
   331     delete iCamcTestClient2; 
       
   332     iCamcTestClient2 = NULL;
       
   333     assertTIntsEqualL( KErrInUse, iError );
       
   334     }
       
   335     
       
   336 // //////////////////////////////////////////////////////////////////
       
   337 //   Dummy Camera API callback functions
       
   338 // //////////////////////////////////////////////////////////////////
       
   339 void CCamcTest_8::ReserveComplete(TInt /*aError*/)
       
   340     {
       
   341     RDebug::Print(_L("CCamcTest_8::ReserveComplete"));
       
   342         
       
   343     // UI level camera is being initialized        
       
   344     if (iWaitScheduler->IsStarted())
       
   345 	    {
       
   346     	 iUiLevelCamera->PowerOn();
       
   347     	 return;
       
   348 	    }
       
   349     }
       
   350 
       
   351 void CCamcTest_8::PowerOnComplete(TInt /*aError*/)
       
   352     {   
       
   353     RDebug::Print(_L("CCamcTest_8::PowerOnComplete"));
       
   354 
       
   355     // UI level camera is being initialized
       
   356     if (iWaitScheduler->IsStarted())
       
   357 	    {
       
   358     	 iWaitScheduler->AsyncStop();
       
   359     	 return;
       
   360     	}        
       
   361     }
       
   362 
       
   363 void CCamcTest_8::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/)
       
   364     {
       
   365     }
       
   366 void CCamcTest_8::ImageReady(CFbsBitmap* /*aBitmap */,HBufC8* /*aData*/,TInt /*aError*/)
       
   367     {    
       
   368     }
       
   369 void CCamcTest_8::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/,TInt /*aError*/ )
       
   370     {
       
   371     }
       
   372     
       
   373   
       
   374 // -----------------------------------------------------------------------------
       
   375 // CCamcTest_8::HandleEvent
       
   376 // MCameraObserver2 call-back handler
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 void CCamcTest_8::HandleEvent( const TECAMEvent& aEvent)
       
   380     {
       
   381     PRINT(( _L( "CCamcTest_8::HandleEvent() entering, type=%x, err=%d" ), aEvent.iEventType.iUid, aEvent.iErrorCode ));
       
   382 
       
   383     if ( aEvent.iEventType == KUidECamEventCameraNoLongerReserved )
       
   384         {
       
   385         PRINT(( _L( "CCamcTest_8::HandleEvent() KUidECamEventCameraNoLongerReserved" ) ));
       
   386         }
       
   387     else if ( aEvent.iEventType == KUidECamEventPowerOnComplete )
       
   388         {
       
   389         PRINT(( _L( "CCamcTest_8::HandleEvent() KUidECamEventPowerOnComplete" ) ));
       
   390         PowerOnComplete( aEvent.iErrorCode );
       
   391         }
       
   392     else if ( aEvent.iEventType == KUidECamEventReserveComplete )
       
   393        {
       
   394        PRINT(( _L( "CCamcTest_8::HandleEvent() KUidECamEventReserveComplete" ) ));
       
   395        ReserveComplete( aEvent.iErrorCode );
       
   396        }
       
   397 
       
   398     PRINT(( _L( "CCamcTestClient_7::HandleEvent() returning" ) ));
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CCamcTest_8::ViewFinderReady
       
   403 // MCameraObserver2 call-back handler
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CCamcTest_8::ViewFinderReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
   407     {
       
   408     PRINT(( _L( "CCamcTest_8::ViewFinderReady() NOT HANDLED err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() ));
       
   409     CFbsBitmap *buffer = NULL;
       
   410     if ( !aError )
       
   411         {
       
   412 	    aCameraBuffer.Release();
       
   413         }
       
   414     ViewFinderFrameReady( *buffer );
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CCamcTest_8::ImageBufferReady
       
   419 // MCameraObserver2 call-back handler
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 void CCamcTest_8::ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
   423     {
       
   424     PRINT(( _L( "CCamcTest_8::ImageBufferReady() BUFFER NOT HANDLED, err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() ));
       
   425 	
       
   426     if ( !aError )
       
   427         {
       
   428 	    aCameraBuffer.Release();
       
   429         }
       
   430     ImageReady( NULL, NULL, aError );
       
   431     }
       
   432     
       
   433 // -----------------------------------------------------------------------------
       
   434 // CCamcTest_8::VideoBufferReady
       
   435 // MCameraObserver2 call-back handler
       
   436 // -----------------------------------------------------------------------------
       
   437 //
       
   438 void CCamcTest_8::VideoBufferReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
   439     {
       
   440     PRINT(( _L( "CCamcTest_8::VideoBufferReady() entering, err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() ));
       
   441     MFrameBuffer* buffer = NULL;
       
   442 	
       
   443     if ( !aError )
       
   444         {
       
   445         aCameraBuffer.Release();
       
   446         }
       
   447     // Call old Camera-API observer handler
       
   448     FrameBufferReady( buffer, aError );
       
   449     
       
   450     PRINT(( _L( "CCamcTest_8::VideoBufferReady() returning" )));
       
   451     }
       
   452 
       
   453 
       
   454 
       
   455 
       
   456 MTest* CCamcTest_8::suiteL ()
       
   457     {
       
   458     // Always use NewL (Do not use NewLC) !!!
       
   459     CTestSuite *suite = CTestSuite::NewL(_L8("CCamcTest_8"));   
       
   460 
       
   461     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_001"), &MultipleInstance_001_L));
       
   462     
       
   463     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_002"), &MultipleInstance_002_L));
       
   464     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_003"), &MultipleInstance_003_L));
       
   465     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_004"), &MultipleInstance_004_L));
       
   466     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_005"), &MultipleInstance_005_L));
       
   467     suite->addTestL(CTestCaller<CCamcTest_8>::NewL(_L8("CAMC_API.MULTIPLEINSTANCE_006"), &MultipleInstance_006_L));
       
   468     
       
   469     return suite;
       
   470     }
       
   471