tsrc/unittest/unittest_statehandler/unittest_statehandler.cpp
changeset 26 c499df2dbb33
parent 23 74c9f037fd5d
child 65 ccee5c4b0de4
equal deleted inserted replaced
24:99ad1390cd33 26:c499df2dbb33
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 #include "hbmainwindow.h"
       
    18 #include "hbapplication.h"
       
    19 
    17 
    20 #include "unittest_statehandler.h"
    18 #include "unittest_statehandler.h"
    21 #include "glxstatemanager.h"
    19 #include "glxstatemanager.h"
    22 #include "glxbasestate.h"
    20 #include "glxbasestate.h"
    23 #include "glxgridstate.h"
    21 #include "glxgridstate.h"
    24 #include "glxfullscreenstate.h"
    22 #include "glxfullscreenstate.h"
    25 #include <glxcollectionpluginall.hrh>
    23 #include <glxcollectionpluginall.hrh>
    26 #include "glxmediaid.h"
    24 #include "glxmediaid.h"
    27 
    25 
    28 int main(int argc, char *argv[])
       
    29 {
       
    30     Q_UNUSED(argc);
       
    31     HbApplication app(argc, argv);	    
       
    32 
       
    33     HbMainWindow *mMainWindow = new HbMainWindow();
       
    34     TestGlxStateManager tv;
       
    35 
       
    36     char *pass[3];
       
    37     pass[0] = argv[0];
       
    38     pass[1] = "-o";
       
    39     pass[2] = "c:\\data\\teststatehandler.txt";
       
    40 
       
    41     int res = QTest::qExec(&tv, 3, pass);
       
    42 
       
    43     return res;
       
    44 }
       
    45 
    26 
    46 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
    47 // initTestCase
    28 // initTestCase
    48 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    49 //
    30 //
    50 void TestGlxStateManager::initTestCase()
    31 void TestGlxStateManager::initTestCase()
    51 {
    32 {    
    52     mStateManager = 0;
    33     mStateManager = new GlxStateManager();
       
    34     //mStateManager->setupItems();
       
    35     mStateManager->mCurrentState = mStateManager->createState(GLX_GRIDVIEW_ID);
       
    36     mStateManager->mCurrentState->setState(ALL_ITEM_S);
       
    37     
       
    38     QVERIFY(mStateManager);
       
    39     QVERIFY(mStateManager->mViewManager);
       
    40     QVERIFY(mStateManager->mActionHandler == 0);
    53 }
    41 }
    54 
    42 
    55 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    56 // init
    44 // init
    57 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    58 //
    46 //
    59 void TestGlxStateManager::init()
    47 void TestGlxStateManager::init()
    60 {
    48 {
    61     mStateManager = new GlxStateManager();
    49     
    62     QVERIFY(mStateManager);
       
    63     QVERIFY(mStateManager->mViewManager);
       
    64     QVERIFY(mStateManager->mActionHandler);
       
    65 }
    50 }
    66 
    51 
    67 void TestGlxStateManager::removeModelTestCase1()
    52 void TestGlxStateManager::removeModelTestCase1()
    68 {
    53 {
    69     mStateManager->createGridModel(ALBUM_ITEM_S, FORWARD_DIR);
    54     mStateManager->createGridModel(ALBUM_ITEM_S, FORWARD_DIR);
   110     mStateManager->mCurrentState->setState(EXTERNAL_S);
    95     mStateManager->mCurrentState->setState(EXTERNAL_S);
   111     mStateManager->createModel(GLX_FULLSCREENVIEW_ID);    
    96     mStateManager->createModel(GLX_FULLSCREENVIEW_ID);    
   112     QVERIFY(mStateManager->mAllMediaModel);
    97     QVERIFY(mStateManager->mAllMediaModel);
   113     
    98     
   114     mStateManager->removeCurrentModel();
    99     mStateManager->removeCurrentModel();
   115     delete mStateManager->mCurrentState;
   100     GlxState *state = mStateManager->mCurrentState;
   116     mStateManager->mCurrentState = NULL;
   101     mStateManager->mCurrentState = state->previousState();
       
   102     delete state;
       
   103     state = NULL;
   117 }
   104 }
   118 
   105 
   119 void TestGlxStateManager::createGridModelTestCase1()
   106 void TestGlxStateManager::createGridModelTestCase1()
   120 {
   107 {
   121     mStateManager->createGridModel(ALL_ITEM_S, NO_DIR);
   108     mStateManager->createGridModel(ALL_ITEM_S, NO_DIR);
   137 // cleanup
   124 // cleanup
   138 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   139 //
   126 //
   140 void TestGlxStateManager::cleanup()
   127 void TestGlxStateManager::cleanup()
   141 {
   128 {
   142     if(mStateManager)
   129     
   143     {
       
   144         delete mStateManager;
       
   145         mStateManager = 0;
       
   146     }  
       
   147 }
   130 }
   148 
   131 
   149 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   150 // cleanupTestCase
   133 // cleanupTestCase
   151 // -----------------------------------------------------------------------------
   134 // -----------------------------------------------------------------------------
   152 //
   135 //
   153 void TestGlxStateManager::cleanupTestCase()
   136 void TestGlxStateManager::cleanupTestCase()
   154 {
   137 {
       
   138     if(mStateManager)
       
   139     {
       
   140         QCoreApplication::processEvents(); //To:Do remove it once mainwindow delete hang problem will resolve
       
   141         delete mStateManager;
       
   142         mStateManager = 0;
       
   143     }  
       
   144 }
   155 
   145 
   156 }
   146 QTEST_MAIN(TestGlxStateManager)
       
   147 #include "moc_unittest_statehandler.cpp"