|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Test class for TDisplayConfiguration |
|
15 // |
|
16 // |
|
17 |
|
18 #include "tdisplayconfiguration.h" |
|
19 #include <test/extendtef.h> |
|
20 |
|
21 #include "../inc/displayconfiguration.h" |
|
22 |
|
23 // This handles any non-member uses of the extended ASSERT_XXX macros |
|
24 void TefUnitFailLeaveL() |
|
25 { |
|
26 |
|
27 User::Leave(KErrTEFUnitFail); |
|
28 } |
|
29 |
|
30 // Create a suite of all the tests |
|
31 CTestSuite* CTestDisplayConfiguration::CreateSuiteL(const TDesC& aName) |
|
32 { |
|
33 SUB_SUITE_OPT(CTestDisplayConfiguration,NULL); |
|
34 |
|
35 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0001L); |
|
36 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0002L); |
|
37 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0003L); |
|
38 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0004L); |
|
39 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0005L); |
|
40 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0006L); |
|
41 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0007L); |
|
42 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0008L); |
|
43 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0009L); |
|
44 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0010L); |
|
45 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0011L); |
|
46 ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0012L); |
|
47 |
|
48 END_SUITE; |
|
49 } |
|
50 |
|
51 // Published Tests |
|
52 |
|
53 /** |
|
54 @SYMTestCaseID GRAPHICS_COMMONHEADER_0001L |
|
55 @SYMTestCaseDesc TDisplayConfiguration field validation |
|
56 @SYMREQ REQ10325 |
|
57 @SYMPREQ PREQ2102 |
|
58 @SYMTestType CT |
|
59 @SYMTestPurpose Check default configuration is empty |
|
60 @SYMTestActions |
|
61 Create an instance of TDisplayConfiguration |
|
62 Check default version is size of TDisplayConfiguration |
|
63 Check each member is not defined and does not change a passed in field |
|
64 @SYMTestExpectedResults |
|
65 Holds correct size and fields are empty |
|
66 **/ |
|
67 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0001L() |
|
68 { |
|
69 TDisplayConfiguration testConfig; |
|
70 |
|
71 ASSERT_EQUALS (testConfig.Version(),(TInt)sizeof(testConfig)); |
|
72 |
|
73 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
74 |
|
75 TSize size(10,11); |
|
76 ASSERT_FALSE (testConfig.GetResolution(size)); |
|
77 ASSERT_EQUALS (size,TSize(10,11)); |
|
78 } |
|
79 |
|
80 /** |
|
81 @SYMTestCaseID GRAPHICS_COMMONHEADER_0002L |
|
82 @SYMTestCaseDesc Setting TDisplayConfiguration variables |
|
83 @SYMREQ REQ10325 |
|
84 @SYMPREQ PREQ2102 |
|
85 @SYMTestType CT |
|
86 @SYMTestPurpose Check setting variables works correctly |
|
87 @SYMTestActions |
|
88 Set resolution 1 |
|
89 Check resolution 1 set |
|
90 Set resolution 2 |
|
91 Check resolution 2 set |
|
92 Set twips resolution 1 |
|
93 Check twips resolution 1 set |
|
94 Set twips resolution 2 |
|
95 Check twips resolution 2 set |
|
96 @SYMTestExpectedResults |
|
97 All 'gets' return as expected |
|
98 **/ |
|
99 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0002L() |
|
100 { |
|
101 TDisplayConfiguration testConfig; |
|
102 |
|
103 TSize sizeSet1(10,11); |
|
104 TSize sizeSet2(12,13); |
|
105 TSize sizeCheck1(14,15); |
|
106 TSize sizeCheck2(16,17); |
|
107 TSize twipsSizeSet1(7620,2858); |
|
108 TSize twipsSizeSet2(7630,2868); |
|
109 TSize twipsSizeCheck1(7640,2878); |
|
110 TSize twipsSizeCheck2(7650,2888); |
|
111 |
|
112 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
113 //Set size check |
|
114 testConfig.SetResolution(sizeSet1); |
|
115 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
116 ASSERT_TRUE (testConfig.GetResolution(sizeCheck1)); |
|
117 ASSERT_EQUALS (sizeSet1,sizeCheck1); |
|
118 //Set size check 2 |
|
119 testConfig.SetResolution(sizeSet2); |
|
120 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
121 ASSERT_TRUE (testConfig.GetResolution(sizeCheck2)); |
|
122 ASSERT_EQUALS (sizeSet2,sizeCheck2); |
|
123 //Set twips check |
|
124 testConfig.SetResolutionTwips(twipsSizeSet1); |
|
125 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips)); |
|
126 ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck1)); |
|
127 ASSERT_EQUALS (twipsSizeSet1,twipsSizeCheck1); |
|
128 //Set twips check 2 |
|
129 testConfig.SetResolutionTwips(twipsSizeSet2); |
|
130 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips)); |
|
131 ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck2)); |
|
132 ASSERT_EQUALS (twipsSizeSet2,twipsSizeCheck2); |
|
133 } |
|
134 |
|
135 /** |
|
136 @SYMTestCaseID GRAPHICS_COMMONHEADER_0003L |
|
137 @SYMTestCaseDesc Clearing TDisplayConfiguration variables |
|
138 @SYMREQ REQ10325 |
|
139 @SYMPREQ PREQ2102 |
|
140 @SYMTestType CT |
|
141 @SYMTestPurpose Checking Clear works as expected |
|
142 @SYMTestActions |
|
143 Set resolution |
|
144 Clear resolution |
|
145 Get resolution *should do nothing* |
|
146 @SYMTestExpectedResults |
|
147 Clears variables as expected |
|
148 **/ |
|
149 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0003L() |
|
150 { |
|
151 TDisplayConfiguration testConfig; |
|
152 |
|
153 TSize size1(10,11); |
|
154 TSize size2(12,13); |
|
155 TSize size2copy(size2); |
|
156 |
|
157 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
158 testConfig.SetResolution(size1); |
|
159 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
160 testConfig.Clear(TDisplayConfiguration::EResolution); |
|
161 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
162 ASSERT_FALSE (testConfig.GetResolution(size2)); |
|
163 //check size2 has not been changed |
|
164 ASSERT_EQUALS (size2,size2copy); |
|
165 } |
|
166 |
|
167 /** |
|
168 @SYMTestCaseID GRAPHICS_COMMONHEADER_0004L |
|
169 @SYMTestCaseDesc Clear all TDisplayConfiguration variables |
|
170 @SYMREQ REQ10325 |
|
171 @SYMPREQ PREQ2102 |
|
172 @SYMTestType CT |
|
173 @SYMTestPurpose Check ClearAll performs correctly |
|
174 @SYMTestActions |
|
175 Set resolution |
|
176 Set color |
|
177 ClearAll() |
|
178 Get resolution *should do nothing* |
|
179 @SYMTestExpectedResults |
|
180 ClearAll should clear all! |
|
181 **/ |
|
182 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0004L() |
|
183 { |
|
184 TDisplayConfiguration testConfig; |
|
185 |
|
186 TSize size1(10,11); |
|
187 TSize size2(12,13); |
|
188 TSize size2copy(size2); |
|
189 |
|
190 TRgb color1(50,255); |
|
191 TRgb color2(52,255); |
|
192 TRgb color2copy(color2); |
|
193 |
|
194 //set values |
|
195 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
196 testConfig.SetResolution(size1); |
|
197 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
198 |
|
199 testConfig.ClearAll(); |
|
200 |
|
201 //check cleared variables |
|
202 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
203 ASSERT_FALSE (testConfig.GetResolution(size2)); |
|
204 //check size2 has not been changed |
|
205 ASSERT_EQUALS(size2,size2copy); |
|
206 } |
|
207 |
|
208 /** |
|
209 @SYMTestCaseID GRAPHICS_COMMONHEADER_0005L |
|
210 @SYMTestCaseDesc TDisplayConfiguration copy operator |
|
211 @SYMREQ REQ10325 |
|
212 @SYMPREQ PREQ2102 |
|
213 @SYMTestType CT |
|
214 @SYMTestPurpose Checking copy works correctly |
|
215 @SYMTestActions |
|
216 Set values |
|
217 Make a copy |
|
218 Check copy has copied values |
|
219 Make slight changes to copy, check operator== works (thorough test fo coverage) |
|
220 @SYMTestExpectedResults |
|
221 Should copy variables to new config |
|
222 Should perform operator== correctly |
|
223 **/ |
|
224 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0005L() |
|
225 { |
|
226 TDisplayConfiguration testConfig1; |
|
227 |
|
228 TSize size1(10,11); |
|
229 TSize size2(12,13); |
|
230 TSize sizeTemp(0,1); |
|
231 TDisplayConfiguration1::TRotation rotTemp = TDisplayConfiguration1::ERotationIllegal; |
|
232 |
|
233 testConfig1.SetResolution(size1); |
|
234 testConfig1.SetResolutionTwips(size2); |
|
235 testConfig1.SetRotation(TDisplayConfiguration1::ERotationNormal); |
|
236 |
|
237 TDisplayConfiguration testConfig2(testConfig1); |
|
238 |
|
239 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolution)); |
|
240 ASSERT_TRUE (testConfig2.GetResolution(sizeTemp)); |
|
241 ASSERT_EQUALS (size1,sizeTemp); |
|
242 |
|
243 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolutionTwips)); |
|
244 ASSERT_TRUE (testConfig2.GetResolutionTwips(sizeTemp)); |
|
245 ASSERT_EQUALS (size2,sizeTemp); |
|
246 |
|
247 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::ERotation)); |
|
248 ASSERT_TRUE (testConfig2.GetRotation(rotTemp)); |
|
249 ASSERT_EQUALS (rotTemp,TDisplayConfiguration1::ERotationNormal); |
|
250 |
|
251 ASSERT_TRUE (testConfig1==testConfig2); |
|
252 |
|
253 testConfig1.Clear(TDisplayConfiguration::EResolution); |
|
254 testConfig2.Clear(TDisplayConfiguration::EResolution); |
|
255 testConfig1.Clear(TDisplayConfiguration::EResolutionTwips); |
|
256 testConfig2.Clear(TDisplayConfiguration::EResolutionTwips); |
|
257 testConfig1.Clear(TDisplayConfiguration::ERotation); |
|
258 testConfig2.Clear(TDisplayConfiguration::ERotation); |
|
259 |
|
260 ASSERT_TRUE (testConfig1==testConfig2); |
|
261 |
|
262 TDisplayConfiguration largeConfig(200); |
|
263 TDisplayConfiguration emptyConfig; |
|
264 ASSERT_FALSE (largeConfig==emptyConfig); |
|
265 ASSERT_FALSE (emptyConfig==largeConfig); |
|
266 } |
|
267 |
|
268 /** |
|
269 @SYMTestCaseID GRAPHICS_COMMONHEADER_0006L |
|
270 @SYMTestCaseDesc Small configs do nothing |
|
271 @SYMREQ REQ10325 |
|
272 @SYMPREQ PREQ2102 |
|
273 @SYMTestType CT |
|
274 @SYMTestPurpose Older config versions should not try to access newer variables |
|
275 @SYMTestActions |
|
276 Create very small config |
|
277 Set resolution |
|
278 Get resolution *should not have set it* |
|
279 @SYMTestExpectedResults |
|
280 Setting when version is too old should fail silently. No returned error, no panic |
|
281 **/ |
|
282 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0006L() |
|
283 { |
|
284 TDisplayConfiguration testConfig(sizeof(TDisplayConfigurationBase)); |
|
285 |
|
286 TSize size1(10,11); |
|
287 TSize size2(12,13); |
|
288 |
|
289 testConfig.SetResolution(size1); |
|
290 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
291 ASSERT_FALSE (testConfig.GetResolution(size2)); |
|
292 ASSERT_NOT_EQUALS (size1,size2); |
|
293 } |
|
294 |
|
295 /** |
|
296 @SYMTestCaseID GRAPHICS_COMMONHEADER_0007L |
|
297 @SYMTestCaseDesc Negative resolution panics client |
|
298 @SYMREQ REQ10325 |
|
299 @SYMPREQ PREQ2102 |
|
300 @SYMTestType CT |
|
301 @SYMTestPurpose Negative resolutions are not allowed and should panic the client |
|
302 @SYMTestActions |
|
303 Set negative X resolution |
|
304 @SYMTestExpectedResults |
|
305 Should panic with DISPCONF 1 |
|
306 **/ |
|
307 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0007L() |
|
308 { |
|
309 TDisplayConfiguration testConfig; |
|
310 |
|
311 TSize size(-10,10); |
|
312 testConfig.SetResolution(size); |
|
313 |
|
314 //Should not get here |
|
315 ASSERT_TRUE(0); |
|
316 } |
|
317 |
|
318 /** |
|
319 @SYMTestCaseID GRAPHICS_COMMONHEADER_0008L |
|
320 @SYMTestCaseDesc Negative resolution panics client |
|
321 @SYMREQ REQ10325 |
|
322 @SYMPREQ PREQ2102 |
|
323 @SYMTestType CT |
|
324 @SYMTestPurpose Negative resolutions are not allowed and should panic the client |
|
325 @SYMTestActions |
|
326 Set negative Y resolution |
|
327 @SYMTestExpectedResults |
|
328 Should panic with DISPCONF 1 |
|
329 **/ |
|
330 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0008L() |
|
331 { |
|
332 TDisplayConfiguration testConfig; |
|
333 |
|
334 TSize size(10,-10); |
|
335 testConfig.SetResolution(size); |
|
336 |
|
337 //Should not get here |
|
338 ASSERT_TRUE(0); |
|
339 } |
|
340 |
|
341 /** |
|
342 @SYMTestCaseID GRAPHICS_COMMONHEADER_0009L |
|
343 @SYMTestCaseDesc One resolution axis 0 panics client |
|
344 @SYMREQ REQ10325 |
|
345 @SYMPREQ PREQ2102 |
|
346 @SYMTestType CT |
|
347 @SYMTestPurpose A resolution with only 1 axis at 0 is invalid |
|
348 @SYMTestActions |
|
349 Set 0 on X axis only for resolution |
|
350 @SYMTestExpectedResults |
|
351 Should panic with DISPCONF 2 |
|
352 |
|
353 **/ |
|
354 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0009L() |
|
355 { |
|
356 TDisplayConfiguration testConfig; |
|
357 |
|
358 TSize size(0,10); |
|
359 testConfig.SetResolution(size); |
|
360 |
|
361 //Should not get here |
|
362 ASSERT_TRUE(0); |
|
363 } |
|
364 |
|
365 /** |
|
366 @SYMTestCaseID GRAPHICS_COMMONHEADER_0010L |
|
367 @SYMTestCaseDesc One resolution axis 0 panics client |
|
368 @SYMREQ REQ10325 |
|
369 @SYMPREQ PREQ2102 |
|
370 @SYMTestType CT |
|
371 @SYMTestPurpose A resolution with only 1 axis at 0 is invalid |
|
372 @SYMTestActions |
|
373 Set 0 on Y axis only for resolution |
|
374 @SYMTestExpectedResults |
|
375 Should panic with DISPCONF 2 |
|
376 **/ |
|
377 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0010L() |
|
378 { |
|
379 TDisplayConfiguration testConfig; |
|
380 |
|
381 TSize size(10,0); |
|
382 testConfig.SetResolution(size); |
|
383 |
|
384 //Should not get here |
|
385 ASSERT_TRUE(0); |
|
386 } |
|
387 |
|
388 /** |
|
389 @SYMTestCaseID GRAPHICS_COMMONHEADER_0011L |
|
390 @SYMTestCaseDesc Both resolution axis 0 valid |
|
391 @SYMREQ REQ10325 |
|
392 @SYMPREQ PREQ2102 |
|
393 @SYMTestType CT |
|
394 @SYMTestPurpose A resolution with only both axis at 0 is valid |
|
395 @SYMTestActions |
|
396 Set 0 on both axes for resolution |
|
397 @SYMTestExpectedResults |
|
398 Should complete and be able to return the same size |
|
399 **/ |
|
400 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0011L() |
|
401 { |
|
402 TDisplayConfiguration testConfig; |
|
403 |
|
404 TSize size1(0,0); |
|
405 TSize size2(1,2); |
|
406 testConfig.SetResolution(size1); |
|
407 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); |
|
408 ASSERT_TRUE (testConfig.GetResolution(size2)); |
|
409 ASSERT_EQUALS (size1,size2); |
|
410 } |
|
411 |
|
412 /** |
|
413 @SYMTestCaseID GRAPHICS_COMMONHEADER_0012L |
|
414 @SYMTestCaseDesc Invalid preferred version causes panic |
|
415 @SYMREQ REQ10325 |
|
416 @SYMPREQ PREQ2102 |
|
417 @SYMTestType CT |
|
418 @SYMTestPurpose An invalid version will cause a panic |
|
419 @SYMTestActions |
|
420 Set version to be 1 |
|
421 Should panic |
|
422 @SYMTestExpectedResults |
|
423 Should panic with DISPCONF 7 |
|
424 **/ |
|
425 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0012L() |
|
426 { |
|
427 TDisplayConfiguration testConfig (1); |
|
428 |
|
429 //Should not get here |
|
430 ASSERT_TRUE(0); |
|
431 } |