tsrc/unittest/unittest_statehandler/unittest_statehandler.cpp
changeset 70 a91aa46552be
parent 26 c499df2dbb33
child 71 27f2d7aec52a
equal deleted inserted replaced
67:199e6e1e0b54 70:a91aa46552be
    30 //
    30 //
    31 void TestGlxStateManager::initTestCase()
    31 void TestGlxStateManager::initTestCase()
    32 {    
    32 {    
    33     mStateManager = new GlxStateManager();
    33     mStateManager = new GlxStateManager();
    34     //mStateManager->setupItems();
    34     //mStateManager->setupItems();
    35     mStateManager->mCurrentState = mStateManager->createState(GLX_GRIDVIEW_ID);
    35     mStateManager->mCurrentState = mStateManager->createState( GLX_GRIDVIEW_ID );
    36     mStateManager->mCurrentState->setState(ALL_ITEM_S);
    36     mStateManager->mCurrentState->setState( ALL_ITEM_S );
    37     
    37     
    38     QVERIFY(mStateManager);
    38     QVERIFY( mStateManager );
    39     QVERIFY(mStateManager->mViewManager);
    39     QVERIFY( mStateManager->mViewManager );
    40     QVERIFY(mStateManager->mActionHandler == 0);
    40     QVERIFY( mStateManager->mActionHandler == 0 );
    41 }
    41 }
    42 
    42 
    43 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    44 // init
    44 // init
    45 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    47 void TestGlxStateManager::init()
    47 void TestGlxStateManager::init()
    48 {
    48 {
    49     
    49     
    50 }
    50 }
    51 
    51 
    52 void TestGlxStateManager::removeModelTestCase1()
    52 void TestGlxStateManager::removeModelGridTestCase()
    53 {
    53 {
    54     mStateManager->createGridModel(ALBUM_ITEM_S, FORWARD_DIR);
    54     mStateManager->createGridModel( ALL_ITEM_S, NO_DIR );
    55     mStateManager->removeCurrentModel();
    55     mStateManager->removeCurrentModel();
    56     QVERIFY(mStateManager->mAlbumGridMediaModel == 0 );   
    56     QVERIFY( mStateManager->mAllMediaModel == 0 );   
    57 }
    57 }
    58 
    58 
    59 void TestGlxStateManager::removeModelTestCase2()
    59 void TestGlxStateManager::removeModelAlbumGridTestCase()
    60 {
    60 {
    61     mStateManager->createModel(GLX_LISTVIEW_ID);
    61     mStateManager->createGridModel( ALBUM_ITEM_S, FORWARD_DIR );
    62     mStateManager->removeCurrentModel();
    62     mStateManager->removeCurrentModel();
    63     QVERIFY(mStateManager->mAlbumMediaModel == 0 );    
    63     QVERIFY( mStateManager->mAlbumGridMediaModel == 0 );   
    64 }
    64 }
    65 
    65 
    66 
    66 void TestGlxStateManager::removeModelAlbumListTestCase()
    67 void TestGlxStateManager::createStateTestCase()
    67 {
    68 {
    68     mStateManager->createModel( GLX_LISTVIEW_ID );
    69     GlxState * state = mStateManager->createState(GLX_GRIDVIEW_ID);
    69     mStateManager->removeCurrentModel();
       
    70     QVERIFY( mStateManager->mAlbumMediaModel == 0 );    
       
    71 }
       
    72 
       
    73 void TestGlxStateManager::cleanModelGridTestCase()
       
    74 {
       
    75     mStateManager->createGridModel( ALL_ITEM_S, NO_DIR );
       
    76     mStateManager->createGridModel( ALBUM_ITEM_S, FORWARD_DIR );
       
    77     mStateManager->cleanAllModel();
       
    78     QVERIFY( mStateManager->mAllMediaModel == 0 ); 
       
    79     QVERIFY( mStateManager->mAlbumGridMediaModel == 0 ); 
       
    80     QVERIFY( mStateManager->mAlbumMediaModel == 0 );
       
    81     QVERIFY( mStateManager->mImageviewerMediaModel == 0 );
       
    82     QVERIFY( mStateManager->mCurrentModel == 0 );    
       
    83 }
       
    84 
       
    85 void TestGlxStateManager::cleanModelAlbumListTestCase()
       
    86 {
       
    87     mStateManager->createModel( GLX_LISTVIEW_ID );
       
    88     mStateManager->cleanAllModel();
       
    89     QVERIFY( mStateManager->mAllMediaModel == 0 ); 
       
    90     QVERIFY( mStateManager->mAlbumGridMediaModel == 0 ); 
       
    91     QVERIFY( mStateManager->mAlbumMediaModel == 0 );
       
    92     QVERIFY( mStateManager->mImageviewerMediaModel == 0 );
       
    93     QVERIFY( mStateManager->mCurrentModel == 0 );    
       
    94 }
       
    95 
       
    96 void TestGlxStateManager::createStateGridTestCase()
       
    97 {
       
    98     GlxState * state = mStateManager->createState( GLX_GRIDVIEW_ID );
    70     QVERIFY(state);
    99     QVERIFY(state);
    71     QCOMPARE(state->id(), GLX_GRIDVIEW_ID);
   100     QCOMPARE( state->id(), GLX_GRIDVIEW_ID );
    72     delete state;
   101     delete state;
    73     state = NULL;
   102     state = NULL; 
    74     
   103 }
    75     state = mStateManager->createState(GLX_LISTVIEW_ID);
   104 
       
   105 void TestGlxStateManager::createStateListTestCase()
       
   106 {
       
   107     GlxState * state = mStateManager->createState( GLX_LISTVIEW_ID );
    76     QVERIFY(state);
   108     QVERIFY(state);
    77     QCOMPARE(state->id(), GLX_LISTVIEW_ID);
   109     QCOMPARE( state->id(), GLX_LISTVIEW_ID );
    78     delete state;
   110     delete state;
    79     state = NULL;
   111     state = NULL; 
    80     
   112 }
    81     state = mStateManager->createState(1000);
   113 
    82     QVERIFY(state == 0);
   114 void TestGlxStateManager::createStateSettingTestCase()
    83 }
   115 {
    84 
   116     GlxState * state = mStateManager->createState( GLX_SLIDESHOWSETTINGSVIEW_ID );
    85 void TestGlxStateManager::createModelTestCase1()
   117     QVERIFY(state);
    86 {
   118     QCOMPARE( state->id(), GLX_SLIDESHOWSETTINGSVIEW_ID );
    87     mStateManager->createModel(GLX_LISTVIEW_ID);
   119     delete state;
    88     QVERIFY(mStateManager->mAlbumMediaModel);
   120     state = NULL; 
    89     mStateManager->removeCurrentModel();
   121 }
    90 }
   122 
    91 
   123 void TestGlxStateManager::createStateDetailTestCase()
    92 void TestGlxStateManager::createModelTestCase2()
   124 {
    93 {
   125     GlxState * state = mStateManager->createState( GLX_DETAILSVIEW_ID );
    94     mStateManager->mCurrentState = mStateManager->createState(GLX_FULLSCREENVIEW_ID);
   126     QVERIFY(state);
    95     mStateManager->mCurrentState->setState(EXTERNAL_S);
   127     QCOMPARE( state->id(), GLX_DETAILSVIEW_ID );
    96     mStateManager->createModel(GLX_FULLSCREENVIEW_ID);    
   128     delete state;
    97     QVERIFY(mStateManager->mAllMediaModel);
   129     state = NULL; 
    98     
   130 }
    99     mStateManager->removeCurrentModel();
   131 
       
   132 void TestGlxStateManager::createStateNoneTestCase()
       
   133 {
       
   134     GlxState * state = mStateManager->createState( 0xFFFFFFFF );
       
   135     QVERIFY( state == 0 );
       
   136 }
       
   137 
       
   138 void TestGlxStateManager::createModelAlbumListTestCase()
       
   139 {
       
   140     mStateManager->createModel( GLX_LISTVIEW_ID );
       
   141     QVERIFY( mStateManager->mAlbumMediaModel );
       
   142     mStateManager->removeCurrentModel();
       
   143 }
       
   144 
       
   145 void TestGlxStateManager::createModelImageViewerTestCase()
       
   146 {
       
   147     mStateManager->mCurrentState = mStateManager->createState( GLX_FULLSCREENVIEW_ID );
       
   148     mStateManager->mCurrentState->setState( IMAGEVIEWER_S );
       
   149     mStateManager->createModel( GLX_FULLSCREENVIEW_ID );    
       
   150     QVERIFY( mStateManager->mImageviewerMediaModel );
       
   151     
       
   152     mStateManager->cleanAllModel();
   100     GlxState *state = mStateManager->mCurrentState;
   153     GlxState *state = mStateManager->mCurrentState;
   101     mStateManager->mCurrentState = state->previousState();
   154     mStateManager->mCurrentState = state->previousState();
   102     delete state;
   155     delete state;
   103     state = NULL;
   156     state = NULL;
   104 }
   157 }
   105 
   158 
   106 void TestGlxStateManager::createGridModelTestCase1()
   159 void TestGlxStateManager::createModelAlbumSlideShowTestCase()
       
   160 {
       
   161     mStateManager->mCurrentState = mStateManager->createState( GLX_SLIDESHOWVIEW_ID );
       
   162     mStateManager->mCurrentState->setState( SLIDESHOW_ALBUM_ITEM_S );
       
   163     mStateManager->createModel( GLX_SLIDESHOWVIEW_ID );    
       
   164     QVERIFY( mStateManager->mAlbumGridMediaModel );
       
   165     
       
   166     mStateManager->cleanAllModel();
       
   167     GlxState *state = mStateManager->mCurrentState;
       
   168     mStateManager->mCurrentState = state->previousState();
       
   169     delete state;
       
   170     state = NULL;
       
   171 }
       
   172 
       
   173 void TestGlxStateManager::createGridModelAllTestCase()
   107 {
   174 {
   108     mStateManager->createGridModel(ALL_ITEM_S, NO_DIR);
   175     mStateManager->createGridModel(ALL_ITEM_S, NO_DIR);
   109     QCOMPARE(mStateManager->mCollectionId, KGlxCollectionPluginAllImplementationUid);
   176     QCOMPARE(mStateManager->mCollectionId, KGlxCollectionPluginAllImplementationUid);
   110     QVERIFY(mStateManager->mAllMediaModel);
   177     QVERIFY(mStateManager->mAllMediaModel);
   111     mStateManager->removeCurrentModel();
   178     mStateManager->removeCurrentModel();
   112 }
   179 }
   113 
   180 
   114 void TestGlxStateManager::createGridModelTestCase2()
   181 void TestGlxStateManager::createGridModelAlbumTestCase()
   115 {
   182 {
   116     mStateManager->createGridModel(ALBUM_ITEM_S, FORWARD_DIR);
   183     mStateManager->createGridModel(ALBUM_ITEM_S, FORWARD_DIR);
   117     QCOMPARE(mStateManager->mCollectionId, (int )KGlxAlbumsMediaId);
   184     QCOMPARE(mStateManager->mCollectionId, ( int )KGlxAlbumsMediaId );
   118     QVERIFY(mStateManager->mAlbumGridMediaModel); 
   185     QVERIFY(mStateManager->mAlbumGridMediaModel); 
   119     mStateManager->removeCurrentModel();
   186     mStateManager->removeCurrentModel();
   120 }
   187 }
   121 
   188 
       
   189 void TestGlxStateManager::gridInternalStateTestCase()
       
   190 {
       
   191     GlxState * state = mStateManager->createState( GLX_GRIDVIEW_ID );
       
   192     QVERIFY( state );
       
   193     
       
   194     state->setState( ALL_ITEM_S );    
       
   195     QCOMPARE( state->state(), (int )ALL_ITEM_S );
       
   196     
       
   197     state->setState( FETCHER_ALBUM_ITEM_S );    
       
   198     QCOMPARE( state->state(), (int )FETCHER_ALBUM_ITEM_S );  
       
   199     delete state;
       
   200 }
       
   201 
       
   202 void TestGlxStateManager::gridTransitionParameterTestCase()
       
   203 {
       
   204     GlxEffect effect = NO_EFFECT ;
       
   205     GlxViewEffect viewEffect = NO_VIEW ;
       
   206     
       
   207     GlxState * state = mStateManager->createState( GLX_GRIDVIEW_ID );
       
   208     QVERIFY( state );
       
   209     
       
   210     state->setTranstionParameter( FORWARD_DIR, effect, viewEffect );
       
   211     QCOMPARE( effect, ALBUMLIST_TO_GRID ); 
       
   212     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   213     
       
   214     state->setTranstionParameter( BACKWARD_DIR, effect, viewEffect );
       
   215     QCOMPARE( effect, GRID_TO_ALBUMLIST ); 
       
   216     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   217     
       
   218     delete state;
       
   219 }
       
   220 
       
   221 void TestGlxStateManager::listInternalStateTestCase()
       
   222 {
       
   223     GlxState * state = mStateManager->createState( GLX_LISTVIEW_ID );
       
   224     QVERIFY( state );
       
   225     
       
   226     state->setState( NO_LIST_S );    
       
   227     QCOMPARE( state->state(), (int )NO_LIST_S );
       
   228     
       
   229     state->setState( FETCHER_ALBUM_S );    
       
   230     QCOMPARE( state->state(), (int )FETCHER_ALBUM_S );
       
   231     delete state;
       
   232 }
       
   233 
       
   234 void TestGlxStateManager::listTransitionParameterTestCase()
       
   235 {
       
   236     GlxEffect effect = NO_EFFECT ;
       
   237     GlxViewEffect viewEffect = NO_VIEW ;
       
   238     
       
   239     GlxState * state = mStateManager->createState( GLX_LISTVIEW_ID );
       
   240     QVERIFY( state );
       
   241     
       
   242     state->setTranstionParameter( NO_DIR, effect, viewEffect );
       
   243     QCOMPARE( effect, GRID_TO_ALBUMLIST ); 
       
   244     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   245     
       
   246     state->setTranstionParameter( BACKWARD_DIR, effect, viewEffect );
       
   247     QCOMPARE( effect, NO_EFFECT ); 
       
   248     QCOMPARE( viewEffect, NO_VIEW ); 
       
   249     
       
   250     delete state;
       
   251 }
       
   252 
       
   253 void TestGlxStateManager::fullScreenInternalStateTestCase()
       
   254 {
       
   255     GlxState * state = mStateManager->createState( GLX_FULLSCREENVIEW_ID );
       
   256     QVERIFY( state );
       
   257     
       
   258     state->setState( ALBUM_FULLSCREEN_S );    
       
   259     QCOMPARE( state->state(), (int )ALBUM_FULLSCREEN_S );
       
   260     
       
   261     state->setState( IMAGEVIEWER_S );    
       
   262     QCOMPARE( state->state(), (int )IMAGEVIEWER_S );
       
   263     delete state;    
       
   264 }
       
   265 
       
   266 void TestGlxStateManager::fullScreenTransitionParameterTestCase()
       
   267 {
       
   268     GlxEffect effect = NO_EFFECT ;
       
   269     GlxViewEffect viewEffect = NO_VIEW ;
       
   270     
       
   271     GlxState * state = mStateManager->createState( GLX_FULLSCREENVIEW_ID );
       
   272     QVERIFY( state );
       
   273     
       
   274     state->setTranstionParameter( FORWARD_DIR, effect, viewEffect );
       
   275     QCOMPARE( effect, GRID_TO_FULLSCREEN ); 
       
   276     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   277     
       
   278     state->setTranstionParameter( BACKWARD_DIR, effect, viewEffect );
       
   279     QCOMPARE( effect, FULLSCREEN_TO_GRID ); 
       
   280     QCOMPARE( viewEffect, LAUNCH_VIEW ); 
       
   281     
       
   282     delete state;
       
   283 }
       
   284 
       
   285 void TestGlxStateManager::slideShowInternalStateTestCase()
       
   286 {
       
   287     GlxState * state = mStateManager->createState( GLX_SLIDESHOWVIEW_ID );
       
   288     QVERIFY( state );
       
   289     
       
   290     state->setState( SLIDESHOW_GRID_ITEM_S );    
       
   291     QCOMPARE( state->state(), (int )SLIDESHOW_GRID_ITEM_S );
       
   292     
       
   293     state->setState( SLIDESHOW_GRID_ITEM_S );    
       
   294     QCOMPARE( state->state(), (int )SLIDESHOW_GRID_ITEM_S );
       
   295     delete state;       
       
   296 }
       
   297 
       
   298 void TestGlxStateManager::detailInternalStateTestCase()
       
   299 {
       
   300     GlxState * state = mStateManager->createState( GLX_DETAILSVIEW_ID );
       
   301     QVERIFY( state );
       
   302     
       
   303     state->setState( NO_DETAIL_S );    
       
   304     QCOMPARE( state->state(), (int )NO_DETAIL_S );
       
   305     
       
   306     state->setState( IMAGEVIEWER_DETAIL_S );    
       
   307     QCOMPARE( state->state(), (int )IMAGEVIEWER_DETAIL_S );
       
   308     delete state;    
       
   309 }
       
   310 
       
   311 void TestGlxStateManager::detailTransitionParameterNegativeTestCase()
       
   312 {
       
   313     GlxEffect effect = NO_EFFECT ;
       
   314     GlxViewEffect viewEffect = NO_VIEW ;
       
   315     
       
   316     GlxState * state = mStateManager->createState( GLX_DETAILSVIEW_ID );
       
   317     QVERIFY( state );
       
   318     
       
   319     state->setTranstionParameter( FORWARD_DIR, effect, viewEffect );
       
   320     QCOMPARE( effect, NO_EFFECT ); 
       
   321     QCOMPARE( viewEffect, NO_VIEW ); 
       
   322     delete state;
       
   323 }
       
   324 
       
   325 void TestGlxStateManager::detailTransitionParameterTestCase()
       
   326 {
       
   327     GlxEffect effect = NO_EFFECT ;
       
   328     GlxViewEffect viewEffect = NO_VIEW ;
       
   329     
       
   330     mStateManager->mCurrentState = mStateManager->createState( GLX_FULLSCREENVIEW_ID );
       
   331     GlxState * state = mStateManager->createState( GLX_DETAILSVIEW_ID );
       
   332     QVERIFY( state );
       
   333     
       
   334     state->setTranstionParameter( FORWARD_DIR, effect, viewEffect );
       
   335     QCOMPARE( effect, FULLSCREEN_TO_DETAIL ); 
       
   336     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   337     
       
   338     state->setTranstionParameter( BACKWARD_DIR, effect, viewEffect );
       
   339     QCOMPARE( effect, DETAIL_TO_FULLSCREEN ); 
       
   340     QCOMPARE( viewEffect, BOTH_VIEW ); 
       
   341     
       
   342     delete state;
       
   343     state = mStateManager->mCurrentState;
       
   344     mStateManager->mCurrentState = state->previousState();
       
   345     delete state;
       
   346 }
   122 
   347 
   123 // -----------------------------------------------------------------------------
   348 // -----------------------------------------------------------------------------
   124 // cleanup
   349 // cleanup
   125 // -----------------------------------------------------------------------------
   350 // -----------------------------------------------------------------------------
   126 //
   351 //