mpengine/tsrc/unittest_mpengine/inc/unittest_mpengine.h
changeset 48 af3740e3753f
child 55 f3930dda3342
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
       
     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 mpengine
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef TESTMPENGINE_H
       
    19 #define TESTMPENGINE_H
       
    20 
       
    21 #include <QtTest/QtTest>
       
    22 
       
    23 class MpEngine;
       
    24 
       
    25 class TestMpEngine : public QObject
       
    26 {
       
    27     Q_OBJECT
       
    28 
       
    29 public:
       
    30 
       
    31     TestMpEngine();
       
    32     ~TestMpEngine();
       
    33 
       
    34 public slots:
       
    35 
       
    36     void initTestCase();
       
    37     void cleanupTestCase();
       
    38     void init();
       
    39     void cleanup();
       
    40     
       
    41 private slots:
       
    42     void testInitialize();
       
    43     void testVerifyUsbBlocking();
       
    44     void testSongScanner(); 
       
    45     void testRefreshLibrary();
       
    46     void testHandleScanStarted();
       
    47     void testHandleScanEnded();
       
    48     void testHandleDiskEvent(); 
       
    49     void testHandleUsbEvent();
       
    50     void testHandleUsbMassStorageStartEvent();
       
    51     void testHandleUsbMassStorageEndEvent();
       
    52     void testHandleUsbMtpStartEvent(); 
       
    53     void testHandleUsbMtpEndEvent(); 
       
    54     void testHandleUsbMtpNotActive(); 
       
    55     void testChangeUsbBlockingState();
       
    56     void testHandleDeleteStarted(); 
       
    57     void testHandleDeleteEnded(); 
       
    58     void testPlaybackData(); 
       
    59     void testSongData(); 
       
    60     void testBalance();
       
    61     void testLoudness();
       
    62     void testSetBalance();
       
    63     void testSetLoudness();
       
    64     void testApplyPreset();
       
    65     void testDisableEqualizer();
       
    66     void testActivePreset();
       
    67     void testPresetNames();
       
    68     void testHandleEqualizerReady(); 
       
    69 
       
    70 private:
       
    71     MpEngine *mTest;
       
    72 };
       
    73 
       
    74 
       
    75 // to test private functions
       
    76 #include <QObject>
       
    77 #include "mpcommondefs.h"
       
    78 // Do this so we can access all member variables.
       
    79 #define private public
       
    80 #include "../../inc/mpengine.h"
       
    81 #undef private
       
    82 
       
    83 class MpEngineFactory : QObject
       
    84 {
       
    85     Q_OBJECT
       
    86 private:
       
    87     explicit MpEngineFactory(){    
       
    88     }
       
    89 
       
    90 public:
       
    91     virtual ~MpEngineFactory(){
       
    92     
       
    93     }
       
    94     static MpEngineFactory * instance() {
       
    95         static MpEngineFactory instance;
       
    96         return &instance;
       
    97     }
       
    98     static MpEngine *createIsolatedEngine( MpEngine::EngineMode mode ) {
       
    99         instance()->mEngines.append( new MpEngine() );
       
   100         instance()->mEngines.last()->initialize( TUid::Uid( MpCommon::KMusicPlayerUid + instance()->mEngines.count() ), mode );
       
   101         return instance()->mEngines.last();
       
   102     }    
       
   103     static void close() {
       
   104         MpEngine *ptr;
       
   105         foreach ( ptr, instance()->mEngines ) {
       
   106             delete ptr;
       
   107             ptr = 0;
       
   108         }
       
   109     }
       
   110     
       
   111 private:    
       
   112     QList<MpEngine *>    mEngines;
       
   113 };
       
   114 
       
   115 
       
   116 #endif  // TESTMPENGINE_H
       
   117 
       
   118 
       
   119 
       
   120