videoplayback/hbvideoplaybackview/tsrc/testdetailsplaybackwindow/src/testdetailsplaybackwindow.cpp
changeset 36 8aed59de29f9
child 20 b9e04db066d4
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
       
     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:  3 %
       
    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 // testMousePressEvent
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void TestDetailsPlaybackWindow::testMousePressEvent()
       
   122 {
       
   123     MPX_ENTER_EXIT(
       
   124             _L("TestDetailsPlaybackWindow::testMousePressEvent()"));
       
   125 
       
   126     init();
       
   127 
       
   128     QGraphicsSceneMouseEvent* event = 
       
   129             new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMousePress );
       
   130     event->setAccepted( false );
       
   131 
       
   132     mWindow->mousePressEvent( event );
       
   133 
       
   134     QVERIFY( event->isAccepted() );
       
   135 
       
   136     cleanup();
       
   137 }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // testMouseReleaseEvent
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void TestDetailsPlaybackWindow::testMouseReleaseEvent()
       
   144 {
       
   145     MPX_ENTER_EXIT(
       
   146             _L("TestDetailsPlaybackWindow::testMouseReleaseEvent()"));
       
   147 
       
   148     init();
       
   149 
       
   150     QGraphicsSceneMouseEvent* event = 
       
   151             new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMouseRelease );
       
   152 
       
   153     mWindow->mouseReleaseEvent( event );
       
   154     QVERIFY( mController->mCommand == EMPXPbvCmdPlayPause );
       
   155 
       
   156     delete event;
       
   157     event = NULL;
       
   158 
       
   159     cleanup();
       
   160 }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // testPlayPause
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void TestDetailsPlaybackWindow::testPlayPause()
       
   167 {
       
   168     MPX_ENTER_EXIT(
       
   169             _L("TestDetailsPlaybackWindow::testPlayPause()"));
       
   170 
       
   171     init();
       
   172 
       
   173     mWindow->mPlayButton->release();
       
   174     QVERIFY( mController->mCommand == EMPXPbvCmdPlayPause );
       
   175 
       
   176     cleanup();
       
   177 }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // testAttach
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 void TestDetailsPlaybackWindow::testAttach()
       
   184 {
       
   185     MPX_ENTER_EXIT(
       
   186             _L("TestDetailsPlaybackWindow::testAttach()"));
       
   187 
       
   188     //
       
   189     // test when 'attach' operation is enabled
       
   190     //
       
   191     init( true );
       
   192     
       
   193     //
       
   194     // connect signal/slot
       
   195     //
       
   196     connect( this, SIGNAL( commandSignal() ), mController, SLOT( attachVideo() ) );
       
   197     
       
   198     //
       
   199     // emit signal
       
   200     //
       
   201     emit commandSignal();     
       
   202     
       
   203     //
       
   204     // verify the controller attachVideo() slot has been called
       
   205     //
       
   206     QVERIFY( mController->mCommand == EMPXPbvCmdClose );
       
   207     QVERIFY( mController->mAttachVideoDone == true );
       
   208 
       
   209     //
       
   210     // disconnect signal/slot
       
   211     //
       
   212     disconnect( this, SIGNAL( commandSignal() ), mController, SLOT( attachVideo() ) );
       
   213 
       
   214     //
       
   215     // clean up
       
   216     //
       
   217     cleanup();
       
   218         
       
   219 }
       
   220 
       
   221 
       
   222 // End of file