photosgallery/viewframework/medialists/tsrc/t_glxlistwindow/t_glxlistwindow.cpp
changeset 0 4e91876724a2
child 18 bcb43dc84c44
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007 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 tests
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include "t_glxlistwindow.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 #include <digia/eunit/EUnitMacros.h>
       
    26 #include <digia/eunit/EUnitDecorators.h>
       
    27  
       
    28 //  INTERNAL INCLUDES
       
    29 #include "glxlistwindow.h"
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // Constructors & destructors
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 t_CGlxListWindow* t_CGlxListWindow::NewL()
       
    36     {
       
    37     t_CGlxListWindow* self = t_CGlxListWindow::NewLC();
       
    38     CleanupStack::Pop();
       
    39 
       
    40     return self;
       
    41     }
       
    42 
       
    43 t_CGlxListWindow* t_CGlxListWindow::NewLC()
       
    44     {
       
    45     t_CGlxListWindow* self = new( ELeave ) t_CGlxListWindow();
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     return self;
       
    49     }
       
    50 
       
    51 // Destructor (virtual by CBase)
       
    52 t_CGlxListWindow::~t_CGlxListWindow()
       
    53     {
       
    54     }
       
    55 
       
    56 // Default constructor
       
    57 t_CGlxListWindow::t_CGlxListWindow()
       
    58     {
       
    59     }
       
    60 
       
    61 // Second phase construct
       
    62 void t_CGlxListWindow::ConstructL()
       
    63     {
       
    64     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    65     // It generates the test case table.
       
    66     CEUnitTestSuiteClass::ConstructL();
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // Setup & Teardown
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void t_CGlxListWindow::SetupL(  )
       
    74     {
       
    75     }
       
    76 
       
    77 void t_CGlxListWindow::Teardown(  )
       
    78     {
       
    79     }    
       
    80 
       
    81 // return string length
       
    82 TInt strlen( const char* aString )
       
    83     {
       
    84     // poor man's strlen...
       
    85     TInt count = 0;
       
    86     const char* tmp = aString;
       
    87     while ( *tmp ) 
       
    88     	{
       
    89     	count++;
       
    90     	tmp++;
       
    91     	}
       
    92     return count;
       
    93     }
       
    94 
       
    95 // entry object for the window
       
    96 class CEntry : public CBase
       
    97     {
       
    98 public: 
       
    99     ~CEntry()
       
   100         {
       
   101         delete iOwned;
       
   102         }
       
   103         
       
   104     void ConstructL() 
       
   105         {
       
   106         iOwned = HBufC::NewL( 1 );
       
   107         }
       
   108     
       
   109     void SetId( TChar aId ) 
       
   110         {
       
   111         iId = aId;
       
   112         iId.LowerCase();
       
   113         }
       
   114         
       
   115     TChar Id() const
       
   116         {
       
   117         return iId;
       
   118         }
       
   119     
       
   120     TInt iCleanupCount;
       
   121 private:
       
   122     TChar iId;
       
   123     HBufC* iOwned; // have an owned object to make sure destructor is being called
       
   124     };
       
   125     
       
   126 // window class
       
   127 class CTestWindow : public CGlxListWindow,
       
   128                     public MGlxWindowObjectFactory
       
   129     {
       
   130 public:
       
   131     CTestWindow( const char* aList ) 
       
   132             : CGlxListWindow( static_cast< MGlxWindowObjectFactory& >( *this ) )
       
   133         {
       
   134         iList = aList;
       
   135         iOldList = iList;
       
   136         }
       
   137         
       
   138     ~CTestWindow() 
       
   139         {
       
   140         iEntries.Close();
       
   141         }
       
   142         
       
   143     // From MGlxWindowObjectFactory
       
   144 	CBase* CreateObjectL() const 
       
   145         {
       
   146         CEntry* entry = new ( ELeave ) CEntry;
       
   147         CleanupStack::PushL( entry );
       
   148         entry->ConstructL();
       
   149         const_cast< CTestWindow* >( this )->iEntries.AppendL( entry );
       
   150         CleanupStack::Pop( entry );
       
   151         return entry;
       
   152         } 
       
   153 	
       
   154     // From MGlxWindowObjectFactory
       
   155 	void SetupObject( TInt aListIndex, CBase& aEntry ) 
       
   156         {
       
   157         CEntry& entry = static_cast< CEntry& >( aEntry );
       
   158         // initialise the entry by setting the id from the original list
       
   159         entry.SetId( iList[ aListIndex ] );
       
   160         }
       
   161 	
       
   162     // From MGlxWindowObjectFactory
       
   163 	void CleanupObject( TInt aListIndex, CBase& aEntry ) 
       
   164         {
       
   165         CEntry& entry = static_cast< CEntry& >( aEntry );
       
   166        
       
   167         EUNIT_ASSERT_DESC( iOldList[ aListIndex ] == entry.Id(), "list index is correct" );
       
   168         
       
   169         // clean up the entry 
       
   170         entry.SetId( 0 );
       
   171         // check how many times entry is cleaned up so can check that object 
       
   172         // is not cleaned up any more often that it needs to 
       
   173         entry.iCleanupCount++; 
       
   174         }
       
   175     
       
   176     const CEntry* operator[]( TInt aIndex ) const
       
   177         {
       
   178         return static_cast< const CEntry* >( At( aIndex ) );
       
   179         }
       
   180         
       
   181     const char* iList; // main list of items. not own
       
   182     const char* iOldList; // list of items before change. not own
       
   183     RPointerArray< CEntry > iEntries; // not own. owned by base class
       
   184     };
       
   185 
       
   186 struct TWindowInfo
       
   187     {
       
   188     TWindowInfo() 
       
   189         {
       
   190         iStartIndex = KErrNotFound;
       
   191         iFocusIndex = KErrNotFound;
       
   192         iWindowSize = 0;
       
   193         }
       
   194     TInt iStartIndex;
       
   195     TInt iFocusIndex;
       
   196     TInt iWindowSize;
       
   197     TInt iTotalSize;
       
   198     };
       
   199     
       
   200 TWindowInfo AnalyzeWindow( const char* aWindow )
       
   201     {
       
   202     TWindowInfo info;
       
   203     TInt index = 0;
       
   204     TChar ch = 0;
       
   205     // gapBefore is to set the start index in case list is "###----###"
       
   206     // i.e., gapBefore is true if there is a gap in the window before 
       
   207     // the index
       
   208     TBool gapBefore = EFalse;
       
   209     while ( 0 != ( ch = aWindow[ index ] ) )
       
   210         {
       
   211         if ( '-' == ch ) // is item a gap (outside window)
       
   212             {
       
   213             gapBefore = ETrue;
       
   214             }
       
   215         else
       
   216             {
       
   217             info.iWindowSize++;
       
   218 
       
   219             if ( ch.IsUpper() ) // focus index?
       
   220                 {
       
   221                 ASSERT( KErrNotFound == info.iFocusIndex ); // Check not multiple focus indexes defined
       
   222                 info.iFocusIndex = index;
       
   223                 }
       
   224 
       
   225             if ( gapBefore ||                        // this is for "###----S##"
       
   226                  KErrNotFound == info.iStartIndex )  // this is for "--S####---"
       
   227                 {
       
   228                 info.iStartIndex = index;
       
   229                 gapBefore = EFalse;
       
   230                 }
       
   231             }
       
   232         index++;
       
   233         }
       
   234     info.iTotalSize = index;
       
   235     return info;
       
   236     }
       
   237 
       
   238 // aWindow: "---abcDe---" 
       
   239 //          - is non-window
       
   240 //          a,b,c,e is id
       
   241 //          D focus
       
   242 void AssertWindow( const CTestWindow& aWindow, const char* aWindowString )
       
   243     {
       
   244     TWindowInfo info = AnalyzeWindow( aWindowString );
       
   245     
       
   246     TGlxWindowIterator iterator = aWindow.Iterator();
       
   247     TInt index = iterator++;
       
   248     // check start index is correct
       
   249     EUNIT_ASSERT_DESC( index == info.iStartIndex, "start index is correct" );
       
   250     
       
   251     TInt size = 0;
       
   252     // check items in window are correct
       
   253     while ( KErrNotFound != index )
       
   254         {
       
   255         TChar ch = aWindowString[ index ];
       
   256         ch.LowerCase();
       
   257         EUNIT_ASSERT_DESC( ch == aWindow[ index ]->Id(), "item is correct" );
       
   258         size++;
       
   259         index = iterator++;
       
   260         }
       
   261         
       
   262     // check window length is correct
       
   263     EUNIT_ASSERT_DESC( size == info.iWindowSize, "window size is correct" );
       
   264     }
       
   265     
       
   266 enum TChange 
       
   267     {
       
   268     ENone,
       
   269     EAdd,
       
   270     ERemove
       
   271     };    
       
   272        
       
   273 /** Convert an index to an index before a change happened */
       
   274 TInt indexBeforeChange( TInt aIndex, TChange aChange, TInt aFirstChanged,
       
   275         TInt aChangeCount )
       
   276     {
       
   277     TInt index = aIndex;
       
   278     if ( aFirstChanged <= aIndex )
       
   279         {
       
   280         if ( aChange == EAdd ) 
       
   281             {
       
   282             if ( aIndex <= aFirstChanged + aChangeCount )
       
   283                 {
       
   284                 index = KErrNotFound;
       
   285                 }
       
   286             else 
       
   287                 {
       
   288                 index -= aChangeCount;
       
   289                 }
       
   290             }
       
   291         else if ( aChange == ERemove ) 
       
   292             {
       
   293             index += aChangeCount;
       
   294             }
       
   295         }
       
   296     return index;
       
   297     }
       
   298     
       
   299 /** Makes sure objects were not cleaned up unnecessarily */
       
   300 void AssertReuse( const CTestWindow& aWindow, const char* aWindowBefore, 
       
   301         const char* aWindowAfter, TChange aChange, TInt aChangedIndex,
       
   302         TInt aChangeCount )
       
   303     {
       
   304     TGlxWindowIterator iterator = aWindow.Iterator();
       
   305     TInt index = 0;
       
   306     while ( KErrNotFound != ( index = iterator++ ) )
       
   307         {
       
   308         TInt indexBefore = indexBeforeChange( index, aChange, aChangedIndex, aChangeCount );
       
   309         if ( KErrNotFound != indexBefore )
       
   310             {
       
   311             TChar chBefore = aWindowBefore[ indexBefore ];
       
   312             chBefore.LowerCase();
       
   313             TChar chAfter = aWindowAfter[ index ];
       
   314             chAfter.LowerCase();
       
   315             if ( chBefore != '-' )
       
   316                 {
       
   317                 ASSERT( chBefore == chAfter ); // error is test case?
       
   318                 ASSERT( aWindow[ index ]->Id() == chAfter ); // error is test code?
       
   319                 EUNIT_ASSERT_DESC( 0 == aWindow[ index ]->iCleanupCount, "reused item was not cleaned up" );
       
   320                 }
       
   321             }
       
   322         }
       
   323     }
       
   324 
       
   325 /** Creates a window */
       
   326 CTestWindow* CreateWindowLC( const char* aListString, TInt aFrontOffset, 
       
   327         TInt aRearOffset, const char* aWindowString )
       
   328     {
       
   329     CTestWindow* window = new ( ELeave ) CTestWindow( aListString );
       
   330     CleanupStack::PushL( window );
       
   331     window->ConstructL();
       
   332     window->SetRangeOffsetsL( aFrontOffset, aRearOffset );
       
   333     AssertWindow( *window, "" ); // kind of unnecessary...
       
   334     
       
   335     // populate initial list
       
   336     TWindowInfo info = AnalyzeWindow( aWindowString );
       
   337     /// @todo combine these 3 lines to a single call to AddObjects
       
   338     if ( info.iTotalSize > 0 )
       
   339         {
       
   340         window->AddObjects( info.iFocusIndex, info.iTotalSize, 
       
   341             0, info.iTotalSize - 1 );
       
   342         }
       
   343     
       
   344     // assert initial window
       
   345     AssertWindow( *window, aWindowString );
       
   346 
       
   347     return window;    
       
   348     }
       
   349 
       
   350 /** Cleans up a window */
       
   351 void Cleanup( CTestWindow& aWindow )
       
   352     {
       
   353     aWindow.Cleanup();
       
   354     // test cleanup ok
       
   355     for ( TInt i = 0; i < aWindow.iEntries.Count(); i++ )
       
   356         {
       
   357         EUNIT_ASSERT_DESC( aWindow.iEntries[ i ]->Id() == 0, "cleaned up correctly" );
       
   358         }       
       
   359     }
       
   360  
       
   361 void VerifyAndCleanup( CTestWindow& aWindow, const char* aWindowBefore, 
       
   362         const char* aWindowAfter, TChange aChange = ENone, 
       
   363         TInt aChangedIndex = KErrNotFound, TInt aChangeCount = 0 )
       
   364     {
       
   365     // assert window after change
       
   366     AssertWindow( aWindow, aWindowAfter );
       
   367     // makes sure reused items have not been cleaned up during update
       
   368     AssertReuse( aWindow, aWindowBefore, aWindowAfter, aChange, aChangedIndex, aChangeCount );
       
   369     Cleanup( aWindow );
       
   370     }
       
   371     
       
   372 /** 
       
   373  * Notation: * focus 
       
   374  *           - items outside of window
       
   375  *           any other char is the id of an item
       
   376  */
       
   377 void TestUpdateL( const char* aListBeforeChange, const char* aWindowBefore, 
       
   378         const char* aWindowAfter, TInt aFrontOffset, TInt aRearOffset, 
       
   379         TChange aChange = ENone, TInt aChangedIndex = KErrNotFound, 
       
   380         const char* aListAfterChange = NULL ) 
       
   381     {
       
   382     // window and list strings must have the same length
       
   383     ASSERT( strlen( aListBeforeChange ) == strlen( aWindowBefore ) );
       
   384     if ( aListAfterChange ) 
       
   385         {
       
   386         ASSERT( strlen( aWindowAfter ) == strlen( aListAfterChange ) );
       
   387         }
       
   388         
       
   389     // create window object
       
   390     CTestWindow* window = CreateWindowLC( aListBeforeChange, aFrontOffset, 
       
   391         aRearOffset, aWindowBefore );
       
   392     
       
   393     // apply changes
       
   394     TInt changeCount = 0;
       
   395     if ( EAdd == aChange )
       
   396         {
       
   397         window->iList = aListAfterChange;
       
   398         changeCount = strlen( aListAfterChange ) - strlen( aListBeforeChange );
       
   399         TWindowInfo info = AnalyzeWindow( aWindowAfter );
       
   400         window->AddObjects( info.iFocusIndex, info.iTotalSize,       // focus, size
       
   401             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
       
   402         window->iOldList = window->iList; // iOldList is used to check cleanup
       
   403         }
       
   404     else if ( ERemove == aChange )
       
   405         {
       
   406         window->iList = aListAfterChange;
       
   407         changeCount = strlen( aListBeforeChange ) - strlen( aListAfterChange );
       
   408         TWindowInfo info = AnalyzeWindow( aWindowAfter );
       
   409         window->RemoveObjects(  info.iFocusIndex, info.iTotalSize, // focus, size
       
   410             aChangedIndex, aChangedIndex + changeCount - 1 ); // first index, last index
       
   411         window->iOldList = window->iList; // iOldList is used to check cleanup
       
   412         }
       
   413     if ( ENone == aChange )
       
   414         {
       
   415         TWindowInfo info = AnalyzeWindow( aWindowAfter );
       
   416         window->SetFocusIndex( info.iFocusIndex, info.iTotalSize );
       
   417         }
       
   418         
       
   419     VerifyAndCleanup( *window, aWindowBefore, aWindowAfter, aChange, 
       
   420         aChangedIndex, changeCount );
       
   421     CleanupStack::PopAndDestroy( window );
       
   422     }
       
   423  
       
   424 /** Test SetRangeOffsetsL */   
       
   425 void TestSetRangesL( const char* aList, 
       
   426         const char* aWindowBefore, TInt aFrontOffsetBefore, TInt aRearOffsetBefore, 
       
   427         const char* aWindowAfter, TInt aFrontOffsetAfter, TInt aRearOffsetAfter )
       
   428     {
       
   429     // window and list strings must have the same length
       
   430     ASSERT( strlen( aList ) == strlen( aWindowBefore ) );
       
   431     ASSERT( strlen( aWindowAfter ) == strlen( aWindowBefore ) );
       
   432         
       
   433     // create window object
       
   434     CTestWindow* window = CreateWindowLC( aList, aFrontOffsetBefore, aRearOffsetBefore, 
       
   435         aWindowBefore );
       
   436     
       
   437     TWindowInfo info = AnalyzeWindow( aWindowAfter );
       
   438     window->SetRangeOffsetsL( info.iFocusIndex, info.iTotalSize, 
       
   439         aFrontOffsetAfter, aRearOffsetAfter );
       
   440         
       
   441     VerifyAndCleanup( *window, aWindowBefore, aWindowAfter );
       
   442     
       
   443     CleanupStack::PopAndDestroy( window );
       
   444     }
       
   445     
       
   446 // -----------------------------------------------------------------------------
       
   447 void t_CGlxListWindow::T_SetRangeOffsetsLL(  )
       
   448     {
       
   449     TestSetRangesL( "abcdefghijk", "---deFghi--", -2, 3, "--cdeFghij-", -3, 4 );
       
   450     TestSetRangesL( "abcdefghijk", "--cdeFghij-", -3, 4, "---deFghi--", -2, 3 );
       
   451     TestSetRangesL( "abcdefghijk", "--cdeFghij-", -3, 4, "-----F-----", 0, 0 );
       
   452     TestSetRangesL( "abcdefghijk", "--cdeFghij-", -3, 4, "abcdeFghijk", -10, 10 );
       
   453     }
       
   454     
       
   455 // -----------------------------------------------------------------------------
       
   456 void t_CGlxListWindow::T_SetFocusIndexL(  )
       
   457     {
       
   458     TestUpdateL( "abcd", "-B--", "-B--", 0, 0 );
       
   459     // when whole list fits to window
       
   460     // ... set focus on list with 1 item
       
   461     TestUpdateL( "a", "A", "A", -2, 3 );
       
   462     // ... set focus on list with multiple items
       
   463     TestUpdateL( "abcde", "Abcde", "abcDe", -2, 3 );
       
   464     // ... set focus when list is as long max length of window
       
   465     TestUpdateL( "abcdef", "Abcdef", "abcDef", -2, 3 );
       
   466     TestUpdateL( "abcdef", "Abcdef", "abcdeF", -2, 3 );
       
   467     TestUpdateL( "abcdef", "abcdeF", "Abcdef", -2, 3 );
       
   468     TestUpdateL( "abcdef", "abcdEf", "abCdef", -2, 3 );
       
   469     // ... set focus to same item again
       
   470     TestUpdateL( "abcdef", "abCdef", "abCdef", -2, 3 );
       
   471     TestUpdateL( "abcdef", "Abcdef", "abcdeF", -2, 3 );
       
   472     TestUpdateL( "abcdef", "Abcdef", "abcdeF", -2, 3 );
       
   473     
       
   474     // when whole list does not fit to window
       
   475     TestUpdateL( "abcdefg", "Abcd-fg", "ab-deFg", -2, 3 );
       
   476     TestUpdateL( "abcdefg", "abc-efG", "-bcDefg", -2, 3 );
       
   477     TestUpdateL( "abcdefg", "abCdef-", "Abcd-fg", -2, 3 );
       
   478     // ... set focus on list with 2 items
       
   479     TestUpdateL( "abcdefghijk", "---deFghi--", "----efGhij-", -2, 3 );
       
   480     TestUpdateL( "abcdefghijk", "---deFghi--", "abc-----ijK", -2, 3 );
       
   481     TestUpdateL( "abcdefghijk", "---deFghi--", "---deFghi--", -2, 3 );
       
   482                 
       
   483     TestUpdateL( "abcdefghijk", "---deFghi--", "abc-----ijK", -2, 3 );
       
   484     TestUpdateL( "abcdefghijk", "---deFghi--", "ab-----hiJk", -2, 3 );
       
   485     TestUpdateL( "abcdefghijk", "---deFghi--", "Abcd-----jk", -2, 3 );
       
   486     TestUpdateL( "abcdefghijk", "---deFghi--", "aBcde-----k", -2, 3 );
       
   487     TestUpdateL( "abcdefghijk", "abc-----ijK", "abc-----ijK", -2, 3 );
       
   488     TestUpdateL( "abcdefghijk", "abc-----ijK", "ab-----hiJk", -2, 3 );
       
   489     TestUpdateL( "abcdefghijk", "abc-----ijK", "Abcd-----jk", -2, 3 );
       
   490     TestUpdateL( "abcdefghijk", "abc-----ijK", "aBcde-----k", -2, 3 );
       
   491     TestUpdateL( "abcdefghijk", "Abcd-----jk", "abc-----ijK", -2, 3 );
       
   492     TestUpdateL( "abcdefghijk", "Abcd-----jk", "ab-----hiJk", -2, 3 );
       
   493     TestUpdateL( "abcdefghijk", "Abcd-----jk", "Abcd-----jk", -2, 3 );
       
   494     TestUpdateL( "abcdefghijk", "Abcd-----jk", "aBcde-----k", -2, 3 );
       
   495     // non-overlapping old and new
       
   496     TestUpdateL( "abcdefghijk", "Abc------jk", "----efGhi--", -2, 2 );
       
   497     TestUpdateL( "abcdefghijk", "Abc------jk", "---deFgh---", -2, 2 );
       
   498     }
       
   499     
       
   500 // -----------------------------------------------------------------------------
       
   501 void t_CGlxListWindow::T_AddObjectsL(  )
       
   502     {
       
   503     TestUpdateL( "abcd", "-B--", "---B---", 0, 0, EAdd, 0, "23abcde" );
       
   504     // add to empty list
       
   505     TestUpdateL( "", "", "Abcd-----jk", -2, 3, EAdd, 0, "abcdefghijk");
       
   506     TestUpdateL( "", "", "----efGhij-", -2, 3, EAdd, 0, "abcdefghijk");
       
   507     TestUpdateL( "", "", "abc-----ijK", -2, 3, EAdd, 0, "abcdefghijk");
       
   508     // add to a list that does not fill the window
       
   509     TestUpdateL( "abc", "Abc", "Abcde", -2, 3, EAdd, 3, "abcde");
       
   510     TestUpdateL( "abc", "Abc", "Adebc", -2, 3, EAdd, 1, "adebc");
       
   511     // add before list
       
   512     TestUpdateL( "abc", "Abc", "Abc-ef", -2, 2, EAdd, 3, "abcdef");
       
   513     TestUpdateL( "abcdefghi", "---deFghi", "-----deFghi", -2, 3, EAdd, 1, "a12bcdefghi");
       
   514     TestUpdateL( "abcdefghi", "---deFghi", "-----deFghi", -2, 3, EAdd, 3, "abc12defghi");
       
   515     TestUpdateL( "abcdefghi", "abc---ghI", "abc-----ghI", -2, 3, EAdd, 1, "abcde12fghi");
       
   516     TestUpdateL( "abcdefghi", "abc---ghI", "abc-----ghI", -2, 3, EAdd, 3, "abcdef12ghi");
       
   517     TestUpdateL( "abcdefghi", "Abcd---hi", "Abcd-----hi", -2, 3, EAdd, 6, "abcdef12ghi");
       
   518     TestUpdateL( "abcdefghi", "Abcd---hi", "Abcd-----hi", -2, 3, EAdd, 7, "abcdefg12hi");
       
   519     // add before focus, on list
       
   520     TestUpdateL( "abcdefghi", "---deFghi", "-----2eFghi", -2, 3, EAdd, 4, "abcd12efghi");
       
   521     TestUpdateL( "abcdefghi", "---deFghi", "-----12Fghi", -2, 3, EAdd, 5, "abcde12fghi");
       
   522     TestUpdateL( "abcdefghi", "abc---ghI", "abc-----2hI", -2, 3, EAdd, 7, "abcdefg12hi");
       
   523     TestUpdateL( "abcdefghi", "abc---ghI", "abc-----12I", -2, 3, EAdd, 8, "abcdefgh12i");
       
   524     TestUpdateL( "abcdefghi", "Abcd---hi", "Abcd-----2i", -2, 3, EAdd, 8, "abcdefgh12i");
       
   525     TestUpdateL( "abcdefghi", "Abcd---hi", "Abcd-----12", -2, 3, EAdd, 9, "abcdefghi12");
       
   526     // add after focus, on list
       
   527     TestUpdateL( "abcdefghi", "---deFghi", "---deF12g--", -2, 3, EAdd, 6, "abcdef12ghi");
       
   528     TestUpdateL( "abcdefghi", "---deFghi", "---deFg12--", -2, 3, EAdd, 7, "abcdefg12hi");
       
   529     TestUpdateL( "abcdefghi", "---deFghi", "---deFgh1--", -2, 3, EAdd, 8, "abcdefgh12i");
       
   530     TestUpdateL( "abcdefghi", "---deFghi", "---deFghi--", -2, 3, EAdd, 9, "abcdefghi12");
       
   531     TestUpdateL( "abcdefghi", "abc---ghI", "12a-----ghI", -2, 3, EAdd, 0, "12abcdefghi");
       
   532     TestUpdateL( "abcdefghi", "abc---ghI", "a12-----ghI", -2, 3, EAdd, 1, "a12bcdefghi");
       
   533     TestUpdateL( "abcdefghi", "abc---ghI", "ab1-----ghI", -2, 3, EAdd, 2, "ab12cdefghi");
       
   534     TestUpdateL( "abcdefghi", "abc---ghI", "abc-----ghI", -2, 3, EAdd, 3, "abc12defghi");
       
   535     // add after list
       
   536     TestUpdateL( "abcdefghi", "---deFgh-", "---deFgh---", -2, 2, EAdd, 9, "abcdefghi12");
       
   537     }
       
   538     
       
   539 // -----------------------------------------------------------------------------
       
   540 void t_CGlxListWindow::T_RemoveObjectsL(  )
       
   541     {
       
   542     TestUpdateL( "abcd", "--C-", "C--", 0, 0, ERemove, 0, "cde" );
       
   543     // test remove before list
       
   544     TestUpdateL( "abcdefghi", "---deFgh-", "-deFgh-", -2, 2, ERemove, 0, "cdefghi");
       
   545     // test remove before focus, on list
       
   546     TestUpdateL( "abcdefghi", "---deFgh-", "-beFgh-", -2, 2, ERemove, 2, "abefghi");
       
   547     TestUpdateL( "abcdefghi", "---deFgh-", "-bcFgh-", -2, 2, ERemove, 3, "abcfghi");
       
   548     // test remove after focus, on list
       
   549     TestUpdateL( "abcdefghi", "---deFgh-", "a--deFg", -2, 2, ERemove, 7, "abcdefg");
       
   550     // test remove after list
       
   551     TestUpdateL( "abcdefghi", "-bcDef---", "-bcDef-", -2, 2, ERemove, 7, "abcdefg");
       
   552     // test remove all
       
   553     TestUpdateL( "abcdefghi", "---deFgh-", "", -2, 2, ERemove, 0, "");
       
   554     TestUpdateL( "abcdefghi", "Abc----hi", "", -2, 2, ERemove, 0, "");
       
   555     TestUpdateL( "abcdefghi", "ab----ghI", "", -2, 2, ERemove, 0, "");
       
   556     // with 0 ranges
       
   557     TestUpdateL( "abcdefghi", "--------I", "", 0, 0, ERemove, 0, "");
       
   558     TestUpdateL( "abcdefghi", "---D-----", "---D---", 0, 0, ERemove, 7, "abcdefg");
       
   559     }
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // Test table
       
   563 // -----------------------------------------------------------------------------
       
   564 //
       
   565 EUNIT_BEGIN_TEST_TABLE(
       
   566     t_CGlxListWindow,
       
   567     "List window test suite",
       
   568     "UNIT" )    
       
   569 
       
   570 EUNIT_TEST(
       
   571     "SetRangeOffsetsL",
       
   572     "CGlxListWindow",
       
   573     "SetRangeOffsetsL",
       
   574     "FUNCTIONALITY",
       
   575     SetupL, T_SetRangeOffsetsLL, Teardown)
       
   576 
       
   577 EUNIT_TEST(
       
   578     "SetFocusIndex",
       
   579     "CGlxListWindow",
       
   580     "SetFocusIndex",
       
   581     "FUNCTIONALITY",
       
   582     SetupL, T_SetFocusIndexL, Teardown)
       
   583     
       
   584 EUNIT_TEST(
       
   585     "AddObjects",
       
   586     "CGlxListWindow",
       
   587     "AddObjects",
       
   588     "FUNCTIONALITY",
       
   589     SetupL, T_AddObjectsL, Teardown)
       
   590     
       
   591 EUNIT_TEST(
       
   592     "RemoveObjects",
       
   593     "CGlxListWindow",
       
   594     "RemoveObjects",
       
   595     "FUNCTIONALITY",
       
   596     SetupL, T_RemoveObjectsL, Teardown)
       
   597 
       
   598 EUNIT_END_TEST_TABLE
       
   599 
       
   600 //  END OF FILE