os/graphics/graphicsutils/commongraphicsheaders/test/src/tdisplayconfiguration.cpp
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test class for TDisplayConfiguration
18 #include "tdisplayconfiguration.h"
19 #include <test/extendtef.h>
21 #include "../inc/displayconfiguration.h"
23 // This handles any non-member uses of the extended ASSERT_XXX macros
24 void TefUnitFailLeaveL()
27 User::Leave(KErrTEFUnitFail);
30 // Create a suite of all the tests
31 CTestSuite* CTestDisplayConfiguration::CreateSuiteL(const TDesC& aName)
33 SUB_SUITE_OPT(CTestDisplayConfiguration,NULL);
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);
54 @SYMTestCaseID GRAPHICS_COMMONHEADER_0001L
55 @SYMTestCaseDesc TDisplayConfiguration field validation
59 @SYMTestPurpose Check default configuration is empty
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
67 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0001L()
69 TDisplayConfiguration testConfig;
71 ASSERT_EQUALS (testConfig.Version(),(TInt)sizeof(testConfig));
73 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
76 ASSERT_FALSE (testConfig.GetResolution(size));
77 ASSERT_EQUALS (size,TSize(10,11));
81 @SYMTestCaseID GRAPHICS_COMMONHEADER_0002L
82 @SYMTestCaseDesc Setting TDisplayConfiguration variables
86 @SYMTestPurpose Check setting variables works correctly
89 Check resolution 1 set
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
99 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0002L()
101 TDisplayConfiguration testConfig;
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);
112 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
114 testConfig.SetResolution(sizeSet1);
115 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
116 ASSERT_TRUE (testConfig.GetResolution(sizeCheck1));
117 ASSERT_EQUALS (sizeSet1,sizeCheck1);
119 testConfig.SetResolution(sizeSet2);
120 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
121 ASSERT_TRUE (testConfig.GetResolution(sizeCheck2));
122 ASSERT_EQUALS (sizeSet2,sizeCheck2);
124 testConfig.SetResolutionTwips(twipsSizeSet1);
125 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips));
126 ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck1));
127 ASSERT_EQUALS (twipsSizeSet1,twipsSizeCheck1);
129 testConfig.SetResolutionTwips(twipsSizeSet2);
130 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips));
131 ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck2));
132 ASSERT_EQUALS (twipsSizeSet2,twipsSizeCheck2);
136 @SYMTestCaseID GRAPHICS_COMMONHEADER_0003L
137 @SYMTestCaseDesc Clearing TDisplayConfiguration variables
141 @SYMTestPurpose Checking Clear works as expected
145 Get resolution *should do nothing*
146 @SYMTestExpectedResults
147 Clears variables as expected
149 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0003L()
151 TDisplayConfiguration testConfig;
155 TSize size2copy(size2);
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);
168 @SYMTestCaseID GRAPHICS_COMMONHEADER_0004L
169 @SYMTestCaseDesc Clear all TDisplayConfiguration variables
173 @SYMTestPurpose Check ClearAll performs correctly
178 Get resolution *should do nothing*
179 @SYMTestExpectedResults
180 ClearAll should clear all!
182 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0004L()
184 TDisplayConfiguration testConfig;
188 TSize size2copy(size2);
192 TRgb color2copy(color2);
195 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
196 testConfig.SetResolution(size1);
197 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
199 testConfig.ClearAll();
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);
209 @SYMTestCaseID GRAPHICS_COMMONHEADER_0005L
210 @SYMTestCaseDesc TDisplayConfiguration copy operator
214 @SYMTestPurpose Checking copy works correctly
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
224 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0005L()
226 TDisplayConfiguration testConfig1;
231 TDisplayConfiguration1::TRotation rotTemp = TDisplayConfiguration1::ERotationIllegal;
233 testConfig1.SetResolution(size1);
234 testConfig1.SetResolutionTwips(size2);
235 testConfig1.SetRotation(TDisplayConfiguration1::ERotationNormal);
237 TDisplayConfiguration testConfig2(testConfig1);
239 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolution));
240 ASSERT_TRUE (testConfig2.GetResolution(sizeTemp));
241 ASSERT_EQUALS (size1,sizeTemp);
243 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolutionTwips));
244 ASSERT_TRUE (testConfig2.GetResolutionTwips(sizeTemp));
245 ASSERT_EQUALS (size2,sizeTemp);
247 ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::ERotation));
248 ASSERT_TRUE (testConfig2.GetRotation(rotTemp));
249 ASSERT_EQUALS (rotTemp,TDisplayConfiguration1::ERotationNormal);
251 ASSERT_TRUE (testConfig1==testConfig2);
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);
260 ASSERT_TRUE (testConfig1==testConfig2);
262 TDisplayConfiguration largeConfig(200);
263 TDisplayConfiguration emptyConfig;
264 ASSERT_FALSE (largeConfig==emptyConfig);
265 ASSERT_FALSE (emptyConfig==largeConfig);
269 @SYMTestCaseID GRAPHICS_COMMONHEADER_0006L
270 @SYMTestCaseDesc Small configs do nothing
274 @SYMTestPurpose Older config versions should not try to access newer variables
276 Create very small config
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
282 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0006L()
284 TDisplayConfiguration testConfig(sizeof(TDisplayConfigurationBase));
289 testConfig.SetResolution(size1);
290 ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
291 ASSERT_FALSE (testConfig.GetResolution(size2));
292 ASSERT_NOT_EQUALS (size1,size2);
296 @SYMTestCaseID GRAPHICS_COMMONHEADER_0007L
297 @SYMTestCaseDesc Negative resolution panics client
301 @SYMTestPurpose Negative resolutions are not allowed and should panic the client
303 Set negative X resolution
304 @SYMTestExpectedResults
305 Should panic with DISPCONF 1
307 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0007L()
309 TDisplayConfiguration testConfig;
312 testConfig.SetResolution(size);
314 //Should not get here
319 @SYMTestCaseID GRAPHICS_COMMONHEADER_0008L
320 @SYMTestCaseDesc Negative resolution panics client
324 @SYMTestPurpose Negative resolutions are not allowed and should panic the client
326 Set negative Y resolution
327 @SYMTestExpectedResults
328 Should panic with DISPCONF 1
330 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0008L()
332 TDisplayConfiguration testConfig;
335 testConfig.SetResolution(size);
337 //Should not get here
342 @SYMTestCaseID GRAPHICS_COMMONHEADER_0009L
343 @SYMTestCaseDesc One resolution axis 0 panics client
347 @SYMTestPurpose A resolution with only 1 axis at 0 is invalid
349 Set 0 on X axis only for resolution
350 @SYMTestExpectedResults
351 Should panic with DISPCONF 2
354 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0009L()
356 TDisplayConfiguration testConfig;
359 testConfig.SetResolution(size);
361 //Should not get here
366 @SYMTestCaseID GRAPHICS_COMMONHEADER_0010L
367 @SYMTestCaseDesc One resolution axis 0 panics client
371 @SYMTestPurpose A resolution with only 1 axis at 0 is invalid
373 Set 0 on Y axis only for resolution
374 @SYMTestExpectedResults
375 Should panic with DISPCONF 2
377 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0010L()
379 TDisplayConfiguration testConfig;
382 testConfig.SetResolution(size);
384 //Should not get here
389 @SYMTestCaseID GRAPHICS_COMMONHEADER_0011L
390 @SYMTestCaseDesc Both resolution axis 0 valid
394 @SYMTestPurpose A resolution with only both axis at 0 is valid
396 Set 0 on both axes for resolution
397 @SYMTestExpectedResults
398 Should complete and be able to return the same size
400 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0011L()
402 TDisplayConfiguration testConfig;
406 testConfig.SetResolution(size1);
407 ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
408 ASSERT_TRUE (testConfig.GetResolution(size2));
409 ASSERT_EQUALS (size1,size2);
413 @SYMTestCaseID GRAPHICS_COMMONHEADER_0012L
414 @SYMTestCaseDesc Invalid preferred version causes panic
418 @SYMTestPurpose An invalid version will cause a panic
422 @SYMTestExpectedResults
423 Should panic with DISPCONF 7
425 void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0012L()
427 TDisplayConfiguration testConfig (1);
429 //Should not get here