videoplayback/videoplaybackview/tsrc/testvideodisplayhandler/src/testvideodisplayhandler.cpp
author hgs
Fri, 15 Oct 2010 16:29:10 +0300
changeset 67 72c709219fcd
parent 66 adb51f74b890
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
hgs
parents:
diff changeset
     1
/**
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 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 Video Display Handler
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <e32err.h>
hgs
parents:
diff changeset
    19
#include <w32std.h>
hgs
parents:
diff changeset
    20
#include <eikenv.h>
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include <hbapplication.h>
hgs
parents:
diff changeset
    23
#include <hbinstance.h>
hgs
parents:
diff changeset
    24
#include <QDebug>
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include <mpxplaybackutility.h>
hgs
parents:
diff changeset
    27
66
hgs
parents: 55
diff changeset
    28
#include "mediaclientvideodisplay.h"
44
hgs
parents:
diff changeset
    29
#include "testvideodisplayhandler.h"
hgs
parents:
diff changeset
    30
#include "../stub/inc/videobaseplaybackview.h"
hgs
parents:
diff changeset
    31
#include "../stub/inc/videoplaybackviewfiledetails.h"
hgs
parents:
diff changeset
    32
#include "mpxvideoviewwrapper.h"
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
#define private public
55
hgs
parents: 50
diff changeset
    35
#include "videoplaybackdisplayhandler.h"
44
hgs
parents:
diff changeset
    36
#undef private
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    40
// main
hgs
parents:
diff changeset
    41
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    42
//
hgs
parents:
diff changeset
    43
int main(int argc, char *argv[])
hgs
parents:
diff changeset
    44
{
hgs
parents:
diff changeset
    45
    HbApplication app(argc, argv);
hgs
parents:
diff changeset
    46
    HbMainWindow window;
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
    TestVideoDisplayHandler tv;
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
    char *pass[3];
hgs
parents:
diff changeset
    51
    pass[0] = argv[0];
hgs
parents:
diff changeset
    52
    pass[1] = "-o";
hgs
parents:
diff changeset
    53
    pass[2] = "c:\\data\\testvideodisplayhandler.txt";
hgs
parents:
diff changeset
    54
hgs
parents:
diff changeset
    55
    int res = QTest::qExec(&tv, 3, pass);
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
    return res;
hgs
parents:
diff changeset
    58
}
hgs
parents:
diff changeset
    59
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    62
// init
hgs
parents:
diff changeset
    63
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    64
//
hgs
parents:
diff changeset
    65
void TestVideoDisplayHandler::init()
hgs
parents:
diff changeset
    66
{
55
hgs
parents: 50
diff changeset
    67
    mBaseVideoView    = new VideoBasePlaybackView();
hgs
parents: 50
diff changeset
    68
    mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView );
44
hgs
parents:
diff changeset
    69
66
hgs
parents: 55
diff changeset
    70
    mDispHdlr = CVideoPlaybackDisplayHandler::NewL( mVideoViewWrapper);
hgs
parents: 55
diff changeset
    71
    mFileDetails = new VideoPlaybackViewFileDetails();
44
hgs
parents:
diff changeset
    72
}
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    75
// cleanup
hgs
parents:
diff changeset
    76
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
//
hgs
parents:
diff changeset
    78
void TestVideoDisplayHandler::cleanup()
hgs
parents:
diff changeset
    79
{
66
hgs
parents: 55
diff changeset
    80
    if ( mFileDetails )
44
hgs
parents:
diff changeset
    81
    {
66
hgs
parents: 55
diff changeset
    82
        delete mFileDetails;
hgs
parents: 55
diff changeset
    83
        mFileDetails = NULL;
hgs
parents: 55
diff changeset
    84
    }
hgs
parents: 55
diff changeset
    85
hgs
parents: 55
diff changeset
    86
    if ( mDispHdlr )
hgs
parents: 55
diff changeset
    87
    {
hgs
parents: 55
diff changeset
    88
        delete mDispHdlr;
hgs
parents: 55
diff changeset
    89
        mDispHdlr = NULL;
44
hgs
parents:
diff changeset
    90
    }
hgs
parents:
diff changeset
    91
66
hgs
parents: 55
diff changeset
    92
    if ( mVideoViewWrapper )
hgs
parents: 55
diff changeset
    93
    {
hgs
parents: 55
diff changeset
    94
        delete mVideoViewWrapper;
hgs
parents: 55
diff changeset
    95
        mVideoViewWrapper = NULL;
hgs
parents: 55
diff changeset
    96
    }
44
hgs
parents:
diff changeset
    97
66
hgs
parents: 55
diff changeset
    98
    if ( mBaseVideoView )
hgs
parents: 55
diff changeset
    99
    {
hgs
parents: 55
diff changeset
   100
        delete mBaseVideoView;
hgs
parents: 55
diff changeset
   101
        mBaseVideoView = NULL;
hgs
parents: 55
diff changeset
   102
    }
44
hgs
parents:
diff changeset
   103
}
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   106
// setup
hgs
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   108
//
hgs
parents:
diff changeset
   109
void TestVideoDisplayHandler::setup()
hgs
parents:
diff changeset
   110
{
hgs
parents:
diff changeset
   111
    init();
hgs
parents:
diff changeset
   112
hgs
parents:
diff changeset
   113
    RWindow *window = mBaseVideoView->getWindow();
hgs
parents:
diff changeset
   114
hgs
parents:
diff changeset
   115
    TRect displayRect = TRect( window->Position().iX,
hgs
parents:
diff changeset
   116
                               window->Position().iY,
hgs
parents:
diff changeset
   117
                               window->Position().iX + window->Size().iWidth,
hgs
parents:
diff changeset
   118
                               window->Position().iY + window->Size().iHeight );
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
    mDispHdlr->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(),
hgs
parents:
diff changeset
   121
                                     *(CCoeEnv::Static()->ScreenDevice()),
hgs
parents:
diff changeset
   122
                                     *window,
66
hgs
parents: 55
diff changeset
   123
                                     displayRect,
hgs
parents: 55
diff changeset
   124
                                     mFileDetails );
44
hgs
parents:
diff changeset
   125
hgs
parents:
diff changeset
   126
    QCOMPARE( mDispHdlr->iWindowRect, displayRect);
hgs
parents:
diff changeset
   127
hgs
parents:
diff changeset
   128
}
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
void TestVideoDisplayHandler::testCreateDisplayWindowL()
hgs
parents:
diff changeset
   132
{
hgs
parents:
diff changeset
   133
    setup();
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
    cleanup();
hgs
parents:
diff changeset
   136
}
hgs
parents:
diff changeset
   137
hgs
parents:
diff changeset
   138
void TestVideoDisplayHandler::testRemoveDisplayWindow()
hgs
parents:
diff changeset
   139
{
hgs
parents:
diff changeset
   140
    setup();
hgs
parents:
diff changeset
   141
hgs
parents:
diff changeset
   142
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
    QVERIFY( mDispHdlr->iVideoContainer == NULL );
hgs
parents:
diff changeset
   145
hgs
parents:
diff changeset
   146
    cleanup();
hgs
parents:
diff changeset
   147
}
hgs
parents:
diff changeset
   148
hgs
parents:
diff changeset
   149
void TestVideoDisplayHandler::testHandleSurfaceCreatedMessageL()
hgs
parents:
diff changeset
   150
{
hgs
parents:
diff changeset
   151
    setup();
hgs
parents:
diff changeset
   152
67
hgs
parents: 66
diff changeset
   153
    mFileDetails->mVideoHeight = 144;
hgs
parents: 66
diff changeset
   154
    mFileDetails->mVideoWidth = 176;
66
hgs
parents: 55
diff changeset
   155
44
hgs
parents:
diff changeset
   156
    CMPXMessage* message = NULL;
hgs
parents:
diff changeset
   157
    TRAP_IGNORE
hgs
parents:
diff changeset
   158
    (
hgs
parents:
diff changeset
   159
        message = CMPXMessage::NewL();
hgs
parents:
diff changeset
   160
        message->SetTObjectValueL<TMPXVideoDisplayCommand>
hgs
parents:
diff changeset
   161
                    ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceCreated );
hgs
parents:
diff changeset
   162
    );
hgs
parents:
diff changeset
   163
hgs
parents:
diff changeset
   164
    mDispHdlr->HandleVideoDisplayMessageL( message );
hgs
parents:
diff changeset
   165
hgs
parents:
diff changeset
   166
    QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
50
hgs
parents: 44
diff changeset
   167
    QVERIFY( mDispHdlr->iViewWrapper->iAttatched );
66
hgs
parents: 55
diff changeset
   168
    QVERIFY( mFileDetails->mAspectRatioChangeable );
44
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   171
    cleanup();
hgs
parents:
diff changeset
   172
}
hgs
parents:
diff changeset
   173
hgs
parents:
diff changeset
   174
void TestVideoDisplayHandler::testHandleSurfaceChangedMessageL()
hgs
parents:
diff changeset
   175
{
hgs
parents:
diff changeset
   176
    setup();
hgs
parents:
diff changeset
   177
67
hgs
parents: 66
diff changeset
   178
    mFileDetails->mVideoHeight = 480;
hgs
parents: 66
diff changeset
   179
    mFileDetails->mVideoWidth = 852;
hgs
parents: 66
diff changeset
   180
44
hgs
parents:
diff changeset
   181
    CMPXMessage* message = NULL;
hgs
parents:
diff changeset
   182
    TRAP_IGNORE
hgs
parents:
diff changeset
   183
    (
hgs
parents:
diff changeset
   184
        message = CMPXMessage::NewL();
hgs
parents:
diff changeset
   185
        message->SetTObjectValueL<TMPXVideoDisplayCommand>
hgs
parents:
diff changeset
   186
                    ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceChanged );
hgs
parents:
diff changeset
   187
    );
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
    mDispHdlr->HandleVideoDisplayMessageL( message );
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
    QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
66
hgs
parents: 55
diff changeset
   192
    QVERIFY( ! mFileDetails->mAspectRatioChangeable );
hgs
parents: 55
diff changeset
   193
    QVERIFY( mVideoViewWrapper->iAspectRatio == EMMFNatural );
44
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   196
    cleanup();
hgs
parents:
diff changeset
   197
}
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
void TestVideoDisplayHandler::testHandleVideoRemovedMessageL()
hgs
parents:
diff changeset
   200
{
hgs
parents:
diff changeset
   201
    setup();
hgs
parents:
diff changeset
   202
hgs
parents:
diff changeset
   203
    CMPXMessage* message = NULL;
hgs
parents:
diff changeset
   204
    TRAP_IGNORE
hgs
parents:
diff changeset
   205
    (
hgs
parents:
diff changeset
   206
        message = CMPXMessage::NewL();
hgs
parents:
diff changeset
   207
        message->SetTObjectValueL<TMPXVideoDisplayCommand>
hgs
parents:
diff changeset
   208
                    ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceRemoved );
hgs
parents:
diff changeset
   209
    );
hgs
parents:
diff changeset
   210
hgs
parents:
diff changeset
   211
    mDispHdlr->HandleVideoDisplayMessageL( message );
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
    QVERIFY( mDispHdlr->iSurfaceId.IsNull() );
50
hgs
parents: 44
diff changeset
   214
    QVERIFY( ! mDispHdlr->iViewWrapper->iAttatched );
44
hgs
parents:
diff changeset
   215
hgs
parents:
diff changeset
   216
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   217
    cleanup();
hgs
parents:
diff changeset
   218
}
hgs
parents:
diff changeset
   219
hgs
parents:
diff changeset
   220
void TestVideoDisplayHandler::testSetAspectRatioL()
hgs
parents:
diff changeset
   221
{
hgs
parents:
diff changeset
   222
    setup();
hgs
parents:
diff changeset
   223
hgs
parents:
diff changeset
   224
    int aspectRatio = mDispHdlr->SetAspectRatioL( EPbCmdNaturalAspectRatio );
hgs
parents:
diff changeset
   225
hgs
parents:
diff changeset
   226
    QVERIFY( aspectRatio == EMMFNatural );
hgs
parents:
diff changeset
   227
hgs
parents:
diff changeset
   228
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   229
    cleanup();
hgs
parents:
diff changeset
   230
}
hgs
parents:
diff changeset
   231
hgs
parents:
diff changeset
   232
void TestVideoDisplayHandler::testSetDefaultAspectRatioL()
hgs
parents:
diff changeset
   233
{
hgs
parents:
diff changeset
   234
    setup();
hgs
parents:
diff changeset
   235
hgs
parents:
diff changeset
   236
    cleanup();
hgs
parents:
diff changeset
   237
}
hgs
parents:
diff changeset
   238
hgs
parents:
diff changeset
   239
void TestVideoDisplayHandler::testUpdateVideoRectL()
hgs
parents:
diff changeset
   240
{
hgs
parents:
diff changeset
   241
    setup();
hgs
parents:
diff changeset
   242
hgs
parents:
diff changeset
   243
    RWindow *window = mBaseVideoView->getWindow();
hgs
parents:
diff changeset
   244
66
hgs
parents: 55
diff changeset
   245
    //
hgs
parents: 55
diff changeset
   246
    // Transition effect is off
hgs
parents: 55
diff changeset
   247
    //
44
hgs
parents:
diff changeset
   248
    TRect displayRect = TRect( 0, 0, 200, 300 );
hgs
parents:
diff changeset
   249
hgs
parents:
diff changeset
   250
    mDispHdlr->UpdateVideoRectL( displayRect, false );
hgs
parents:
diff changeset
   251
hgs
parents:
diff changeset
   252
    QCOMPARE( mDispHdlr->iWindowRect, displayRect);
hgs
parents:
diff changeset
   253
66
hgs
parents: 55
diff changeset
   254
    //
hgs
parents: 55
diff changeset
   255
    // iRotation is off
hgs
parents: 55
diff changeset
   256
    //
hgs
parents: 55
diff changeset
   257
    displayRect = TRect( 0, 0, 300, 400 );
hgs
parents: 55
diff changeset
   258
    mDispHdlr->iRotation = EVideoRotationNone;
hgs
parents: 55
diff changeset
   259
hgs
parents: 55
diff changeset
   260
    mDispHdlr->UpdateVideoRectL( displayRect, false );
hgs
parents: 55
diff changeset
   261
hgs
parents: 55
diff changeset
   262
    QCOMPARE( mDispHdlr->iWindowRect, displayRect);
hgs
parents: 55
diff changeset
   263
hgs
parents: 55
diff changeset
   264
    //
hgs
parents: 55
diff changeset
   265
    // iRotation is on
hgs
parents: 55
diff changeset
   266
    //
hgs
parents: 55
diff changeset
   267
    displayRect = TRect( 0, 0, 200, 300 );
hgs
parents: 55
diff changeset
   268
hgs
parents: 55
diff changeset
   269
    TRect expectedRect = TRect( 60, 0, 360, 200 );
hgs
parents: 55
diff changeset
   270
    mDispHdlr->iRotation = EVideoRotationClockwise90;
hgs
parents: 55
diff changeset
   271
hgs
parents: 55
diff changeset
   272
    mDispHdlr->UpdateVideoRectL( displayRect, false );
hgs
parents: 55
diff changeset
   273
hgs
parents: 55
diff changeset
   274
    QCOMPARE( mDispHdlr->iWindowRect, displayRect );
hgs
parents: 55
diff changeset
   275
    QCOMPARE( mDispHdlr->iVideoDisplay->iVideoExtent, expectedRect );
hgs
parents: 55
diff changeset
   276
44
hgs
parents:
diff changeset
   277
    mDispHdlr->RemoveDisplayWindow();
hgs
parents:
diff changeset
   278
    cleanup();
hgs
parents:
diff changeset
   279
}
hgs
parents:
diff changeset
   280
hgs
parents:
diff changeset
   281
// End of file
hgs
parents:
diff changeset
   282