videoplayback/videoplaybackview/tsrc/testtoolbar/src/testtoolbar.cpp
author hgs
Fri, 06 Aug 2010 09:43:48 +0300
changeset 50 21fe8338c6bf
parent 44 518105d52e45
child 58 d2b028fd1f7d
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
hgs
parents:
diff changeset
     1
/**
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:   tester for methods in TestToolBar
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
50
hgs
parents: 44
diff changeset
    18
// Version : %version:  7 %
44
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
#include <qdebug>
hgs
parents:
diff changeset
    22
#include <hbmainwindow.h>
hgs
parents:
diff changeset
    23
#include <hbapplication.h>
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
#include "hbtoolbar.h"
hgs
parents:
diff changeset
    26
#include "hbtoolbutton.h"
hgs
parents:
diff changeset
    27
#include "testtoolbar.h"
hgs
parents:
diff changeset
    28
#include "videoplaybackviewfiledetails.h"
hgs
parents:
diff changeset
    29
#include "videoplaybackcontrolscontroller.h"
hgs
parents:
diff changeset
    30
#include "videoplaybackdocumentloader.h"
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
#define private public
hgs
parents:
diff changeset
    33
#include "videoplaybacktoolbar.h"
hgs
parents:
diff changeset
    34
#undef private
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    37
// main
hgs
parents:
diff changeset
    38
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    39
//
hgs
parents:
diff changeset
    40
int main(int argc, char *argv[])
hgs
parents:
diff changeset
    41
{
hgs
parents:
diff changeset
    42
    MPX_ENTER_EXIT(_L("TestToolBar::Main()"));
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
    HbApplication app(argc, argv);
hgs
parents:
diff changeset
    45
    HbMainWindow window;
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
    TestToolBar tv;
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
    char *pass[3];
hgs
parents:
diff changeset
    50
    pass[0] = argv[0];
hgs
parents:
diff changeset
    51
    pass[1] = "-o";
hgs
parents:
diff changeset
    52
    pass[2] = "c:\\data\\testtoolbar.txt";
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
    int res = QTest::qExec(&tv, 3, pass);
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
    return res;
hgs
parents:
diff changeset
    57
}
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    60
// init
hgs
parents:
diff changeset
    61
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    62
//
hgs
parents:
diff changeset
    63
void TestToolBar::init( bool attachOperation )
hgs
parents:
diff changeset
    64
{
hgs
parents:
diff changeset
    65
    MPX_ENTER_EXIT(_L("TestToolBar::init()"));
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
    mController = new VideoPlaybackControlsController( attachOperation );
hgs
parents:
diff changeset
    68
    mVideoToolBar = new VideoPlaybackToolBar( mController );
hgs
parents:
diff changeset
    69
hgs
parents:
diff changeset
    70
    mVideoToolBar->setVisible( true );
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
    connect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( retrieveButtons() ) );
hgs
parents:
diff changeset
    73
    emit commandSignal();
hgs
parents:
diff changeset
    74
    disconnect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( retrieveButtons() ) );
hgs
parents:
diff changeset
    75
}
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    78
// cleanup
hgs
parents:
diff changeset
    79
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    80
//
hgs
parents:
diff changeset
    81
void TestToolBar::cleanup()
hgs
parents:
diff changeset
    82
{
hgs
parents:
diff changeset
    83
    MPX_ENTER_EXIT(_L("TestToolBar::cleanup()"));
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
    if ( mController )
hgs
parents:
diff changeset
    86
    {
hgs
parents:
diff changeset
    87
        delete mController;
hgs
parents:
diff changeset
    88
        mController = NULL;
hgs
parents:
diff changeset
    89
    }
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
    if ( mVideoToolBar )
hgs
parents:
diff changeset
    92
    {
hgs
parents:
diff changeset
    93
        delete mVideoToolBar;
hgs
parents:
diff changeset
    94
        mVideoToolBar = NULL;
hgs
parents:
diff changeset
    95
    }
hgs
parents:
diff changeset
    96
}
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
// testPlay
hgs
parents:
diff changeset
   100
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   101
//
hgs
parents:
diff changeset
   102
void TestToolBar::testPlay()
hgs
parents:
diff changeset
   103
{
hgs
parents:
diff changeset
   104
    MPX_ENTER_EXIT(_L("TestToolBar::testPlay()"));
hgs
parents:
diff changeset
   105
hgs
parents:
diff changeset
   106
    init();
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
    mVideoToolBar->mButtons[E3rdButton]->release();
hgs
parents:
diff changeset
   109
hgs
parents:
diff changeset
   110
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   111
    QVERIFY( mController->mCommand == EMPXPbvCmdPlayPause );
hgs
parents:
diff changeset
   112
hgs
parents:
diff changeset
   113
    cleanup();
hgs
parents:
diff changeset
   114
}
hgs
parents:
diff changeset
   115
hgs
parents:
diff changeset
   116
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   117
// testLongTapOnFF
hgs
parents:
diff changeset
   118
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   119
//
hgs
parents:
diff changeset
   120
void TestToolBar::testLongTapOnFF()
hgs
parents:
diff changeset
   121
{
hgs
parents:
diff changeset
   122
    MPX_ENTER_EXIT(_L("TestToolBar::testLongTapOnFF()"));
hgs
parents:
diff changeset
   123
hgs
parents:
diff changeset
   124
    init();
hgs
parents:
diff changeset
   125
hgs
parents:
diff changeset
   126
    //
hgs
parents:
diff changeset
   127
    // Start seeking
hgs
parents:
diff changeset
   128
    //
hgs
parents:
diff changeset
   129
    mVideoToolBar->mButtons[E4thButton]->press();
hgs
parents:
diff changeset
   130
    QVERIFY( mController->mTimerAction == ETimerCancel );
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
    connect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( ffPressing() ) );
hgs
parents:
diff changeset
   133
    emit commandSignal();
hgs
parents:
diff changeset
   134
    disconnect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( ffPressing() ) );
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
    QVERIFY( mVideoToolBar->mSeekingState == EFastForwarding );
hgs
parents:
diff changeset
   137
    QVERIFY( mController->mCommand == EMPXPbvCmdSeekForward );
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
    //
hgs
parents:
diff changeset
   140
    // End seeking
hgs
parents:
diff changeset
   141
    //
hgs
parents:
diff changeset
   142
    mVideoToolBar->mButtons[E4thButton]->release();
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
    QVERIFY( mVideoToolBar->mSeekingState == ENotSeeking );
hgs
parents:
diff changeset
   145
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   146
    QVERIFY( mController->mCommand == EMPXPbvCmdEndSeek );
hgs
parents:
diff changeset
   147
hgs
parents:
diff changeset
   148
    cleanup();
hgs
parents:
diff changeset
   149
}
hgs
parents:
diff changeset
   150
hgs
parents:
diff changeset
   151
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   152
// testLongTapOnRW
hgs
parents:
diff changeset
   153
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   154
//
hgs
parents:
diff changeset
   155
void TestToolBar::testLongTapOnRW()
hgs
parents:
diff changeset
   156
{
hgs
parents:
diff changeset
   157
    MPX_ENTER_EXIT(_L("TestToolBar::testLongTapOnRW()"));
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
    init();
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
    //
hgs
parents:
diff changeset
   162
    // Start seeking
hgs
parents:
diff changeset
   163
    //
hgs
parents:
diff changeset
   164
    mVideoToolBar->mButtons[E2ndButton]->press();
hgs
parents:
diff changeset
   165
    QVERIFY( mController->mTimerAction == ETimerCancel );
hgs
parents:
diff changeset
   166
hgs
parents:
diff changeset
   167
    connect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( rwPressing() ) );
hgs
parents:
diff changeset
   168
    emit commandSignal();
hgs
parents:
diff changeset
   169
    disconnect( this, SIGNAL( commandSignal() ), mVideoToolBar, SLOT( rwPressing() ) );
hgs
parents:
diff changeset
   170
hgs
parents:
diff changeset
   171
    QVERIFY( mVideoToolBar->mSeekingState == ERewinding );
hgs
parents:
diff changeset
   172
    QVERIFY( mController->mCommand == EMPXPbvCmdSeekBackward );
hgs
parents:
diff changeset
   173
hgs
parents:
diff changeset
   174
    //
hgs
parents:
diff changeset
   175
    // End seeking
hgs
parents:
diff changeset
   176
    //
hgs
parents:
diff changeset
   177
    mVideoToolBar->mButtons[E2ndButton]->release();
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
    QVERIFY( mVideoToolBar->mSeekingState == ENotSeeking );
hgs
parents:
diff changeset
   180
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   181
    QVERIFY( mController->mCommand == EMPXPbvCmdEndSeek );
hgs
parents:
diff changeset
   182
hgs
parents:
diff changeset
   183
    cleanup();
hgs
parents:
diff changeset
   184
}
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   187
// testShortTapOnFF
hgs
parents:
diff changeset
   188
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   189
//
hgs
parents:
diff changeset
   190
void TestToolBar::testShortTapOnFF()
hgs
parents:
diff changeset
   191
{
hgs
parents:
diff changeset
   192
    MPX_ENTER_EXIT(_L("TestToolBar::testShortTapOnFF()"));
hgs
parents:
diff changeset
   193
hgs
parents:
diff changeset
   194
    init();
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
    //
hgs
parents:
diff changeset
   197
    // If mPostion + KMPXFastForward < mDuration
hgs
parents:
diff changeset
   198
    //
hgs
parents:
diff changeset
   199
    mVideoToolBar->mPosition = 30;
hgs
parents:
diff changeset
   200
    mVideoToolBar->mDuration = 70;
hgs
parents:
diff changeset
   201
    mVideoToolBar->mButtons[E4thButton]->release();
hgs
parents:
diff changeset
   202
hgs
parents:
diff changeset
   203
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   204
    QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
hgs
parents:
diff changeset
   205
    QVERIFY( mController->mCommandValue == mVideoToolBar->mPosition + KMPXFastForward );
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
    //
hgs
parents:
diff changeset
   208
    // If mPostion + KMPXFastForward < mDuration
hgs
parents:
diff changeset
   209
    //
hgs
parents:
diff changeset
   210
    mVideoToolBar->mDuration = 50;
hgs
parents:
diff changeset
   211
    mController->mCommand = EMPXPbvCmdPlay;
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
    mVideoToolBar->mButtons[E4thButton]->release();
hgs
parents:
diff changeset
   214
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   215
    QVERIFY( mController->mCommand == EMPXPbvCmdPlay );
hgs
parents:
diff changeset
   216
hgs
parents:
diff changeset
   217
    cleanup();
hgs
parents:
diff changeset
   218
}
hgs
parents:
diff changeset
   219
hgs
parents:
diff changeset
   220
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   221
// testShortTapOnRW
hgs
parents:
diff changeset
   222
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   223
//
hgs
parents:
diff changeset
   224
void TestToolBar::testShortTapOnRW()
hgs
parents:
diff changeset
   225
{
hgs
parents:
diff changeset
   226
    MPX_ENTER_EXIT(_L("TestToolBar::testShortTapOnRW()"));
hgs
parents:
diff changeset
   227
hgs
parents:
diff changeset
   228
    init();
hgs
parents:
diff changeset
   229
hgs
parents:
diff changeset
   230
    //
hgs
parents:
diff changeset
   231
    // If mPostion + KMPXRewind > 0
hgs
parents:
diff changeset
   232
    //
hgs
parents:
diff changeset
   233
    mVideoToolBar->mPosition = 30;
hgs
parents:
diff changeset
   234
    mVideoToolBar->mButtons[E2ndButton]->release();
hgs
parents:
diff changeset
   235
hgs
parents:
diff changeset
   236
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   237
    QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
hgs
parents:
diff changeset
   238
    QVERIFY( mController->mCommandValue == mVideoToolBar->mPosition + KMPXRewind );
hgs
parents:
diff changeset
   239
hgs
parents:
diff changeset
   240
    //
hgs
parents:
diff changeset
   241
    // If mPostion + KMPXRewind < 0
hgs
parents:
diff changeset
   242
    //
hgs
parents:
diff changeset
   243
    mVideoToolBar->mPosition = 4;
hgs
parents:
diff changeset
   244
    mVideoToolBar->mButtons[E2ndButton]->release();
hgs
parents:
diff changeset
   245
hgs
parents:
diff changeset
   246
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   247
    QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition );
hgs
parents:
diff changeset
   248
    QVERIFY( mController->mCommandValue == 0 );
hgs
parents:
diff changeset
   249
hgs
parents:
diff changeset
   250
    cleanup();
hgs
parents:
diff changeset
   251
}
hgs
parents:
diff changeset
   252
hgs
parents:
diff changeset
   253
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   254
// testPause
hgs
parents:
diff changeset
   255
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   256
//
hgs
parents:
diff changeset
   257
void TestToolBar::testPause()
hgs
parents:
diff changeset
   258
{
hgs
parents:
diff changeset
   259
    MPX_ENTER_EXIT(_L("TestToolBar::testPause()"));
hgs
parents:
diff changeset
   260
hgs
parents:
diff changeset
   261
    init();
hgs
parents:
diff changeset
   262
hgs
parents:
diff changeset
   263
    mVideoToolBar->mButtons[E3rdButton]->release();
hgs
parents:
diff changeset
   264
hgs
parents:
diff changeset
   265
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   266
    QVERIFY( mController->mCommand == EMPXPbvCmdPlayPause );
hgs
parents:
diff changeset
   267
hgs
parents:
diff changeset
   268
    cleanup();
hgs
parents:
diff changeset
   269
}
hgs
parents:
diff changeset
   270
hgs
parents:
diff changeset
   271
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   272
// testChangeAspectRatio
hgs
parents:
diff changeset
   273
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   274
//
hgs
parents:
diff changeset
   275
void TestToolBar::testChangeAspectRatio()
hgs
parents:
diff changeset
   276
{
hgs
parents:
diff changeset
   277
    MPX_ENTER_EXIT(_L("TestToolBar::testChangeAspectRatio()"));
hgs
parents:
diff changeset
   278
hgs
parents:
diff changeset
   279
    init();
hgs
parents:
diff changeset
   280
hgs
parents:
diff changeset
   281
    //
hgs
parents:
diff changeset
   282
    // Test natural
hgs
parents:
diff changeset
   283
    //
hgs
parents:
diff changeset
   284
    mVideoToolBar->mAspectRatio = EMMFZoom;
hgs
parents:
diff changeset
   285
    mVideoToolBar->mButtons[E1stButton]->release();
hgs
parents:
diff changeset
   286
hgs
parents:
diff changeset
   287
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   288
    QVERIFY( mController->mCommand == EMPXPbvCmdNaturalAspectRatio );
hgs
parents:
diff changeset
   289
hgs
parents:
diff changeset
   290
    //
hgs
parents:
diff changeset
   291
    // Test stretch
hgs
parents:
diff changeset
   292
    //
hgs
parents:
diff changeset
   293
    mVideoToolBar->mAspectRatio = EMMFStretch;
hgs
parents:
diff changeset
   294
    mVideoToolBar->mButtons[E1stButton]->release();
hgs
parents:
diff changeset
   295
hgs
parents:
diff changeset
   296
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   297
    QVERIFY( mController->mCommand == EMPXPbvCmdZoomAspectRatio );
hgs
parents:
diff changeset
   298
hgs
parents:
diff changeset
   299
    //
hgs
parents:
diff changeset
   300
    // Test stretch
hgs
parents:
diff changeset
   301
    //
hgs
parents:
diff changeset
   302
    mVideoToolBar->mAspectRatio = EMMFNatural;
hgs
parents:
diff changeset
   303
    mVideoToolBar->mButtons[E1stButton]->release();
hgs
parents:
diff changeset
   304
hgs
parents:
diff changeset
   305
    QVERIFY( mController->mTimerAction == ETimerReset );
hgs
parents:
diff changeset
   306
    QVERIFY( mController->mCommand == EMPXPbvCmdStretchAspectRatio );
hgs
parents:
diff changeset
   307
hgs
parents:
diff changeset
   308
    cleanup();
hgs
parents:
diff changeset
   309
}
hgs
parents:
diff changeset
   310
hgs
parents:
diff changeset
   311
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   312
// testUpdateState
hgs
parents:
diff changeset
   313
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   314
//
hgs
parents:
diff changeset
   315
void TestToolBar::testUpdateState()
hgs
parents:
diff changeset
   316
{
hgs
parents:
diff changeset
   317
    MPX_ENTER_EXIT(_L("TestToolBar::testUpdateState()"));
hgs
parents:
diff changeset
   318
hgs
parents:
diff changeset
   319
    init();
hgs
parents:
diff changeset
   320
hgs
parents:
diff changeset
   321
    VideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
   322
hgs
parents:
diff changeset
   323
    //
hgs
parents:
diff changeset
   324
    // Playing
hgs
parents:
diff changeset
   325
    //
hgs
parents:
diff changeset
   326
    TMPXPlaybackState state = EPbStatePlaying;
hgs
parents:
diff changeset
   327
    details->mPausableStream = false;
hgs
parents:
diff changeset
   328
    mVideoToolBar->updateState( state );
hgs
parents:
diff changeset
   329
hgs
parents:
diff changeset
   330
    QVERIFY( mVideoToolBar->mToolBar->mEnabled == true );
hgs
parents:
diff changeset
   331
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == false );
hgs
parents:
diff changeset
   332
hgs
parents:
diff changeset
   333
    //
hgs
parents:
diff changeset
   334
    // Paused
hgs
parents:
diff changeset
   335
    //
hgs
parents:
diff changeset
   336
    state = EPbStatePaused;
hgs
parents:
diff changeset
   337
    mVideoToolBar->updateState( state );
hgs
parents:
diff changeset
   338
hgs
parents:
diff changeset
   339
    QVERIFY( mVideoToolBar->mToolBar->mEnabled == true );
hgs
parents:
diff changeset
   340
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   341
hgs
parents:
diff changeset
   342
    //
50
hgs
parents: 44
diff changeset
   343
    // Seeking
hgs
parents: 44
diff changeset
   344
    //
hgs
parents: 44
diff changeset
   345
    state = EPbStatePluginSeeking;
hgs
parents: 44
diff changeset
   346
    mVideoToolBar->updateState( state );
hgs
parents: 44
diff changeset
   347
hgs
parents: 44
diff changeset
   348
    QVERIFY( mVideoToolBar->mToolBar->mEnabled == true );
hgs
parents: 44
diff changeset
   349
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents: 44
diff changeset
   350
hgs
parents: 44
diff changeset
   351
    //
44
hgs
parents:
diff changeset
   352
    // Not initialized
hgs
parents:
diff changeset
   353
    //
hgs
parents:
diff changeset
   354
    state = EPbStateNotInitialised;
hgs
parents:
diff changeset
   355
    mVideoToolBar->updateState( state );
hgs
parents:
diff changeset
   356
hgs
parents:
diff changeset
   357
    QVERIFY( mVideoToolBar->mToolBar->mEnabled == false );
hgs
parents:
diff changeset
   358
hgs
parents:
diff changeset
   359
    cleanup();
hgs
parents:
diff changeset
   360
}
hgs
parents:
diff changeset
   361
hgs
parents:
diff changeset
   362
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   363
// testAspectRatioChanged
hgs
parents:
diff changeset
   364
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   365
//
hgs
parents:
diff changeset
   366
void TestToolBar::testAspectRatioChanged()
hgs
parents:
diff changeset
   367
{
hgs
parents:
diff changeset
   368
    MPX_ENTER_EXIT(_L("TestToolBar::testAspectRatioChanged()"));
hgs
parents:
diff changeset
   369
hgs
parents:
diff changeset
   370
    init();
hgs
parents:
diff changeset
   371
hgs
parents:
diff changeset
   372
    //
hgs
parents:
diff changeset
   373
    // Natural
hgs
parents:
diff changeset
   374
    //
hgs
parents:
diff changeset
   375
    int aspectRatio = EMMFNatural;
hgs
parents:
diff changeset
   376
    mVideoToolBar->aspectRatioChanged( aspectRatio );
hgs
parents:
diff changeset
   377
    QVERIFY( mVideoToolBar->mAspectRatio == EMMFNatural );
hgs
parents:
diff changeset
   378
hgs
parents:
diff changeset
   379
    //
hgs
parents:
diff changeset
   380
    // Stretch
hgs
parents:
diff changeset
   381
    //
hgs
parents:
diff changeset
   382
    aspectRatio = EMMFStretch;
hgs
parents:
diff changeset
   383
    mVideoToolBar->aspectRatioChanged( aspectRatio );
hgs
parents:
diff changeset
   384
    QVERIFY( mVideoToolBar->mAspectRatio == EMMFStretch );
hgs
parents:
diff changeset
   385
hgs
parents:
diff changeset
   386
    //
hgs
parents:
diff changeset
   387
    // Zoom
hgs
parents:
diff changeset
   388
    //
hgs
parents:
diff changeset
   389
    aspectRatio = EMMFZoom;
hgs
parents:
diff changeset
   390
    mVideoToolBar->aspectRatioChanged( aspectRatio );
hgs
parents:
diff changeset
   391
    QVERIFY( mVideoToolBar->mAspectRatio == EMMFZoom );
hgs
parents:
diff changeset
   392
hgs
parents:
diff changeset
   393
    cleanup();
hgs
parents:
diff changeset
   394
}
hgs
parents:
diff changeset
   395
hgs
parents:
diff changeset
   396
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   397
// testHandleButtonPressed
hgs
parents:
diff changeset
   398
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   399
//
hgs
parents:
diff changeset
   400
void TestToolBar::testHandleButtonPressed()
hgs
parents:
diff changeset
   401
{
hgs
parents:
diff changeset
   402
    MPX_ENTER_EXIT(_L("TestToolBar::testHandleButtonPressed()"));
hgs
parents:
diff changeset
   403
hgs
parents:
diff changeset
   404
    init();
hgs
parents:
diff changeset
   405
hgs
parents:
diff changeset
   406
    mVideoToolBar->mButtons[E1stButton]->press();
hgs
parents:
diff changeset
   407
hgs
parents:
diff changeset
   408
    QVERIFY( mController->mTimerAction == ETimerCancel );
hgs
parents:
diff changeset
   409
hgs
parents:
diff changeset
   410
    cleanup();
hgs
parents:
diff changeset
   411
}
hgs
parents:
diff changeset
   412
hgs
parents:
diff changeset
   413
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   414
// testUpdateWithFileDetails
hgs
parents:
diff changeset
   415
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   416
//
hgs
parents:
diff changeset
   417
void TestToolBar::testUpdateWithFileDetails()
hgs
parents:
diff changeset
   418
{
hgs
parents:
diff changeset
   419
    MPX_ENTER_EXIT(_L("TestToolBar::testUpdateWithFileDetails()"));
hgs
parents:
diff changeset
   420
hgs
parents:
diff changeset
   421
    //
hgs
parents:
diff changeset
   422
    // 'non-attach' mode
hgs
parents:
diff changeset
   423
    //
hgs
parents:
diff changeset
   424
    init();
hgs
parents:
diff changeset
   425
hgs
parents:
diff changeset
   426
    VideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
   427
hgs
parents:
diff changeset
   428
    //
hgs
parents:
diff changeset
   429
    // video clip, view mode is full-screen
hgs
parents:
diff changeset
   430
    //
hgs
parents:
diff changeset
   431
    details->mVideoEnabled = true;
hgs
parents:
diff changeset
   432
    details->mVideoHeight = 1;
hgs
parents:
diff changeset
   433
    details->mVideoWidth = 1;
hgs
parents:
diff changeset
   434
    details->mTvOutConnected = false;
hgs
parents:
diff changeset
   435
    details->mSeekable = true;
hgs
parents:
diff changeset
   436
    details->mPausableStream = true;
hgs
parents:
diff changeset
   437
    mController->mViewMode = EFullScreenView;
hgs
parents:
diff changeset
   438
hgs
parents:
diff changeset
   439
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   440
hgs
parents:
diff changeset
   441
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == true );
hgs
parents:
diff changeset
   442
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == true );
hgs
parents:
diff changeset
   443
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   444
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   445
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   446
hgs
parents:
diff changeset
   447
    //
hgs
parents:
diff changeset
   448
    // video clip has same aspect ratio as display window
hgs
parents:
diff changeset
   449
    //
hgs
parents:
diff changeset
   450
    details->mVideoEnabled = true;
hgs
parents:
diff changeset
   451
    details->mVideoHeight = 360;
hgs
parents:
diff changeset
   452
    details->mVideoWidth = 640;
hgs
parents:
diff changeset
   453
    details->mTvOutConnected = false;
hgs
parents:
diff changeset
   454
    mController->mViewMode = EFullScreenView;
hgs
parents:
diff changeset
   455
hgs
parents:
diff changeset
   456
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   457
hgs
parents:
diff changeset
   458
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == false );
hgs
parents:
diff changeset
   459
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == true );
hgs
parents:
diff changeset
   460
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   461
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   462
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   463
hgs
parents:
diff changeset
   464
    //
hgs
parents:
diff changeset
   465
    // audio-only clip, view mode is full-screen
hgs
parents:
diff changeset
   466
    //
hgs
parents:
diff changeset
   467
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   468
    details->mVideoHeight = 0;
hgs
parents:
diff changeset
   469
    details->mVideoWidth = 1;
hgs
parents:
diff changeset
   470
    details->mTvOutConnected = true;
hgs
parents:
diff changeset
   471
    details->mSeekable = false;
hgs
parents:
diff changeset
   472
    details->mPausableStream = true;
hgs
parents:
diff changeset
   473
hgs
parents:
diff changeset
   474
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   475
hgs
parents:
diff changeset
   476
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == false );
hgs
parents:
diff changeset
   477
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == false );
hgs
parents:
diff changeset
   478
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   479
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   480
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   481
hgs
parents:
diff changeset
   482
    //
hgs
parents:
diff changeset
   483
    // local audio-only clip, view mode is audio-only
hgs
parents:
diff changeset
   484
    //
hgs
parents:
diff changeset
   485
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   486
    details->mVideoHeight = 0;
hgs
parents:
diff changeset
   487
    details->mVideoWidth = 1;
hgs
parents:
diff changeset
   488
    details->mTvOutConnected = true;
hgs
parents:
diff changeset
   489
    details->mSeekable = true;
hgs
parents:
diff changeset
   490
    details->mPausableStream = false;
hgs
parents:
diff changeset
   491
    mController->mState = EPbStatePlaying;
hgs
parents:
diff changeset
   492
    mController->mViewMode = EAudioOnlyView;
hgs
parents:
diff changeset
   493
hgs
parents:
diff changeset
   494
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   495
hgs
parents:
diff changeset
   496
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == true );
hgs
parents:
diff changeset
   497
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == false );
hgs
parents:
diff changeset
   498
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == false );
hgs
parents:
diff changeset
   499
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   500
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   501
hgs
parents:
diff changeset
   502
    //
hgs
parents:
diff changeset
   503
    // streaming audio-only clip, view mode is audio-only, non-pausable stream in 'playing' state
hgs
parents:
diff changeset
   504
    //
hgs
parents:
diff changeset
   505
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   506
    details->mPlaybackMode = EMPXVideoStreaming;
hgs
parents:
diff changeset
   507
    mController->mViewMode = EAudioOnlyView;
hgs
parents:
diff changeset
   508
    details->mSeekable = false;
hgs
parents:
diff changeset
   509
    details->mPausableStream = false;
hgs
parents:
diff changeset
   510
    mController->mState = EPbStatePlaying;
hgs
parents:
diff changeset
   511
hgs
parents:
diff changeset
   512
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   513
hgs
parents:
diff changeset
   514
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == false );
hgs
parents:
diff changeset
   515
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == false );
hgs
parents:
diff changeset
   516
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == false );
hgs
parents:
diff changeset
   517
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   518
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   519
hgs
parents:
diff changeset
   520
    //
hgs
parents:
diff changeset
   521
    // streaming audio-only clip, view mode is audio-only, non-pausable stream in 'paused' state
hgs
parents:
diff changeset
   522
    //
hgs
parents:
diff changeset
   523
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   524
    details->mPlaybackMode = EMPXVideoStreaming;
hgs
parents:
diff changeset
   525
    mController->mViewMode = EAudioOnlyView;
hgs
parents:
diff changeset
   526
    details->mSeekable = false;
hgs
parents:
diff changeset
   527
    details->mPausableStream = false;
hgs
parents:
diff changeset
   528
    mController->mState = EPbStatePaused;
hgs
parents:
diff changeset
   529
hgs
parents:
diff changeset
   530
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   531
hgs
parents:
diff changeset
   532
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == false );
hgs
parents:
diff changeset
   533
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == false );
hgs
parents:
diff changeset
   534
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   535
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   536
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == false );
hgs
parents:
diff changeset
   537
hgs
parents:
diff changeset
   538
    cleanup();
hgs
parents:
diff changeset
   539
hgs
parents:
diff changeset
   540
    //
hgs
parents:
diff changeset
   541
    // 'attach' mode
hgs
parents:
diff changeset
   542
    //
hgs
parents:
diff changeset
   543
    init( true );
hgs
parents:
diff changeset
   544
hgs
parents:
diff changeset
   545
    //
hgs
parents:
diff changeset
   546
    // video clip, view mode is full-screen
hgs
parents:
diff changeset
   547
    //
hgs
parents:
diff changeset
   548
    details->mVideoEnabled = true;
hgs
parents:
diff changeset
   549
    details->mVideoHeight = 1;
hgs
parents:
diff changeset
   550
    details->mVideoWidth = 1;
hgs
parents:
diff changeset
   551
    details->mTvOutConnected = false;
hgs
parents:
diff changeset
   552
    details->mSeekable = true;
hgs
parents:
diff changeset
   553
    details->mPausableStream = true;
hgs
parents:
diff changeset
   554
hgs
parents:
diff changeset
   555
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   556
hgs
parents:
diff changeset
   557
    QVERIFY( mVideoToolBar->mButtons[E1stButton]->isEnabled() == true );
hgs
parents:
diff changeset
   558
    QVERIFY( mVideoToolBar->mButtons[E2ndButton]->isEnabled() == true );
hgs
parents:
diff changeset
   559
    QVERIFY( mVideoToolBar->mButtons[E3rdButton]->isEnabled() == true );
hgs
parents:
diff changeset
   560
    QVERIFY( mVideoToolBar->mButtons[E4thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   561
    QVERIFY( mVideoToolBar->mButtons[E5thButton]->isEnabled() == true );
hgs
parents:
diff changeset
   562
hgs
parents:
diff changeset
   563
    cleanup();
hgs
parents:
diff changeset
   564
}
hgs
parents:
diff changeset
   565
hgs
parents:
diff changeset
   566
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   567
// testOpenDetailsView
hgs
parents:
diff changeset
   568
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   569
//
hgs
parents:
diff changeset
   570
void TestToolBar::testOpenDetailsView()
hgs
parents:
diff changeset
   571
{
hgs
parents:
diff changeset
   572
    MPX_ENTER_EXIT(_L("TestToolBar::testOpenDetailsView()"));
hgs
parents:
diff changeset
   573
hgs
parents:
diff changeset
   574
    init();
hgs
parents:
diff changeset
   575
hgs
parents:
diff changeset
   576
    QSignalSpy spy( mVideoToolBar, SIGNAL( openDetailsView() ) );
hgs
parents:
diff changeset
   577
hgs
parents:
diff changeset
   578
    mController->mViewMode = EFullScreenView;
hgs
parents:
diff changeset
   579
    mVideoToolBar->mButtons[E5thButton]->release();
hgs
parents:
diff changeset
   580
    QVERIFY( mController->mViewMode == EDetailsView );
hgs
parents:
diff changeset
   581
hgs
parents:
diff changeset
   582
    mController->mViewMode = EDetailsView;
hgs
parents:
diff changeset
   583
    mVideoToolBar->mButtons[E5thButton]->release();
hgs
parents:
diff changeset
   584
    QVERIFY( mController->mViewMode == EDetailsView );
hgs
parents:
diff changeset
   585
hgs
parents:
diff changeset
   586
    mController->mViewMode = EAudioOnlyView;
hgs
parents:
diff changeset
   587
    mVideoToolBar->mButtons[E5thButton]->release();
hgs
parents:
diff changeset
   588
    QVERIFY( mController->mViewMode == EAudioOnlyView );
hgs
parents:
diff changeset
   589
hgs
parents:
diff changeset
   590
    cleanup();
hgs
parents:
diff changeset
   591
}
hgs
parents:
diff changeset
   592
hgs
parents:
diff changeset
   593
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   594
// testAttach
hgs
parents:
diff changeset
   595
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   596
//
hgs
parents:
diff changeset
   597
void TestToolBar::testAttach()
hgs
parents:
diff changeset
   598
{
hgs
parents:
diff changeset
   599
    MPX_ENTER_EXIT(_L("TestToolBar::testAttach()"));
hgs
parents:
diff changeset
   600
hgs
parents:
diff changeset
   601
    //
hgs
parents:
diff changeset
   602
    // test when 'attach' operation is enabled
hgs
parents:
diff changeset
   603
    //
hgs
parents:
diff changeset
   604
    init( true );
hgs
parents:
diff changeset
   605
hgs
parents:
diff changeset
   606
    VideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
   607
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   608
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   609
hgs
parents:
diff changeset
   610
    //
hgs
parents:
diff changeset
   611
    // release 'attach' button
hgs
parents:
diff changeset
   612
    //
hgs
parents:
diff changeset
   613
    mVideoToolBar->mButtons[E1stButton]->release();
hgs
parents:
diff changeset
   614
hgs
parents:
diff changeset
   615
    //
hgs
parents:
diff changeset
   616
    // verify the controller attachVideo() slot has been called
hgs
parents:
diff changeset
   617
    //
hgs
parents:
diff changeset
   618
    QVERIFY( mController->mCommand == EMPXPbvCmdClose );
hgs
parents:
diff changeset
   619
    QVERIFY( mController->mAttachVideoDone == true );
hgs
parents:
diff changeset
   620
hgs
parents:
diff changeset
   621
    //
hgs
parents:
diff changeset
   622
    // clean up
hgs
parents:
diff changeset
   623
    //
hgs
parents:
diff changeset
   624
    cleanup();
hgs
parents:
diff changeset
   625
hgs
parents:
diff changeset
   626
    //
hgs
parents:
diff changeset
   627
    // test when 'attach' operation is disabled
hgs
parents:
diff changeset
   628
    //
hgs
parents:
diff changeset
   629
    init();
hgs
parents:
diff changeset
   630
hgs
parents:
diff changeset
   631
    //
hgs
parents:
diff changeset
   632
    // verify the controller attachVideo() slot is not called
hgs
parents:
diff changeset
   633
    //
hgs
parents:
diff changeset
   634
    QVERIFY( mController->mAttachVideoDone == false );
hgs
parents:
diff changeset
   635
hgs
parents:
diff changeset
   636
    //
hgs
parents:
diff changeset
   637
    // clean up
hgs
parents:
diff changeset
   638
    //
hgs
parents:
diff changeset
   639
    cleanup();
hgs
parents:
diff changeset
   640
hgs
parents:
diff changeset
   641
}
hgs
parents:
diff changeset
   642
hgs
parents:
diff changeset
   643
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   644
// testSend
hgs
parents:
diff changeset
   645
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   646
//
hgs
parents:
diff changeset
   647
void TestToolBar::testSend()
hgs
parents:
diff changeset
   648
{
hgs
parents:
diff changeset
   649
    MPX_ENTER_EXIT(_L("TestToolBar::testSend()"));
hgs
parents:
diff changeset
   650
hgs
parents:
diff changeset
   651
    //
hgs
parents:
diff changeset
   652
    // test when 'share' operation is enabled
hgs
parents:
diff changeset
   653
    //
hgs
parents:
diff changeset
   654
    init( false );
hgs
parents:
diff changeset
   655
hgs
parents:
diff changeset
   656
    VideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
   657
    details->mVideoEnabled = false;
hgs
parents:
diff changeset
   658
    mController->mViewMode = EAudioOnlyView;
hgs
parents:
diff changeset
   659
    mVideoToolBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   660
hgs
parents:
diff changeset
   661
    //
hgs
parents:
diff changeset
   662
    // release 'share' button
hgs
parents:
diff changeset
   663
    //
hgs
parents:
diff changeset
   664
    mVideoToolBar->mButtons[E1stButton]->release();
hgs
parents:
diff changeset
   665
hgs
parents:
diff changeset
   666
    //
hgs
parents:
diff changeset
   667
    // verify the controller sendVideo() slot has been called
hgs
parents:
diff changeset
   668
    //
hgs
parents:
diff changeset
   669
    QVERIFY( mController->mCommand == EMPXPbvCmdPause );
hgs
parents:
diff changeset
   670
    QVERIFY( mController->mSendVideoDone == true );
hgs
parents:
diff changeset
   671
hgs
parents:
diff changeset
   672
    //
hgs
parents:
diff changeset
   673
    // clean up
hgs
parents:
diff changeset
   674
    //
hgs
parents:
diff changeset
   675
    cleanup();
hgs
parents:
diff changeset
   676
}
hgs
parents:
diff changeset
   677
hgs
parents:
diff changeset
   678
// End of file