videoplayback/videoplaybackview/tsrc/testvideodisplayhandler/src/testvideodisplayhandler.cpp
changeset 66 adb51f74b890
parent 55 4bfa887905cf
child 67 72c709219fcd
equal deleted inserted replaced
63:4707a0db12f6 66:adb51f74b890
    23 #include <hbinstance.h>
    23 #include <hbinstance.h>
    24 #include <QDebug>
    24 #include <QDebug>
    25 
    25 
    26 #include <mpxplaybackutility.h>
    26 #include <mpxplaybackutility.h>
    27 
    27 
       
    28 #include "mediaclientvideodisplay.h"
    28 #include "testvideodisplayhandler.h"
    29 #include "testvideodisplayhandler.h"
    29 #include "../stub/inc/videobaseplaybackview.h"
    30 #include "../stub/inc/videobaseplaybackview.h"
    30 #include "../stub/inc/videoplaybackviewfiledetails.h"
    31 #include "../stub/inc/videoplaybackviewfiledetails.h"
    31 #include "mpxvideoviewwrapper.h"
    32 #include "mpxvideoviewwrapper.h"
    32 
    33 
    61 // init
    62 // init
    62 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    63 //
    64 //
    64 void TestVideoDisplayHandler::init()
    65 void TestVideoDisplayHandler::init()
    65 {
    66 {
    66     mPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
       
    67 
       
    68     mBaseVideoView    = new VideoBasePlaybackView();
    67     mBaseVideoView    = new VideoBasePlaybackView();
    69     mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView );
    68     mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView );
    70 
    69 
    71     mDispHdlr = CVideoPlaybackDisplayHandler::NewL(mPlaybackUtility, mVideoViewWrapper);
    70     mDispHdlr = CVideoPlaybackDisplayHandler::NewL( mVideoViewWrapper);
       
    71     mFileDetails = new VideoPlaybackViewFileDetails();
    72 }
    72 }
    73 
    73 
    74 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    75 // cleanup
    75 // cleanup
    76 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    77 //
    77 //
    78 void TestVideoDisplayHandler::cleanup()
    78 void TestVideoDisplayHandler::cleanup()
    79 {
    79 {
    80     if ( mPlaybackUtility )
    80     if ( mFileDetails )
    81     {
    81     {
    82         mPlaybackUtility->Close();
    82         delete mFileDetails;
    83         mPlaybackUtility = NULL;
    83         mFileDetails = NULL;
    84     }
    84     }
    85 
    85 
    86     delete mDispHdlr;
    86     if ( mDispHdlr )
    87     mDispHdlr = NULL;
    87     {
    88 
    88         delete mDispHdlr;
    89     delete mVideoViewWrapper;
    89         mDispHdlr = NULL;
    90     mVideoViewWrapper = NULL;
    90     }
    91 
    91 
    92     delete mBaseVideoView;
    92     if ( mVideoViewWrapper )
    93     mBaseVideoView = NULL;
    93     {
       
    94         delete mVideoViewWrapper;
       
    95         mVideoViewWrapper = NULL;
       
    96     }
       
    97 
       
    98     if ( mBaseVideoView )
       
    99     {
       
   100         delete mBaseVideoView;
       
   101         mBaseVideoView = NULL;
       
   102     }
    94 }
   103 }
    95 
   104 
    96 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
    97 // setup
   106 // setup
    98 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   109                                window->Position().iY + window->Size().iHeight );
   118                                window->Position().iY + window->Size().iHeight );
   110 
   119 
   111     mDispHdlr->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(),
   120     mDispHdlr->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(),
   112                                      *(CCoeEnv::Static()->ScreenDevice()),
   121                                      *(CCoeEnv::Static()->ScreenDevice()),
   113                                      *window,
   122                                      *window,
   114                                      displayRect);
   123                                      displayRect,
       
   124                                      mFileDetails );
   115 
   125 
   116     QCOMPARE( mDispHdlr->iWindowRect, displayRect);
   126     QCOMPARE( mDispHdlr->iWindowRect, displayRect);
   117 
   127 
   118 }
   128 }
   119 
   129 
   137 }
   147 }
   138 
   148 
   139 void TestVideoDisplayHandler::testHandleSurfaceCreatedMessageL()
   149 void TestVideoDisplayHandler::testHandleSurfaceCreatedMessageL()
   140 {
   150 {
   141     setup();
   151     setup();
       
   152 
       
   153     mFileDetails->mVideoHeight = 174;
       
   154     mFileDetails->mVideoWidth = 144;
   142 
   155 
   143     CMPXMessage* message = NULL;
   156     CMPXMessage* message = NULL;
   144     TRAP_IGNORE
   157     TRAP_IGNORE
   145     (
   158     (
   146         message = CMPXMessage::NewL();
   159         message = CMPXMessage::NewL();
   150 
   163 
   151     mDispHdlr->HandleVideoDisplayMessageL( message );
   164     mDispHdlr->HandleVideoDisplayMessageL( message );
   152 
   165 
   153     QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
   166     QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
   154     QVERIFY( mDispHdlr->iViewWrapper->iAttatched );
   167     QVERIFY( mDispHdlr->iViewWrapper->iAttatched );
       
   168     QVERIFY( mFileDetails->mAspectRatioChangeable );
   155 
   169 
   156     mDispHdlr->RemoveDisplayWindow();
   170     mDispHdlr->RemoveDisplayWindow();
   157     cleanup();
   171     cleanup();
   158 }
   172 }
   159 
   173 
   170     );
   184     );
   171 
   185 
   172     mDispHdlr->HandleVideoDisplayMessageL( message );
   186     mDispHdlr->HandleVideoDisplayMessageL( message );
   173 
   187 
   174     QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
   188     QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() );
       
   189     QVERIFY( ! mFileDetails->mAspectRatioChangeable );
       
   190     QVERIFY( mVideoViewWrapper->iAspectRatio == EMMFNatural );
   175 
   191 
   176     mDispHdlr->RemoveDisplayWindow();
   192     mDispHdlr->RemoveDisplayWindow();
   177     cleanup();
   193     cleanup();
   178 }
   194 }
   179 
   195 
   212 
   228 
   213 void TestVideoDisplayHandler::testSetDefaultAspectRatioL()
   229 void TestVideoDisplayHandler::testSetDefaultAspectRatioL()
   214 {
   230 {
   215     setup();
   231     setup();
   216 
   232 
   217     //
   233     cleanup();
   218     // get window size
   234 }
   219     //
   235 
       
   236 void TestVideoDisplayHandler::testUpdateVideoRectL()
       
   237 {
       
   238     setup();
       
   239 
   220     RWindow *window = mBaseVideoView->getWindow();
   240     RWindow *window = mBaseVideoView->getWindow();
   221     TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
   241 
   222 
   242     //
   223     //
   243     // Transition effect is off
   224     // get window aspect ratio
   244     //
   225     //   if device is in landscape mode, width > height
       
   226     //   if device is in portrait mode, width < height
       
   227     //
       
   228     TReal32 width = (TReal32) displayRect.Width();
       
   229     TReal32 height = (TReal32) displayRect.Height();
       
   230     TReal32 displayAspectRatio = (width > height)? (width / height) : (height / width);
       
   231 
       
   232     //
       
   233     // aspect ratio zoom
       
   234     //
       
   235     mFileDetails = new VideoPlaybackViewFileDetails();
       
   236     mFileDetails->mVideoHeight = 280;
       
   237     mFileDetails->mVideoWidth  = 600;
       
   238 
       
   239     int aspectRatio = mDispHdlr->SetDefaultAspectRatioL( mFileDetails, displayAspectRatio );
       
   240 
       
   241     QVERIFY( aspectRatio == EMMFZoom );
       
   242 
       
   243     //
       
   244     // aspect ratio stretch
       
   245     //
       
   246     mFileDetails->mVideoHeight = 144;
       
   247     mFileDetails->mVideoWidth  = 220;
       
   248 
       
   249     aspectRatio = mDispHdlr->SetDefaultAspectRatioL( mFileDetails, displayAspectRatio );
       
   250 
       
   251     QVERIFY( aspectRatio == EMMFStretch );
       
   252 
       
   253     mDispHdlr->RemoveDisplayWindow();
       
   254 
       
   255     cleanup();
       
   256 }
       
   257 
       
   258 void TestVideoDisplayHandler::testUpdateVideoRectL()
       
   259 {
       
   260     setup();
       
   261 
       
   262     RWindow *window = mBaseVideoView->getWindow();
       
   263 
       
   264     TRect displayRect = TRect( 0, 0, 200, 300 );
   245     TRect displayRect = TRect( 0, 0, 200, 300 );
   265 
   246 
   266     mDispHdlr->UpdateVideoRectL( displayRect, false );
   247     mDispHdlr->UpdateVideoRectL( displayRect, false );
   267 
   248 
   268     QCOMPARE( mDispHdlr->iWindowRect, displayRect);
   249     QCOMPARE( mDispHdlr->iWindowRect, displayRect);
   269 
   250 
       
   251     //
       
   252     // iRotation is off
       
   253     //
       
   254     displayRect = TRect( 0, 0, 300, 400 );
       
   255     mDispHdlr->iRotation = EVideoRotationNone;
       
   256 
       
   257     mDispHdlr->UpdateVideoRectL( displayRect, false );
       
   258 
       
   259     QCOMPARE( mDispHdlr->iWindowRect, displayRect);
       
   260 
       
   261     //
       
   262     // iRotation is on
       
   263     //
       
   264     displayRect = TRect( 0, 0, 200, 300 );
       
   265 
       
   266     TRect expectedRect = TRect( 60, 0, 360, 200 );
       
   267     mDispHdlr->iRotation = EVideoRotationClockwise90;
       
   268 
       
   269     mDispHdlr->UpdateVideoRectL( displayRect, false );
       
   270 
       
   271     QCOMPARE( mDispHdlr->iWindowRect, displayRect );
       
   272     QCOMPARE( mDispHdlr->iVideoDisplay->iVideoExtent, expectedRect );
       
   273 
   270     mDispHdlr->RemoveDisplayWindow();
   274     mDispHdlr->RemoveDisplayWindow();
   271     cleanup();
   275     cleanup();
   272 }
   276 }
   273 
   277 
   274 // End of file
   278 // End of file