videoplayback/hbvideoplaybackview/tsrc/testfullscreencontrol/src/testfullscreencontrol.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
     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 QMPXVideoPlaybackFullScreenControl
       
    15 * 
       
    16 */
       
    17 
       
    18 // Version : %version:  3 %
       
    19 
       
    20 
       
    21 #include <hbapplication.h>
       
    22 #include <hbinstance.h>
       
    23 #include <qdebug>
       
    24 
       
    25 #include "mpxhelixplaybackplugindefs.h"
       
    26 
       
    27 #include "testfullscreencontrol.h"
       
    28 
       
    29 #include "mpxvideoplaybackviewfiledetails.h"
       
    30 #include "mpxvideoplaybackcontrolscontroller.h"
       
    31 #include "mpxvideoplaybackcontrolbar.h"
       
    32 
       
    33 
       
    34 #define private public
       
    35 #define protected public
       
    36 #include "mpxvideoplaybackfullscreencontrol.h"
       
    37 #undef protected
       
    38 #undef private
       
    39 
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // main
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 int main(int argc, char *argv[])
       
    46 {
       
    47     MPX_ENTER_EXIT(_L("TestFullScreenControl::Main()"));
       
    48 
       
    49     HbApplication app(argc, argv);
       
    50     HbMainWindow window;
       
    51     
       
    52     TestFullScreenControl tv;
       
    53 
       
    54     char *pass[3];
       
    55     pass[0] = argv[0];
       
    56     pass[1] = "-o";
       
    57     pass[2] = "c:\\data\\TestFullScreenControl.txt";
       
    58     
       
    59     int res = QTest::qExec(&tv, 3, pass);
       
    60     
       
    61     return res;
       
    62 }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // init
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void TestFullScreenControl::init()
       
    69 {
       
    70     MPX_ENTER_EXIT(_L("TestFullScreenControl::init()"));
       
    71 }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // setup
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void TestFullScreenControl::setup(TMPXVideoPlaybackControls control)
       
    78 {
       
    79     MPX_ENTER_EXIT(_L("TestFullScreenControl::setup()"));
       
    80 
       
    81 
       
    82     mControlsController = new QMPXVideoPlaybackControlsController();
       
    83     
       
    84     createControl( control );                                                                                                                                           
       
    85 }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // createControl
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void TestFullScreenControl::createControl(TMPXVideoPlaybackControls control)
       
    92 {
       
    93     MPX_ENTER_EXIT(_L("TestFullScreenControl::createControl()"));
       
    94 
       
    95     switch ( control )
       
    96     {
       
    97         case EMPXStatusPane:
       
    98         {
       
    99             mFullScreenControl = new QMPXVideoPlaybackFullScreenControl( mControlsController, 
       
   100                                                                          control,
       
   101                                                                          NULL, 
       
   102                                                                          0 );         
       
   103             break;    
       
   104         }
       
   105         case EMPXControlBar:
       
   106         {
       
   107             QMPXVideoPlaybackControlBar *controlBar = 
       
   108                     new QMPXVideoPlaybackControlBar( mControlsController );            
       
   109     
       
   110             mFullScreenControl = new QMPXVideoPlaybackFullScreenControl( mControlsController,
       
   111                                                                          control,
       
   112                                                                          controlBar,
       
   113                                                                          0 );            
       
   114              
       
   115             break;
       
   116         }
       
   117         case EMPXDetailsViewPlaybackWindow:
       
   118         {
       
   119             break;    
       
   120         }
       
   121     }    
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // cleanup
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void TestFullScreenControl::cleanup()
       
   129 {
       
   130     MPX_ENTER_EXIT(_L("TestFullScreenControl::cleanup()"));
       
   131 
       
   132     if ( mControlsController )
       
   133     {
       
   134         delete mControlsController;
       
   135         mControlsController = NULL;    
       
   136     }
       
   137     
       
   138     if ( mFullScreenControl )
       
   139     {
       
   140         delete mFullScreenControl;
       
   141         mFullScreenControl = NULL;    
       
   142     }
       
   143 }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // testControlIndex
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void TestFullScreenControl::testControlIndex()
       
   150 {
       
   151     MPX_ENTER_EXIT(_L("TestFullScreenControl::testControlIndex()"));
       
   152 
       
   153     setup( EMPXStatusPane );
       
   154     
       
   155     QVERIFY( mFullScreenControl->controlIndex() == EMPXStatusPane );
       
   156 }
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // testDurationChanged
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 void TestFullScreenControl::testDurationChanged()
       
   163 {
       
   164     MPX_ENTER_EXIT(_L("TestFullScreenControl::testDurationChanged()"));
       
   165 
       
   166     // test for progress bar
       
   167     delete mFullScreenControl;
       
   168     mFullScreenControl = NULL;    
       
   169     setup( EMPXControlBar );
       
   170     QVERIFY( mFullScreenControl->durationChanged( 100 ) );      
       
   171     QVERIFY( static_cast<QMPXVideoPlaybackControlBar*>(mFullScreenControl->mControl)->mDuration == 100 );       
       
   172     
       
   173     // test for something other than progress bar
       
   174     delete mFullScreenControl;
       
   175     mFullScreenControl = NULL;
       
   176     setup( EMPXStatusPane );    
       
   177     QVERIFY( ! mFullScreenControl->durationChanged( 100 ) );    
       
   178             
       
   179 }
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // testPositionChanged
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void TestFullScreenControl::testPositionChanged()
       
   186 { 
       
   187     MPX_ENTER_EXIT(_L("TestFullScreenControl::testPositionChanged()"));
       
   188 
       
   189     // test for progress bar
       
   190     delete mFullScreenControl;
       
   191     mFullScreenControl = NULL;    
       
   192     setup( EMPXControlBar );
       
   193     QVERIFY( mFullScreenControl->positionChanged( 100 ) );      
       
   194     QVERIFY( static_cast<QMPXVideoPlaybackControlBar*>(mFullScreenControl->mControl)->mPosition == 100 );      
       
   195     
       
   196     // test for something other than progress bar
       
   197     delete mFullScreenControl;
       
   198     mFullScreenControl = NULL;
       
   199     setup( EMPXStatusPane );    
       
   200     QVERIFY( ! mFullScreenControl->positionChanged( 100 ) );
       
   201 }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // testAspectRatioChanged
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void TestFullScreenControl::testAspectRatioChanged()
       
   208 {
       
   209     MPX_ENTER_EXIT(_L("TestFullScreenControl::testAspectRatioChanged()"));
       
   210 
       
   211     // test for button bar
       
   212     delete mFullScreenControl;
       
   213     mFullScreenControl = NULL;    
       
   214     setup( EMPXControlBar );        
       
   215     QVERIFY( mFullScreenControl->aspectRatioChanged( 3 ) );  // EMMFNatural
       
   216     QVERIFY( static_cast<QMPXVideoPlaybackControlBar*>(mFullScreenControl->mControl)->mAspectRatio == 3 ); 
       
   217     
       
   218     // test for something other than button bar
       
   219     delete mFullScreenControl;
       
   220     mFullScreenControl = NULL;    
       
   221     setup( EMPXStatusPane );        
       
   222     QVERIFY( ! mFullScreenControl->aspectRatioChanged( 3 ) );  // EMMFNatural
       
   223 }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // testUpdateState
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 void TestFullScreenControl::testUpdateState()
       
   230 {
       
   231     MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateState()"));
       
   232 
       
   233     delete mFullScreenControl;
       
   234     mFullScreenControl = NULL;    
       
   235     setup( EMPXControlBar );     
       
   236     mFullScreenControl->updateState( EPbStatePaused ); 
       
   237     QVERIFY( static_cast<QMPXVideoPlaybackControlBar*>(mFullScreenControl->mControl)->mState == EPbStatePaused );         
       
   238 }
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // testUpdateControlsWithFileDetails
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 void TestFullScreenControl::testUpdateControlsWithFileDetails()
       
   245 {
       
   246     MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateControlsWithFileDetails()"));
       
   247 
       
   248     QMPXVideoPlaybackViewFileDetails *fileDetails = new QMPXVideoPlaybackViewFileDetails(); 
       
   249     
       
   250     setup( EMPXControlBar );
       
   251     
       
   252     fileDetails->mPausableStream = true;
       
   253     
       
   254     mFullScreenControl->updateControlsWithFileDetails( fileDetails );
       
   255     
       
   256     QVERIFY( static_cast<QMPXVideoPlaybackControlBar*>(mFullScreenControl->mControl)->mFileDetails->mPausableStream );    
       
   257 
       
   258     if ( fileDetails )
       
   259     {
       
   260         delete fileDetails;
       
   261         fileDetails = NULL;    
       
   262     }
       
   263 }
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // testUpdateControlProperties
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 void TestFullScreenControl::testUpdateControlProperties()
       
   270 {  
       
   271     MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateControlProperties()"));
       
   272 
       
   273     setup(EMPXStatusPane);
       
   274     
       
   275     mFullScreenControl->updateControlProperties( 1 );
       
   276     
       
   277     QVERIFY( mFullScreenControl != NULL );
       
   278     
       
   279     QVERIFY( mFullScreenControl->mProperties == 1 );
       
   280 }
       
   281         
       
   282 // End of file