videoplayback/hbvideoplaybackview/tsrc/testmpxvideoplaybackcontrolbar/src/testmpxvideoplaybackcontrolbar.cpp
author hgs
Fri, 11 Jun 2010 09:44:20 +0300
changeset 40 13331705e488
parent 37 4eb2df7f7cbe
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
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 TestMPXVideoPlaybackControlBar
hgs
parents:
diff changeset
    15
* 
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
37
hgs
parents: 35
diff changeset
    18
// Version : %version:  2 %
35
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
37
hgs
parents: 35
diff changeset
    25
#include "mpxvideoplaybacktoolbar.h"
35
hgs
parents:
diff changeset
    26
#include "mpxvideoplaybackprogressbar.h"
hgs
parents:
diff changeset
    27
#include "testmpxvideoplaybackcontrolbar.h"
hgs
parents:
diff changeset
    28
#include "mpxvideoplaybackviewfiledetails.h"
hgs
parents:
diff changeset
    29
#include "mpxvideoplaybackcontrolscontroller.h"
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
#define private public
hgs
parents:
diff changeset
    32
#include "mpxvideoplaybackcontrolbar.h"
hgs
parents:
diff changeset
    33
#undef private
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    36
// main
hgs
parents:
diff changeset
    37
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    38
//
hgs
parents:
diff changeset
    39
int main(int argc, char *argv[])
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::Main()"));
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
    HbApplication app(argc, argv);
hgs
parents:
diff changeset
    44
    HbMainWindow window;
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
    TestMPXVideoPlaybackControlBar tv;
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
    char *pass[3];
hgs
parents:
diff changeset
    49
    pass[0] = argv[0];
hgs
parents:
diff changeset
    50
    pass[1] = "-o";
hgs
parents:
diff changeset
    51
    pass[2] = "c:\\data\\testmpxvideoplaybackcontrolbar.txt";
hgs
parents:
diff changeset
    52
    
hgs
parents:
diff changeset
    53
    int res = QTest::qExec(&tv, 3, pass);
hgs
parents:
diff changeset
    54
    
hgs
parents:
diff changeset
    55
    return res;
hgs
parents:
diff changeset
    56
}
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 TestMPXVideoPlaybackControlBar::init()
hgs
parents:
diff changeset
    64
{
hgs
parents:
diff changeset
    65
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::init()"));
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
    mController = new QMPXVideoPlaybackControlsController();   
hgs
parents:
diff changeset
    68
    mControlBar = new QMPXVideoPlaybackControlBar( mController );
hgs
parents:
diff changeset
    69
hgs
parents:
diff changeset
    70
    mControlBar->initialize();
hgs
parents:
diff changeset
    71
}
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    74
// cleanup
hgs
parents:
diff changeset
    75
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    76
//
hgs
parents:
diff changeset
    77
void TestMPXVideoPlaybackControlBar::cleanup()
hgs
parents:
diff changeset
    78
{
hgs
parents:
diff changeset
    79
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::cleanup()"));
hgs
parents:
diff changeset
    80
hgs
parents:
diff changeset
    81
    if ( mController )
hgs
parents:
diff changeset
    82
    {
hgs
parents:
diff changeset
    83
        delete mController;
hgs
parents:
diff changeset
    84
        mController = NULL;
hgs
parents:
diff changeset
    85
    }
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
    if ( mControlBar )
hgs
parents:
diff changeset
    88
    {
hgs
parents:
diff changeset
    89
        delete mControlBar;
hgs
parents:
diff changeset
    90
        mControlBar = NULL;
hgs
parents:
diff changeset
    91
    }
hgs
parents:
diff changeset
    92
}
hgs
parents:
diff changeset
    93
hgs
parents:
diff changeset
    94
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    95
// testupdateState
hgs
parents:
diff changeset
    96
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    97
//
hgs
parents:
diff changeset
    98
void TestMPXVideoPlaybackControlBar::testupdateState()
hgs
parents:
diff changeset
    99
{
hgs
parents:
diff changeset
   100
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testupdateState()"));
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
    init();
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
    TMPXPlaybackState state = EPbStatePlaying;
hgs
parents:
diff changeset
   105
    mControlBar->updateState( state );
37
hgs
parents: 35
diff changeset
   106
    QVERIFY( mControlBar->mToolBar->mState == EPbStatePlaying );
35
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
    state = EPbStatePaused;
hgs
parents:
diff changeset
   109
    mControlBar->updateState( state );
37
hgs
parents: 35
diff changeset
   110
    QVERIFY( mControlBar->mToolBar->mState == EPbStatePaused );
35
hgs
parents:
diff changeset
   111
hgs
parents:
diff changeset
   112
    cleanup();
hgs
parents:
diff changeset
   113
}
hgs
parents:
diff changeset
   114
hgs
parents:
diff changeset
   115
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   116
// testaspectRatioChanged
hgs
parents:
diff changeset
   117
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   118
//
hgs
parents:
diff changeset
   119
