photosgallery/viewframework/medialists/tsrc/t_glxlistwindow/t_glxlistwindow.cpp
branchRCL_3
changeset 47 f9e827349359
parent 18 bcb43dc84c44
equal deleted inserted replaced
35:420f6808bf21 47:f9e827349359
   334     // populate initial list
   334     // populate initial list
   335     TWindowInfo info = AnalyzeWindow( aWindowString );
   335     TWindowInfo info = AnalyzeWindow( aWindowString );
   336     /// @todo combine these 3 lines to a single call to AddObjects
   336     /// @todo combine these 3 lines to a single call to AddObjects
   337     if ( info.iTotalSize > 0 )
   337     if ( info.iTotalSize > 0 )
   338         {
   338         {
   339         window->AddObjects( info.iFocusIndex, info.iTotalSize, 
   339         window->AddObjectsL( info.iFocusIndex, info.iTotalSize, 
   340             0, info.iTotalSize - 1 );
   340             0, info.iTotalSize - 1 );
   341         }
   341         }
   342     
   342     
   343     // assert initial window
   343     // assert initial window
   344     AssertWindow( *window, aWindowString );
   344     AssertWindow( *window, aWindowString );
   345 
   345 
   346     return window;    
   346     return window;    
   347     }
   347     }
   348 
   348 
   349 /** Cleans up a window */
   349 /** Cleans up a window */
   350 void Cleanup( CTestWindow& aWindow )
   350 void CleanupL( CTestWindow& aWindow )
   351     {
   351     {
   352     aWindow.Cleanup();
   352     aWindow.CleanupL();
   353     // test cleanup ok
   353     // test cleanup ok
   354     for ( TInt i = 0; i < aWindow.iEntries.Count(); i++ )
   354     for ( TInt i = 0; i < aWindow.iEntries.Count(); i++ )
   355         {
   355         {
   356         EUNIT_ASSERT_DESC( aWindow.iEntries[ i ]->Id() == 0, "cleaned up correctly" );
   356         EUNIT_ASSERT_DESC( aWindow.iEntries[ i ]->Id() == 0, "cleaned up correctly" );
   357         }       
   357         }       
   363     {
   363     {
   364     // assert window after change
   364     // assert window after change
   365     AssertWindow( aWindow, aWindowAfter );
   365     AssertWindow( aWindow, aWindowAfter );
   366     // makes sure reused items have not been cleaned up during update
   366     // makes sure reused items have not been cleaned up during update
   367     AssertReuse( aWindow, aWindowBefore, aWindowAfter, aChange, aChangedIndex, aChangeCount );
   367     AssertReuse( aWindow, aWindowBefore, aWindowAfter, aChange, aChangedIndex, aChangeCount );
   368     Cleanup( aWindow );
   368     CleanupL( aWindow );
   369     }
   369     }
   370     
   370     
   371 /** 
   371 /** 
   372  * Notation: * focus 
   372  * Notation: * focus 
   373  *           - items outside of window
   373  *           - items outside of window
   394     if ( EAdd == aChange )
   394     if ( EAdd == aChange )
   395         {
   395         {
   396         window->iList = aListAfterChange;
   396         window->iList = aListAfterChange;
   397         changeCount = strlen( aListAfterChange ) - strlen( aListBeforeChange );
   397         changeCount = strlen( aListAfterChange ) - strlen( aListBeforeChange );
   398         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   398         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   399         window->AddObjects( info.iFocusIndex, info.iTotalSize,       // focus, size
   399         window->AddObjectsL( info.iFocusIndex, info.iTotalSize,       // focus, size
   400             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
   400             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
   401         window->iOldList = window->iList; // iOldList is used to check cleanup
   401         window->iOldList = window->iList; // iOldList is used to check cleanup
   402         }
   402         }
   403     else if ( ERemove == aChange )
   403     else if ( ERemove == aChange )
   404         {
   404         {
   405         window->iList = aListAfterChange;
   405         window->iList = aListAfterChange;
   406         changeCount = strlen( aListBeforeChange ) - strlen( aListAfterChange );
   406         changeCount = strlen( aListBeforeChange ) - strlen( aListAfterChange );
   407         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   407         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   408         window->RemoveObjects(  info.iFocusIndex, info.iTotalSize, // focus, size
   408         window->RemoveObjectsL(  info.iFocusIndex, info.iTotalSize, // focus, size
   409             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
   409             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
   410         window->iOldList = window->iList; // iOldList is used to check cleanup
   410         window->iOldList = window->iList; // iOldList is used to check cleanup
   411         }
   411         }
   412     if ( ENone == aChange )
   412     if ( ENone == aChange )
   413         {
   413         {
   414         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   414         TWindowInfo info = AnalyzeWindow( aWindowAfter );
   415         window->SetFocusIndex( info.iFocusIndex, info.iTotalSize );
   415         window->SetFocusIndexL( info.iFocusIndex, info.iTotalSize );
   416         }
   416         }
   417         
   417         
   418     VerifyAndCleanup( *window, aWindowBefore, aWindowAfter, aChange, 
   418     VerifyAndCleanup( *window, aWindowBefore, aWindowAfter, aChange, 
   419         aChangedIndex, changeCount );
   419         aChangedIndex, changeCount );
   420     CleanupStack::PopAndDestroy( window );
   420     CleanupStack::PopAndDestroy( window );
   572     "SetRangeOffsetsL",
   572     "SetRangeOffsetsL",
   573     "FUNCTIONALITY",
   573     "FUNCTIONALITY",
   574     SetupL, T_SetRangeOffsetsLL, Teardown)
   574     SetupL, T_SetRangeOffsetsLL, Teardown)
   575 
   575 
   576 EUNIT_TEST(
   576 EUNIT_TEST(
   577     "SetFocusIndex",
   577     "SetFocusIndexL",
   578     "CGlxListWindow",
   578     "CGlxListWindow",
   579     "SetFocusIndex",
   579     "SetFocusIndexL",
   580     "FUNCTIONALITY",
   580     "FUNCTIONALITY",
   581     SetupL, T_SetFocusIndexL, Teardown)
   581     SetupL, T_SetFocusIndexL, Teardown)
   582     
   582     
   583 EUNIT_TEST(
   583 EUNIT_TEST(
   584     "AddObjects",
   584     "AddObjectsL",
   585     "CGlxListWindow",
   585     "CGlxListWindow",
   586     "AddObjects",
   586     "AddObjectsL",
   587     "FUNCTIONALITY",
   587     "FUNCTIONALITY",
   588     SetupL, T_AddObjectsL, Teardown)
   588     SetupL, T_AddObjectsL, Teardown)
   589     
   589     
   590 EUNIT_TEST(
   590 EUNIT_TEST(
   591     "RemoveObjects",
   591     "RemoveObjectsL",
   592     "CGlxListWindow",
   592     "CGlxListWindow",
   593     "RemoveObjects",
   593     "RemoveObjectsL",
   594     "FUNCTIONALITY",
   594     "FUNCTIONALITY",
   595     SetupL, T_RemoveObjectsL, Teardown)
   595     SetupL, T_RemoveObjectsL, Teardown)
   596 
   596 
   597 EUNIT_END_TEST_TABLE
   597 EUNIT_END_TEST_TABLE
   598 
   598