videoplayback/hbvideoplaybackview/tsrc/testdetailsplaybackwindow/src/testdetailsplaybackwindow.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 TestDetailsPlaybackWindow
       
    15 * 
       
    16 */
       
    17 
       
    18 // Version : %version:  7 %
       
    19 
       
    20 
       
    21 #include <qdebug>
       
    22 #include <qgraphicsscenemouseevent>
       
    23 
       
    24 #include <hbmainwindow.h>
       
    25 #include <hbapplication.h>
       
    26 
       
    27 #include "hbpushbutton.h"
       
    28 #include "mpxvideoplaybackviewfiledetails.h"
       
    29 #include "mpxvideoplaybackcontrolscontroller.h"
       
    30 #include "testdetailsplaybackwindow.h"
       
    31 
       
    32 
       
    33 #define private public
       
    34 #include "mpxvideoplaybackdetailsplaybackwindow.h"
       
    35 #undef private
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // main
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 int main(int argc, char *argv[])
       
    42 {
       
    43     MPX_ENTER_EXIT(_L("TestDetailsPlaybackWindow::Main()"));
       
    44 
       
    45     HbApplication app(argc, argv);
       
    46     HbMainWindow window;
       
    47 
       
    48     TestDetailsPlaybackWindow tv;
       
    49 
       
    50     char *pass[3];
       
    51     pass[0] = argv[0];
       
    52     pass[1] = "-o";
       
    53     pass[2] = "c:\\data\\testdetailsplaybackwindow.txt";
       
    54     
       
    55     int res = QTest::qExec(&tv, 3, pass);
       
    56     
       
    57     return res;
       
    58 }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // init
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void TestDetailsPlaybackWindow::init( bool attachOperation )
       
    65 {
       
    66     MPX_ENTER_EXIT(_L("TestDetailsPlaybackWindow::init()"));
       
    67 
       
    68     mController = new QMPXVideoPlaybackControlsController( attachOperation );   
       
    69     mWindow = new QMPXVideoPlaybackDetailsPlaybackWindow( mController );
       
    70 
       
    71     mWindow->initialize();
       
    72 }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // cleanup
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void TestDetailsPlaybackWindow::cleanup()
       
    79 {
       
    80     MPX_ENTER_EXIT(_L("TestDetailsPlaybackWindow::cleanup()"));
       
    81 
       
    82     if ( mController )
       
    83     {
       
    84         delete mController;
       
    85         mController = NULL;
       
    86     }
       
    87 
       
    88     if ( mWindow )
       
    89     {
       
    90         delete mWindow;
       
    91         mWindow = NULL;
       
    92     }
       
    93 }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // testUpdateState
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void TestDetailsPlaybackWindow::testUpdateState()
       
   100 {
       
   101     MPX_ENTER_EXIT(
       
   102             _L("TestDetailsPlaybackWindow::testUpdateState()"));
       
   103 
       
   104     init();
       
   105 
       
   106     TMPXPlaybackState state = EPbStatePlaying;
       
   107     mWindow->updateState( state );
       
   108     QVERIFY( mWindow->mPlayButton->isVisible() == false );
       
   109     
       
   110     state = EPbStatePaused;
       
   111     mWindow->updateState( state );
       
   112     QVERIFY( mWindow->mPlayButton->isVisible() == true );
       
   113 
       
   114     cleanup();
       
   115 }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // testPlayPause
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void TestDetailsPlaybackWindow::testPlayPause()
       
   122 {
       
   123     MPX_ENTER_EXIT(
       
   124             _L("TestDetailsPlaybackWindow::testPlayPause()"));
       
   125 
       
   126     init();
       
   127 
       
   128     mWindow->mPlayButton->release();
       
   129     QVERIFY( mController->mCommand == EMPXPbvCmdPlayPause );
       
   130 
       
   131     cleanup();
       
   132 }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // testAttach
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void TestDetailsPlaybackWindow::testAttach()
       
   139 {
       
   140     MPX_ENTER_EXIT(
       
   141             _L("TestDetailsPlaybackWindow::testAttach()"));
       
   142 
       
   143     //
       
   144     // test when 'attach' operation is enabled
       
   145     //
       
   146     init( true );
       
   147     
       
   148     //
       
   149     // connect signal/slot
       
   150     //
       
   151     connect( this, SIGNAL( commandSignal() ), mController, SLOT( attachVideo() ) );
       
   152     
       
   153     //
       
   154     // emit signal
       
   155     //
       
   156     emit commandSignal();     
       
   157     
       
   158     //
       
   159     // verify the controller attachVideo() slot has been called
       
   160     //
       
   161     QVERIFY( mController->mAttachVideoDone == true );
       
   162 
       
   163     //
       
   164     // disconnect signal/slot
       
   165     //
       
   166     disconnect( this, SIGNAL( commandSignal() ), mController, SLOT( attachVideo() ) );
       
   167 
       
   168     //
       
   169     // clean up
       
   170     //
       
   171     cleanup();
       
   172         
       
   173 }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // testSend
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 void TestDetailsPlaybackWindow::testSend()
       
   180 {
       
   181     MPX_ENTER_EXIT(
       
   182             _L("TestDetailsPlaybackWindow::testSend()"));
       
   183 
       
   184     //
       
   185     // test when 'share' operation is enabled
       
   186     //
       
   187     init( false );
       
   188     
       
   189     //
       
   190     // connect signal/slot
       
   191     //
       
   192     connect( this, SIGNAL( commandSignal() ), mController, SLOT( sendVideo() ) );
       
   193     
       
   194     //
       
   195     // emit signal
       
   196     //
       
   197     emit commandSignal();     
       
   198     
       
   199     //
       
   200     // verify the controller sendVideo() slot has been called
       
   201     //
       
   202     QVERIFY( mController->mCommand == EMPXPbvCmdPause );
       
   203     QVERIFY( mController->mSendVideoDone == true );
       
   204 
       
   205     //
       
   206     // disconnect signal/slot
       
   207     //
       
   208     disconnect( this, SIGNAL( commandSignal() ), mController, SLOT( sendVideo() ) );
       
   209 
       
   210     //
       
   211     // clean up
       
   212     //
       
   213     cleanup();
       
   214         
       
   215 }
       
   216 
       
   217 // End of file