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