mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpmpxasframeworkwrapper/src/unittest_mpmpxasframeworkwrapper.cpp
changeset 43 0f32e550d9d8
parent 38 b93f525c9244
child 45 612c4815aebe
equal deleted inserted replaced
38:b93f525c9244 43:0f32e550d9d8
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Unit test for MpMpxAsFrameworkWrapper
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QSignalSpy>
       
    19 #include <qnamespace.h>
       
    20 
       
    21 #include "unittest_mpmpxasframeworkwrapper.h"
       
    22 #include "stub/inc/mpxaudioeffectproperties.h"
       
    23 #include "stub/inc/mpxplaybackutility.h"
       
    24 
       
    25 
       
    26 // Do this so we can access all member variables.
       
    27 #define private public
       
    28 #include "mpmpxasframeworkwrapper.h"
       
    29 #include "mpmpxasframeworkwrapper_p.h"
       
    30 #undef private
       
    31 
       
    32 //This so we can test private functions
       
    33 #include "mpmpxasframeworkwrapper_p.cpp"
       
    34 
       
    35 /*!
       
    36  Make our test case a stand-alone executable that runs all the test functions.
       
    37  */
       
    38 int main(int argc, char *argv[])
       
    39 {
       
    40     TestMpMpxAsFrameworkWrapper tv;
       
    41 
       
    42     if ( argc > 1 ) {
       
    43         return QTest::qExec( &tv, argc, argv);
       
    44     }
       
    45     else {
       
    46         char *pass[3];
       
    47         pass[0] = argv[0];
       
    48         pass[1] = "-o";
       
    49         pass[2] = "c:\\data\\unittest_mpmpxasframeworkwrapper.txt";
       
    50 
       
    51         return QTest::qExec(&tv, 3, pass);
       
    52     }
       
    53 }
       
    54 
       
    55 TestMpMpxAsFrameworkWrapper::TestMpMpxAsFrameworkWrapper()
       
    56     : mTest(0)
       
    57 {
       
    58 }
       
    59 
       
    60 TestMpMpxAsFrameworkWrapper::~TestMpMpxAsFrameworkWrapper()
       
    61 {
       
    62     delete mTest;
       
    63 }
       
    64 
       
    65 /*!
       
    66  Called before the first testfunction is executed.
       
    67  */
       
    68 void TestMpMpxAsFrameworkWrapper::initTestCase()
       
    69 {
       
    70 }
       
    71 
       
    72 /*!
       
    73  Called after the last testfunction was executed.
       
    74  */
       
    75 void TestMpMpxAsFrameworkWrapper::cleanupTestCase()
       
    76 {
       
    77 }
       
    78 
       
    79 /*!
       
    80  Called before each testfunction is executed.
       
    81  */
       
    82 void TestMpMpxAsFrameworkWrapper::init()
       
    83 {
       
    84     mTest = new MpMpxAsFrameworkWrapper();
       
    85     mTestPrivate = mTest->d_ptr;
       
    86 }
       
    87 
       
    88 /*!
       
    89  Called after every testfunction.
       
    90  */
       
    91 void TestMpMpxAsFrameworkWrapper::cleanup()
       
    92 {
       
    93     delete mTest;
       
    94     mTest = 0;
       
    95 }
       
    96 
       
    97 /*!
       
    98  test Constructor
       
    99  */
       
   100 void TestMpMpxAsFrameworkWrapper::testConstructor()
       
   101 {
       
   102     QVERIFY(mTestPrivate->iPlaybackUtility == 0);
       
   103     QVERIFY(mTestPrivate->iAudioEffectProperties != 0);
       
   104     QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoadFromFile, TBool(ETrue));
       
   105     mTestPrivate->iAudioEffectProperties->iLeave = ETrue;
       
   106     mTestPrivate->iAudioEffectProperties->LoadFromFileL();
       
   107     QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, 0);
       
   108     QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(EFalse));
       
   109     
       
   110 }
       
   111 
       
   112 /*!
       
   113  test balance
       
   114  */
       
   115 void TestMpMpxAsFrameworkWrapper::testBalance()
       
   116 {
       
   117     QCOMPARE( mTest->balance(), 0 );
       
   118     mTest->setBalance( -100 );
       
   119     QCOMPARE( mTest->balance(), -100 );
       
   120     mTest->setBalance( 100 );
       
   121     QCOMPARE( mTest->balance(), 100 );
       
   122 }
       
   123 
       
   124 /*!
       
   125  test loudness
       
   126  */
       
   127 void TestMpMpxAsFrameworkWrapper::testLoudness()
       
   128 {
       
   129     QCOMPARE(mTest->loudness(), false);
       
   130     mTest->setLoudness(true);
       
   131     QCOMPARE(mTest->loudness(), true);
       
   132 }
       
   133 
       
   134 /*!
       
   135  test setBalance
       
   136  */
       
   137 void TestMpMpxAsFrameworkWrapper::testSetBalance()
       
   138 {
       
   139     for(TInt i = -10; i < 10; i++){
       
   140         mTest->setBalance(i);
       
   141         QVERIFY(mTestPrivate->iPlaybackUtility != 0);
       
   142         QCOMPARE(mTestPrivate->iPlaybackUtility->iProperty, EPbPropertyBalance);
       
   143         QCOMPARE(mTestPrivate->iPlaybackUtility->iBalance, i);   
       
   144         QCOMPARE(mTestPrivate->iAudioEffectProperties->iBalance, i);
       
   145         QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
       
   146         mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
       
   147         
       
   148     }   
       
   149 }
       
   150 
       
   151 /*!
       
   152  test setLoudness   
       
   153  */
       
   154 void TestMpMpxAsFrameworkWrapper::testSetLoudness()
       
   155 {   
       
   156     mTest->setLoudness(true);
       
   157     QVERIFY(mTestPrivate->iPlaybackUtility != 0);
       
   158     QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(ETrue));
       
   159     QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
       
   160     QCOMPARE(mTestPrivate->iPlaybackUtility->iCommand, EPbApplyEffect );
       
   161     QCOMPARE(mTestPrivate->iPlaybackUtility->iEffectId, 0x101FFC02 );
       
   162     mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
       
   163     mTest->setLoudness(false);
       
   164     QVERIFY(mTestPrivate->iPlaybackUtility != 0);
       
   165     QCOMPARE(mTestPrivate->iAudioEffectProperties->iLoudness, TBool(EFalse));
       
   166     QCOMPARE(mTestPrivate->iAudioEffectProperties->iSaveToFile, TBool(ETrue));
       
   167     QCOMPARE(mTestPrivate->iPlaybackUtility->iCommand, EPbApplyEffect );
       
   168     QCOMPARE(mTestPrivate->iPlaybackUtility->iEffectId, 0x101FFC02 );
       
   169     mTestPrivate->iAudioEffectProperties->iLoadFromFile = EFalse;
       
   170 }
       
   171 
       
   172     
       
   173 // end of file