videoplayback/videoplaybackview/tsrc/testcontrolconfiguration/src/testcontrolconfiguration.cpp
changeset 63 4707a0db12f6
parent 50 21fe8338c6bf
equal deleted inserted replaced
58:d2b028fd1f7d 63:4707a0db12f6
    13 *
    13 *
    14 * Description:   tester for methods in videoplaybackcontrolconfiguration
    14 * Description:   tester for methods in videoplaybackcontrolconfiguration
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 6 %
    18 // Version : %version: 7 %
    19 
    19 
    20 #include <hbapplication.h>
    20 #include <hbapplication.h>
    21 #include <hbinstance.h>
    21 #include <hbinstance.h>
    22 #include <qdebug>
    22 #include <qdebug>
    23 #include <qgraphicswidget>
    23 #include <qgraphicswidget>
    35 #define private public
    35 #define private public
    36 #include "videoplaybackcontrolconfiguration.h"
    36 #include "videoplaybackcontrolconfiguration.h"
    37 #undef private
    37 #undef private
    38 
    38 
    39 
    39 
    40 // ---------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------------------------------------------------
    41 // main
    41 // main
    42 // ---------------------------------------------------------------------------
    42 // -------------------------------------------------------------------------------------------------
    43 //
    43 //
    44 int main(int argc, char *argv[])
    44 int main(int argc, char *argv[])
    45 {
    45 {
    46     MPX_ENTER_EXIT(_L("TestControlConfiguration::Main()"));
    46     MPX_ENTER_EXIT(_L("TestControlConfiguration::Main()"));
    47 
    47 
    58     int res = QTest::qExec(&tv, 3, pass);
    58     int res = QTest::qExec(&tv, 3, pass);
    59 
    59 
    60     return res;
    60     return res;
    61 }
    61 }
    62 
    62 
    63 // ---------------------------------------------------------------------------
    63 // -------------------------------------------------------------------------------------------------
    64 // init
    64 // init
    65 // ---------------------------------------------------------------------------
    65 // -------------------------------------------------------------------------------------------------
    66 //
    66 //
    67 void TestControlConfiguration::init()
    67 void TestControlConfiguration::init()
    68 {
    68 {
    69     MPX_ENTER_EXIT(_L("TestControlConfiguration::init()"));
    69     MPX_ENTER_EXIT(_L("TestControlConfiguration::init()"));
    70 }
    70 }
    71 
    71 
    72 // ---------------------------------------------------------------------------
    72 // -------------------------------------------------------------------------------------------------
    73 // init
    73 // setup
    74 // ---------------------------------------------------------------------------
    74 // -------------------------------------------------------------------------------------------------
    75 //
    75 //
    76 void TestControlConfiguration::setup()
    76 void TestControlConfiguration::setup()
    77 {
    77 {
    78     MPX_ENTER_EXIT(_L("TestControlConfiguration::setup()"));
    78     MPX_ENTER_EXIT(_L("TestControlConfiguration::setup()"));
    79 
    79 
    82     mControlsController = new VideoPlaybackControlsController( mFileDetails );
    82     mControlsController = new VideoPlaybackControlsController( mFileDetails );
    83 
    83 
    84     mControlConfig = new VideoPlaybackControlConfiguration( mControlsController );
    84     mControlConfig = new VideoPlaybackControlConfiguration( mControlsController );
    85 }
    85 }
    86 
    86 
    87 // ---------------------------------------------------------------------------
    87 // -------------------------------------------------------------------------------------------------
    88 // cleanup
    88 // cleanup
    89 // ---------------------------------------------------------------------------
    89 // -------------------------------------------------------------------------------------------------
    90 //
    90 //
    91 void TestControlConfiguration::cleanup()
    91 void TestControlConfiguration::cleanup()
    92 {
    92 {
    93     MPX_ENTER_EXIT(_L("TestControlConfiguration::cleanup()"));
    93     MPX_ENTER_EXIT(_L("TestControlConfiguration::cleanup()"));
    94 
    94 
   109         delete mControlConfig;
   109         delete mControlConfig;
   110         mControlConfig = NULL;
   110         mControlConfig = NULL;
   111     }
   111     }
   112 }
   112 }
   113 
   113 
   114 // ---------------------------------------------------------------------------
   114 // -------------------------------------------------------------------------------------------------
   115 // testControlList
   115 // testControlList
   116 // ---------------------------------------------------------------------------
   116 // -------------------------------------------------------------------------------------------------
   117 //
   117 //
   118 void TestControlConfiguration::testControlList()
   118 void TestControlConfiguration::testControlList()
   119 {
   119 {
   120     MPX_ENTER_EXIT(_L("TestControlConfiguration::testControlList()"));
   120     MPX_ENTER_EXIT(_L("TestControlConfiguration::testControlList()"));
   121 
   121 
   122     setup();
   122     setup();
       
   123 
       
   124     QSignalSpy spy( mControlConfig, SIGNAL( controlListUpdated() ) );
       
   125     QCOMPARE( spy.count(), 0 );
   123 
   126 
   124     //
   127     //
   125     // Streaming case
   128     // Streaming case
   126     //
   129     //
   127     mFileDetails->mPlaybackMode = EMPXVideoStreaming;
   130     mFileDetails->mPlaybackMode = EMPXVideoStreaming;
   131 
   134 
   132     QVERIFY( controlsList.contains( EStatusPane ) );
   135     QVERIFY( controlsList.contains( EStatusPane ) );
   133     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
   136     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
   134     QVERIFY( controlsList.contains( EBufferingAnimation ) );
   137     QVERIFY( controlsList.contains( EBufferingAnimation ) );
   135 
   138 
   136     cleanup();
   139     QCOMPARE( spy.count(), 1 );
   137 
   140 
   138     //
   141     //
   139     // local + RN
   142     // local + RN
   140     //
   143     //
   141     setup();
   144     mControlConfig->mControlsList.clear();
   142 
   145 
   143     mFileDetails->mPlaybackMode = EMPXVideoLocal;
   146     mFileDetails->mPlaybackMode = EMPXVideoLocal;
   144     mFileDetails->mRNFormat = true;
   147     mFileDetails->mRNFormat = true;
   145 
   148 
   146     mControlConfig->createControlList();
   149     mControlConfig->createControlList();
   148 
   151 
   149     QVERIFY( controlsList.contains( EStatusPane ) );
   152     QVERIFY( controlsList.contains( EStatusPane ) );
   150     QVERIFY( controlsList.contains( ERealLogoBitmap ) );
   153     QVERIFY( controlsList.contains( ERealLogoBitmap ) );
   151     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
   154     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
   152 
   155 
   153     cleanup();
   156     QCOMPARE( spy.count(), 2 );
   154 
   157 
   155     //
   158     //
   156     // local + non RN
   159     // local + non RN
   157     //
   160     //
   158     setup();
   161     mControlConfig->mControlsList.clear();
   159 
   162 
   160     mFileDetails->mPlaybackMode = EMPXVideoLocal;
   163     mFileDetails->mPlaybackMode = EMPXVideoLocal;
   161     mFileDetails->mRNFormat = false;
   164     mFileDetails->mRNFormat = false;
   162 
   165 
   163     mControlConfig->createControlList();
   166     mControlConfig->createControlList();
   164     controlsList = mControlConfig->controlList();
   167     controlsList = mControlConfig->controlList();
   165 
   168 
   166     QVERIFY( controlsList.contains( EStatusPane ) );
   169     QVERIFY( controlsList.contains( EStatusPane ) );
   167     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
   170     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
   168     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
   171     QVERIFY( ! controlsList.contains( EBufferingAnimation ) );
       
   172     QCOMPARE( spy.count(), 2 );
       
   173 
       
   174     spy.clear();
   169 
   175 
   170     cleanup();
   176     cleanup();
   171 }
   177 }
   172 
   178 
   173 // ---------------------------------------------------------------------------
   179 // -------------------------------------------------------------------------------------------------
   174 // testUpdateControlsWithFileDetails
   180 // testUpdateControlsWithFileDetails
   175 // ---------------------------------------------------------------------------
   181 // -------------------------------------------------------------------------------------------------
   176 //
   182 //
   177 void TestControlConfiguration::testUpdateControlsWithFileDetails()
   183 void TestControlConfiguration::testUpdateControlsWithFileDetails()
   178 {
   184 {
   179     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlsWithFileDetails()"));
   185     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlsWithFileDetails()"));
   180 
   186 
   181     setup();
   187     setup();
   182     mControlConfig->createControlList();
   188     mControlConfig->createControlList();
   183 
   189 
   184     //
   190     QSignalSpy spy( mControlConfig, SIGNAL( controlListUpdated() ) );
   185     // 1. test with mVideoEnabled = false
   191     QCOMPARE( spy.count(), 0 );
   186     //
       
   187     mControlsController->mFileDetails->mVideoEnabled = false;
       
   188 
   192 
   189     mControlConfig->updateControlsWithFileDetails();
   193     mControlConfig->updateControlsWithFileDetails();
   190 
   194 
   191     QList<TVideoPlaybackControls> controlsList = mControlConfig->controlList();
   195     QList<TVideoPlaybackControls> controlsList = mControlConfig->controlList();
   192 
   196 
   193     QVERIFY( controlsList.contains( EControlBar ) );
   197     QVERIFY( controlsList.contains( EControlBar ) );
   194 
   198     QCOMPARE( spy.count(), 1 );
   195     //
   199 
   196     // 2. test with mVideoEnabled = true
   200     spy.clear();
   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 
   201 
   209     cleanup();
   202     cleanup();
   210 }
   203 }
   211 
   204 
   212 // ---------------------------------------------------------------------------
   205 // -------------------------------------------------------------------------------------------------
   213 // testUpdateControlList
   206 // testUpdateControlList
   214 // ---------------------------------------------------------------------------
   207 // -------------------------------------------------------------------------------------------------
   215 //
   208 //
   216 void TestControlConfiguration::testUpdateControlList()
   209 void TestControlConfiguration::testUpdateControlList()
   217 {
   210 {
   218     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlList()"));
   211     MPX_ENTER_EXIT(_L("TestControlConfiguration::testUpdateControlList()"));
   219 
   212 
   220     setup();
   213     setup();
       
   214 
       
   215     QSignalSpy spy( mControlConfig, SIGNAL( controlListUpdated() ) );
       
   216     QCOMPARE( spy.count(), 0 );
       
   217 
   221     mControlConfig->createControlList();
   218     mControlConfig->createControlList();
   222 
   219 
   223     QGraphicsWidget *widget =
   220     QGraphicsWidget *widget =
   224             mControlConfig->mControlsController->layoutLoader()->findWidget( QString( "transparentWindow" ) );
   221             mControlConfig->mControlsController->layoutLoader()->findWidget( QString( "transparentWindow" ) );
   225     //
   222     //
   230 
   227 
   231     QVERIFY( ! widget->isVisible() );
   228     QVERIFY( ! widget->isVisible() );
   232     QVERIFY( controlsList.contains( EFileDetailsWidget ) );
   229     QVERIFY( controlsList.contains( EFileDetailsWidget ) );
   233     QVERIFY( controlsList.contains( EDetailsViewPlaybackWindow ) );
   230     QVERIFY( controlsList.contains( EDetailsViewPlaybackWindow ) );
   234     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
   231     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
       
   232     QCOMPARE( spy.count(), 1 );
   235 
   233 
   236     //
   234     //
   237     // 2-1. Test for Fullscreen View
   235     // 2-1. Test for Fullscreen View
   238     //
   236     //
   239     mControlConfig->mSurfaceAttached = false;
   237     mControlConfig->mSurfaceAttached = false;
   242 
   240 
   243     QVERIFY( ! widget->isVisible() );
   241     QVERIFY( ! widget->isVisible() );
   244     QVERIFY( ! controlsList.contains( EFileDetailsWidget ) );
   242     QVERIFY( ! controlsList.contains( EFileDetailsWidget ) );
   245     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   243     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   246     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
   244     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
       
   245     QCOMPARE( spy.count(), 2 );
   247 
   246 
   248     //
   247     //
   249     // 2-2. Test for Fullscreen View
   248     // 2-2. Test for Fullscreen View
   250     //
   249     //
   251     mControlConfig->mSurfaceAttached = true;
   250     mControlConfig->mSurfaceAttached = true;
   254 
   253 
   255     QVERIFY( widget->isVisible() );
   254     QVERIFY( widget->isVisible() );
   256     QVERIFY( ! controlsList.contains( EFileDetailsWidget ) );
   255     QVERIFY( ! controlsList.contains( EFileDetailsWidget ) );
   257     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   256     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   258     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
   257     QVERIFY( ! controlsList.contains( EIndicatorBitmap ) );
       
   258     QCOMPARE( spy.count(), 3 );
   259 
   259 
   260     //
   260     //
   261     // 3. Test for Audio Only View
   261     // 3. Test for Audio Only View
   262     //
   262     //
   263     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
   263     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
   265 
   265 
   266     QVERIFY( ! widget->isVisible() );
   266     QVERIFY( ! widget->isVisible() );
   267     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   267     QVERIFY( ! controlsList.contains( EDetailsViewPlaybackWindow ) );
   268     QVERIFY( controlsList.contains( EIndicatorBitmap ) );
   268     QVERIFY( controlsList.contains( EIndicatorBitmap ) );
   269     QVERIFY( controlsList.contains( EFileDetailsWidget ) );
   269     QVERIFY( controlsList.contains( EFileDetailsWidget ) );
       
   270     QCOMPARE( spy.count(), 4 );
   270 
   271 
   271     //
   272     //
   272     // 4. RN log gets removed
   273     // 4. RN log gets removed
   273     //
   274     //
   274     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
   275     mControlConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
   275     controlsList = mControlConfig->controlList();
   276     controlsList = mControlConfig->controlList();
   276 
   277 
   277     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
   278     QVERIFY( ! controlsList.contains( ERealLogoBitmap ) );
       
   279     QCOMPARE( spy.count(), 5 );
   278 
   280 
   279     //
   281     //
   280     // 5. Surface attached
   282     // 5. Surface attached
   281     //
   283     //
   282     mControlConfig->updateControlList( EControlCmdSurfaceAttached );
   284     mControlConfig->updateControlList( EControlCmdSurfaceAttached );
   283     controlsList = mControlConfig->controlList();
   285     controlsList = mControlConfig->controlList();
   284 
   286 
   285     QVERIFY( widget->isVisible() );
   287     QVERIFY( widget->isVisible() );
       
   288     QCOMPARE( spy.count(), 5 );
   286 
   289 
   287     //
   290     //
   288     // 6. Surface detached
   291     // 6. Surface detached
   289     //
   292     //
   290     mControlConfig->updateControlList( EControlCmdSurfaceDetached );
   293     mControlConfig->updateControlList( EControlCmdSurfaceDetached );
   291     controlsList = mControlConfig->controlList();
   294     controlsList = mControlConfig->controlList();
   292 
   295 
   293     QVERIFY( ! widget->isVisible() );
   296     QVERIFY( ! widget->isVisible() );
       
   297     QCOMPARE( spy.count(), 5 );
       
   298 
       
   299     spy.clear();
       
   300 
   294     cleanup();
   301     cleanup();
   295 }
   302 }
   296 
   303 
   297 // End of file
   304 // End of file