sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Test class for TDisplayConfiguration sl@0: // sl@0: // sl@0: sl@0: #include "tdisplayconfiguration.h" sl@0: #include sl@0: sl@0: #include "../inc/displayconfiguration.h" sl@0: sl@0: // This handles any non-member uses of the extended ASSERT_XXX macros sl@0: void TefUnitFailLeaveL() sl@0: { sl@0: sl@0: User::Leave(KErrTEFUnitFail); sl@0: } sl@0: sl@0: // Create a suite of all the tests sl@0: CTestSuite* CTestDisplayConfiguration::CreateSuiteL(const TDesC& aName) sl@0: { sl@0: SUB_SUITE_OPT(CTestDisplayConfiguration,NULL); sl@0: sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0001L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0002L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0003L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0004L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0005L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0006L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0007L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0008L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0009L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0010L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0011L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_COMMONHEADER_0012L); sl@0: sl@0: END_SUITE; sl@0: } sl@0: sl@0: // Published Tests sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0001L sl@0: @SYMTestCaseDesc TDisplayConfiguration field validation sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Check default configuration is empty sl@0: @SYMTestActions sl@0: Create an instance of TDisplayConfiguration sl@0: Check default version is size of TDisplayConfiguration sl@0: Check each member is not defined and does not change a passed in field sl@0: @SYMTestExpectedResults sl@0: Holds correct size and fields are empty sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0001L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: ASSERT_EQUALS (testConfig.Version(),(TInt)sizeof(testConfig)); sl@0: sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: sl@0: TSize size(10,11); sl@0: ASSERT_FALSE (testConfig.GetResolution(size)); sl@0: ASSERT_EQUALS (size,TSize(10,11)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0002L sl@0: @SYMTestCaseDesc Setting TDisplayConfiguration variables sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Check setting variables works correctly sl@0: @SYMTestActions sl@0: Set resolution 1 sl@0: Check resolution 1 set sl@0: Set resolution 2 sl@0: Check resolution 2 set sl@0: Set twips resolution 1 sl@0: Check twips resolution 1 set sl@0: Set twips resolution 2 sl@0: Check twips resolution 2 set sl@0: @SYMTestExpectedResults sl@0: All 'gets' return as expected sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0002L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize sizeSet1(10,11); sl@0: TSize sizeSet2(12,13); sl@0: TSize sizeCheck1(14,15); sl@0: TSize sizeCheck2(16,17); sl@0: TSize twipsSizeSet1(7620,2858); sl@0: TSize twipsSizeSet2(7630,2868); sl@0: TSize twipsSizeCheck1(7640,2878); sl@0: TSize twipsSizeCheck2(7650,2888); sl@0: sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: //Set size check sl@0: testConfig.SetResolution(sizeSet1); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_TRUE (testConfig.GetResolution(sizeCheck1)); sl@0: ASSERT_EQUALS (sizeSet1,sizeCheck1); sl@0: //Set size check 2 sl@0: testConfig.SetResolution(sizeSet2); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_TRUE (testConfig.GetResolution(sizeCheck2)); sl@0: ASSERT_EQUALS (sizeSet2,sizeCheck2); sl@0: //Set twips check sl@0: testConfig.SetResolutionTwips(twipsSizeSet1); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips)); sl@0: ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck1)); sl@0: ASSERT_EQUALS (twipsSizeSet1,twipsSizeCheck1); sl@0: //Set twips check 2 sl@0: testConfig.SetResolutionTwips(twipsSizeSet2); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolutionTwips)); sl@0: ASSERT_TRUE (testConfig.GetResolutionTwips(twipsSizeCheck2)); sl@0: ASSERT_EQUALS (twipsSizeSet2,twipsSizeCheck2); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0003L sl@0: @SYMTestCaseDesc Clearing TDisplayConfiguration variables sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Checking Clear works as expected sl@0: @SYMTestActions sl@0: Set resolution sl@0: Clear resolution sl@0: Get resolution *should do nothing* sl@0: @SYMTestExpectedResults sl@0: Clears variables as expected sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0003L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size1(10,11); sl@0: TSize size2(12,13); sl@0: TSize size2copy(size2); sl@0: sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: testConfig.SetResolution(size1); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: testConfig.Clear(TDisplayConfiguration::EResolution); sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_FALSE (testConfig.GetResolution(size2)); sl@0: //check size2 has not been changed sl@0: ASSERT_EQUALS (size2,size2copy); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0004L sl@0: @SYMTestCaseDesc Clear all TDisplayConfiguration variables sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Check ClearAll performs correctly sl@0: @SYMTestActions sl@0: Set resolution sl@0: Set color sl@0: ClearAll() sl@0: Get resolution *should do nothing* sl@0: @SYMTestExpectedResults sl@0: ClearAll should clear all! sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0004L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size1(10,11); sl@0: TSize size2(12,13); sl@0: TSize size2copy(size2); sl@0: sl@0: TRgb color1(50,255); sl@0: TRgb color2(52,255); sl@0: TRgb color2copy(color2); sl@0: sl@0: //set values sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: testConfig.SetResolution(size1); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: sl@0: testConfig.ClearAll(); sl@0: sl@0: //check cleared variables sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_FALSE (testConfig.GetResolution(size2)); sl@0: //check size2 has not been changed sl@0: ASSERT_EQUALS(size2,size2copy); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0005L sl@0: @SYMTestCaseDesc TDisplayConfiguration copy operator sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Checking copy works correctly sl@0: @SYMTestActions sl@0: Set values sl@0: Make a copy sl@0: Check copy has copied values sl@0: Make slight changes to copy, check operator== works (thorough test fo coverage) sl@0: @SYMTestExpectedResults sl@0: Should copy variables to new config sl@0: Should perform operator== correctly sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0005L() sl@0: { sl@0: TDisplayConfiguration testConfig1; sl@0: sl@0: TSize size1(10,11); sl@0: TSize size2(12,13); sl@0: TSize sizeTemp(0,1); sl@0: TDisplayConfiguration1::TRotation rotTemp = TDisplayConfiguration1::ERotationIllegal; sl@0: sl@0: testConfig1.SetResolution(size1); sl@0: testConfig1.SetResolutionTwips(size2); sl@0: testConfig1.SetRotation(TDisplayConfiguration1::ERotationNormal); sl@0: sl@0: TDisplayConfiguration testConfig2(testConfig1); sl@0: sl@0: ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_TRUE (testConfig2.GetResolution(sizeTemp)); sl@0: ASSERT_EQUALS (size1,sizeTemp); sl@0: sl@0: ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::EResolutionTwips)); sl@0: ASSERT_TRUE (testConfig2.GetResolutionTwips(sizeTemp)); sl@0: ASSERT_EQUALS (size2,sizeTemp); sl@0: sl@0: ASSERT_TRUE (testConfig2.IsDefined(TDisplayConfiguration::ERotation)); sl@0: ASSERT_TRUE (testConfig2.GetRotation(rotTemp)); sl@0: ASSERT_EQUALS (rotTemp,TDisplayConfiguration1::ERotationNormal); sl@0: sl@0: ASSERT_TRUE (testConfig1==testConfig2); sl@0: sl@0: testConfig1.Clear(TDisplayConfiguration::EResolution); sl@0: testConfig2.Clear(TDisplayConfiguration::EResolution); sl@0: testConfig1.Clear(TDisplayConfiguration::EResolutionTwips); sl@0: testConfig2.Clear(TDisplayConfiguration::EResolutionTwips); sl@0: testConfig1.Clear(TDisplayConfiguration::ERotation); sl@0: testConfig2.Clear(TDisplayConfiguration::ERotation); sl@0: sl@0: ASSERT_TRUE (testConfig1==testConfig2); sl@0: sl@0: TDisplayConfiguration largeConfig(200); sl@0: TDisplayConfiguration emptyConfig; sl@0: ASSERT_FALSE (largeConfig==emptyConfig); sl@0: ASSERT_FALSE (emptyConfig==largeConfig); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0006L sl@0: @SYMTestCaseDesc Small configs do nothing sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Older config versions should not try to access newer variables sl@0: @SYMTestActions sl@0: Create very small config sl@0: Set resolution sl@0: Get resolution *should not have set it* sl@0: @SYMTestExpectedResults sl@0: Setting when version is too old should fail silently. No returned error, no panic sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0006L() sl@0: { sl@0: TDisplayConfiguration testConfig(sizeof(TDisplayConfigurationBase)); sl@0: sl@0: TSize size1(10,11); sl@0: TSize size2(12,13); sl@0: sl@0: testConfig.SetResolution(size1); sl@0: ASSERT_FALSE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_FALSE (testConfig.GetResolution(size2)); sl@0: ASSERT_NOT_EQUALS (size1,size2); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0007L sl@0: @SYMTestCaseDesc Negative resolution panics client sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Negative resolutions are not allowed and should panic the client sl@0: @SYMTestActions sl@0: Set negative X resolution sl@0: @SYMTestExpectedResults sl@0: Should panic with DISPCONF 1 sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0007L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size(-10,10); sl@0: testConfig.SetResolution(size); sl@0: sl@0: //Should not get here sl@0: ASSERT_TRUE(0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0008L sl@0: @SYMTestCaseDesc Negative resolution panics client sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Negative resolutions are not allowed and should panic the client sl@0: @SYMTestActions sl@0: Set negative Y resolution sl@0: @SYMTestExpectedResults sl@0: Should panic with DISPCONF 1 sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0008L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size(10,-10); sl@0: testConfig.SetResolution(size); sl@0: sl@0: //Should not get here sl@0: ASSERT_TRUE(0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0009L sl@0: @SYMTestCaseDesc One resolution axis 0 panics client sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose A resolution with only 1 axis at 0 is invalid sl@0: @SYMTestActions sl@0: Set 0 on X axis only for resolution sl@0: @SYMTestExpectedResults sl@0: Should panic with DISPCONF 2 sl@0: sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0009L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size(0,10); sl@0: testConfig.SetResolution(size); sl@0: sl@0: //Should not get here sl@0: ASSERT_TRUE(0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0010L sl@0: @SYMTestCaseDesc One resolution axis 0 panics client sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose A resolution with only 1 axis at 0 is invalid sl@0: @SYMTestActions sl@0: Set 0 on Y axis only for resolution sl@0: @SYMTestExpectedResults sl@0: Should panic with DISPCONF 2 sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0010L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size(10,0); sl@0: testConfig.SetResolution(size); sl@0: sl@0: //Should not get here sl@0: ASSERT_TRUE(0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0011L sl@0: @SYMTestCaseDesc Both resolution axis 0 valid sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose A resolution with only both axis at 0 is valid sl@0: @SYMTestActions sl@0: Set 0 on both axes for resolution sl@0: @SYMTestExpectedResults sl@0: Should complete and be able to return the same size sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0011L() sl@0: { sl@0: TDisplayConfiguration testConfig; sl@0: sl@0: TSize size1(0,0); sl@0: TSize size2(1,2); sl@0: testConfig.SetResolution(size1); sl@0: ASSERT_TRUE (testConfig.IsDefined(TDisplayConfiguration::EResolution)); sl@0: ASSERT_TRUE (testConfig.GetResolution(size2)); sl@0: ASSERT_EQUALS (size1,size2); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_COMMONHEADER_0012L sl@0: @SYMTestCaseDesc Invalid preferred version causes panic sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose An invalid version will cause a panic sl@0: @SYMTestActions sl@0: Set version to be 1 sl@0: Should panic sl@0: @SYMTestExpectedResults sl@0: Should panic with DISPCONF 7 sl@0: **/ sl@0: void CTestDisplayConfiguration::GRAPHICS_COMMONHEADER_0012L() sl@0: { sl@0: TDisplayConfiguration testConfig (1); sl@0: sl@0: //Should not get here sl@0: ASSERT_TRUE(0); sl@0: }