|
1 /* |
|
2 * Copyright (c) 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: Testing glxexclusioniterator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_tglxexclusioniterator.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 #include <digia/eunit/eunitdecorators.h> |
|
27 |
|
28 |
|
29 // INTERNAL INCLUDES |
|
30 |
|
31 // CONSTRUCTION |
|
32 t_tglxexclusioniterator* t_tglxexclusioniterator::NewL() |
|
33 { |
|
34 t_tglxexclusioniterator* self = t_tglxexclusioniterator::NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 t_tglxexclusioniterator* t_tglxexclusioniterator::NewLC() |
|
41 { |
|
42 t_tglxexclusioniterator* self = new( ELeave ) t_tglxexclusioniterator(); |
|
43 CleanupStack::PushL( self ); |
|
44 |
|
45 self->ConstructL(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor (virtual by CBase) |
|
51 t_tglxexclusioniterator::~t_tglxexclusioniterator() |
|
52 { |
|
53 } |
|
54 |
|
55 // Default constructor |
|
56 t_tglxexclusioniterator::t_tglxexclusioniterator(): iList(0),iExclusionOrder(iIncludeIterator,iExcludeIterator) |
|
57 { |
|
58 } |
|
59 |
|
60 // Second phase construct |
|
61 void t_tglxexclusioniterator::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 // METHODS |
|
69 |
|
70 |
|
71 void t_tglxexclusioniterator::SetupL( ) |
|
72 { |
|
73 iExclusionOrder.SetToFirst(&iList); |
|
74 } |
|
75 void t_tglxexclusioniterator::Teardown( ) |
|
76 { |
|
77 // Do nothing |
|
78 EUNIT_PRINT(_L("test done")); |
|
79 } |
|
80 |
|
81 void t_tglxexclusioniterator::T_InRangeL() |
|
82 { |
|
83 |
|
84 EUNIT_PRINT(_L(" test for T_InRangeL")); |
|
85 |
|
86 // test for less than a screenfull of items |
|
87 iIncludeIterator.SetRange(2*7); |
|
88 iExcludeIterator.SetRangeOffsets(7,7); |
|
89 TestRange_False(2,0,1); |
|
90 |
|
91 |
|
92 iIncludeIterator.SetRange(2*7); |
|
93 iExcludeIterator.SetRangeOffsets(7,7); |
|
94 TestRange_False(2,1,1); |
|
95 |
|
96 |
|
97 |
|
98 iIncludeIterator.SetRange(2*7); |
|
99 iExcludeIterator.SetRangeOffsets(7,7); |
|
100 TestRange_False(4,2,2); |
|
101 |
|
102 |
|
103 iIncludeIterator.SetRange(2*7); |
|
104 iExcludeIterator.SetRangeOffsets(7,7); |
|
105 TestRange_False(15,8,7); |
|
106 |
|
107 |
|
108 |
|
109 iIncludeIterator.SetRange(2*7); |
|
110 iExcludeIterator.SetRangeOffsets(7,7); |
|
111 TestRange_False(16,9,9); |
|
112 |
|
113 //test for more than a screenfull of items |
|
114 |
|
115 iIncludeIterator.SetRange(2*7); |
|
116 iExcludeIterator.SetRangeOffsets(7,7); |
|
117 TestRange_True(100,20,9); |
|
118 |
|
119 |
|
120 |
|
121 iIncludeIterator.SetRange(2*7); |
|
122 iExcludeIterator.SetRangeOffsets(7,7); |
|
123 TestRange_True(100,17,9); |
|
124 |
|
125 |
|
126 iIncludeIterator.SetRange(2*7); |
|
127 iExcludeIterator.SetRangeOffsets(7,7); |
|
128 TestRange_True(100,18,9); |
|
129 |
|
130 |
|
131 iIncludeIterator.SetRange(2*7); |
|
132 iExcludeIterator.SetRangeOffsets(7,7); |
|
133 TestRange_True(100,19,9); |
|
134 |
|
135 |
|
136 iIncludeIterator.SetRange(2*7); |
|
137 iExcludeIterator.SetRangeOffsets(7,7); |
|
138 TestRange_False(100,99,0); |
|
139 |
|
140 |
|
141 iIncludeIterator.SetRange(2*7); |
|
142 iExcludeIterator.SetRangeOffsets(7,7); |
|
143 TestRange_False(100,98,0); |
|
144 |
|
145 |
|
146 iIncludeIterator.SetRange(2*7); |
|
147 iExcludeIterator.SetRangeOffsets(7,7); |
|
148 TestRange_False(100,97,0); |
|
149 |
|
150 |
|
151 iIncludeIterator.SetRange(2*7); |
|
152 iExcludeIterator.SetRangeOffsets(7,7); |
|
153 TestRange_False(100,96,0); |
|
154 } |
|
155 void t_tglxexclusioniterator::TestRange_True(TInt aCount,TInt aIndex,TInt aFocusIndex) |
|
156 { |
|
157 iList.iCount = aCount; |
|
158 iList.iFocus = aFocusIndex; |
|
159 EUNIT_ASSERT(iExclusionOrder.InRange(aIndex)==ETrue); |
|
160 |
|
161 } |
|
162 void t_tglxexclusioniterator::TestRange_False(TInt aCount,TInt aIndex,TInt aFocusIndex) |
|
163 { |
|
164 iList.iCount = aCount; |
|
165 iList.iFocus = aFocusIndex; |
|
166 EUNIT_ASSERT(iExclusionOrder.InRange(aIndex)==EFalse); |
|
167 } |
|
168 void t_tglxexclusioniterator::T_PlusPlusL() |
|
169 { |
|
170 EUNIT_PRINT(_L(" Test T_PlusPlusL L-R ")); |
|
171 |
|
172 Test(100,17,8); |
|
173 |
|
174 Test(100,18,9); |
|
175 |
|
176 Test(100,19,10); |
|
177 |
|
178 Test(100,20,11); |
|
179 |
|
180 EUNIT_PRINT(_L(" Test T_PlusPlusL--R-L ")); |
|
181 |
|
182 Test(100,91,92); |
|
183 |
|
184 Test(100,90,89); |
|
185 |
|
186 Test(100,89,88); |
|
187 |
|
188 Test(100,86,87); |
|
189 } |
|
190 void t_tglxexclusioniterator::Test( TInt aCount,TInt aIndex,TInt aFocusIndex) |
|
191 { |
|
192 iList.iCount = aCount; |
|
193 iList.iFocus = aFocusIndex; |
|
194 iIncludeIterator.SetRange(2*7); |
|
195 iExcludeIterator.SetRangeOffsets(7,7); |
|
196 |
|
197 TInt newIndex = iExclusionOrder++; |
|
198 EUNIT_ASSERT(iExclusionOrder.InRange(newIndex )); |
|
199 } |
|
200 // TEST TABLE |
|
201 EUNIT_BEGIN_TEST_TABLE( |
|
202 t_tglxexclusioniterator, |
|
203 "Add test suite description here.", |
|
204 "UNIT" ) |
|
205 |
|
206 /*EUNIT_TEST( |
|
207 "Test InRange", |
|
208 "t_tglxexclusioniterator", |
|
209 "T_InRangeL", |
|
210 "FUNCTIONALITY", |
|
211 SetupL,T_InRangeL,Teardown) */ |
|
212 EUNIT_TEST( |
|
213 "Test PlusPlus ", |
|
214 "t_tglxexclusioniterator", |
|
215 "T_PlusPlusL", |
|
216 "FUNCTIONALITY", |
|
217 SetupL,T_PlusPlusL,Teardown) |
|
218 |
|
219 |
|
220 EUNIT_END_TEST_TABLE |
|
221 |
|
222 // END OF FILE |