videoplayback/hbvideoplaybackview/tsrc/testvideoplaybackcontrolscontroller/src/testmpxvideoplaybackcontrolscontroller.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     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:   tester for methods in Video Playback Controls Controller
       
    15 * 
       
    16 */
       
    17 
       
    18 // Version : %version:  1 %
       
    19 
       
    20 #include <e32err.h>
       
    21 #include <w32std.h>
       
    22 #include <qobject>
       
    23 
       
    24 #include <hbapplication.h>
       
    25 #include <hbinstance.h>
       
    26 #include <hblabel.h>
       
    27 #include <MMFScalingCustomCommandConstants.h>
       
    28 
       
    29 #include "mpxvideo_debug.h"
       
    30 #include "mpxvideoplaybackcontrol.hrh"
       
    31 #include "mpxcommonvideoplaybackview.hrh"
       
    32 #include "testmpxvideoplaybackcontrolscontroller.h"
       
    33 #include "hbvideobaseplaybackview.h"
       
    34 #include "mpxvideoplaybackviewfiledetails.h"
       
    35 #include "mpxvideoviewwrapper.h"
       
    36 #include "mpxvideoplaybackfullscreencontrol.h"
       
    37 #include "mpxvideoplaybackcontrolconfiguration.h"
       
    38 #include "mpxvideoplaybacknontouchvolumebar.h"
       
    39 #include "thumbnailmanager_qt.h"
       
    40 #include "mpxvideoplaybackdocumentloader.h"
       
    41 
       
    42 #define private public
       
    43 #include "mpxvideoplaybackcontrolscontroller.h"
       
    44 #undef private
       
    45 
       
    46 const TInt KControlListsUpdated = 12; // additional extension of TMPXPlaybackState
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // main
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 int main(int argc, char *argv[])
       
    53 {
       
    54     HbApplication app(argc, argv);
       
    55     HbMainWindow window;
       
    56     
       
    57     TestMPXVideoPlaybackControlsController tv;
       
    58 
       
    59     char *pass[3];
       
    60     pass[0] = argv[0];
       
    61     pass[1] = "-o";
       
    62     pass[2] = "c:\\data\\TestMPXVideoPlaybackControlsController.txt";
       
    63     
       
    64     int res = QTest::qExec(&tv, 3, pass);
       
    65     
       
    66     return res;
       
    67 }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // init
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void TestMPXVideoPlaybackControlsController::init()
       
    75 {	  
       
    76     MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlsController::init()"));
       
    77     
       
    78     mBaseVideoView = new HbVideoBasePlaybackView();
       
    79     mFileDetails   = new QMPXVideoPlaybackViewFileDetails();
       
    80     mViewWrapper   = CMPXVideoViewWrapper::NewL( mBaseVideoView );	  
       
    81     mController    = new QMPXVideoPlaybackControlsController( mBaseVideoView,
       
    82                                                               mViewWrapper,
       
    83                                                               mFileDetails );       
       
    84 }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // cleanup
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void TestMPXVideoPlaybackControlsController::cleanup()
       
    91 {
       
    92     MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlsController::cleanup()"));
       
    93     
       
    94     delete mController;
       
    95     mController = NULL;
       
    96 
       
    97     delete mFileDetails;
       
    98     mFileDetails = NULL;
       
    99 
       
   100     delete mViewWrapper;
       
   101     mViewWrapper = NULL;
       
   102     
       
   103     delete mBaseVideoView;
       
   104     mBaseVideoView = NULL;
       
   105 }
       
   106 
       
   107 // -------------------------------------------------------------------------------------------------
       
   108 // TestMPXVideoPlaybackControlsController::testAddFileDetails
       
   109 // -------------------------------------------------------------------------------------------------
       
   110 //
       
   111 void TestMPXVideoPlaybackControlsController::testAddFileDetails()
       
   112 {
       
   113     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testAddFileDetails()") );
       
   114     
       
   115     init();    
       
   116     
       
   117     //
       
   118     // local real media with no video
       
   119     //
       
   120     mFileDetails->mClipName = QString("testClip.rm");
       
   121     mFileDetails->mMimeType = QString("video/x-pn-realvideo");
       
   122         
       
   123     mController->addFileDetails( mFileDetails );    
       
   124     
       
   125     QVERIFY( mController->mFileDetails->mRNFormat == true );
       
   126     QVERIFY( mController->mViewMode == EAudioOnlyView );
       
   127     QVERIFY( mController->mControlsConfig->mUpdateControlsWithFileDetails == true );
       
   128     QVERIFY( mController->mControlsConfig->mState == EMPXControlCmdTvOutConnected );
       
   129             
       
   130     //
       
   131     // local 3GPP media with video-only
       
   132     //    
       
   133     mFileDetails->mClipName = QString("testClip.3gp");
       
   134     mFileDetails->mMimeType = QString("video/3gpp");
       
   135     mFileDetails->mVideoEnabled = true;
       
   136     mController->mViewMode = EFullScreenView;
       
   137     mFileDetails->mTvOutConnected = true;
       
   138     QFileInfo videoOnlyFile( mFileDetails->mClipName );
       
   139     
       
   140     mController->addFileDetails( mFileDetails );    
       
   141     
       
   142     QVERIFY( mController->mFileDetails->mRNFormat == false );
       
   143     QVERIFY( mController->mControlsConfig->mUpdateControlsWithFileDetails == true ); 
       
   144     
       
   145     //
       
   146     // validate 'TvOutConnected'
       
   147     //
       
   148     verifyHandleEventTvOutResult(true, true);
       
   149 
       
   150     //
       
   151     // video-only, validate volume control is dimmed
       
   152     //
       
   153     QVERIFY( mController->mVolumeControl->mValue == 0 ); 
       
   154     QVERIFY( mController->mVolumeControl->isEnabled() == false ); 
       
   155     
       
   156     //
       
   157     // verify 'title' (via mClipName) is set properly
       
   158     //
       
   159     for ( int i=0 ; i < mController->mLoader->mWidgets.count() ; i++ )
       
   160     {        
       
   161         if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "title" ) )
       
   162         {        
       
   163             HbLabel *titleLabel = qobject_cast<HbLabel*>( mController->mLoader->mWidgets[i] );        
       
   164             QVERIFY( titleLabel->plainText() == videoOnlyFile.baseName() ); 
       
   165             break;
       
   166         }
       
   167     }    
       
   168     
       
   169     //
       
   170     // non-local audio-video media, TvOut is not connected
       
   171     //
       
   172     mFileDetails->mClipName = QString("rtsp:://www.youtube.com/testClip.rm");
       
   173     mFileDetails->mPlaybackMode = EMPXVideoStreaming;
       
   174     mFileDetails->mTvOutConnected = false;
       
   175     mFileDetails->mAudioEnabled = true;
       
   176     mFileDetails->mTitle = QString("Clip Title");
       
   177     
       
   178     mController->addFileDetails( mFileDetails );    
       
   179     
       
   180     QVERIFY( mController->mFileDetails->mRNFormat == true );
       
   181     QVERIFY( mController->mControlsConfig->mUpdateControlsWithFileDetails == true ); 
       
   182     
       
   183     //
       
   184     // verify 'title' (via mTitle) is set properly
       
   185     //
       
   186     for ( int i=0 ; i < mController->mLoader->mWidgets.count() ; i++ )
       
   187     {        
       
   188         if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "title" ) )
       
   189         {        
       
   190             HbLabel *titleLabel = qobject_cast<HbLabel*>( mController->mLoader->mWidgets[i] );        
       
   191             QVERIFY( titleLabel->plainText() == mFileDetails->mTitle ); 
       
   192             break;
       
   193         }
       
   194     }    
       
   195     
       
   196     cleanup();    
       
   197 }
       
   198 
       
   199 // -------------------------------------------------------------------------------------------------
       
   200 // TestMPXVideoPlaybackControlsController::testHandleEventSetPosition
       
   201 // -------------------------------------------------------------------------------------------------
       
   202 //
       
   203 void TestMPXVideoPlaybackControlsController::testHandleEventSetPosition()
       
   204 {
       
   205     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetPosition()"));  
       
   206     
       
   207     init();    
       
   208     int value = 20000;    
       
   209     
       
   210     mController->handleEvent( EMPXControlCmdSetPosition, value );  
       
   211     
       
   212     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   213     {
       
   214         QVERIFY( mController->mControls[i]->mPosition == ( value / KPbMilliMultiplier ) );
       
   215     }
       
   216     
       
   217     cleanup();    
       
   218 }
       
   219 
       
   220 // -------------------------------------------------------------------------------------------------
       
   221 // TestMPXVideoPlaybackControlsController::testHandleEventSetDuration
       
   222 // -------------------------------------------------------------------------------------------------
       
   223 //
       
   224 void TestMPXVideoPlaybackControlsController::testHandleEventSetDuration()
       
   225 {
       
   226     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetDuration()"));  
       
   227     
       
   228     init();    
       
   229     int value = 30000;    
       
   230     
       
   231     mController->handleEvent( EMPXControlCmdSetDuration, value );  
       
   232     
       
   233     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   234     {
       
   235         QVERIFY( mController->mControls[i]->mDuration == ( value / KPbMilliMultiplier ) );    
       
   236     }
       
   237     
       
   238     cleanup();    
       
   239 }
       
   240 
       
   241 // -------------------------------------------------------------------------------------------------
       
   242 // TestMPXVideoPlaybackControlsController::testHandleEventStateChanged
       
   243 // -------------------------------------------------------------------------------------------------
       
   244 //
       
   245 void TestMPXVideoPlaybackControlsController::testHandleEventStateChanged()
       
   246 {
       
   247     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventStateChanged()"));  
       
   248     
       
   249     init();    
       
   250     TMPXVideoPlaybackControlCommandIds event = EMPXControlCmdStateChanged;
       
   251     
       
   252     //
       
   253     // state change (EPbStateInitialised, streaming)
       
   254     //
       
   255     int value = EPbStateInitialised;  
       
   256     mFileDetails->mPlaybackMode = EMPXVideoStreaming;
       
   257     mController->handleEvent( event, value );    
       
   258     verifyHandleEventStateChangedResult( value );
       
   259     
       
   260     //
       
   261     // state change (EPbStateInitialised, live-streaming)
       
   262     //
       
   263     value = EPbStateInitialised;  
       
   264     mFileDetails->mPlaybackMode = EMPXVideoLiveStreaming;
       
   265     mController->handleEvent( event, value );    
       
   266     verifyHandleEventStateChangedResult( value );
       
   267     
       
   268     //
       
   269     // state change (EPbStateInitialised, non-streaming)
       
   270     //
       
   271     value = EPbStateInitialised;    
       
   272     mFileDetails->mPlaybackMode = EMPXVideoLocal;
       
   273     mController->handleEvent( event, value );    
       
   274     verifyHandleEventStateChangedResult( value );
       
   275     
       
   276     //
       
   277     // state change (EPbStateInitialising)
       
   278     //
       
   279     value = EPbStateInitialising;    
       
   280     mController->handleEvent( event, value );    
       
   281     verifyHandleEventStateChangedResult( value );
       
   282         
       
   283     //
       
   284     // state change (EPbStateBuffering)
       
   285     //
       
   286     value = EPbStateBuffering;    
       
   287     mController->handleEvent( event, value );    
       
   288     verifyHandleEventStateChangedResult( value );
       
   289     
       
   290     //
       
   291     // state change (EPbStatePlaying)
       
   292     //
       
   293     value = EPbStatePlaying;    
       
   294     mController->handleEvent( event, value );    
       
   295     verifyHandleEventStateChangedResult( value );
       
   296     
       
   297     //
       
   298     // state change (EPbStatePaused)
       
   299     //
       
   300     value = EPbStatePaused;    
       
   301     mController->handleEvent( event, value );    
       
   302     verifyHandleEventStateChangedResult( value );
       
   303 
       
   304     //
       
   305     // state change (EPbStateNotInitialised)
       
   306     //
       
   307     value = EPbStateNotInitialised;    
       
   308     mController->handleEvent( event, value );    
       
   309     verifyHandleEventStateChangedResult( value );
       
   310 
       
   311     //
       
   312     // state change (EPbStateStopped)
       
   313     //
       
   314     value = EPbStateStopped;    
       
   315     mController->handleEvent( event, value );    
       
   316     verifyHandleEventStateChangedResult( value );
       
   317 
       
   318     //
       
   319     // state change (EPbStateSeekingForward)
       
   320     //
       
   321     value = EPbStateSeekingForward;    
       
   322     mController->handleEvent( event, value );    
       
   323     verifyHandleEventStateChangedResult( value );
       
   324     
       
   325     //
       
   326     // state change (EPbStateSeekingBackward)
       
   327     //
       
   328     value = EPbStateSeekingBackward;    
       
   329     mController->handleEvent( event, value );    
       
   330     verifyHandleEventStateChangedResult( value );
       
   331     
       
   332     //
       
   333     // state change (EPbStateShuttingDown)
       
   334     //
       
   335     value = EPbStateShuttingDown;    
       
   336     mController->handleEvent( event, value );    
       
   337     verifyHandleEventStateChangedResult( value );
       
   338     
       
   339     //
       
   340     // state change (EPbStateDownloading)
       
   341     //
       
   342     value = EPbStateDownloading;    
       
   343     mController->handleEvent( event, value );    
       
   344     verifyHandleEventStateChangedResult( value );
       
   345     
       
   346     //
       
   347     // state change (EPbStatePluginSeeking)
       
   348     //
       
   349     value = EPbStatePluginSeeking;    
       
   350     mController->handleEvent( event, value );    
       
   351     verifyHandleEventStateChangedResult( value );
       
   352     
       
   353     cleanup();        
       
   354 }
       
   355 
       
   356 // -------------------------------------------------------------------------------------------------
       
   357 // TestMPXVideoPlaybackControlsController::verifyHandleEventStateChangedResult
       
   358 // -------------------------------------------------------------------------------------------------
       
   359 //
       
   360 void TestMPXVideoPlaybackControlsController::verifyHandleEventStateChangedResult( int value )
       
   361 {
       
   362     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::verifyHandleEventStateChangedResult()"));  
       
   363 
       
   364     if ( value == EPbStateInitialised && 
       
   365             ( mController->mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
       
   366               mController->mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming ) )
       
   367     {
       
   368         QVERIFY( mController->mControlsConfig->mState == EMPXControlCmdPluginInitialized );                    
       
   369     }
       
   370     else if ( value == EPbStatePlaying || value == EPbStateInitialising || 
       
   371               value == EPbStateBuffering || value == EPbStatePaused || 
       
   372               value == EPbStateNotInitialised )
       
   373     {
       
   374         for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   375         {
       
   376             QVERIFY( mController->mControls[i]->mState == value );    
       
   377             QVERIFY( mController->mControls[i]->mVisibilityState == value );    
       
   378         }
       
   379     }
       
   380     else
       
   381     {
       
   382         QVERIFY( mController->mState == value );                
       
   383     }
       
   384 }
       
   385 
       
   386 // -------------------------------------------------------------------------------------------------
       
   387 // TestMPXVideoPlaybackControlsController::testHandleEventSetVolume
       
   388 // -------------------------------------------------------------------------------------------------
       
   389 //
       
   390 void TestMPXVideoPlaybackControlsController::testHandleEventSetVolume()
       
   391 {
       
   392     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetVolume()"));  
       
   393     
       
   394     init();    
       
   395     int value = 40;    
       
   396     
       
   397     mController->handleEvent( EMPXControlCmdSetVolume, value );    
       
   398     QVERIFY( mController->mVolumeControl->mValue == value );  
       
   399     
       
   400     cleanup();    
       
   401 }
       
   402 
       
   403 // -------------------------------------------------------------------------------------------------
       
   404 // TestMPXVideoPlaybackControlsController::testHandleEventSetAspectRatio
       
   405 // -------------------------------------------------------------------------------------------------
       
   406 //
       
   407 void TestMPXVideoPlaybackControlsController::testHandleEventSetAspectRatio()
       
   408 {
       
   409     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetAspectRatio()"));  
       
   410     
       
   411     init();    
       
   412     int numScalingType = 5;
       
   413     
       
   414     for ( int i = 0; i < numScalingType; i++ )
       
   415     {    
       
   416         mController->handleEvent( EMPXControlCmdSetAspectRatio, i );   
       
   417     
       
   418         for ( int j = 0 ; j < mController->mControls.count() ; j++ )
       
   419         {
       
   420             QVERIFY( mController->mControls[j]->mAspectRatio == i );  
       
   421         }    
       
   422     }
       
   423     
       
   424     cleanup();    
       
   425 }
       
   426 
       
   427 // -------------------------------------------------------------------------------------------------
       
   428 // TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadSize
       
   429 // -------------------------------------------------------------------------------------------------
       
   430 //
       
   431 void TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadSize()
       
   432 {
       
   433     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadSize()") );
       
   434     
       
   435     init();    
       
   436     int value = 50;    
       
   437     
       
   438     mController->handleEvent( EMPXControlCmdSetDownloadSize, value );    
       
   439     
       
   440     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   441     {
       
   442         QVERIFY( mController->mControls[i]->mDownloadSize == value );  
       
   443     }
       
   444     
       
   445     cleanup();    
       
   446 }
       
   447 
       
   448 // -------------------------------------------------------------------------------------------------
       
   449 // TestMPXVideoPlaybackControlsController::testHandleEventDownloadUpdated
       
   450 // -------------------------------------------------------------------------------------------------
       
   451 //
       
   452 void TestMPXVideoPlaybackControlsController::testHandleEventDownloadUpdated()
       
   453 {
       
   454     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventDownloadUpdated()") );
       
   455     
       
   456     init();    
       
   457     int value = 55;
       
   458     
       
   459     mController->handleEvent( EMPXControlCmdDownloadUpdated, value );    
       
   460     
       
   461     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   462     {
       
   463         QVERIFY( mController->mControls[i]->mDownloadPosition == value );  
       
   464     }
       
   465     
       
   466     cleanup();    
       
   467 }
       
   468 
       
   469 // -------------------------------------------------------------------------------------------------
       
   470 // TestMPXVideoPlaybackControlsController::testHandleEventDownloadComplete
       
   471 // -------------------------------------------------------------------------------------------------
       
   472 //
       
   473 void TestMPXVideoPlaybackControlsController::testHandleEventDownloadComplete()
       
   474 {
       
   475     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventDownloadComplete()") );
       
   476     
       
   477     init();    
       
   478     int value = 60;
       
   479     
       
   480     mController->handleEvent( EMPXControlCmdDownloadComplete, value );    
       
   481     
       
   482     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   483     {
       
   484         QVERIFY( mController->mControls[i]->mDownloadPosition == value );  
       
   485     }
       
   486     
       
   487     cleanup();    
       
   488 }
       
   489 
       
   490 // -------------------------------------------------------------------------------------------------
       
   491 // TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadPaused
       
   492 // -------------------------------------------------------------------------------------------------
       
   493 //
       
   494 void TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadPaused()
       
   495 {
       
   496     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventSetDownloadPaused()") );
       
   497     
       
   498     init();    
       
   499     int value = 0;
       
   500     
       
   501     mController->handleEvent( EMPXControlCmdSetDownloadPaused, value );    
       
   502     
       
   503     QVERIFY( mController->mControlsConfig->mState == KControlListsUpdated );                    
       
   504     
       
   505     cleanup();    
       
   506 }
       
   507 
       
   508 // -------------------------------------------------------------------------------------------------
       
   509 // TestMPXVideoPlaybackControlsController::testHandleEventClearDownloadPaused
       
   510 // -------------------------------------------------------------------------------------------------
       
   511 //
       
   512 void TestMPXVideoPlaybackControlsController::testHandleEventClearDownloadPaused()
       
   513 {
       
   514     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventClearDownloadPaused()") );
       
   515     
       
   516     init();    
       
   517     int value = 0;
       
   518     
       
   519     mController->handleEvent( EMPXControlCmdClearDownloadPaused, value );    
       
   520     
       
   521     QVERIFY( mController->mControlsConfig->mState == KControlListsUpdated );                    
       
   522     
       
   523     cleanup();    
       
   524 }
       
   525 
       
   526 // -------------------------------------------------------------------------------------------------
       
   527 // TestMPXVideoPlaybackControlsController::testHandleEventTvOutConnected
       
   528 // -------------------------------------------------------------------------------------------------
       
   529 //
       
   530 void TestMPXVideoPlaybackControlsController::testHandleEventTvOutConnected()
       
   531 {
       
   532     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventTvOutConnected()") );
       
   533     
       
   534     init();    
       
   535     
       
   536     //
       
   537     // TV-Out Connected, value = true, EMPXVideoLocal
       
   538     //
       
   539     mController->handleEvent( EMPXControlCmdTvOutConnected, true );    
       
   540     verifyHandleEventTvOutResult( true, true );
       
   541         
       
   542     //
       
   543     // TV-Out Connected, value = false, EMPXVideoLocal
       
   544     //
       
   545     mController->handleEvent( EMPXControlCmdTvOutConnected, false );    
       
   546     verifyHandleEventTvOutResult( true, false );
       
   547         
       
   548     //
       
   549     // TV-Out Connected, value = false, non-EMPXVideoLocal
       
   550     //
       
   551     mController->mFileDetails->mPlaybackMode = EMPXVideoStreaming;
       
   552     mController->handleEvent( EMPXControlCmdTvOutConnected, false );    
       
   553     verifyHandleEventTvOutResult( true, false );
       
   554     
       
   555     cleanup();    
       
   556 }
       
   557 
       
   558 // -------------------------------------------------------------------------------------------------
       
   559 // TestMPXVideoPlaybackControlsController::verifyHandleEventTvOutResult
       
   560 // -------------------------------------------------------------------------------------------------
       
   561 //
       
   562 void TestMPXVideoPlaybackControlsController::verifyHandleEventTvOutResult( bool tvOutConnected,
       
   563         bool value )
       
   564 {
       
   565     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::verifyHandleEventTvOutResult(%d,%d)"),
       
   566             tvOutConnected, value ); 
       
   567     
       
   568     QVERIFY( mController->mFileDetails->mTvOutConnected == tvOutConnected );   
       
   569     
       
   570     //
       
   571     // validate setDefaultBitmap()
       
   572     //
       
   573     for ( int i=0 ; i < mController->mLoader->mWidgets.count() ; i++ )
       
   574     {        
       
   575         bool val = mController->mLoader->isVisible(i);
       
   576         
       
   577         if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "tvOutBitmap" ) )
       
   578         {
       
   579             QVERIFY( tvOutConnected? val == true : val == false ); 
       
   580         }
       
   581         else if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "realAudioOnlyBitmap" )  )
       
   582         {
       
   583             QVERIFY( mFileDetails->mRNFormat? val == true : val == false ); 
       
   584         }
       
   585         else if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "partialAudioOnlyBitmap" )  )
       
   586         {
       
   587             QVERIFY( mFileDetails->mPartialPlayback? val == true : val == false ); 
       
   588         }
       
   589         else if( mController->mLoader->mWidgets[i]->objectName() ==  QString( "audioOnlyBitmap" )  )
       
   590         {
       
   591             QVERIFY( tvOutConnected? val == false : val == true ); 
       
   592         }
       
   593     }
       
   594         
       
   595     //
       
   596     // validate generateThumbNail()
       
   597     //
       
   598     if ( tvOutConnected )
       
   599     {
       
   600         QVERIFY( ( mController->mFileDetails->mPlaybackMode == EMPXVideoLocal )? 
       
   601                    mController->mThumbNailState == EThumbNailRequsted : 
       
   602                    mController->mThumbNailState == EThumbNailNotAvailable ); 
       
   603         QVERIFY( mController->mFileDetails->mTvOutPlayAllowed == value );      
       
   604         QVERIFY( mController->mViewMode == EAudioOnlyView );          
       
   605         QVERIFY( mController->mControlsConfig->mState == EMPXControlCmdTvOutConnected );          
       
   606         QVERIFY( mController->mThumbnailManager->mThumbSize == ThumbnailManager::ThumbnailLarge );          
       
   607         QVERIFY( mController->mThumbnailManager->mQuality == ThumbnailManager::OptimizeForPerformance );          
       
   608         QVERIFY( mController->mViewTransitionIsGoingOn == false );          
       
   609     }
       
   610     else if ( mController->mFileDetails->mVideoEnabled )
       
   611     {
       
   612         QVERIFY( mController->mViewTransitionIsGoingOn == true );          
       
   613         QVERIFY( mController->mFileDetails->mTvOutPlayAllowed == true );      
       
   614         QVERIFY( mController->mViewMode == EFullScreenView );          
       
   615     }
       
   616     else if ( ! mController->mFileDetails->mVideoEnabled )
       
   617     {
       
   618         QVERIFY( mController->mViewTransitionIsGoingOn == false );          
       
   619         QVERIFY( mController->mFileDetails->mTvOutPlayAllowed == true );      
       
   620         QVERIFY( mController->mViewMode == EAudioOnlyView );          
       
   621     }
       
   622 
       
   623 }
       
   624 
       
   625 // -------------------------------------------------------------------------------------------------
       
   626 // TestMPXVideoPlaybackControlsController::testHandleEventTvOutDisconnected
       
   627 // -------------------------------------------------------------------------------------------------
       
   628 //
       
   629 void TestMPXVideoPlaybackControlsController::testHandleEventTvOutDisconnected()
       
   630 {
       
   631     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventTvOutDisconnected()") );
       
   632     
       
   633     init();    
       
   634     
       
   635     //
       
   636     // TV-Out Disconnected, value = true
       
   637     //
       
   638     mController->handleEvent( EMPXControlCmdTvOutDisconnected, true );    
       
   639     verifyHandleEventTvOutResult( false, true );
       
   640         
       
   641     //
       
   642     // TV-Out Disconnected, value = false
       
   643     //
       
   644     mController->handleEvent( EMPXControlCmdTvOutDisconnected, false );    
       
   645     verifyHandleEventTvOutResult( false, false );
       
   646     
       
   647     cleanup();    
       
   648 }
       
   649 
       
   650 // -------------------------------------------------------------------------------------------------
       
   651 // TestMPXVideoPlaybackControlsController::testHandleEventHandleErrors
       
   652 // -------------------------------------------------------------------------------------------------
       
   653 //
       
   654 void TestMPXVideoPlaybackControlsController::testHandleEventHandleErrors()
       
   655 {
       
   656     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventHandleErrors()") );
       
   657     
       
   658     init();    
       
   659     
       
   660     //
       
   661     // handle error
       
   662     //
       
   663     mController->handleEvent( EMPXControlCmdHandleErrors, 0 );    
       
   664     
       
   665     QVERIFY( mController->mThumbNailState == EThumbNailEmpty );          
       
   666     QVERIFY( mController->mState == EPbStateNotInitialised );      
       
   667     QVERIFY( mController->mViewMode == EFullScreenView );          
       
   668     
       
   669     cleanup();    
       
   670 }
       
   671 
       
   672 // -------------------------------------------------------------------------------------------------
       
   673 // TestMPXVideoPlaybackControlsController::testHandleEventShowVolumeControls
       
   674 // -------------------------------------------------------------------------------------------------
       
   675 //
       
   676 void TestMPXVideoPlaybackControlsController::testHandleEventShowVolumeControls()
       
   677 {
       
   678     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleEventShowVolumeControls()") );
       
   679     
       
   680     init();    
       
   681     
       
   682     mController->handleEvent( EMPXControlCmdShowVolumeControls, 0 );    
       
   683     
       
   684     QVERIFY( mController->mVolumeControl->mVisible == true );          
       
   685     
       
   686     cleanup();    
       
   687 }
       
   688 
       
   689 // -------------------------------------------------------------------------------------------------
       
   690 // TestMPXVideoPlaybackControlsController::testHandleCommand
       
   691 // -------------------------------------------------------------------------------------------------
       
   692 //
       
   693 void TestMPXVideoPlaybackControlsController::testHandleCommand()
       
   694 {
       
   695     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleCommand()") );
       
   696     
       
   697     init();    
       
   698     
       
   699     mController->handleCommand( EMPXPbvCmdSetPosition, 0 );    
       
   700     QVERIFY( mViewWrapper->mProperty == EPbPropertyPosition );          
       
   701     
       
   702     mController->handleCommand( EMPXPbvCmdSetVolume, 0 );    
       
   703     QVERIFY( mViewWrapper->mProperty == EPbPropertyVolume );          
       
   704     
       
   705     mController->handleCommand( EMPXPbvCmdPlay, 0 );    
       
   706     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPlay );          
       
   707     
       
   708     mController->handleCommand( EMPXPbvCmdPause, 0 );    
       
   709     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPause );          
       
   710     
       
   711     mController->handleCommand( EMPXPbvCmdPlayPause, 0 );    
       
   712     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPlayPause );          
       
   713     
       
   714     mController->handleCommand( EMPXPbvCmdStop, 0 );    
       
   715     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdStop );          
       
   716     
       
   717     mController->handleCommand( EMPXPbvCmdClose, 0 );    
       
   718     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdClose );          
       
   719     
       
   720     mController->handleCommand( EMPXPbvCmdMute, 0 );    
       
   721     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdMute );          
       
   722     
       
   723     mController->handleCommand( EMPXPbvCmdUnMute, 0 );    
       
   724     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdUnMute );          
       
   725     
       
   726     mController->handleCommand( EMPXPbvCmdChangeAspectRatio, 0 );    
       
   727     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdChangeAspectRatio );          
       
   728     
       
   729     mController->handleCommand( EMPXPbvCmdNaturalAspectRatio, 0 );    
       
   730     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdNaturalAspectRatio );          
       
   731     
       
   732     mController->handleCommand( EMPXPbvCmdZoomAspectRatio, 0 );    
       
   733     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdZoomAspectRatio );          
       
   734     
       
   735     mController->handleCommand( EMPXPbvCmdStretchAspectRatio, 0 );    
       
   736     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdStretchAspectRatio );          
       
   737     
       
   738     mController->handleCommand( EMPXPbvCmdSeekForward, 0 );    
       
   739     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdSeekForward );          
       
   740     
       
   741     mController->handleCommand( EMPXPbvCmdSeekBackward, 0 );    
       
   742     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdSeekBackward );          
       
   743     
       
   744     mController->handleCommand( EMPXPbvCmdEndSeek, 0 );    
       
   745     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdEndSeek );          
       
   746     
       
   747     mController->handleCommand( EMPXPbvCmdNextListItem, 0 );    
       
   748     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdNextListItem );          
       
   749     
       
   750     mController->handleCommand( EMPXPbvCmdPreviousListItem, 0 );    
       
   751     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPreviousListItem );          
       
   752     
       
   753     mController->handleCommand( EMPXPbvCmdDecreaseVolume, 0 );    
       
   754     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdDecreaseVolume );          
       
   755     
       
   756     mController->handleCommand( EMPXPbvCmdIncreaseVolume, 0 );    
       
   757     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdIncreaseVolume );          
       
   758     
       
   759     mController->handleCommand( EMPXPbvCmdPosition, 0 );    
       
   760     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPosition );          
       
   761     
       
   762     mController->handleCommand( EMPXPbvCmdSave, 0 );    
       
   763     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdSave );          
       
   764     
       
   765     mController->handleCommand( EMPXPbvCmdResetControls, 0 );    
       
   766     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdResetControls );          
       
   767     
       
   768     mController->handleCommand( EMPXPbvCmdShortPressForward, 0 );    
       
   769     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdShortPressForward );          
       
   770     
       
   771     mController->handleCommand( EMPXPbvCmdShortPressBackward, 0 );    
       
   772     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdShortPressBackward );          
       
   773     
       
   774     mController->handleCommand( EMPXPbvCmdShowFileDetails, 0 );    
       
   775     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdShowFileDetails );          
       
   776     
       
   777     mController->handleCommand( EMPXPbvCmdEndOfClip, 0 );    
       
   778     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdEndOfClip );          
       
   779     
       
   780     mController->handleCommand( EMPXPbvCmdCustomPause, 0 );    
       
   781     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdCustomPause );          
       
   782     
       
   783     mController->handleCommand( EMPXPbvCmdCustomPlay, 0 );    
       
   784     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdCustomPlay );          
       
   785     
       
   786     mController->handleCommand( EMPXPbvCmdExit, 0 );    
       
   787     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdExit );          
       
   788     
       
   789     mController->handleCommand( EMPXPbvLaunchDRMDetails, 0 );    
       
   790     QVERIFY( mViewWrapper->mCommandId == EMPXPbvLaunchDRMDetails );          
       
   791     
       
   792     mController->handleCommand( EMPXPbvSurfaceCreated, 0 );    
       
   793     QVERIFY( mViewWrapper->mCommandId == EMPXPbvSurfaceCreated );          
       
   794         
       
   795     cleanup();    
       
   796 }
       
   797 
       
   798 // -------------------------------------------------------------------------------------------------
       
   799 // TestMPXVideoPlaybackControlsController::testHandleTappedOnScreen
       
   800 // -------------------------------------------------------------------------------------------------
       
   801 //
       
   802 void TestMPXVideoPlaybackControlsController::testHandleTappedOnScreen()
       
   803 {
       
   804     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testHandleTappedOnScreen()") );
       
   805     
       
   806     init();    
       
   807     
       
   808     //
       
   809     // preset variables
       
   810     //
       
   811     mFileDetails->mVideoEnabled = true;
       
   812     mController->mViewMode = EFullScreenView;
       
   813     
       
   814     //
       
   815     // playing state
       
   816     //
       
   817     mController->mState = EPbStatePlaying;                
       
   818     mBaseVideoView->mouseReleaseEvent(0);    
       
   819     QVERIFY( mController->mControlsTimer->isActive() == true );
       
   820     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   821     {
       
   822         QVERIFY( mController->mControls[i]->mVisibilityState == EPbStatePlaying );
       
   823     }
       
   824     
       
   825     //
       
   826     // pause state
       
   827     //
       
   828     mController->mState = EPbStatePaused;
       
   829     mBaseVideoView->mouseReleaseEvent(0);    
       
   830     QVERIFY( mController->mControlsTimer->isActive() == false );
       
   831     for ( int i = 0 ; i < mController->mControls.count() ; i++ )
       
   832     {
       
   833         QVERIFY( mController->mControls[i]->mVisibilityState == EPbStatePaused );    
       
   834     }
       
   835     
       
   836     cleanup();    
       
   837 }
       
   838 
       
   839 // -------------------------------------------------------------------------------------------------
       
   840 // TestMPXVideoPlaybackControlsController::testUpdateVideoRectDone
       
   841 // -------------------------------------------------------------------------------------------------
       
   842 //
       
   843 void TestMPXVideoPlaybackControlsController::testUpdateVideoRectDone()
       
   844 {
       
   845     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testUpdateVideoRectDone()") );
       
   846     
       
   847     init();    
       
   848     
       
   849     mController->updateVideoRectDone();    
       
   850     
       
   851     //
       
   852     // default is full-screen
       
   853     //
       
   854     QVERIFY( mController->mControlsConfig->mState == EMPXControlCmdFullScreenViewOpened );                    
       
   855     
       
   856     //
       
   857     // validate Details view
       
   858     //
       
   859     mController->mViewMode = EDetailsView;
       
   860     
       
   861     mController->updateVideoRectDone(); 
       
   862     
       
   863     QVERIFY( mController->mControlsConfig->mState == EMPXControlCmdDetailsViewOpened );                    
       
   864             
       
   865     cleanup();    
       
   866 }
       
   867 
       
   868 // -------------------------------------------------------------------------------------------------
       
   869 // TestMPXVideoPlaybackControlsController::testslot_skipToNextVideoItem
       
   870 // -------------------------------------------------------------------------------------------------
       
   871 //
       
   872 void TestMPXVideoPlaybackControlsController::testslot_skipToNextVideoItem()
       
   873 {
       
   874     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testslot_skipToNextVideoItem()") );
       
   875 
       
   876     init();    
       
   877     
       
   878     connect( this, SIGNAL( commandSignal() ), mController, SLOT( skipToNextVideoItem() ) );
       
   879     
       
   880     emit commandSignal();     
       
   881     
       
   882     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdNextListItem ); 
       
   883     
       
   884     disconnect( this, SIGNAL( commandSignal() ), mController, SLOT( skipToNextVideoItem() ) );
       
   885     
       
   886     cleanup();    
       
   887 }
       
   888 
       
   889 // -------------------------------------------------------------------------------------------------
       
   890 // TestMPXVideoPlaybackControlsController::testslot_skipToPreviousVideoItem
       
   891 // -------------------------------------------------------------------------------------------------
       
   892 //
       
   893 void TestMPXVideoPlaybackControlsController::testslot_skipToPreviousVideoItem()
       
   894 {
       
   895     MPX_DEBUG(_L("TestMPXVideoPlaybackControlsController::testslot_skipToPreviousVideoItem()") );
       
   896 
       
   897     init();    
       
   898     
       
   899     connect( this, SIGNAL( commandSignal() ), mController, SLOT( skipToPreviousVideoItem() ) );
       
   900     
       
   901     emit commandSignal();     
       
   902     
       
   903     QVERIFY( mViewWrapper->mCommandId == EMPXPbvCmdPreviousListItem ); 
       
   904     
       
   905     disconnect( this, SIGNAL( commandSignal() ), mController, SLOT( skipToPreviousVideoItem() ) );
       
   906     
       
   907     cleanup();    
       
   908 }
       
   909 
       
   910 // End of file
       
   911     
       
   912 
       
   913