os/graphics/graphicsdeviceinterface/bitgdi/tbit/tmultiplescreens.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/tmultiplescreens.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,210 @@
     1.4 +// Copyright (c) 2010 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 +//
    1.18 +
    1.19 +#include <hal.h>
    1.20 +#include <graphics/gdi/gdiconsts.h>
    1.21 +#include "tmultiplescreens.h"
    1.22 +
    1.23 +CTMultipleScreens::CTMultipleScreens(CTestStep* aStep):
    1.24 +	CTGraphicsBase(aStep),
    1.25 +	iScrDev(NULL),
    1.26 +	iGc(NULL)
    1.27 +	{
    1.28 +	}
    1.29 +
    1.30 +CTMultipleScreens::~CTMultipleScreens()
    1.31 +	{
    1.32 +	DestroyFont();
    1.33 +	DeleteGraphicsContext();
    1.34 +	DeleteScreenDevice();
    1.35 +	}
    1.36 +
    1.37 +void CTMultipleScreens::ConstructL()
    1.38 +	{
    1.39 +	}
    1.40 +
    1.41 +void CTMultipleScreens::RunTestCaseL(TInt aCurTestCase)
    1.42 +	{
    1.43 +	((CTMultipleScreensStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    1.44 +	_LIT(KTest1,"SubTest %d: Create multiple screens");
    1.45 +	switch(aCurTestCase)
    1.46 +		{
    1.47 +	case 1:
    1.48 +		((CTMultipleScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0072"));
    1.49 +		INFO_PRINTF2(KTest1,aCurTestCase);
    1.50 +		CreateScreenDeviceL();
    1.51 +		break;
    1.52 +	case 2:
    1.53 +		((CTMultipleScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
    1.54 +		((CTMultipleScreensStep*)iStep)->CloseTMSGraphicsStep();
    1.55 +		TestComplete();
    1.56 +		break;
    1.57 +		}
    1.58 +	((CTMultipleScreensStep*)iStep)->RecordTestResultL();
    1.59 +	}
    1.60 +
    1.61 +
    1.62 +/**
    1.63 +  @SYMTestCaseID GRAPHICS-BITGDI-0072
    1.64 + 
    1.65 +  @SYMDEF             
    1.66 +
    1.67 +  @SYMTestCaseDesc Multiple screen test
    1.68 +   
    1.69 +  @SYMTestPriority High
    1.70 +
    1.71 +  @SYMTestStatus Implemented
    1.72 +
    1.73 +  @SYMTestActions creates some screens in different modes then writes some rotated text to them and test.
    1.74 + 
    1.75 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
    1.76 +*/	
    1.77 +void CTMultipleScreens::CreateScreenDeviceL()
    1.78 +	{
    1.79 +	TDisplayMode testMode[] =  {EColor4K, EColor64K, EColor16M, EColor16MU, EColor256, EColor16MA, EColor16MAP};//tested display modes
    1.80 +	for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
    1.81 +		{
    1.82 +		TInt screenCnt = 0;
    1.83 +		TEST(HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCnt) == KErrNone);
    1.84 +		for(TInt screenNo=0;screenNo<screenCnt;++screenNo)
    1.85 +			{
    1.86 +			TInt err = CreateScrDevAndContext(screenNo, testMode[ii]);
    1.87 +			if(err == KErrNone)
    1.88 +				{
    1.89 +				DoRotateMoveTextL();
    1.90 +				}
    1.91 +			DeleteGraphicsContext();
    1.92 +			DeleteScreenDevice();
    1.93 +			}
    1.94 +		}
    1.95 +	}
    1.96 +
    1.97 +void CTMultipleScreens::DoRotateMoveTextL()
    1.98 +	{
    1.99 +	__ASSERT_ALWAYS(iScrDev, User::Invariant());
   1.100 +	__ASSERT_ALWAYS(iGc, User::Invariant());
   1.101 +	
   1.102 +	CreateFontL();
   1.103 +
   1.104 +	const CFbsBitGc::TGraphicsOrientation KOrientation[] = 
   1.105 +		{
   1.106 +		CFbsBitGc::EGraphicsOrientationNormal,
   1.107 +		CFbsBitGc::EGraphicsOrientationRotated90,
   1.108 +		CFbsBitGc::EGraphicsOrientationRotated180,
   1.109 +		CFbsBitGc::EGraphicsOrientationRotated270
   1.110 +		};
   1.111 +
   1.112 +	for(TInt ii=0;ii<TInt(sizeof(KOrientation)/sizeof(KOrientation[0]));++ii)
   1.113 +		{
   1.114 +		if(!iGc->SetOrientation(KOrientation[ii]))
   1.115 +			{
   1.116 +			continue;
   1.117 +			}
   1.118 +		_LIT(KRotation,"===EOrientation%S===");
   1.119 +		INFO_PRINTF2(KRotation,&RotationName(KOrientation[ii]));
   1.120 +
   1.121 +		TSize size = iScrDev->SizeInPixels();
   1.122 +		RDebug::Print(_L("Size: %d, %d\r\n"), size.iWidth, size.iHeight);
   1.123 +		for(TInt x=-40;x<(size.iWidth+30);x+=27)
   1.124 +			{
   1.125 +			for(TInt y=-40;y<(size.iHeight+30);y+=23)
   1.126 +				{
   1.127 +				iGc->Clear();
   1.128 +				iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.129 +				iGc->SetPenColor(TRgb(0x00, 0x00, 0x00));
   1.130 +				iGc->SetPenSize(TSize(1, 1));
   1.131 +				
   1.132 +				iGc->DrawText(_L("Test text"), TPoint(x, y));
   1.133 +				
   1.134 +				iScrDev->Update();
   1.135 +				}
   1.136 +			}
   1.137 +		}
   1.138 +	iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
   1.139 +	DestroyFont();
   1.140 +	}
   1.141 +
   1.142 +
   1.143 +TInt CTMultipleScreens::CreateScrDevAndContext(TInt aScreenNo, TDisplayMode aDisplayMode)
   1.144 +	{
   1.145 +	DeleteGraphicsContext();
   1.146 +	DeleteScreenDevice();
   1.147 +	TRAPD(err, iScrDev = CFbsScreenDevice::NewL(aScreenNo, aDisplayMode));
   1.148 +	if ( !iScrDev )
   1.149 +		{
   1.150 +		TESTE( err == KErrNotSupported, err );
   1.151 +		return err;
   1.152 +		}
   1.153 +	TEST(err == KErrNone);
   1.154 +	TEST(iScrDev->ScreenNo() == aScreenNo);
   1.155 +	err = iScrDev->CreateContext((CGraphicsContext*&)iGc);
   1.156 +	if ( !iGc )
   1.157 +		{
   1.158 +		return err;
   1.159 +		}
   1.160 +	TEST(err == KErrNone);
   1.161 +	iGc->SetUserDisplayMode(aDisplayMode);
   1.162 +	iScrDev->ChangeScreenDevice(NULL);
   1.163 +	iScrDev->SetAutoUpdate(EFalse);
   1.164 +	return err;
   1.165 +	}
   1.166 +
   1.167 +TInt CTMultipleScreens::CreateScrDevAndContext(TDisplayMode aDisplayMode)
   1.168 +	{
   1.169 +	return CreateScrDevAndContext(KDefaultScreenNo,aDisplayMode);
   1.170 +	}
   1.171 +
   1.172 +void CTMultipleScreens::DeleteScreenDevice()
   1.173 +	{
   1.174 +	delete iScrDev;
   1.175 +	iScrDev = NULL;
   1.176 +	}
   1.177 +
   1.178 +void CTMultipleScreens::DeleteGraphicsContext()
   1.179 +	{
   1.180 +	delete iGc;
   1.181 +	iGc = NULL;
   1.182 +	}
   1.183 +
   1.184 +void CTMultipleScreens::CreateFontL()
   1.185 +	{
   1.186 +	CFbsFont* font = NULL;
   1.187 +	TFontSpec fs(_L("Swiss"), 12);
   1.188 +	User::LeaveIfError(iScrDev->GetNearestFontToDesignHeightInPixels(font, fs));
   1.189 +	iGc->UseFont(font);
   1.190 +	}
   1.191 +
   1.192 +void CTMultipleScreens::DestroyFont()
   1.193 +	{
   1.194 +	if(iGc)
   1.195 +		{
   1.196 +		iGc->DiscardFont();
   1.197 +		}
   1.198 +	}
   1.199 +
   1.200 +
   1.201 +//
   1.202 +
   1.203 +
   1.204 +//--------------
   1.205 +__CONSTRUCT_STEP__(MultipleScreens)
   1.206 +
   1.207 +void CTMultipleScreensStep::TestSetupL()
   1.208 +	{
   1.209 +	}
   1.210 +	
   1.211 +void CTMultipleScreensStep::TestClose()
   1.212 +	{
   1.213 +	}