videoplayback/videoplaybackview/tsrc/testcontrolconfiguration/src/testcontrolconfiguration.cpp
changeset 44 518105d52e45
child 50 21fe8338c6bf
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
       
     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 videoplaybackcontrolconfiguration
       
    15 * 
       
    16 */
       
    17 
       
    18 // Version : %version: 5 %
       
    19 
       
    20 #include <hbapplication.h>
       
    21 #include <hbinstance.h>
       
    22 #include <qdebug>
       
    23 #include <qgraphicswidget>
       
    24 
       
    25 #include "videoplaybackcontrol.hrh"
       
    26 #include "mpxhelixplaybackplugindefs.h"
       
    27 
       
    28 #include "testcontrolconfiguration.h"
       
    29 
       
    30 #include "videoplaybackviewfiledetails.h"
       
    31 #include "videoplaybackcontrolscontroller.h"
       
    32 #include "videoplaybackdocumentloader.h"
       
    33 
       
    34 
       
    35 #define private public
       
    36 #include "videoplaybackcontrolconfiguration.h"
       
    37 #undef private
       
    38 
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // main
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 int main(int argc, char *argv[])
       
    45 {
       
    46     MPX_ENTER_EXIT(_L("TestControlConfiguration::Main()"));
       
    47 
       
    48     HbApplication app(argc, argv);
       
    49     HbMainWindow window;
       
    50     
       
    51     TestControlConfiguration tv;
       
    52 
       
    53     char *pass[3];
       
    54     pass[0] = argv[0];
       
    55     pass[1] = "-o";
       
    56     pass[2] = "c:\\data\\testcontrolconfiguration.txt";
       
    57     
       
    58     int res = QTest::qExec(&tv, 3, pass);
       
    59 
       
    60     return res;
       
    61 }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // init
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void TestControlConfiguration::init()
       
    68 {
       
    69     MPX_ENTER_EXIT(_L("TestControlConfiguration::init()"));
       
    70 }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // init
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void TestControlConfiguration::setup()
       
    77 {
       
    78     MPX_ENTER_EXIT(_L("TestControlConfiguration::setup()"));
       
    79 
       
    80     mFileDetails = new VideoPlaybackViewFileDetails();  
       
    81     
       
    82     mControlsController = new VideoPlaybackControlsController( mFileDetails );
       
    83                                                                      
       
    84     mControlConfig = new VideoPlaybackControlConfiguration( mControlsController );
       
    85 }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // cleanup
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void TestControlConfiguration::cleanup()
       
    92 {
       
    93     MPX_ENTER_EXIT(_L("TestControlConfiguration::cleanup()"));
       
    94 
       
    95     if ( mFileDetails )
       
    96     {
       
    97         delete mFileDetails;
       
    98         mFileDetails = NULL;    
       
    99     }
       
   100     
       
   101     if ( mControlsController )
       
   102     {
       
   103         delete mControlsController;
       
   104         mControlsController = NULL;    
       
   105     }
       
   106     
       
   107     if ( mControlConfig )
       
   108     {
       
   109         delete mControlConfig;
       
   110         mControlConfig = NULL;    
       
   111     }
       
   112 }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // testControlList
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void TestControlConfiguration::testControlList()
       
   119 {
       
   120     MPX_ENTER_EXIT(_L("TestControlConfiguration::testControlList()"));
       
   121 
       
   122     setup();
       
   123 
       
   124     //
       
   125     // Streaming case
       
   126     //
       
   127     mFileDetails->mPlaybackMode = EMPXVideoStreaming;
       
   128 
       
   129     mControlConfig->createControlList();
       
   130     QList<TVideoPlaybackControls> controlsList = mControlConfig->controlList();
       
   131 
       
   132     QVERIFY( controlsList.contains( EStatusPane ) );
       
   133     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
       
   134     QVERIFY( controlsList.contains( EBufferingAnimation ) );
       
   135 
       
   136     cleanup();
       
   137 
       
   138     //
       
   139     // local + RN
       
   140     //
       
   141     setup();
       
   142 
       
   143     mFileDetails->mPlaybackMode = EMPXVideoLocal;
       
   144     mFileDetails->mRNFormat = true;
       
   145 
       
   146     mControlConfig->createControlList();
       
   147     controlsList = mControlConfig->controlList();
       
   148 
       
   149     QVERIFY( controlsList.contains( EStatusPane ) );
       
   150     QVERIFY( controlsList.contains( ERealLogoBitmap ) );
       
   151     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
       
   152 
       
   153     cleanup();
       
   154 
       
   155     //
       
   156     // local + non RN
       
   157     //
       
   158     setup();
       
   159 
       
   160     mFileDetails->mPlaybackMode = EMPXVideoLocal;
       
   161     mFileDetails->mRNFormat = false;
       
   162 
       
   163     mControlConfig->createControlList();
       
   164     controlsList = mControlConfig->controlList();
       
   165 
       
   166     QVERIFY( controlsList.contains( EStatusPane ) );
       
   167     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
       
   168     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
       
   169 
       
   170     cleanup();
       
   171 }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // testUpdateControlsWithFileDetails
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void TestControlConfiguration::testUpdateControlsWithFileDetails()
       
   178 {
       
   179     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlsWithFileDetails()"));
       
   180 
       
   181     setup();
       
   182     mControlConfig->createControlList();
       
   183 
       
   184     //
       
   185     // 1. test with mVideoEnabled = false
       
   186     //
       
   187     mControlsController->mFileDetails->mVideoEnabled = false;
       
   188     
       
   189     mControlConfig->updateControlsWithFileDetails();
       
   190     
       
   191     QList<TVideoPlaybackControls> controlsList = mControlConfig->controlList();
       
   192     
       
   193     QVERIFY( controlsList.contains( EControlBar ) );
       
   194 
       
   195     //
       
   196     // 2. test with mVideoEnabled = true
       
   197     //
       
   198     mControlsController->mFileDetails->mVideoEnabled = false;
       
   199     
       
   200     mControlConfig->updateControlsWithFileDetails(); 
       
   201     
       
   202     QVERIFY( controlsList.contains( EControlBar ) );
       
   203     
       
   204     QGraphicsWidget *widget = 
       
   205             mControlsController->layoutLoader()->findWidget( QString( "transparentWindow" ) );
       
   206 
       
   207     QVERIFY( widget->isVisible() );
       
   208 
       
   209     cleanup();
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // testUpdateControlList
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void TestControlConfiguration::testUpdateControlList()
       
   217 {
       
   218     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlList()"));
       
   219 
       
   220     setup();    
       
   221     mControlConfig->createControlList();
       
   222 
       
   223     //
       
   224     // 1.  Test for Details View
       
   225     //
       
   226     mControlConfig->updateControlList( EControlCmdDetailsViewOpened );
       
   227     QList<TVideoPlaybackControls> controlsList = mControlConfig->controlList();
       
   228 
       
   229     QVERIFY( controlsList.contains( EFileDetailsWidget ) );    
       
   230     QVERIFY( controlsList.contains( EDetailsViewPlaybackWindow ) );
       
   231     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );    
       
   232 
       
   233 
       
   234     //
       
   235     // 2. Test for Fullscreen View
       
   236     //
       
   237     mControlConfig->updateControlList( EControlCmdFullScreenViewOpened );
       
   238     controlsList = mControlConfig->controlList();
       
   239     
       
   240     QVERIFY( ! controlsList.contains( EFileDetailsWidget ) );    
       
   241     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );    
       
   242     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
       
   243 
       
   244     //
       
   245     // 3. Test for Audio Only View
       
   246     //
       
   247     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
       
   248     controlsList = mControlConfig->controlList();
       
   249     
       
   250     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) ); 
       
   251     QVERIFY( controlsList.contains( EIndicatorBitmap ) );
       
   252     QVERIFY( controlsList.contains( EFileDetailsWidget ) );
       
   253 
       
   254     //
       
   255     // 4. RN log gets removed
       
   256     //
       
   257     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
       
   258     controlsList = mControlConfig->controlList();
       
   259 
       
   260     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) ); 
       
   261 
       
   262     cleanup();
       
   263 }
       
   264 
       
   265 // End of file