os/graphics/graphicsutils/commongraphicsheaders/test/src/tdisplayconfiguration.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsutils/commongraphicsheaders/test/src/tdisplayconfiguration.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,431 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Test class for TDisplayConfiguration
1.18 +//
1.19 +//
1.20 +
1.21 +#include "tdisplayconfiguration.h"
1.22 +#include <test/extendtef.h>
1.23 +
1.24 +#include "../inc/displayconfiguration.h"
1.25 +
1.26 +// This handles any non-member uses of the extended ASSERT_XXX macros
1.27 +void TefUnitFailLeaveL()
1.28 + {
1.29 +
1.30 + User::Leave(KErrTEFUnitFail);
1.31 + }
1.32 +
1.33 +// Create a suite of all the tests
1.34 +CTestSuite* CTestDisplayConfiguration::CreateSuiteL(const TDesC& aName)
1.35 + {
1.36 + SUB_SUITE_OPT(CTestDisplayConfiguration,NULL);
1.37 +
1.38 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0001L);
1.39 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0002L);
1.40 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0003L);
1.41 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0004L);
1.42 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0005L);
1.43 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0006L);
1.44 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0007L);
1.45 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0008L);
1.46 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0009L);
1.47 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0010L);
1.48 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0011L);
1.49 + ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0012L);
1.50 +
1.51 + END_SUITE;
1.52 + }
1.53 +
1.54 +// Published Tests
1.55 +
1.56 +/**
1.57 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0001L
1.58 +@SYMTestCaseDesc TDisplayConfiguration field validation
1.59 +@SYMREQ REQ10325
1.60 +@SYMPREQ PREQ2102
1.61 +@SYMTestType CT
1.62 +@SYMTestPurpose Check default configuration is empty
1.63 +@SYMTestActions
1.64 + Create an instance of TDisplayConfiguration
1.65 + Check default version is size of TDisplayConfiguration
1.66 + Check each member is not defined and does not change a passed in field
1.67 +@SYMTestExpectedResults
1.68 + Holds correct size and fields are empty
1.69 +**/
1.70 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0001L()
1.71 + {
1.72 + TDisplayConfiguration testConfig;
1.73 +
1.74 + ASSERT_EQUALS (testConfig.Version(),(TInt)sizeof(testConfig));
1.75 +
1.76 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.77 +
1.78 + TSize size(10,11);
1.79 + ASSERT_FALSE (testConfig.GetResolution(size));
1.80 + ASSERT_EQUALS (size,TSize(10,11));
1.81 + }
1.82 +
1.83 +/**
1.84 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0002L
1.85 +@SYMTestCaseDesc Setting TDisplayConfiguration variables
1.86 +@SYMREQ REQ10325
1.87 +@SYMPREQ PREQ2102
1.88 +@SYMTestType CT
1.89 +@SYMTestPurpose Check setting variables works correctly
1.90 +@SYMTestActions
1.91 + Set resolution 1
1.92 + Check resolution 1 set
1.93 + Set resolution 2
1.94 + Check resolution 2 set
1.95 + Set twips resolution 1
1.96 + Check twips resolution 1 set
1.97 + Set twips resolution 2
1.98 + Check twips resolution 2 set
1.99 +@SYMTestExpectedResults
1.100 + All 'gets' return as expected
1.101 +**/
1.102 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0002L()
1.103 + {
1.104 + TDisplayConfiguration testConfig;
1.105 +
1.106 + TSize sizeSet1(10,11);
1.107 + TSize sizeSet2(12,13);
1.108 + TSize sizeCheck1(14,15);
1.109 + TSize sizeCheck2(16,17);
1.110 + TSize twipsSizeSet1(7620,2858);
1.111 + TSize twipsSizeSet2(7630,2868);
1.112 + TSize twipsSizeCheck1(7640,2878);
1.113 + TSize twipsSizeCheck2(7650,2888);
1.114 +
1.115 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.116 + //Set size check
1.117 + testConfig.SetResolution(sizeSet1);
1.118 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.119 + ASSERT_TRUE (testConfig.GetResolution(sizeCheck1));
1.120 + ASSERT_EQUALS (sizeSet1,sizeCheck1);
1.121 + //Set size check 2
1.122 + testConfig.SetResolution(sizeSet2);
1.123 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.124 + ASSERT_TRUE (testConfig.GetResolution(sizeCheck2));
1.125 + ASSERT_EQUALS (sizeSet2,sizeCheck2);
1.126 + //Set twips check
1.127 + testConfig.SetResolutionTwips(twipsSizeSet1);
1.128 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips));
1.129 + ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck1));
1.130 + ASSERT_EQUALS (twipsSizeSet1,twipsSizeCheck1);
1.131 + //Set twips check 2
1.132 + testConfig.SetResolutionTwips(twipsSizeSet2);
1.133 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips));
1.134 + ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck2));
1.135 + ASSERT_EQUALS (twipsSizeSet2,twipsSizeCheck2);
1.136 + }
1.137 +
1.138 +/**
1.139 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0003L
1.140 +@SYMTestCaseDesc Clearing TDisplayConfiguration variables
1.141 +@SYMREQ REQ10325
1.142 +@SYMPREQ PREQ2102
1.143 +@SYMTestType CT
1.144 +@SYMTestPurpose Checking Clear works as expected
1.145 +@SYMTestActions
1.146 + Set resolution
1.147 + Clear resolution
1.148 + Get resolution *should do nothing*
1.149 +@SYMTestExpectedResults
1.150 + Clears variables as expected
1.151 +**/
1.152 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0003L()
1.153 + {
1.154 + TDisplayConfiguration testConfig;
1.155 +
1.156 + TSize size1(10,11);
1.157 + TSize size2(12,13);
1.158 + TSize size2copy(size2);
1.159 +
1.160 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.161 + testConfig.SetResolution(size1);
1.162 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.163 + testConfig.Clear(TDisplayConfiguration::EResolution);
1.164 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.165 + ASSERT_FALSE (testConfig.GetResolution(size2));
1.166 + //check size2 has not been changed
1.167 + ASSERT_EQUALS (size2,size2copy);
1.168 + }
1.169 +
1.170 +/**
1.171 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0004L
1.172 +@SYMTestCaseDesc Clear all TDisplayConfiguration variables
1.173 +@SYMREQ REQ10325
1.174 +@SYMPREQ PREQ2102
1.175 +@SYMTestType CT
1.176 +@SYMTestPurpose Check ClearAll performs correctly
1.177 +@SYMTestActions
1.178 + Set resolution
1.179 + Set color
1.180 + ClearAll()
1.181 + Get resolution *should do nothing*
1.182 +@SYMTestExpectedResults
1.183 + ClearAll should clear all!
1.184 +**/
1.185 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0004L()
1.186 + {
1.187 + TDisplayConfiguration testConfig;
1.188 +
1.189 + TSize size1(10,11);
1.190 + TSize size2(12,13);
1.191 + TSize size2copy(size2);
1.192 +
1.193 + TRgb color1(50,255);
1.194 + TRgb color2(52,255);
1.195 + TRgb color2copy(color2);
1.196 +
1.197 + //set values
1.198 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.199 + testConfig.SetResolution(size1);
1.200 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.201 +
1.202 + testConfig.ClearAll();
1.203 +
1.204 + //check cleared variables
1.205 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.206 + ASSERT_FALSE (testConfig.GetResolution(size2));
1.207 + //check size2 has not been changed
1.208 + ASSERT_EQUALS(size2,size2copy);
1.209 + }
1.210 +
1.211 +/**
1.212 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0005L
1.213 +@SYMTestCaseDesc TDisplayConfiguration copy operator
1.214 +@SYMREQ REQ10325
1.215 +@SYMPREQ PREQ2102
1.216 +@SYMTestType CT
1.217 +@SYMTestPurpose Checking copy works correctly
1.218 +@SYMTestActions
1.219 + Set values
1.220 + Make a copy
1.221 + Check copy has copied values
1.222 + Make slight changes to copy, check operator== works (thorough test fo coverage)
1.223 +@SYMTestExpectedResults
1.224 + Should copy variables to new config
1.225 + Should perform operator== correctly
1.226 +**/
1.227 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0005L()
1.228 + {
1.229 + TDisplayConfiguration testConfig1;
1.230 +
1.231 + TSize size1(10,11);
1.232 + TSize size2(12,13);
1.233 + TSize sizeTemp(0,1);
1.234 + TDisplayConfiguration1::TRotation rotTemp = TDisplayConfiguration1::ERotationIllegal;
1.235 +
1.236 + testConfig1.SetResolution(size1);
1.237 + testConfig1.SetResolutionTwips(size2);
1.238 + testConfig1.SetRotation(TDisplayConfiguration1::ERotationNormal);
1.239 +
1.240 + TDisplayConfiguration testConfig2(testConfig1);
1.241 +
1.242 + ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolution));
1.243 + ASSERT_TRUE (testConfig2.GetResolution(sizeTemp));
1.244 + ASSERT_EQUALS (size1,sizeTemp);
1.245 +
1.246 + ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolutionTwips));
1.247 + ASSERT_TRUE (testConfig2.GetResolutionTwips(sizeTemp));
1.248 + ASSERT_EQUALS (size2,sizeTemp);
1.249 +
1.250 + ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::ERotation));
1.251 + ASSERT_TRUE (testConfig2.GetRotation(rotTemp));
1.252 + ASSERT_EQUALS (rotTemp,TDisplayConfiguration1::ERotationNormal);
1.253 +
1.254 + ASSERT_TRUE (testConfig1==testConfig2);
1.255 +
1.256 + testConfig1.Clear(TDisplayConfiguration::EResolution);
1.257 + testConfig2.Clear(TDisplayConfiguration::EResolution);
1.258 + testConfig1.Clear(TDisplayConfiguration::EResolutionTwips);
1.259 + testConfig2.Clear(TDisplayConfiguration::EResolutionTwips);
1.260 + testConfig1.Clear(TDisplayConfiguration::ERotation);
1.261 + testConfig2.Clear(TDisplayConfiguration::ERotation);
1.262 +
1.263 + ASSERT_TRUE (testConfig1==testConfig2);
1.264 +
1.265 + TDisplayConfiguration largeConfig(200);
1.266 + TDisplayConfiguration emptyConfig;
1.267 + ASSERT_FALSE (largeConfig==emptyConfig);
1.268 + ASSERT_FALSE (emptyConfig==largeConfig);
1.269 + }
1.270 +
1.271 +/**
1.272 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0006L
1.273 +@SYMTestCaseDesc Small configs do nothing
1.274 +@SYMREQ REQ10325
1.275 +@SYMPREQ PREQ2102
1.276 +@SYMTestType CT
1.277 +@SYMTestPurpose Older config versions should not try to access newer variables
1.278 +@SYMTestActions
1.279 + Create very small config
1.280 + Set resolution
1.281 + Get resolution *should not have set it*
1.282 +@SYMTestExpectedResults
1.283 + Setting when version is too old should fail silently. No returned error, no panic
1.284 +**/
1.285 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0006L()
1.286 + {
1.287 + TDisplayConfiguration testConfig(sizeof(TDisplayConfigurationBase));
1.288 +
1.289 + TSize size1(10,11);
1.290 + TSize size2(12,13);
1.291 +
1.292 + testConfig.SetResolution(size1);
1.293 + ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.294 + ASSERT_FALSE (testConfig.GetResolution(size2));
1.295 + ASSERT_NOT_EQUALS (size1,size2);
1.296 + }
1.297 +
1.298 +/**
1.299 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0007L
1.300 +@SYMTestCaseDesc Negative resolution panics client
1.301 +@SYMREQ REQ10325
1.302 +@SYMPREQ PREQ2102
1.303 +@SYMTestType CT
1.304 +@SYMTestPurpose Negative resolutions are not allowed and should panic the client
1.305 +@SYMTestActions
1.306 + Set negative X resolution
1.307 +@SYMTestExpectedResults
1.308 + Should panic with DISPCONF 1
1.309 +**/
1.310 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0007L()
1.311 + {
1.312 + TDisplayConfiguration testConfig;
1.313 +
1.314 + TSize size(-10,10);
1.315 + testConfig.SetResolution(size);
1.316 +
1.317 + //Should not get here
1.318 + ASSERT_TRUE(0);
1.319 + }
1.320 +
1.321 +/**
1.322 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0008L
1.323 +@SYMTestCaseDesc Negative resolution panics client
1.324 +@SYMREQ REQ10325
1.325 +@SYMPREQ PREQ2102
1.326 +@SYMTestType CT
1.327 +@SYMTestPurpose Negative resolutions are not allowed and should panic the client
1.328 +@SYMTestActions
1.329 + Set negative Y resolution
1.330 +@SYMTestExpectedResults
1.331 + Should panic with DISPCONF 1
1.332 +**/
1.333 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0008L()
1.334 + {
1.335 + TDisplayConfiguration testConfig;
1.336 +
1.337 + TSize size(10,-10);
1.338 + testConfig.SetResolution(size);
1.339 +
1.340 + //Should not get here
1.341 + ASSERT_TRUE(0);
1.342 + }
1.343 +
1.344 +/**
1.345 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0009L
1.346 +@SYMTestCaseDesc One resolution axis 0 panics client
1.347 +@SYMREQ REQ10325
1.348 +@SYMPREQ PREQ2102
1.349 +@SYMTestType CT
1.350 +@SYMTestPurpose A resolution with only 1 axis at 0 is invalid
1.351 +@SYMTestActions
1.352 + Set 0 on X axis only for resolution
1.353 +@SYMTestExpectedResults
1.354 + Should panic with DISPCONF 2
1.355 +
1.356 +**/
1.357 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0009L()
1.358 + {
1.359 + TDisplayConfiguration testConfig;
1.360 +
1.361 + TSize size(0,10);
1.362 + testConfig.SetResolution(size);
1.363 +
1.364 + //Should not get here
1.365 + ASSERT_TRUE(0);
1.366 + }
1.367 +
1.368 +/**
1.369 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0010L
1.370 +@SYMTestCaseDesc One resolution axis 0 panics client
1.371 +@SYMREQ REQ10325
1.372 +@SYMPREQ PREQ2102
1.373 +@SYMTestType CT
1.374 +@SYMTestPurpose A resolution with only 1 axis at 0 is invalid
1.375 +@SYMTestActions
1.376 + Set 0 on Y axis only for resolution
1.377 +@SYMTestExpectedResults
1.378 + Should panic with DISPCONF 2
1.379 +**/
1.380 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0010L()
1.381 + {
1.382 + TDisplayConfiguration testConfig;
1.383 +
1.384 + TSize size(10,0);
1.385 + testConfig.SetResolution(size);
1.386 +
1.387 + //Should not get here
1.388 + ASSERT_TRUE(0);
1.389 + }
1.390 +
1.391 +/**
1.392 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0011L
1.393 +@SYMTestCaseDesc Both resolution axis 0 valid
1.394 +@SYMREQ REQ10325
1.395 +@SYMPREQ PREQ2102
1.396 +@SYMTestType CT
1.397 +@SYMTestPurpose A resolution with only both axis at 0 is valid
1.398 +@SYMTestActions
1.399 + Set 0 on both axes for resolution
1.400 +@SYMTestExpectedResults
1.401 + Should complete and be able to return the same size
1.402 +**/
1.403 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0011L()
1.404 + {
1.405 + TDisplayConfiguration testConfig;
1.406 +
1.407 + TSize size1(0,0);
1.408 + TSize size2(1,2);
1.409 + testConfig.SetResolution(size1);
1.410 + ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution));
1.411 + ASSERT_TRUE (testConfig.GetResolution(size2));
1.412 + ASSERT_EQUALS (size1,size2);
1.413 + }
1.414 +
1.415 +/**
1.416 +@SYMTestCaseID GRAPHICS_COMMONHEADER_0012L
1.417 +@SYMTestCaseDesc Invalid preferred version causes panic
1.418 +@SYMREQ REQ10325
1.419 +@SYMPREQ PREQ2102
1.420 +@SYMTestType CT
1.421 +@SYMTestPurpose An invalid version will cause a panic
1.422 +@SYMTestActions
1.423 + Set version to be 1
1.424 + Should panic
1.425 +@SYMTestExpectedResults
1.426 + Should panic with DISPCONF 7
1.427 +**/
1.428 +void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0012L()
1.429 + {
1.430 + TDisplayConfiguration testConfig (1);
1.431 +
1.432 + //Should not get here
1.433 + ASSERT_TRUE(0);
1.434 + }