videoplayback/hbvideoplaybackview/tsrc/testprogressbar/src/testprogressbar.cpp
changeset 41 229f037ce963
parent 39 f6d44a0cd476
equal deleted inserted replaced
40:13331705e488 41:229f037ce963
     1 /**
     1 /**
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   tester for methods in TestMPXVideoPlaybackButtonBar
    14 * Description:   tester for methods in TestMPXVideoPlaybackButtonBar
    15 * 
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version:  5 %
    18 // Version : %version:  6 %
    19 
    19 
    20 
    20 
    21 #include <qdebug>
    21 #include <qdebug>
    22 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    23 #include <hbapplication.h>
    23 #include <hbapplication.h>
    48 
    48 
    49     char *pass[3];
    49     char *pass[3];
    50     pass[0] = argv[0];
    50     pass[0] = argv[0];
    51     pass[1] = "-o";
    51     pass[1] = "-o";
    52     pass[2] = "c:\\data\\testprogressbar.txt";
    52     pass[2] = "c:\\data\\testprogressbar.txt";
    53     
    53 
    54     int res = QTest::qExec(&tv, 3, pass);
    54     int res = QTest::qExec(&tv, 3, pass);
    55     
    55 
    56     return res;
    56     return res;
    57 }
    57 }
    58 
    58 
    59 
    59 
    60 // -------------------------------------------------------------------------------------------------
    60 // -------------------------------------------------------------------------------------------------
    72 //
    72 //
    73 void TestProgressBar::setup()
    73 void TestProgressBar::setup()
    74 {
    74 {
    75     MPX_ENTER_EXIT(_L("TestProgressBar::setup()"));
    75     MPX_ENTER_EXIT(_L("TestProgressBar::setup()"));
    76 
    76 
    77     mController = new QMPXVideoPlaybackControlsController();   
    77     mController = new QMPXVideoPlaybackControlsController();
    78     mProgBar = new QMPXVideoPlaybackProgressBar( mController );
    78     mProgBar = new QMPXVideoPlaybackProgressBar( mController );
    79 
    79 
    80     mProgBar->initialize();
    80     mProgBar->initialize();
    81 }
    81 }
    82 
    82 
   112     setup();
   112     setup();
   113 
   113 
   114     //
   114     //
   115     // If it is playing state
   115     // If it is playing state
   116     //
   116     //
   117     mController->mState = EPbStatePlaying;        
   117     mController->mState = EPbStatePlaying;
   118 
   118 
   119     emit mProgBar->mProgressSlider->press();
   119     emit mProgBar->mProgressSlider->press();
   120 
   120 
   121     QVERIFY( mController->mTimerAction == EMPXTimerCancel );
   121     QVERIFY( mController->mTimerAction == EMPXTimerCancel );
   122     QVERIFY( mController->mCommand == EMPXPbvCmdCustomPause );
   122     QVERIFY( mController->mCommand == EMPXPbvCmdCustomPause );
   124     QVERIFY( mProgBar->mNeedToResumeAfterSetPosition );
   124     QVERIFY( mProgBar->mNeedToResumeAfterSetPosition );
   125 
   125 
   126     //
   126     //
   127     // If it is pause state
   127     // If it is pause state
   128     //
   128     //
   129     mController->mState = EPbStatePaused;        
   129     mController->mState = EPbStatePaused;
   130     mController->mCommand = EMPXPbvCmdStop;        
   130     mController->mCommand = EMPXPbvCmdStop;
   131 
   131 
   132     emit mProgBar->mProgressSlider->press();
   132     emit mProgBar->mProgressSlider->press();
   133 
   133 
   134     QVERIFY( mController->mTimerAction == EMPXTimerCancel );
   134     QVERIFY( mController->mTimerAction == EMPXTimerCancel );
   135     QVERIFY( mController->mCommand == EMPXPbvCmdStop );
   135     QVERIFY( mController->mCommand == EMPXPbvCmdStop );
   153     // Moved position >= duration
   153     // Moved position >= duration
   154     //
   154     //
   155     mProgBar->mDuration = 120;
   155     mProgBar->mDuration = 120;
   156     mProgBar->mProgressSlider->mSliderValue = 130;
   156     mProgBar->mProgressSlider->mSliderValue = 130;
   157     mController->mTimerAction = EMPXTimerCancel;
   157     mController->mTimerAction = EMPXTimerCancel;
   158     mController->mCommand = EMPXPbvCmdStop;        
   158     mController->mCommand = EMPXPbvCmdStop;
   159 
   159 
   160     emit mProgBar->mProgressSlider->release();
   160     emit mProgBar->mProgressSlider->release();
   161     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   161     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   162     QVERIFY( ! mProgBar->mSliderDragging );
   162     QVERIFY( ! mProgBar->mSliderDragging );
   163     QVERIFY( mController->mCommand == EMPXPbvCmdEndOfClip );
   163     QVERIFY( mController->mCommand == EMPXPbvCmdEndOfClip );
   165     //
   165     //
   166     // Moved position < 0
   166     // Moved position < 0
   167     //
   167     //
   168     mProgBar->mProgressSlider->mSliderValue = -1;
   168     mProgBar->mProgressSlider->mSliderValue = -1;
   169     mController->mTimerAction = EMPXTimerCancel;
   169     mController->mTimerAction = EMPXTimerCancel;
   170     mController->mCommand = EMPXPbvCmdStop;        
   170     mController->mCommand = EMPXPbvCmdStop;
   171     mController->mValue = 100;        
   171     mController->mValue = 100;
   172 
   172 
   173     emit mProgBar->mProgressSlider->release();
   173     emit mProgBar->mProgressSlider->release();
   174     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   174     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   175     QVERIFY( ! mProgBar->mSliderDragging );
   175     QVERIFY( ! mProgBar->mSliderDragging );
   176     QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
   176     QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
   177     QVERIFY( mController->mValue == 0 );
   177     QVERIFY( mController->mValue == 0 );
   178     
   178 
   179     //
   179     //
   180     // 0 <= moved position < duration
   180     // 0 <= moved position < duration
   181     //
   181     //
   182     mProgBar->mProgressSlider->mSliderValue = 60;
   182     mProgBar->mProgressSlider->mSliderValue = 60;
   183     mController->mTimerAction = EMPXTimerCancel;
   183     mController->mTimerAction = EMPXTimerCancel;
   184     mController->mCommand = EMPXPbvCmdStop;        
   184     mController->mCommand = EMPXPbvCmdStop;
   185 
   185 
   186     emit mProgBar->mProgressSlider->release();
   186     emit mProgBar->mProgressSlider->release();
   187     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   187     QVERIFY( mController->mTimerAction == EMPXTimerReset );
   188     QVERIFY( ! mProgBar->mSliderDragging );
   188     QVERIFY( ! mProgBar->mSliderDragging );
   189     QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
   189     QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
   297 
   297 
   298     setup();
   298     setup();
   299 
   299 
   300     // test for 1st block of cases
   300     // test for 1st block of cases
   301     mProgBar->updateState( EPbStatePlaying );
   301     mProgBar->updateState( EPbStatePlaying );
   302     QVERIFY( mProgBar->isEnabled() );
   302     QVERIFY( mProgBar->mProgressSlider->isEnabled() );
   303 
   303 
   304     // test for 2nd block of cases
   304     // test for 2nd block of cases
   305     mProgBar->updateState( EPbStateBuffering );
   305     mProgBar->updateState( EPbStateBuffering );
   306     QVERIFY( ! mProgBar->isEnabled() );
   306     QVERIFY( ! mProgBar->mProgressSlider->isEnabled() );
   307 
   307 
   308     cleanup();
   308     cleanup();
   309 }
   309 }
   310 
   310 
   311 // -------------------------------------------------------------------------------------------------
   311 // -------------------------------------------------------------------------------------------------
   397 {
   397 {
   398     MPX_ENTER_EXIT(_L("TestProgressBar::testHandleSeekingTimeout()"));
   398     MPX_ENTER_EXIT(_L("TestProgressBar::testHandleSeekingTimeout()"));
   399 
   399 
   400     setup();
   400     setup();
   401 
   401 
   402     mProgBar->mDraggingPosition = 10; 
   402     mProgBar->mDraggingPosition = 10;
   403     mProgBar->mDuration = 30;
   403     mProgBar->mDuration = 30;
   404     mProgBar->mSetPosition = 0;
   404     mProgBar->mSetPosition = 0;
   405 
   405 
   406     connect( this, SIGNAL( commandSignal() ), mProgBar, SLOT( handleSeekingTimeout() ) );
   406     connect( this, SIGNAL( commandSignal() ), mProgBar, SLOT( handleSeekingTimeout() ) );
   407     emit commandSignal();
   407     emit commandSignal();