|
1 /* |
|
2 * Copyright (c) 2006-2006 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: TGlxFromFocusOutwardIterator unit tests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __T_GLXFROMFOCUSOUTWARDITERATOR_H__ |
|
22 #define __T_GLXFROMFOCUSOUTWARDITERATOR_H__ |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/ceunittestsuiteclass.h> |
|
26 |
|
27 // INTERNAL INCLUDES |
|
28 #include "mglxmedialist.h" |
|
29 #include "glxmedialistiterator.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 #include <e32def.h> |
|
34 #ifndef NONSHARABLE_CLASS |
|
35 #define NONSHARABLE_CLASS(x) class x |
|
36 #endif |
|
37 |
|
38 // CLASS DEFINITION |
|
39 /** |
|
40 * |
|
41 * EUnitWizard generated test class. |
|
42 * |
|
43 */ |
|
44 NONSHARABLE_CLASS( T_CGlxFromFocusOutwardIterator ) |
|
45 : public CEUnitTestSuiteClass |
|
46 { |
|
47 public: // Constructors and destructors |
|
48 static T_CGlxFromFocusOutwardIterator* NewL(); |
|
49 static T_CGlxFromFocusOutwardIterator* NewLC(); |
|
50 ~T_CGlxFromFocusOutwardIterator(); |
|
51 |
|
52 private: // Constructors and destructors |
|
53 T_CGlxFromFocusOutwardIterator(); |
|
54 void ConstructL(); |
|
55 |
|
56 private: // New methods |
|
57 void SetupL(); |
|
58 void Teardown(); |
|
59 |
|
60 void UT_TestEmptyL(); |
|
61 void UT_TestSymmetricRangeL(); |
|
62 void UT_TestAsymmetricRangeL(); |
|
63 void UT_TestOneSideRangeL(); |
|
64 void UT_TestInRangeL(); |
|
65 |
|
66 /** |
|
67 * Run a single test |
|
68 * @param aCount Number of items in list |
|
69 * @param aFocusIndex index of focus |
|
70 * @param aFrontOffset |
|
71 * @param aRearOffset |
|
72 * @param aResult expected results in format "iiiii*e", |
|
73 * where i is an index, and e means KErrNotFound. |
|
74 * E.g., "14523ee" means iOrder++ should return 1 first, |
|
75 * 4 then, etc. and finally KErrNotFound two times |
|
76 */ |
|
77 void TestSingleRange(TInt aCount, TInt aFocusIndex, TInt aRearOffset, |
|
78 TInt aFrontOffset, char* aResult); |
|
79 |
|
80 /** |
|
81 * Run a single "InRange()" test |
|
82 * @param aCount Number of items in list |
|
83 * @param aFocusIndex index of focus |
|
84 * @param aFrontOffset |
|
85 * @param aRearOffset |
|
86 * @param aResult expected results in format "xxx xx", |
|
87 * where x means the n-th item is in range, and space means it is not |
|
88 */ |
|
89 void TestSingleInRange(TInt aCount, TInt aFocusIndex, TInt aRearOffset, |
|
90 TInt aFrontOffset, char* aResult); |
|
91 |
|
92 private: |
|
93 // Dummy media list class |
|
94 struct TGlxMediaListTester : public MGlxMediaList |
|
95 { |
|
96 TGlxMediaListTester() : iItem(TGlxMediaId(1)), iSelectedItems() |
|
97 { |
|
98 iCount = 0; |
|
99 iFocusIndex = KErrNotFound; |
|
100 }; |
|
101 virtual void Close() {}; |
|
102 virtual TGlxMediaListId Id() const { return TGlxMediaListId(1); }; |
|
103 virtual TInt Count(NGlxListDefs::TCountType /*aType*/) const { return iCount; }; |
|
104 virtual TInt FocusIndex() const { return iFocusIndex; }; |
|
105 virtual void SetFocusL(NGlxListDefs::TFocusSetType /*aType*/, TInt aValue) { iFocusIndex = aValue; }; |
|
106 virtual const TGlxMedia& Item(TInt /*aIndex*/) const { return iItem; }; |
|
107 virtual TInt Index(const TGlxIdSpaceId& /* aIdSpaceId */, const TGlxMediaId& /*aId*/) const { return 0; }; |
|
108 virtual void AddMediaListObserverL(MGlxMediaListObserver* /*aObserver*/) {}; |
|
109 virtual void RemoveMediaListObserver(MGlxMediaListObserver* /*aObserver*/) {}; |
|
110 virtual void AddContextL(const MGlxFetchContext* /*aContext*/, TInt /*aPriority*/) {}; |
|
111 virtual void RemoveContext(const MGlxFetchContext* /*aContext*/) {}; |
|
112 virtual MMPXCollection& Collection() const { MMPXCollection* c = NULL; return *c; }; // Don't call |
|
113 virtual CMPXCollectionPath* PathLC(NGlxListDefs::TPathType /*aType*/) const { CMPXCollectionPath* p = NULL; return p; }; // Don't call |
|
114 virtual TBool IsSelected(TInt /*aIndex*/) const { return EFalse; }; |
|
115 virtual void SetSelectedL(TInt /*aIndex*/, TBool /*aSelected*/) {}; |
|
116 virtual TInt SelectionCount() const { return iSelectedItems.Count(); }; |
|
117 virtual TInt SelectedItemIndex(TInt /*aSelectionIndex*/) const { return KErrNotFound; }; |
|
118 virtual void CommandL(CMPXCommand& /*aCommand*/) {}; |
|
119 virtual void CancelCommand() {}; |
|
120 virtual void SetFilterL(CMPXFilter* /*aFilter*/) {}; |
|
121 virtual CMPXFilter* Filter() const { return NULL; }; |
|
122 virtual TGlxIdSpaceId IdSpaceId(TInt /*aIndex*/) const { return TGlxIdSpaceId(1); }; |
|
123 virtual TBool IsPopulated() const { return ETrue; }; // Don't call |
|
124 virtual void AddStaticItemL( CGlxMedia* /*aStaticItem*/, |
|
125 NGlxListDefs::TInsertionPosition /*aTargetPosition*/ ) {}; |
|
126 virtual void RemoveStaticItem(const TGlxMediaId& /*aItemId*/) {}; |
|
127 virtual void SetStaticItemsEnabled( TBool aEnabled ) { iStaticItemsEnabled = aEnabled; }; |
|
128 virtual TBool IsStaticItemsEnabled() const { return iStaticItemsEnabled; }; |
|
129 virtual void SetFocusInitialPosition(NGlxListDefs::TFocusInitialPosition /*aFocusInitialPosition*/) { }; |
|
130 virtual void ResetFocus(){ }; |
|
131 virtual void SetVisibleWindowIndexL( TInt /*aIndex*/) { }; |
|
132 virtual TInt VisibleWindowIndex() const { }; |
|
133 virtual void CancelPreviousRequests() {}; |
|
134 |
|
135 TGlxMedia iItem; |
|
136 TInt iCount; |
|
137 TInt iFocusIndex; |
|
138 RArray<TInt> iSelectedItems; |
|
139 TBool iStaticItemsEnabled; |
|
140 }; |
|
141 |
|
142 private: // Data |
|
143 MGlxMediaListIterator* iOrder; // To access virtual functions only |
|
144 TGlxMediaListTester iList; |
|
145 TGlxFromFocusOutwardIterator iFocusOrder; |
|
146 |
|
147 EUNIT_DECLARE_TEST_TABLE; |
|
148 }; |
|
149 |
|
150 #endif // __T_GLXFROMFOCUSOUTWARDITERATOR_H__ |