os/graphics/windowing/windowserver/test/t_integ/src/t_winutils.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_winutils.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,134 @@
     1.4 +// Copyright (c) 2007-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 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent
    1.23 +*/
    1.24 +
    1.25 +#include <hal.h>
    1.26 +#include "t_winutils.h"
    1.27 +#include "t_pseudoapputils.h"
    1.28 +
    1.29 +EXPORT_C CTestBitmap* CTestBitmap::NewLC(const TSize& aSizeInPixels, TDisplayMode aDispMode)
    1.30 +	{
    1.31 +	return NewLC(0, aSizeInPixels, aDispMode);
    1.32 +	}
    1.33 +
    1.34 +EXPORT_C CTestBitmap* CTestBitmap::NewL(const TSize& aSizeInPixels, TDisplayMode aDispMode)
    1.35 +	{
    1.36 +	CTestBitmap* self = NewLC(0, aSizeInPixels, aDispMode);
    1.37 +	CleanupStack::Pop(self);
    1.38 +	return self;
    1.39 +	}
    1.40 +
    1.41 +EXPORT_C CTestBitmap* CTestBitmap::NewL(TInt aHandle)
    1.42 +	{
    1.43 +	CTestBitmap* self = NewLC(aHandle, TSize(), ENone);
    1.44 +	CleanupStack::Pop(self);
    1.45 +	return self;
    1.46 +	}
    1.47 +
    1.48 +CTestBitmap* CTestBitmap::NewLC(TInt aHandle, const TSize& aSizeInPixels, TDisplayMode aDispMode)
    1.49 +	{
    1.50 +	CTestBitmap* self = new(ELeave) CTestBitmap();
    1.51 +	CleanupStack::PushL(self);
    1.52 +	self->ConstructL(aHandle, aSizeInPixels, aDispMode);
    1.53 +	return self;
    1.54 +	}
    1.55 +
    1.56 +void CTestBitmap::ConstructL(TInt aHandle, const TSize& aSizeInPixels, TDisplayMode aDispMode)
    1.57 +	{
    1.58 +	iBitmap = new(ELeave) CFbsBitmap();
    1.59 +	CleanupStack::PushL(iBitmap);
    1.60 +
    1.61 +	if (aHandle==0)
    1.62 +		{
    1.63 +		User::LeaveIfError(iBitmap->Create(aSizeInPixels, aDispMode));
    1.64 +		}
    1.65 +	else
    1.66 +		{
    1.67 +		User::LeaveIfError(iBitmap->Duplicate(aHandle));
    1.68 +		}
    1.69 +	iDevice = CFbsBitmapDevice::NewL(iBitmap);
    1.70 +	CleanupStack::PushL(iDevice);
    1.71 +
    1.72 +	User::LeaveIfError(iDevice->CreateContext(iGc));
    1.73 +
    1.74 +	CleanupStack::Pop(2);
    1.75 +	}
    1.76 +
    1.77 +CTestBitmap::~CTestBitmap()
    1.78 +	{
    1.79 +	delete iGc;
    1.80 +	delete iDevice;
    1.81 +	delete iBitmap;
    1.82 +	}
    1.83 +
    1.84 +EXPORT_C void TImportPseudoAppConfig::ImportPseudoAppConfigL(TInt aScreenNo, TInt& aFrameDuration, TInt& aFrameDelay,
    1.85 +                                                             TDisplayMode& aMode, TSize& aScreenSize, CIniData* aUtils)
    1.86 +	{
    1.87 +	TInt screenMode;
    1.88 +	TInt numberOfScreens;
    1.89 +	TPtrC screenAspectRatio;
    1.90 +	TInt screenNumber;
    1.91 +
    1.92 +	READ_INI1(frame_duration, aFrameDuration, aUtils);
    1.93 +	READ_INI1(screen_aspect_ratio, screenAspectRatio, aUtils);
    1.94 +	READ_INI1(number_of_screens, numberOfScreens, aUtils);
    1.95 +	READ_INI1(frame_delay, aFrameDelay, aUtils);
    1.96 +	READ_INI2(screen_mode, EColor16MA, EColor64K, screenMode, EColor16MA, EColor64K, aUtils);
    1.97 +
    1.98 +	aMode = static_cast<TDisplayMode>(screenMode);
    1.99 +
   1.100 +	//Determine the number of screens from the hardware and compare with the value from the ini file
   1.101 +	HAL::Get(HALData::EDisplayNumberOfScreens, screenNumber);
   1.102 +	if(numberOfScreens != screenNumber)
   1.103 +		{
   1.104 +		RDebug::Print(_L("Error: A %d screen test has been indicated, but %d screen(s) exist\n"), numberOfScreens, screenNumber);
   1.105 +		}
   1.106 +
   1.107 +	//Determine the screen dimensions
   1.108 +	RWsSession session;
   1.109 +	User::LeaveIfError(session.Connect());
   1.110 +
   1.111 +	CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice(session);
   1.112 +	CleanupStack::PushL(screenDevice);
   1.113 +
   1.114 +	User::LeaveIfError(screenDevice->Construct(aScreenNo));
   1.115 +
   1.116 +	aScreenSize = screenDevice->SizeInPixels();
   1.117 +
   1.118 +	//Check that the aspect ratio matches that of the screen
   1.119 +	TSize aSpectRatio;
   1.120 +
   1.121 +	if(TImportScreenConfig::ExtractAspectRatio(screenAspectRatio, aSpectRatio) == KErrNone)
   1.122 +		{
   1.123 +		if(aScreenSize.iWidth*aSpectRatio.iHeight != aScreenSize.iHeight*aSpectRatio.iWidth)
   1.124 +			{
   1.125 +			RDebug::Print(_L("Aspect ratio from string does not match screen dimensions\n"));
   1.126 +			RDebug::Print(_L("Read in %d:%d, Actual dimensions %d:%d\n"), aSpectRatio.iWidth, aSpectRatio.iHeight, aScreenSize.iWidth, aScreenSize.iHeight);
   1.127 +			}
   1.128 +		}
   1.129 +	else
   1.130 +		{
   1.131 +		RDebug::Print(_L("Cannot determine aspect ratio from string, quitting: %s\n"), screenAspectRatio.Ptr());
   1.132 +		User::Exit(0);
   1.133 +		}
   1.134 +
   1.135 +	CleanupStack::PopAndDestroy(screenDevice);
   1.136 +	session.Close();
   1.137 +	}