void TestMPXVideoPlaybackControlBar::testaspectRatioChanged()
hgs
parents:
diff changeset
   120
{
hgs
parents:
diff changeset
   121
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testaspectRatioChanged()"));
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
    init();
hgs
parents:
diff changeset
   124
hgs
parents:
diff changeset
   125
    int aspectRatio = 1;
hgs
parents:
diff changeset
   126
    mControlBar->aspectRatioChanged( aspectRatio );
37
hgs
parents: 35
diff changeset
   127
    QVERIFY( mControlBar->mToolBar->mAspectRatio == aspectRatio );
35
hgs
parents:
diff changeset
   128
hgs
parents:
diff changeset
   129
    cleanup();
hgs
parents:
diff changeset
   130
}
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   133
// testUpdateWithFileDetails
hgs
parents:
diff changeset
   134
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   135
//
hgs
parents:
diff changeset
   136
void TestMPXVideoPlaybackControlBar::testUpdateWithFileDetails()
hgs
parents:
diff changeset
   137
{
hgs
parents:
diff changeset
   138
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testUpdateWithFileDetails()"));
hgs
parents:
diff changeset
   139
hgs
parents:
diff changeset
   140
    init();
hgs
parents:
diff changeset
   141
hgs
parents:
diff changeset
   142
    QMPXVideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
   143
    details->mSeekable = false;
hgs
parents:
diff changeset
   144
    details->mVideoEnabled = true;
hgs
parents:
diff changeset
   145
hgs
parents:
diff changeset
   146
    mControlBar->updateWithFileDetails( details );
hgs
parents:
diff changeset
   147
37
hgs
parents: 35
diff changeset
   148
    QVERIFY( mControlBar->mToolBar->mFileDetails->mSeekable == details->mSeekable );
35
hgs
parents:
diff changeset
   149
    QVERIFY( mControlBar->mProgressBar->mFileDetails->mVideoEnabled == details->mVideoEnabled );
hgs
parents:
diff changeset
   150
hgs
parents:
diff changeset
   151
    cleanup();
hgs
parents:
diff changeset
   152
}
hgs
parents:
diff changeset
   153
hgs
parents:
diff changeset
   154
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   155
// testSetVisibleToControlBar
hgs
parents:
diff changeset
   156
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   157
//
hgs
parents:
diff changeset
   158
void TestMPXVideoPlaybackControlBar::testSetVisibleToControlBar()
hgs
parents:
diff changeset
   159
{
hgs
parents:
diff changeset
   160
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testSetVisibleToControlBar()"));
hgs
parents:
diff changeset
   161
hgs
parents:
diff changeset
   162
    init();
hgs
parents:
diff changeset
   163
hgs
parents:
diff changeset
   164
    //
hgs
parents:
diff changeset
   165
    // Make visible
hgs
parents:
diff changeset
   166
    //
hgs
parents:
diff changeset
   167
    mControlBar->setVisible( false );
hgs
parents:
diff changeset
   168
    mControlBar->setVisibleToControlBar( true );
hgs
parents:
diff changeset
   169
    QVERIFY( mControlBar->isVisible() == true );
hgs
parents:
diff changeset
   170
hgs
parents:
diff changeset
   171
    //
hgs
parents:
diff changeset
   172
    // Make invisible
hgs
parents:
diff changeset
   173
    //
hgs
parents:
diff changeset
   174
    mControlBar->setVisible( true );
hgs
parents:
diff changeset
   175
    mControlBar->setVisibleToControlBar( false );
hgs
parents:
diff changeset
   176
    QVERIFY( mControlBar->isVisible() == false );
hgs
parents:
diff changeset
   177
hgs
parents:
diff changeset
   178
    cleanup();
hgs
parents:
diff changeset
   179
}
hgs
parents:
diff changeset
   180
hgs
parents:
diff changeset
   181
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   182
// testDurationChanged
hgs
parents:
diff changeset
   183
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   184
//
hgs
parents:
diff changeset
   185
void TestMPXVideoPlaybackControlBar::testDurationChanged()
hgs
parents:
diff changeset
   186
{
hgs
parents:
diff changeset
   187
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testDurationChanged()"));
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
    init();
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
    int duration = 12345;
hgs
parents:
diff changeset
   192
    mControlBar->durationChanged( duration );
hgs
parents:
diff changeset
   193
    QVERIFY( mControlBar->mProgressBar->mDuration == duration );
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
    cleanup();
hgs
parents:
diff changeset
   196
}
hgs
parents:
diff changeset
   197
hgs
parents:
diff changeset
   198
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   199
// testPositionChanged
hgs
parents:
diff changeset
   200
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   201
//
hgs
parents:
diff changeset
   202
void TestMPXVideoPlaybackControlBar::testPositionChanged()
hgs
parents:
diff changeset
   203
{
hgs
parents:
diff changeset
   204
    MPX_ENTER_EXIT(_L("TestMPXVideoPlaybackControlBar::testPositionChanged()"));
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
    init();
hgs
parents:
diff changeset
   207
hgs
parents:
diff changeset
   208
    int position = 54321;
hgs
parents:
diff changeset
   209
    mControlBar->positionChanged( position );
hgs
parents:
diff changeset
   210
    QVERIFY( mControlBar->mProgressBar->mPosition == position );
hgs
parents:
diff changeset
   211
hgs
parents:
diff changeset
   212
    cleanup();
hgs
parents:
diff changeset
   213
}
hgs
parents:
diff changeset
   214
hgs
parents:
diff changeset
   215
// End of file