lafagnosticuifoundation/cone/tef/tconecoecntssstep.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code.    
       
    20 */
       
    21 
       
    22 
       
    23 #include <coecntss.h>
       
    24 #include <coemain.h>
       
    25 #include <coefontprovider.h>
       
    26 #include <coefont.h>
       
    27 #include <eikenv.h>
       
    28 
       
    29 #include "tconecoecntssstep.h"
       
    30 
       
    31 	
       
    32 /**
       
    33    @SYMTestCaseID 	UIF-TConeTestApp-TestSetLogicalToPixelFontSizesL
       
    34   
       
    35    @SYMPREQ			DEF093550
       
    36   
       
    37    @SYMTestCaseDesc Tests the correct bevaciour of Set and Get LogicalToPixelFontSizes methods
       
    38   
       
    39    @SYMTestPriority High
       
    40   
       
    41    @SYMTestType : 	CIT 
       
    42 
       
    43    @SYMTestStatus 	Implemented
       
    44    
       
    45    @SYMTestActions: The tests starts by getting a copy of the default array of font pixel sizes by means of
       
    46    					a call to GetLogicalToPixelFontSizesL().
       
    47    					Different Font sizes are appended to the RArray and SetLogicalToPixelFontSizesL() function
       
    48    					is invoked, checking that the new values have been correctly added.
       
    49    					All original value are restored before finishing the test case.
       
    50   
       
    51    @SYMTestExpectedResults The Font's Size should be equal to the size that is appended.\n  
       
    52  */
       
    53 void CTConeCoeCntSSAppUi::TestGetSetLogicalToPixelFontSizesL()
       
    54 	{
       
    55 
       
    56 	INFO_PRINTF1(_L("TestGetSetLogicalToPixelFontSizesL() test case started"));
       
    57 
       
    58 	//Get a copy of the old sizes, for later restoration.
       
    59 	INFO_PRINTF1(_L("Populates a TInt array provided as a parameter with the font pixel sizes..."));
       
    60 	RArray<TInt> oldSizes;
       
    61 	CleanupClosePushL(oldSizes);
       
    62 	
       
    63 	TRAPD(ret, CCoeControlStaticSettings::GetLogicalToPixelFontSizesL(oldSizes));
       
    64 	TEST(ret == KErrNone);
       
    65 
       
    66 	INFO_PRINTF1(_L("Values of original array:"));
       
    67 	for (TInt ii=0; ii<oldSizes.Count(); ii++)
       
    68 		{
       
    69 		INFO_PRINTF3(_L("	Array[%d] = '%d'"), ii, oldSizes[ii]);
       
    70 		}		
       
    71 	
       
    72 	//Append different sizes to the array.	
       
    73 	INFO_PRINTF1(_L("Set new default array of font pixel sizes..."));
       
    74 	RArray<TInt> newSizes;
       
    75 	CleanupClosePushL(newSizes);
       
    76 
       
    77 	newSizes.AppendL(24);		// Extra Small
       
    78 	newSizes.AppendL(34);		// Small
       
    79 	newSizes.AppendL(44);		// Medium
       
    80 	newSizes.AppendL(54);		// Large
       
    81 	newSizes.AppendL(64);		// Extra Large
       
    82    
       
    83 	TRAP(ret, CCoeControlStaticSettings::SetLogicalToPixelFontSizesL(newSizes));
       
    84 	TEST(ret == KErrNone);
       
    85 	
       
    86     //Get the Zoomfactor and Font provider to obtain the fontsize and check it matches with new values.
       
    87 	TZoomFactor accZoomFactor(iCoeEnv->ScreenDevice());
       
    88 	const CCoeFontProvider& fontProvider = iCoeEnv->DefaultFontProvider();
       
    89 	
       
    90 	const CFont& font1 = fontProvider.Font(TCoeFont(TCoeFont::EExtraSmall, TCoeFont::EPlain), accZoomFactor);
       
    91 	TInt actualSize1 = font1.FontMaxHeight();
       
    92 	TEST(Rng(23, actualSize1, 24));
       
    93 
       
    94 	const CFont& font2 = fontProvider.Font(TCoeFont(TCoeFont::ESmall, TCoeFont::EPlain), accZoomFactor);
       
    95 	TInt actualSize2 = font2.FontMaxHeight();
       
    96 	TEST(Rng(33, actualSize2, 34));
       
    97 
       
    98 	const CFont& font3 = fontProvider.Font(TCoeFont(TCoeFont::EMedium, TCoeFont::EPlain), accZoomFactor);
       
    99 	TInt actualSize3 = font3.FontMaxHeight();
       
   100 	TEST(Rng(43, actualSize3, 44));
       
   101 
       
   102 	const CFont& font4 = fontProvider.Font(TCoeFont(TCoeFont::ELarge, TCoeFont::EPlain), accZoomFactor);
       
   103 	TInt actualSize4 = font4.FontMaxHeight();
       
   104 	TEST(Rng(53, actualSize4, 54));
       
   105 
       
   106 	const CFont& font5 = fontProvider.Font(TCoeFont(TCoeFont::EExtraLarge, TCoeFont::EPlain), accZoomFactor);
       
   107 	TInt actualSize5 = font5.FontMaxHeight();
       
   108 	TEST(Rng(63, actualSize5, 64));
       
   109 
       
   110 	//Print new values of the array
       
   111 	newSizes.Reset();
       
   112 	TRAP(ret, CCoeControlStaticSettings::GetLogicalToPixelFontSizesL(newSizes));
       
   113 	TEST(ret == KErrNone);
       
   114 
       
   115 	INFO_PRINTF1(_L("Values of new array:"));
       
   116 	for (TInt jj=0; jj<newSizes.Count(); jj++)
       
   117 		{
       
   118 		INFO_PRINTF3(_L("	Array[%d] = '%d'"), jj, newSizes[jj]);
       
   119 		}		
       
   120 
       
   121 	//Restoring original values
       
   122 	INFO_PRINTF1(_L("Restoring original values..."));
       
   123 	TRAP(ret, CCoeControlStaticSettings::SetLogicalToPixelFontSizesL(oldSizes));
       
   124 	TEST(ret == KErrNone);
       
   125 	
       
   126 	//clean-up
       
   127 	CleanupStack::PopAndDestroy(2, &oldSizes);
       
   128 	}
       
   129 
       
   130 
       
   131 void CTConeCoeCntSSAppUi::RunTestStepL(TInt aStepNum)
       
   132 	{
       
   133 	switch(aStepNum)
       
   134 		{
       
   135 		case 1:
       
   136 			{
       
   137 			SetTestStepID(_L("UIF-TConeTestApp-TestSetLogicalToPixelFontSizesL"));			
       
   138 			TRAPD(ret, TestGetSetLogicalToPixelFontSizesL());
       
   139 			TEST(ret == KErrNone);
       
   140 			INFO_PRINTF2(_L("TestSetLogicalToPixelFontSizesL() finished with code '%d'"), ret);
       
   141 			RecordTestResultL();	
       
   142 			CloseTMSGraphicsStep();
       
   143 			}
       
   144 			break;
       
   145 
       
   146 		default:
       
   147 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   148 			break;
       
   149 		}
       
   150 	}
       
   151 
       
   152 
       
   153 void CTConeCoeCntSSAppUi::ConstructL()
       
   154 	{
       
   155 	CTestCoeAppUi::ConstructL();
       
   156 	AutoTestManager().StartAutoTest();	
       
   157 	}
       
   158 
       
   159 CTConeCoeCntSSAppUi::CTConeCoeCntSSAppUi(CTmsTestStep* aStep) :
       
   160 	CTestCoeAppUi(aStep)
       
   161 	{
       
   162 	}
       
   163 
       
   164 CTConeCoeCntSSAppUi::~CTConeCoeCntSSAppUi()
       
   165 	{
       
   166 	}
       
   167 
       
   168 
       
   169 //----------
       
   170 
       
   171 void CTConeCoeCntSSStep::ConstructAppL(CCoeEnv* aCoe)
       
   172 	{ // runs inside a TRAP harness
       
   173 	aCoe->ConstructL();
       
   174 	CTConeCoeCntSSAppUi* appUi= new (ELeave) CTConeCoeCntSSAppUi(this);
       
   175 	aCoe->SetAppUi(appUi);
       
   176 	appUi->ConstructL();
       
   177 	}
       
   178 
       
   179 
       
   180 CTConeCoeCntSSStep::CTConeCoeCntSSStep()
       
   181 	{
       
   182 	SetTestStepName(KTConeCoeCntSSStep);
       
   183 	}
       
   184 
       
   185 CTConeCoeCntSSStep::~CTConeCoeCntSSStep()
       
   186 	{
       
   187 	}
       
   188 
       
   189 TVerdict CTConeCoeCntSSStep::doTestStepL()
       
   190 	{
       
   191 	INFO_PRINTF1(_L("Testing of CoeContolStaticSettings started..."));
       
   192 	
       
   193 	PreallocateHALBuffer();
       
   194 
       
   195 	__UHEAP_MARK;
       
   196 	CCoeEnv* coe=new(ELeave) CCoeEnv;
       
   197 	TRAPD(err,ConstructAppL(coe));
       
   198 
       
   199 	if (!err)
       
   200 		coe->ExecuteD();
       
   201 	else
       
   202 		{
       
   203 		SetTestStepResult(EFail);
       
   204 		delete coe;
       
   205 		}
       
   206 	
       
   207 	REComSession::FinalClose();	
       
   208 	__UHEAP_MARKEND;
       
   209 
       
   210 	INFO_PRINTF1(_L("...testing of CoeContolStaticSettings finished!"));
       
   211 	return TestStepResult();
       
   212 	}