videoplayback/hbvideoplaybackview/tsrc/testvideoplaybackview/src/testvideoplaybackview.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
--- a/videoplayback/hbvideoplaybackview/tsrc/testvideoplaybackview/src/testvideoplaybackview.cpp	Tue Jul 06 14:17:50 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-/**
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:   tester for methods in VideoSortFilterProxyModel
-*
-*/
-
-// Version : %version: 10 %
-
-#include <e32err.h>
-#include <w32std.h>
-
-#include <mmf/common/mmferrors.h>
-#include <caf/caferr.h>
-
-#include <mpxvideoplaybackdefs.h>
-
-#include <hbapplication.h>
-#include <hbinstance.h>
-#include <qgraphicssceneevent>
-#include <QDebug>
-
-#include "mpxvideoplaybackviewfiledetails.h"
-#include "mpxcommonvideoplaybackview.hrh"
-
-#include "testvideoplaybackview.h"
-#include "mpxvideoviewwrapper.h"
-#include "hbtapgesture.h"
-#include "hbpangesture.h"
-
-#define private public
-#define protected public
-#include "hbvideoplaybackview.h"
-#include "hbvideobaseplaybackview.h"
-#undef protected
-#undef private
-
-
-// ---------------------------------------------------------------------------
-// main
-// ---------------------------------------------------------------------------
-//
-int main(int argc, char *argv[])
-{
-    HbApplication app(argc, argv);
-    HbMainWindow window;
-
-    TestVideoPlaybackView tv;
-
-    char *pass[3];
-    pass[0] = argv[0];
-    pass[1] = "-o";
-    pass[2] = "c:\\data\\TestVideoPlaybackView.txt";
-
-    int res = QTest::qExec(&tv, 3, pass);
-
-    return res;
-}
-
-// ---------------------------------------------------------------------------
-// init
-// ---------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::init()
-{
-	  mVideoView = new HbVideoPlaybackView();
-}
-
-// ---------------------------------------------------------------------------
-// cleanup
-// ---------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::cleanup()
-{
-    delete mVideoView;
-    mVideoView = NULL;
-}
-
-// ---------------------------------------------------------------------------
-// setup
-// ---------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::setup()
-{
-    init();
-    mVideoView->handleActivateView();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleActivateView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleActivateView()
-{
-    init();
-    mVideoView->handleActivateView();
-
-    QVERIFY( mVideoView->mVideoMpxWrapper->iMediaRequested == true );
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mBitRate, 16000 );
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mTitle, QString("Test Video Title") );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandlePluginError()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandlePluginError()
-{
-    //
-    // playback view is closed after displaying these error notes
-    //
-    verifyHandlePluginError( KErrNotSupported );
-    verifyHandlePluginError( KErrUnknown );
-    verifyHandlePluginError( KErrMMDecoder );
-    verifyHandlePluginError( KErrCorrupt );
-    verifyHandlePluginError( KErrTooBig );
-    verifyHandlePluginError( KErrMMInvalidProtocol );
-    verifyHandlePluginError( KErrMMInvalidURL );
-    verifyHandlePluginError( KErrArgument );
-    verifyHandlePluginError( KErrSessionClosed );
-    verifyHandlePluginError( KErrTimedOut );
-    verifyHandlePluginError( KErrNotFound );
-    verifyHandlePluginError( KErrMMNotEnoughBandwidth );
-    verifyHandlePluginError( KErrDisconnected );
-    verifyHandlePluginError( KErrMMProxyServer );
-    verifyHandlePluginError( KErrCouldNotConnect );
-    verifyHandlePluginError( KErrAbort );
-    verifyHandlePluginError( KErrCancel );
-    verifyHandlePluginError( KErrMMDRMNotAuthorized );
-    verifyHandlePluginError( KErrCANoRights );
-    verifyHandlePluginError( KErrCANoPermission );
-
-    //
-    // playback view remains open after displaying these error notes
-    //
-    verifyHandlePluginError( KMPXVideoCallOngoingError, false );
-    verifyHandlePluginError( KMPXVideoPlayOver2GDuringVoiceCallError, false );
-
-    //
-    // default error case, playback view is closed after displaying error note
-    //
-    verifyHandlePluginError( KErrGeneral );
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testShowDialog()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testShowDialog()
-{
-    //
-    // construct and activate playback view
-    //
-    setup();
-
-    //
-    // ensure that playback view is currently activated
-    //
-    QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-
-    //
-    // test showDialog() method
-    //
-    mVideoView->showDialog( "test error msg" );
-
-    //
-    // connect and emit signal for handleClosePopupDialog() slot
-    //
-    connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) );
-    emit commandSignal();
-
-    //
-    // verify that playback view is properly closed
-    //
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    //
-    // disconnect signal for handleClosePopupDialog() slot
-    //
-    disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) );
-
-    //
-    // destruct playback view
-    //
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testGetWindow()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testGetWindow()
-{
-    setup();
-
-    QVERIFY( mVideoView->getWindow() != NULL );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testIssuePlayCommand()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testIssuePlayCommand()
-{
-    setup();
-
-    mVideoView->issuePlayCommand();
-
-    //JAM remove
-    QVERIFY( mVideoView->isEnabled() );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testEventFilter()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testEventFilter()
-{
-    setup();
-
-    //
-    // ensure default foreground is false
-    //
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 );
-
-    //
-    // declare foreground/background event
-    //
-    QEvent* appActivate   = new QEvent( QEvent::ApplicationActivate );
-    QEvent* appDeactivate = new QEvent( QEvent::ApplicationDeactivate );
-
-    //
-    // verify the returned value (consumed) of HbVideoBasePlaybackView::event()
-    // for QEvent::ApplicationActivate is false
-    //
-    QVERIFY( ! mVideoView->eventFilter( NULL, appActivate ) );
-
-    //
-    // verify view is in foreground
-    //
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 1 );
-
-    //
-    // verify the returned value (consumed) of HbVideoBasePlaybackView::event()
-    // for QEvent::ApplicationDeactivate is false
-    //
-    QVERIFY( ! mVideoView->eventFilter( NULL, appDeactivate ) );
-
-    //
-    // verify view is in background
-    //
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 );
-
-    //
-    // clean up
-    //
-    if ( appActivate )
-    {
-        delete appActivate;
-        appActivate = NULL;
-    }
-
-    if ( appDeactivate )
-    {
-        delete appDeactivate;
-        appDeactivate = NULL;
-    }
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testClosePlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testClosePlaybackView()
-{
-    setup();
-
-    QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-
-    mVideoView->closePlaybackView();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandlePdlStateChange()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandlePdlStateChange()
-{
-    setup();
-
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") );
-
-    mVideoView->handlePdlStateChange( 0 );
-
-    QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleStoppedStateNoPrevView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleStoppedStateNoPrevView()
-{
-    setup();
-
-    QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-    mVideoView->handleStoppedState();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleStoppedStatePrevView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleStoppedStatePrevView()
-{
-    setup();
-
-    mVideoView->handleStoppedState();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleBackNoPrevView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleBackNoPrevView()
-{
-    setup();
-
-    QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-    mVideoView->handleBack();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleBackPrevView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleBackPrevView()
-{
-    setup();
-
-    mVideoView->handleBack();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleSoftkeyback()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleSoftkeyback()
-{
-    setup();
-
-    mVideoView->handleSoftkeyBack();
-
-    QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testDoClosePlayer()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testDoClosePlayer()
-{
-    // quits app - which can be problematic for the qvptestrunner app
-
-//    setup();
-//
-//    mVideoView->handleActivateView();
-//
-//    mVideoView->doClosePlayer();
-//
-//    cleanup();
-
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testHandleDeactivateView()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testHandleDeactivateView()
-{
-    setup();
-
-    mVideoView->handleDeactivateView();
-
-    QVERIFY( mVideoView->mVideoMpxWrapper == NULL );
-
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::verifyHandlePluginError()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::verifyHandlePluginError( TInt error, bool closeView )
-{
-    //
-    // construct and activate playback view
-    //
-    setup();
-
-    //
-    // ensure that playback view is currently open
-    //
-    QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-
-    //
-    // test handlePluginError() method
-    //
-    mVideoView->handlePluginError( error );
-
-    //
-    // close playback view after error note has been launched
-    //
-    if ( closeView )
-    {
-        //
-        // connect and emit signal for handleClosePopupDialog() slot
-        //
-        connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) );
-        emit commandSignal();
-
-        //
-        // verify that playback view is properly closed
-        //
-        QVERIFY( mVideoView->mTimerForClosingView->isActive() );
-
-        //
-        // disconnect signal for handleClosePopupDialog() slot
-        //
-        disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) );
-    }
-    else
-    {
-        //
-        // verify that playback view is still open after error note has been launched
-        //
-        QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
-    }
-
-    //
-    // destruct playback view
-    //
-    cleanup();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   TestVideoPlaybackView::testGestureEvent()
-// -------------------------------------------------------------------------------------------------
-//
-void TestVideoPlaybackView::testGestureEvent()
-{
-    setup();
-
-    //
-    // 1. Test tap gesture
-    //
-    QList<QGesture *> list;
-    HbTapGesture *tapGesture = new HbTapGesture();
-    list.append( tapGesture );
-    QGestureEvent* event = new QGestureEvent( list );
-
-    //
-    // connect to tappedOnScreen() signal and record its emission
-    //
-    QSignalSpy spy( mVideoView, SIGNAL( tappedOnScreen() ) );
-
-    //
-    // ensure signal has not been emitted yet
-    //
-    QCOMPARE( spy.count(), 0 );
-
-    //
-    // With GestureStarted
-    //
-    tapGesture->mState = Qt::GestureStarted;
-    mVideoView->gestureEvent( event );
-
-    //
-    // ensure signal hasn't been emitted and its emission count is not incremented
-    //
-    QCOMPARE( spy.count(), 0 );
-
-    //
-    // With GestureFinished
-    //
-    tapGesture->mState = Qt::GestureFinished;
-    mVideoView->gestureEvent( event );
-
-    //
-    // ensure signal has been emitted and its emission count is incremented
-    //
-    QCOMPARE( spy.count(), 1 );
-
-    //
-    // clean up
-    //
-    spy.clear();
-
-    list.clear();
-
-    if ( tapGesture )
-    {
-        delete tapGesture;
-        tapGesture = NULL;
-    }
-
-    if ( event )
-    {
-        delete event;
-        event = NULL;
-    }
-
-    //
-    // 2. Test pan gesture
-    //
-    HbPanGesture *panGesture = new HbPanGesture();
-    list.append( panGesture );
-    event = new QGestureEvent( list );
-
-    //
-    // connect to pannedToRight() signal and record its emission
-    //
-    QSignalSpy spy1( mVideoView, SIGNAL( pannedToRight() ) );
-
-    //
-    // ensure signal has not been emitted yet
-    //
-    QCOMPARE( spy1.count(), 0 );
-
-    //
-    // Test pan gesture With GestureStarted
-    //
-    panGesture->mState = Qt::GestureStarted;
-    mVideoView->gestureEvent( event );
-
-    //
-    // ensure signal has not been emitted yet
-    //
-    QCOMPARE( spy1.count(), 0 );
-
-    //
-    // Test pan gesture with GestureFinished
-    //
-    panGesture->mState = Qt::GestureFinished;
-    panGesture->mSceneDelta = QPointF( 5, 0 );
-    mVideoView->gestureEvent( event );
-
-    //
-    // ensure signal has been emitted
-    //
-    QCOMPARE( spy1.count(), 1 );
-    spy1.clear();
-
-    //
-    // Test pan gesture with GestureFinished
-    //
-
-    //
-    // connect to pannedToRight() signal and record its emission
-    //
-    QSignalSpy spy2( mVideoView, SIGNAL( pannedToLeft() ) );
-
-    //
-    // ensure signal has not been emitted yet
-    //
-    QCOMPARE( spy2.count(), 0 );
-
-    panGesture->mState = Qt::GestureFinished;
-    panGesture->mSceneDelta = QPointF( -5, 0 );
-    mVideoView->gestureEvent( event );
-
-    //
-    // ensure signal has not been emitted yet
-    //
-    QCOMPARE( spy2.count(), 1 );
-
-    //
-    // clean up
-    //
-    spy2.clear();
-    list.clear();
-
-    if ( panGesture )
-    {
-        delete panGesture;
-        panGesture = NULL;
-    }
-
-    if ( event )
-    {
-        delete event;
-        event = NULL;
-    }
-
-    cleanup();
-}
-
-// End of file