os/graphics/graphicsdeviceinterface/screendriver/tsrc/tscdvdevorientation.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32math.h>
sl@0
    17
#include <hal.h>
sl@0
    18
#include <bitdraw.h>
sl@0
    19
#include <bitdrawinterfaceid.h>
sl@0
    20
#include <graphics/gdi/gdiconsts.h>
sl@0
    21
#include "tscdvdevorientation.h"
sl@0
    22
sl@0
    23
void AutoPanic(TInt aPanic)
sl@0
    24
	{
sl@0
    25
	User::Panic(_L("Auto"),aPanic);
sl@0
    26
	}
sl@0
    27
sl@0
    28
LOCAL_C TInt PanicThreadFunc(TAny *aPointerToAny)
sl@0
    29
	{
sl@0
    30
	CTrapCleanup* CleanUpStack=CTrapCleanup::New();
sl@0
    31
	SPanicParams *pointerPanicParams=(SPanicParams *)aPointerToAny;
sl@0
    32
	TInt ret;
sl@0
    33
	TRAP(ret,(*pointerPanicParams->functionName)(*pointerPanicParams->pointerDeviceOrientation,*pointerPanicParams->pointerDisplayMode,*pointerPanicParams->pointerScreenNo));
sl@0
    34
	delete CleanUpStack;
sl@0
    35
	if (ret==EWsExitReasonBad)
sl@0
    36
		AutoPanic(EAutoPanicPanicFailed);
sl@0
    37
	return(ret);
sl@0
    38
	}
sl@0
    39
sl@0
    40
CPanicTest::CPanicTest()
sl@0
    41
	{
sl@0
    42
	
sl@0
    43
	}
sl@0
    44
	
sl@0
    45
CPanicTest::~CPanicTest()
sl@0
    46
	{
sl@0
    47
	
sl@0
    48
	}
sl@0
    49
TInt CPanicTest::LaunchPanicThread(RThread &aThread, SPanicParams *aPointerPanicParams)
sl@0
    50
	{
sl@0
    51
	TBuf<32> threadName;
sl@0
    52
	threadName.Format(TRefByValue<const TDesC>(_L("AutoPanicThread%d")),iThreadNumber++);
sl@0
    53
	return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPointerPanicParams,EOwnerThread));
sl@0
    54
	}
sl@0
    55
sl@0
    56
TInt CPanicTest::TestPanicL(SPanicParams *aPointerPanicParams, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished)
sl@0
    57
	{
sl@0
    58
	RThread thread;
sl@0
    59
	TRequestStatus stat;
sl@0
    60
	TInt err=LaunchPanicThread(thread, aPointerPanicParams);
sl@0
    61
	if (err==KErrAlreadyExists)
sl@0
    62
		{
sl@0
    63
		// wait for kernel to clear up old threads
sl@0
    64
		// and have several attempts at starting the thread
sl@0
    65
		// if unsuccessful the first time
sl@0
    66
		for (TInt i=0;i<3;i++)
sl@0
    67
			{
sl@0
    68
			User::After(TTimeIntervalMicroSeconds32(100000));		//0.1 secs
sl@0
    69
			err=LaunchPanicThread(thread, aPointerPanicParams);
sl@0
    70
			if (err!=KErrAlreadyExists)
sl@0
    71
				break;
sl@0
    72
			}
sl@0
    73
		}
sl@0
    74
	User::LeaveIfError(err);
sl@0
    75
	thread.Logon(stat);
sl@0
    76
	User::SetJustInTime(EFalse);
sl@0
    77
	thread.Resume();
sl@0
    78
	User::WaitForRequest(stat);
sl@0
    79
	User::SetJustInTime(ETrue);
sl@0
    80
sl@0
    81
	TBool testFinished=EFalse;
sl@0
    82
	TBool testPassed=EFalse;
sl@0
    83
	if (thread.ExitType()==EExitPanic)	   // the function is panicked
sl@0
    84
		{
sl@0
    85
		// ignore code for transparency
sl@0
    86
		if(aExitReason == thread.ExitReason())  // panic reason is equal to the scdv EScreenDriverPanicInvalidParameter
sl@0
    87
			{
sl@0
    88
			testPassed=ETrue;
sl@0
    89
  			}
sl@0
    90
		iActualPanicCode=thread.ExitReason();
sl@0
    91
		testFinished=ETrue;	// Finish tests
sl@0
    92
		}
sl@0
    93
	else
sl@0
    94
		{
sl@0
    95
		if((thread.ExitCategory().Compare(aCategory)!=0)
sl@0
    96
		|| (thread.ExitReason()!=aExitReason)
sl@0
    97
		|| (thread.ExitType()!=EExitPanic)		//This last condition is always true!!!!!!
sl@0
    98
			)
sl@0
    99
			{
sl@0
   100
			testPassed=EFalse;
sl@0
   101
			}			
sl@0
   102
		iActualPanicCode=0;
sl@0
   103
		}
sl@0
   104
sl@0
   105
	if(aTestFinished)
sl@0
   106
		*aTestFinished=testFinished;
sl@0
   107
	thread.Close();
sl@0
   108
	return(testPassed);
sl@0
   109
	}
sl@0
   110
sl@0
   111
TInt CPanicTest::TestInvalidModePanicL(TPanicFunction aFunction, TScreenDriverPanic aExitReason,TDisplayMode* aPointerDispMode, TDeviceOrientation* aPointerDevOrientation,TInt* aPtrScreenNo, TBool* aTestFinished)
sl@0
   112
	{
sl@0
   113
	// function name, exit reason, and parameters
sl@0
   114
	return TestPanicL(aFunction,aExitReason,KSCDVPanicCategory, aPointerDispMode, aPointerDevOrientation, aPtrScreenNo, aTestFinished);
sl@0
   115
	}
sl@0
   116
	
sl@0
   117
TInt CPanicTest::TestPanicL(TPanicFunction aFunction, TInt aExitReason, const TDesC &aCategory, TDisplayMode* aPointerDispMode, TDeviceOrientation* aPointerDevOrientation,TInt* aPtrScreenNo, TBool* aTestFinished)
sl@0
   118
	{
sl@0
   119
	SPanicParams params;
sl@0
   120
	params.functionName=aFunction;
sl@0
   121
	params.pointerDeviceOrientation = aPointerDevOrientation;
sl@0
   122
	params.pointerDisplayMode = aPointerDispMode;
sl@0
   123
	params.pointerScreenNo = aPtrScreenNo;
sl@0
   124
	return TestPanicL(&params, aExitReason, aCategory, aTestFinished);
sl@0
   125
	}
sl@0
   126
sl@0
   127
sl@0
   128
//
sl@0
   129
//Test code
sl@0
   130
//
sl@0
   131
sl@0
   132
CTDevOrientation::CTDevOrientation(CTestStep *aTest, RArray<TInt> aArrayDispModes) :
sl@0
   133
				CTGraphicsBase(aTest),iArrayDispModesPerScreen(aArrayDispModes)
sl@0
   134
	{
sl@0
   135
	INFO_PRINTF1(_L("Screen Device Orientation tests"));
sl@0
   136
	}
sl@0
   137
sl@0
   138
CTDevOrientation::CTDevOrientation(CTestStep *aTest) :
sl@0
   139
				CTGraphicsBase(aTest)
sl@0
   140
	{
sl@0
   141
	INFO_PRINTF1(_L("Screen Device Orientation tests"));
sl@0
   142
	}
sl@0
   143
sl@0
   144
void CTDevOrientation::ConstructL()	
sl@0
   145
	{
sl@0
   146
	iPanicTest = new (ELeave) CPanicTest();
sl@0
   147
	}
sl@0
   148
	
sl@0
   149
CTDevOrientation::~CTDevOrientation()
sl@0
   150
	{
sl@0
   151
	iArrayOrientation.Close();
sl@0
   152
	iArrayDispModesPerScreen.Close();
sl@0
   153
	delete iPanicTest;
sl@0
   154
	}
sl@0
   155
sl@0
   156
/**
sl@0
   157
Create the screen device and surface interface objects for the specific screen and display mode
sl@0
   158
@internalAll
sl@0
   159
@return ETrue means valid screen device and surface interface objects are created, EFalse means a leave or an error
sl@0
   160
@param aScreenNo the screen no
sl@0
   161
@param aDisplayMode the specified display mode
sl@0
   162
@param aDrawScreenDevice 
sl@0
   163
@param aSurfaceIdInterface
sl@0
   164
*/
sl@0
   165
TBool CTDevOrientation::GetSurfaceIdInterfaceL(const TInt& aScreenNo,const TDisplayMode& aDisplayMode, CFbsDrawDevice*& aDrawScreenDevice, MSurfaceId*& aSurfaceIdInterface )
sl@0
   166
	{
sl@0
   167
	
sl@0
   168
	TInt address = NULL;
sl@0
   169
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress,address));
sl@0
   170
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, iPhysSize.iWidth));
sl@0
   171
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, iPhysSize.iHeight));
sl@0
   172
	__ASSERT_DEBUG(iPhysSize.iWidth > 0 && iPhysSize.iHeight > 0 && address != NULL, User::Invariant());
sl@0
   173
sl@0
   174
   	aDrawScreenDevice = NULL;
sl@0
   175
	TRAPD(err, aDrawScreenDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDisplayMode));
sl@0
   176
sl@0
   177
	if(err == KErrNone)	  // as aDisplayMode is verified to be supported so this should be the case
sl@0
   178
		{  
sl@0
   179
		__ASSERT_ALWAYS(aDrawScreenDevice != NULL, User::Invariant());
sl@0
   180
		//Set other properties
sl@0
   181
    	aDrawScreenDevice->SetUserDisplayMode(aDisplayMode);
sl@0
   182
		aDrawScreenDevice->SetAutoUpdate(EFalse);
sl@0
   183
		if(!aSurfaceIdInterface)
sl@0
   184
			{
sl@0
   185
			err = aDrawScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (aSurfaceIdInterface));
sl@0
   186
			}
sl@0
   187
		if (err == KErrNone && aSurfaceIdInterface != NULL)
sl@0
   188
			{
sl@0
   189
			return ETrue;
sl@0
   190
			}
sl@0
   191
		else 
sl@0
   192
			{
sl@0
   193
			delete aDrawScreenDevice;
sl@0
   194
			return EFalse;
sl@0
   195
			}
sl@0
   196
		}
sl@0
   197
	else 
sl@0
   198
	 	{
sl@0
   199
	 	// Leave with error codes
sl@0
   200
	 	INFO_PRINTF2(_L("CFbsDrawDevice::NewScreenDeviceL leaves with code =%d"), err);
sl@0
   201
	 	return EFalse;
sl@0
   202
	 	}
sl@0
   203
	}
sl@0
   204
sl@0
   205
/**
sl@0
   206
Retrive the required bpp value and pixel format based on the specified display mode
sl@0
   207
@internalAll
sl@0
   208
@return ETrue means the display mode is supported
sl@0
   209
@param aDisplayMode the specified display mode
sl@0
   210
@param aBpp the required bpp value
sl@0
   211
@param aPixelFormat the required pixel format 
sl@0
   212
*/
sl@0
   213
TBool CTDevOrientation::ReqBppAndPixelFormat(TDisplayMode aDisplayMode, TInt& aBpp, TUint32& aPixelFormat)	
sl@0
   214
	{
sl@0
   215
//	aBpp = TDisplayModeUtils::NumDisplayModeBitsPerPixel(aDisplayMode);
sl@0
   216
sl@0
   217
	switch(aDisplayMode)
sl@0
   218
		{
sl@0
   219
	case EGray2:
sl@0
   220
		aPixelFormat = 0;
sl@0
   221
        aBpp = 1;
sl@0
   222
        break;
sl@0
   223
    case EGray4:
sl@0
   224
		aPixelFormat = 0;
sl@0
   225
        aBpp = 2;
sl@0
   226
        break;
sl@0
   227
    case EGray16:
sl@0
   228
    case EColor16:
sl@0
   229
		aPixelFormat = 0;
sl@0
   230
        aBpp = 4;
sl@0
   231
        break;
sl@0
   232
    case EGray256:
sl@0
   233
    case EColor256: // 8 Bpp color mode
sl@0
   234
		aPixelFormat = 0;
sl@0
   235
		aBpp = 8;
sl@0
   236
		break;
sl@0
   237
	case EColor4K:
sl@0
   238
		aPixelFormat = EUidPixelFormatXRGB_4444; //12 Bpp color mode
sl@0
   239
		aBpp = 12;
sl@0
   240
		break;
sl@0
   241
	case EColor64K: // 16 Bpp color mode
sl@0
   242
		aPixelFormat = EUidPixelFormatRGB_565;
sl@0
   243
		aBpp = 16;
sl@0
   244
		break;
sl@0
   245
	case EColor16MU:   //24 Bpp color mode
sl@0
   246
		aPixelFormat = EUidPixelFormatXRGB_8888;
sl@0
   247
		aBpp = 24;
sl@0
   248
		break;
sl@0
   249
	case EColor16MA:   // 32 Bpp color mode
sl@0
   250
		aPixelFormat = EUidPixelFormatARGB_8888;
sl@0
   251
		aBpp = 32;
sl@0
   252
		break;
sl@0
   253
	case EColor16MAP:
sl@0
   254
		aPixelFormat = EUidPixelFormatARGB_8888_PRE;
sl@0
   255
		aBpp = 32;
sl@0
   256
		break;
sl@0
   257
		default:
sl@0
   258
		return EFalse;	
sl@0
   259
		}  
sl@0
   260
	return ETrue;
sl@0
   261
	}
sl@0
   262
	
sl@0
   263
void CTDevOrientation::TestGetSurfaceWithValidDispModeL(const MSurfaceId* aSurfaceIdInterface, const TDisplayMode& aDisplayMode, TInt aScreenNo)
sl@0
   264
	{
sl@0
   265
	// Sanity check
sl@0
   266
	__ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   267
	TSurfaceId surfaceId;
sl@0
   268
	aSurfaceIdInterface->GetSurface(surfaceId);
sl@0
   269
	INFO_PRINTF1(_L("Test GetSurface() returns valid surface Id with the specified display modes"));		
sl@0
   270
	//Check the screen no
sl@0
   271
	TEST(surfaceId.iInternal[0] == aScreenNo);
sl@0
   272
	// Hal mode
sl@0
   273
	TInt halMode = surfaceId.iInternal[1];	 // 24bpp and 32bpp are currently considered the same by HAL
sl@0
   274
	User::LeaveIfError(HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode));
sl@0
   275
    TUint32 pixelFormat = 0;
sl@0
   276
    TInt bpp = 0;
sl@0
   277
    if (ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat))
sl@0
   278
    	{
sl@0
   279
    	// Check the color depth 
sl@0
   280
   		TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
sl@0
   281
		// Check the pixel format
sl@0
   282
		TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
sl@0
   283
		// Check the surface type
sl@0
   284
		TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
sl@0
   285
		}
sl@0
   286
	else
sl@0
   287
		INFO_PRINTF1(_L("Unsupported display modes"));			
sl@0
   288
	}
sl@0
   289
sl@0
   290
/**
sl@0
   291
Retrive all the availably supported device orientation modes by the hardware.
sl@0
   292
@internalAll
sl@0
   293
@return ETrue means there are valid device orientation modes supported, EFalse means no good mode supported
sl@0
   294
@param aSurfaceIdInterface MSurfaceId* 
sl@0
   295
*/
sl@0
   296
TBool CTDevOrientation::ChooseOrientationMode( MSurfaceId* aSurfaceIdInterface)
sl@0
   297
	{
sl@0
   298
	__ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   299
	TUint orAvailable = aSurfaceIdInterface->DeviceOrientationsAvailable();
sl@0
   300
	iArrayOrientation.Reset();
sl@0
   301
	if ( orAvailable <= 15 || orAvailable > 0)
sl@0
   302
		{
sl@0
   303
		if (iArrayOrientation.Count() == 0)	   // Only fills the array once
sl@0
   304
			{
sl@0
   305
			// there is at least one mode available
sl@0
   306
			// Find one availabe device orientation mode
sl@0
   307
			for (TUint32 mode = (TUint32)EDeviceOrientationNormal; mode <= (TUint)EDeviceOrientation270CW; mode*=2)
sl@0
   308
				{
sl@0
   309
				if ( orAvailable & (TDeviceOrientation)mode)
sl@0
   310
					{
sl@0
   311
					iArrayOrientation.Append((TDeviceOrientation)mode);
sl@0
   312
					}
sl@0
   313
				}
sl@0
   314
			} 
sl@0
   315
		return ETrue;
sl@0
   316
		}
sl@0
   317
	else 
sl@0
   318
		{
sl@0
   319
		// No available mode supported
sl@0
   320
		return EFalse;
sl@0
   321
		}
sl@0
   322
	}
sl@0
   323
sl@0
   324
void CTDevOrientation::TestGetDeviceOrientation( MSurfaceId* aSurfaceIdInterface)
sl@0
   325
	{
sl@0
   326
    if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
sl@0
   327
    	{
sl@0
   328
       	INFO_PRINTF1(_L("Test DeviceOrientationAvailabe() returns one or a combination of valid modes"));		
sl@0
   329
    	}
sl@0
   330
    else
sl@0
   331
       	INFO_PRINTF1(_L("Test DeviceOrientationAvailabe() gives no valid returns"));		
sl@0
   332
	}
sl@0
   333
sl@0
   334
	
sl@0
   335
void CTDevOrientation::TestDeviceOrientationSettingandGetting( MSurfaceId* aSurfaceIdInterface)
sl@0
   336
	{
sl@0
   337
	__ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   338
    if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
sl@0
   339
    	{
sl@0
   340
       	for (TInt i = 0; i < iArrayOrientation.Count(); i++)
sl@0
   341
       		{
sl@0
   342
	       	// Set the orientation
sl@0
   343
			aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]);
sl@0
   344
			INFO_PRINTF2(_L("Test SetDeviceOrientation() and GetDeviceOrientation() for DeviceOrientation Mode %d"), i);
sl@0
   345
			//Get the orientation
sl@0
   346
			TEST(iArrayOrientation[i] == aSurfaceIdInterface->DeviceOrientation());		
sl@0
   347
       		}
sl@0
   348
    	}
sl@0
   349
	else
sl@0
   350
		{
sl@0
   351
		// No avaialbe orientation modes
sl@0
   352
		INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
sl@0
   353
		}
sl@0
   354
	}
sl@0
   355
sl@0
   356
void CTDevOrientation::TestHorizontalVerticalTwips(const CFbsDrawDevice* aDrawScreenDevice,  MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode, TInt aScreenNo)
sl@0
   357
	{
sl@0
   358
    __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   359
	TInt horTwipsRef = aDrawScreenDevice->HorzTwipsPerThousandPixels();
sl@0
   360
	TInt verTwipsRef = aDrawScreenDevice->VertTwipsPerThousandPixels();
sl@0
   361
sl@0
   362
	TUint32 pixelFormat = 0;
sl@0
   363
    TInt bpp = 0;
sl@0
   364
    // Find the required color depth and pixel format based on the aDisplayMode
sl@0
   365
    TEST(ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat));
sl@0
   366
    
sl@0
   367
    TSurfaceId surfaceId;	
sl@0
   368
   	
sl@0
   369
   	if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0 )
sl@0
   370
    	{
sl@0
   371
	   	for (TInt i = 0; i < iArrayOrientation.Count(); i++)
sl@0
   372
    		{
sl@0
   373
 			// Set the orientation
sl@0
   374
			if (aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]))
sl@0
   375
				{
sl@0
   376
				// Retrieve SurfaceId to test the second bit
sl@0
   377
				aSurfaceIdInterface->GetSurface(surfaceId);
sl@0
   378
				INFO_PRINTF1(_L("CFbsDrawDevice, Retrieve the surfaceId to test whether the second bit has been modified accordingly and other bits left unchanged"));		
sl@0
   379
				//Check the values
sl@0
   380
				TEST(surfaceId.iInternal[0] == aScreenNo);
sl@0
   381
				TInt halMode = surfaceId.iInternal[1] &~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
sl@0
   382
				HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode);
sl@0
   383
		   	
sl@0
   384
				TInt horTwipsRotated = aDrawScreenDevice->HorzTwipsPerThousandPixels();
sl@0
   385
				TInt verTwipsRotated = aDrawScreenDevice->VertTwipsPerThousandPixels();
sl@0
   386
		   	
sl@0
   387
				if (iArrayOrientation[i] & (EDeviceOrientation90CW | EDeviceOrientation270CW))
sl@0
   388
					{  
sl@0
   389
					INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns swapped horizontal and vertical twip values"), i);
sl@0
   390
					TEST(horTwipsRef == verTwipsRotated);
sl@0
   391
					TEST(verTwipsRef == horTwipsRotated);
sl@0
   392
					TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) != 0); //flipped
sl@0
   393
					}
sl@0
   394
				else 
sl@0
   395
					{
sl@0
   396
					INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns no swapped horizontal and vertical twip values"), i);
sl@0
   397
					TEST(verTwipsRef == verTwipsRotated);
sl@0
   398
					TEST(horTwipsRef == horTwipsRotated);
sl@0
   399
					TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) == 0); //no flipped
sl@0
   400
					}
sl@0
   401
				// Check the color depth unchanged
sl@0
   402
 	  			TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
sl@0
   403
				TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
sl@0
   404
				TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
sl@0
   405
 				}
sl@0
   406
 			else
sl@0
   407
	    		INFO_PRINTF1(_L("No attributes have been changed after calling SetDeviceOrientation()"));
sl@0
   408
    		}
sl@0
   409
    	}
sl@0
   410
    else 
sl@0
   411
    	{
sl@0
   412
		INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
sl@0
   413
    	}
sl@0
   414
sl@0
   415
	}
sl@0
   416
	
sl@0
   417
void CTDevOrientation::TestSetDeviceOrientationWithValidMode(const CFbsDrawDevice* aDrawScreenDevice,  MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode, TInt aScreenNo)
sl@0
   418
	{
sl@0
   419
	__ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   420
	TSize sizeRef = aDrawScreenDevice->SizeInPixels();
sl@0
   421
	TSize sizeRotated;
sl@0
   422
	TUint32 pixelFormat = 0;
sl@0
   423
    TInt bpp = 0;
sl@0
   424
    // Find the required color depth and pixel format based on the aDisplayMode
sl@0
   425
    TEST(ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat));
sl@0
   426
    
sl@0
   427
    TSurfaceId surfaceId;	
sl@0
   428
   	
sl@0
   429
   	if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0 )
sl@0
   430
    	{
sl@0
   431
	   	for (TInt i = 0; i < iArrayOrientation.Count(); i++)
sl@0
   432
    		{
sl@0
   433
 			// Set the orientation
sl@0
   434
			if (aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]))
sl@0
   435
				{
sl@0
   436
				// Retrieve SurfaceId to test the second bit
sl@0
   437
				aSurfaceIdInterface->GetSurface(surfaceId);
sl@0
   438
				INFO_PRINTF1(_L("CFbsDrawDevice, Retrieve the surfaceId to test whether the second bit has been modified accordingly and other bits left unchanged"));		
sl@0
   439
				//Check the values
sl@0
   440
				TEST(surfaceId.iInternal[0] == aScreenNo);
sl@0
   441
				TInt halMode = surfaceId.iInternal[1] &~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
sl@0
   442
				HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode);
sl@0
   443
				// Retrieve the size in pixel after setting the device rotation
sl@0
   444
	  			sizeRotated = aDrawScreenDevice->SizeInPixels();
sl@0
   445
		   	
sl@0
   446
				if (iArrayOrientation[i] & (EDeviceOrientation90CW | EDeviceOrientation270CW))
sl@0
   447
					{  
sl@0
   448
					INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns swapped screen Height and Width"), i);
sl@0
   449
					TEST(sizeRef.iHeight == sizeRotated.iWidth);
sl@0
   450
					TEST(sizeRef.iWidth == sizeRotated.iHeight);
sl@0
   451
					TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) != 0); //has set to 8 ---  flipped
sl@0
   452
					}
sl@0
   453
				else 
sl@0
   454
					{
sl@0
   455
					INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns no swapped screen Height and Width"), i);
sl@0
   456
					TEST(sizeRef.iWidth == sizeRotated.iWidth);
sl@0
   457
					TEST(sizeRef.iHeight == sizeRotated.iHeight);
sl@0
   458
					TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) == 0); //has set to 0  --- no flipped
sl@0
   459
					}
sl@0
   460
				// Check the color depth unchanged
sl@0
   461
 	  			TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
sl@0
   462
				TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
sl@0
   463
				TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
sl@0
   464
				}
sl@0
   465
			else
sl@0
   466
	    		INFO_PRINTF1(_L("No attributes have been changed after calling SetDeviceOrientation()"));
sl@0
   467
    		}
sl@0
   468
    	}
sl@0
   469
    else 
sl@0
   470
    	{
sl@0
   471
		INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
sl@0
   472
    	}
sl@0
   473
	}
sl@0
   474
sl@0
   475
sl@0
   476
// THIS METHOD IS EXPECTED TO PANIC
sl@0
   477
LOCAL_C TInt DoSetDeviceOrientationWithInvalidModeL(TDeviceOrientation aOrientation, TDisplayMode aDisplayMode, TInt aScreenNo)
sl@0
   478
	{
sl@0
   479
	CFbsDrawDevice* drawScreenDevice =  NULL;
sl@0
   480
	TRAPD(err, drawScreenDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDisplayMode));
sl@0
   481
    CleanupStack::PushL(drawScreenDevice);
sl@0
   482
    if(err == KErrNone)
sl@0
   483
		{  
sl@0
   484
		__ASSERT_ALWAYS(drawScreenDevice != NULL, User::Invariant());
sl@0
   485
		//Set other properties
sl@0
   486
    	drawScreenDevice->SetUserDisplayMode(EColor16MA);
sl@0
   487
		drawScreenDevice->SetAutoUpdate(EFalse);
sl@0
   488
		MSurfaceId* surfaceIdInterface = NULL;
sl@0
   489
		err = drawScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (surfaceIdInterface));
sl@0
   490
		if (err == KErrNone)
sl@0
   491
			{
sl@0
   492
			// Currently Panics the secondary thread
sl@0
   493
			surfaceIdInterface->SetDeviceOrientation(aOrientation);
sl@0
   494
			}
sl@0
   495
		}
sl@0
   496
	else
sl@0
   497
		{
sl@0
   498
		User::LeaveIfError(err);
sl@0
   499
		}
sl@0
   500
	CleanupStack::PopAndDestroy();
sl@0
   501
	return(EWsExitReasonBad);
sl@0
   502
	}
sl@0
   503
sl@0
   504
sl@0
   505
void CTDevOrientation::TestSetDeviceOrientationWithInvalidModeL(TDisplayMode aDisplayMode)
sl@0
   506
	{
sl@0
   507
	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes -1"));
sl@0
   508
	// Invalid bit is set
sl@0
   509
    TDeviceOrientation aInvalidMode = (TDeviceOrientation)-1;
sl@0
   510
    // Check the test results in the secondary thread
sl@0
   511
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, (TDisplayMode*)&aDisplayMode, &aInvalidMode,&iCurrScreen));
sl@0
   512
sl@0
   513
   	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 0"));
sl@0
   514
    aInvalidMode = (TDeviceOrientation)0;
sl@0
   515
    // Check the test results in the secondary thread
sl@0
   516
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   517
sl@0
   518
	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 3"));
sl@0
   519
    aInvalidMode = (TDeviceOrientation)3;
sl@0
   520
    // Check the test results in the secondary thread
sl@0
   521
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter,&aDisplayMode, &aInvalidMode,&iCurrScreen));
sl@0
   522
sl@0
   523
   	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 5"));
sl@0
   524
    aInvalidMode = (TDeviceOrientation)5;
sl@0
   525
    // Check the test results in the secondary thread
sl@0
   526
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   527
sl@0
   528
	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 7"));
sl@0
   529
    aInvalidMode = (TDeviceOrientation)7;
sl@0
   530
    // Check the test results in the secondary thread
sl@0
   531
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   532
sl@0
   533
	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 9"));
sl@0
   534
    aInvalidMode = (TDeviceOrientation)9;
sl@0
   535
    // Check the test results in the secondary thread
sl@0
   536
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   537
    
sl@0
   538
   	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 15"));
sl@0
   539
    aInvalidMode = (TDeviceOrientation)15;
sl@0
   540
    // Check the test results in the secondary thread
sl@0
   541
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   542
sl@0
   543
   	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 16"));
sl@0
   544
    aInvalidMode = (TDeviceOrientation)16;
sl@0
   545
    // Check the test results in the secondary thread
sl@0
   546
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter,&aDisplayMode, &aInvalidMode,&iCurrScreen));
sl@0
   547
sl@0
   548
	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 17"));
sl@0
   549
  	aInvalidMode = (TDeviceOrientation)17;
sl@0
   550
    // Check the test results in the secondary thread
sl@0
   551
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   552
sl@0
   553
   	INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 32"));
sl@0
   554
  	aInvalidMode = (TDeviceOrientation)32;
sl@0
   555
    // Check the test results in the secondary thread
sl@0
   556
	TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
sl@0
   557
sl@0
   558
	}
sl@0
   559
sl@0
   560
void CTDevOrientation::TestValidButUnavailableOrientationL(MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode)
sl@0
   561
	{
sl@0
   562
sl@0
   563
	__ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
sl@0
   564
    if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
sl@0
   565
    	{// Find a valid but unavailable device orientation
sl@0
   566
    	if (iArrayOrientation.Count() ==4)
sl@0
   567
    		{
sl@0
   568
			INFO_PRINTF1(_L("All four possible device orientation modes are supported"));
sl@0
   569
    		}
sl@0
   570
    	else
sl@0
   571
    		{ // There must be one valid but unsupported display  modes
sl@0
   572
    		RArray<TDeviceOrientation> arrayValidUnsupOrientation;
sl@0
   573
    		CleanupClosePushL(arrayValidUnsupOrientation); 
sl@0
   574
    		
sl@0
   575
    		for (TUint32 mode = (TUint32)EDeviceOrientationNormal; mode <= (TUint32)EDeviceOrientation270CW; mode *= 2)
sl@0
   576
    			{
sl@0
   577
    			// Insert into the arry arrayValidUnsupOrientation
sl@0
   578
    			if (iArrayOrientation.Find((TDeviceOrientation)mode) == KErrNotFound)
sl@0
   579
	    		    {
sl@0
   580
	    			arrayValidUnsupOrientation.Append((TDeviceOrientation)mode);
sl@0
   581
	    			}
sl@0
   582
    			}
sl@0
   583
sl@0
   584
    		for (TInt i = 0; i < arrayValidUnsupOrientation.Count(); i++)
sl@0
   585
 				{
sl@0
   586
 				INFO_PRINTF2(_L("Test SetDeviceOrientation() with valid but unsupported display modes %d"), i);
sl@0
   587
   				// Also retrieve the current device orientation for reference
sl@0
   588
   				TDeviceOrientation devOrientationRef = aSurfaceIdInterface->DeviceOrientation();
sl@0
   589
   				TBool panicTestPass=iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode, &arrayValidUnsupOrientation[i],&iCurrScreen);
sl@0
   590
   				if (!panicTestPass)
sl@0
   591
   					if (iPanicTest->iActualPanicCode==0)
sl@0
   592
   						{
sl@0
   593
   						INFO_PRINTF1(_L("Panic test failed to panic!?"));
sl@0
   594
   						}
sl@0
   595
   					else
sl@0
   596
   						{
sl@0
   597
   						INFO_PRINTF2(_L("Panic test: wrong code %i"),iPanicTest->iActualPanicCode);
sl@0
   598
   						}
sl@0
   599
   				TEST(panicTestPass);
sl@0
   600
				// Call GetDeviceOrientation() again to check the orientation mode hasnt been changed
sl@0
   601
				INFO_PRINTF1(_L("Test the current device orientation mode has not been changed when the second thread panics"));
sl@0
   602
				TEST(devOrientationRef == aSurfaceIdInterface->DeviceOrientation());	
sl@0
   603
				}
sl@0
   604
			CleanupStack::PopAndDestroy();
sl@0
   605
      		}
sl@0
   606
    	}
sl@0
   607
    else 
sl@0
   608
    	{
sl@0
   609
		// No avaialbe orientation modes
sl@0
   610
		INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
sl@0
   611
    	}
sl@0
   612
	}
sl@0
   613
/**	Copies the given screendevice to a new screendevice
sl@0
   614
 *  Assertion is that if the old screen device is different rotation then the updated screen device gets the rotation of the old device.
sl@0
   615
 *  Try to force the devices to have different rotations before we start in order to detect that the update does occur.
sl@0
   616
 * 
sl@0
   617
 **/
sl@0
   618
void CTDevOrientation::TestSetDisplayMode(CFbsDrawDevice* aDrawScreenDevice,MSurfaceId* aSurfaceIdInterface)
sl@0
   619
	{
sl@0
   620
	// Create a new screendevice and surfaceId
sl@0
   621
	CFbsDrawDevice* inputScreenDevice = NULL;
sl@0
   622
	MSurfaceId* inputSurfaceIdInterface = NULL;
sl@0
   623
	
sl@0
   624
	TRAPD(err, inputScreenDevice = CFbsDrawDevice::NewScreenDeviceL(iCurrScreen, aDrawScreenDevice->DisplayMode()));
sl@0
   625
	if(err == KErrNone && !inputSurfaceIdInterface)
sl@0
   626
		{
sl@0
   627
		err = inputScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (inputSurfaceIdInterface));
sl@0
   628
		}
sl@0
   629
	TInt beforeOrientation=aSurfaceIdInterface->DeviceOrientation();
sl@0
   630
	TInt inputOrientation=inputSurfaceIdInterface->DeviceOrientation();
sl@0
   631
	TInt alternateOrientation=(inputOrientation>1)?(inputOrientation>>1):(inputOrientation<<1);
sl@0
   632
sl@0
   633
	if (err == KErrNone)
sl@0
   634
		{
sl@0
   635
		if (beforeOrientation==inputOrientation)
sl@0
   636
			{
sl@0
   637
			// Set orientation on aDrawScreenDevice
sl@0
   638
			// (deviceOrientation*2) mod 8 
sl@0
   639
		  	INFO_PRINTF1(_L("Test SetDisplayMode() copys "));
sl@0
   640
		  	if (aSurfaceIdInterface->DeviceOrientationsAvailable()&alternateOrientation)
sl@0
   641
		  		{
sl@0
   642
				TBool didIt=aSurfaceIdInterface->SetDeviceOrientation(TDeviceOrientation(alternateOrientation));
sl@0
   643
			  	INFO_PRINTF1(_L("[done SetDeviceOrientation] SetDisplayMode() copys "));
sl@0
   644
			  	TEST(!didIt|| aSurfaceIdInterface->DeviceOrientation() == alternateOrientation);
sl@0
   645
		  		}
sl@0
   646
		  	else
sl@0
   647
		  		{
sl@0
   648
		  		INFO_PRINTF1(_L("*** source device couldn't change orientation ***"));
sl@0
   649
		  		}
sl@0
   650
			}
sl@0
   651
	  	INFO_PRINTF1(_L("Test SetDisplayMode() copys "));
sl@0
   652
		aDrawScreenDevice->SetDisplayMode(inputScreenDevice);
sl@0
   653
	  	INFO_PRINTF1(_L("[done SetDisplayMode] SetDisplayMode() copys "));
sl@0
   654
	  	
sl@0
   655
		// Compare the orientation if they are the same... right...
sl@0
   656
		if (inputSurfaceIdInterface->DeviceOrientationsAvailable()&inputOrientation)
sl@0
   657
			{
sl@0
   658
			TEST(aSurfaceIdInterface->DeviceOrientation() == inputOrientation);
sl@0
   659
			}
sl@0
   660
		else
sl@0
   661
			{	//target device doesn't support this orientation
sl@0
   662
	  		INFO_PRINTF1(_L("*** target device couldn't change orientation to honour copied source device ***"));
sl@0
   663
			TEST(aSurfaceIdInterface->DeviceOrientation() == beforeOrientation);
sl@0
   664
			}
sl@0
   665
	  	INFO_PRINTF1(_L("[done DeviceOrientation] SetDisplayMode() copys "));
sl@0
   666
		}	
sl@0
   667
	else
sl@0
   668
		{
sl@0
   669
	  	INFO_PRINTF1(_L("Error in GetInterface()"));
sl@0
   670
		}
sl@0
   671
	delete inputScreenDevice;
sl@0
   672
	}
sl@0
   673
sl@0
   674
void CTDevOrientation::RunTestCaseL(TInt aCurTestCase)
sl@0
   675
	{
sl@0
   676
	if (aCurTestCase < 9)
sl@0
   677
   		{
sl@0
   678
		//All screens
sl@0
   679
		for (TInt count = 0; count < iArrayDispModesPerScreen.Count(); count++)
sl@0
   680
			{
sl@0
   681
			iCurrScreen=count;
sl@0
   682
	    	for (TInt ind = 0;iArrayDispModesPerScreen[count]>=(1<<ind); ind++)
sl@0
   683
	    		{
sl@0
   684
	    		TDisplayMode mode= (TDisplayMode)ind;
sl@0
   685
	    		if (iArrayDispModesPerScreen[count]&(1<<ind))
sl@0
   686
	    			{
sl@0
   687
				  	INFO_PRINTF3(_L("The current screen number =%d The current display mode =%d"), count, ind);
sl@0
   688
					CFbsDrawDevice* drawScreenDevice = NULL;
sl@0
   689
					MSurfaceId* surfaceIdInterface = NULL;
sl@0
   690
					if (!GetSurfaceIdInterfaceL(count,mode, drawScreenDevice, surfaceIdInterface))
sl@0
   691
	    				{
sl@0
   692
	   		  			INFO_PRINTF1(_L("** GCE INTERFACE NOT SUPPORTED ***"));
sl@0
   693
	    				}
sl@0
   694
					else
sl@0
   695
	    				{
sl@0
   696
		
sl@0
   697
	    				CleanupStack::PushL(drawScreenDevice);
sl@0
   698
	    				((CTDevOrientationStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   699
	    				switch(aCurTestCase)
sl@0
   700
							{
sl@0
   701
/**
sl@0
   702
@SYMTestCaseID			GRAPHICS-SCDV-0010
sl@0
   703
@SYMPREQ			PREQ1019
sl@0
   704
@SYMREQ				REQ8228,REQ8223,REQ8227		
sl@0
   705
@SYMTestPriority		High 
sl@0
   706
@SYMTestCaseDesc		This test gets a screen surface and checks the expected values of the surfaceID
sl@0
   707
@SYMTestStatus			Implemented
sl@0
   708
sl@0
   709
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::GetSurface() 
sl@0
   710
@SYMTestExpectedResults This test passes with surfaceId has the expected values in each field.  				
sl@0
   711
*/
sl@0
   712
		case 1:
sl@0
   713
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0010"));
sl@0
   714
			TestGetSurfaceWithValidDispModeL(surfaceIdInterface,mode, count);
sl@0
   715
			break;
sl@0
   716
/**
sl@0
   717
@SYMTestCaseID			GRAPHICS-SCDV-0011
sl@0
   718
@SYMPREQ			PREQ1019
sl@0
   719
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   720
@SYMTestPriority		High 
sl@0
   721
@SYMTestCaseDesc		This test checks DeviceOrientationAvailable() returns a valid orientation mode or a combination of them
sl@0
   722
SYMTestStatus			Implemented
sl@0
   723
sl@0
   724
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::DeviceOrientationAvailable() 
sl@0
   725
@SYMTestExpectedResults This test passes after checking the return values of DeviceOrientationAvailable()  
sl@0
   726
*/
sl@0
   727
		case 2:
sl@0
   728
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0011"));
sl@0
   729
			TestGetDeviceOrientation(surfaceIdInterface);
sl@0
   730
			break;
sl@0
   731
/**
sl@0
   732
@SYMTestCaseID			GRAPHICS-SCDV-0012
sl@0
   733
@SYMPREQ			PREQ1019	
sl@0
   734
@SYMREQ				REQ8228,REQ8223,REQ8227
sl@0
   735
@SYMTestPriority		High 
sl@0
   736
@SYMTestCaseDesc		This test checks the change of screen size before and after calling SetDeviceOrientation with a valid orientation mode
sl@0
   737
@SYMTestStatus			Implemented
sl@0
   738
sl@0
   739
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), CFbsDrawDevice::SizeInPixel() 
sl@0
   740
@SYMTestExpectedResults In the case of EDeviceOrientation90CW and EDeviceOrientation270CW the size width and height are swapped after calling SetDeviceOrientation, while in other cases, the values remained the same before and after the rotation setting.  
sl@0
   741
*/
sl@0
   742
		case 3:
sl@0
   743
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0012"));
sl@0
   744
			TestSetDeviceOrientationWithValidMode(drawScreenDevice, surfaceIdInterface,mode,count);
sl@0
   745
sl@0
   746
			break;
sl@0
   747
/**
sl@0
   748
@SYMTestCaseID			GRAPHICS-SCDV-0013
sl@0
   749
@SYMPREQ			PREQ1019
sl@0
   750
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   751
@SYMTestPriority		High 
sl@0
   752
@SYMTestCaseDesc		This test checks the change of horizontal and vertical twips before and after calling SetDeviceOrientation with a valid orientation mode
sl@0
   753
@SYMTestStatus			Implemented
sl@0
   754
sl@0
   755
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), CFbsDrawDevice::HorzTwipsPerThousandPixels() and CFbsDrawDevice:: VertTwipsPerThousandPixels() 
sl@0
   756
@SYMTestExpectedResults In the case of EDeviceOrientation90CW and EDeviceOrientation270CW the horizontal and vertical twips are swapped after calling SetDeviceOrientation, while in other cases, the values remained the same before and after the rotation setting.  
sl@0
   757
*/
sl@0
   758
		case 4:
sl@0
   759
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0013"));
sl@0
   760
			TestHorizontalVerticalTwips(drawScreenDevice, surfaceIdInterface,mode, count);
sl@0
   761
			break;
sl@0
   762
/**
sl@0
   763
@SYMTestCaseID			GRAPHICS-SCDV-0014
sl@0
   764
@SYMPREQ			PREQ1019
sl@0
   765
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   766
@SYMTestPriority		High 
sl@0
   767
@SYMTestCaseDesc		This test checks the functionality of SetDeviceOrientation() and DeviceOrientation()
sl@0
   768
@SYMTestStatus			Implemented
sl@0
   769
sl@0
   770
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), MSurfaceId::DeviceOrientation() 
sl@0
   771
@SYMTestExpectedResults The orientation mode value passed into SetDeviceOrientation is identical to that returned from calling DeviceOrientation().  
sl@0
   772
*/
sl@0
   773
		case 5:
sl@0
   774
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0014"));
sl@0
   775
			TestDeviceOrientationSettingandGetting(surfaceIdInterface);
sl@0
   776
			break;
sl@0
   777
/**
sl@0
   778
@SYMTestCaseID			GRAPHICS-SCDV-0015
sl@0
   779
@SYMPREQ			PREQ1019
sl@0
   780
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   781
@SYMTestPriority		High 
sl@0
   782
@SYMTestCaseDesc		This test checks SetDeviceOrientation does not accept an invalid device orientation mode
sl@0
   783
@SYMTestStatus			Implemented
sl@0
   784
sl@0
   785
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation() 
sl@0
   786
@SYMTestExpectedResults This test panic with code EScreenDriverPanicInvalidParameter.  
sl@0
   787
*/
sl@0
   788
		case 6:
sl@0
   789
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0015"));
sl@0
   790
			TestSetDeviceOrientationWithInvalidModeL(mode);
sl@0
   791
			break;
sl@0
   792
/**
sl@0
   793
@SYMTestCaseID			GRAPHICS-SCDV-0016
sl@0
   794
@SYMPREQ			PREQ1019
sl@0
   795
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   796
@SYMTestPriority		High 
sl@0
   797
@SYMTestCaseDesc		This test checks SetDeviceOrientation does not accept a valid but unsupported device orientation mode
sl@0
   798
@SYMTestStatus			Implemented
sl@0
   799
sl@0
   800
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation() 
sl@0
   801
@SYMTestExpectedResults This test panic with code EScreenDriverPanicInvalidParameter.  
sl@0
   802
*/		
sl@0
   803
		case 7:
sl@0
   804
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0016"));
sl@0
   805
			TestValidButUnavailableOrientationL(surfaceIdInterface,mode);
sl@0
   806
			break;
sl@0
   807
/**
sl@0
   808
@SYMTestCaseID			GRAPHICS-SCDV-0017
sl@0
   809
@SYMPREQ			PREQ1019
sl@0
   810
@SYMREQ				REQ8228,REQ8223,REQ8227	
sl@0
   811
@SYMTestPriority		High 
sl@0
   812
@SYMTestCaseDesc		This test compares the two draw devices after copying one to the other
sl@0
   813
@SYMTestStatus			Implemented
sl@0
   814
sl@0
   815
@SYMTestActions			Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), CFbsDrawDevice::SetDisplayMode(), MSurfaceId::SetDeviceOrientation() 
sl@0
   816
@SYMTestExpectedResults This test should pass all the device orientation checking.  
sl@0
   817
*/
sl@0
   818
		case 8:
sl@0
   819
			((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0017"));
sl@0
   820
			TestSetDisplayMode(drawScreenDevice,surfaceIdInterface);
sl@0
   821
			break;
sl@0
   822
							}
sl@0
   823
	    				((CTDevOrientationStep*)iStep)->RecordTestResultL();
sl@0
   824
	    				CleanupStack::PopAndDestroy();
sl@0
   825
				   		}
sl@0
   826
					}
sl@0
   827
sl@0
   828
				}
sl@0
   829
			}
sl@0
   830
		}
sl@0
   831
    else
sl@0
   832
    	{
sl@0
   833
        ((CTDevOrientationStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   834
        ((CTDevOrientationStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   835
    	TestComplete();
sl@0
   836
    	}
sl@0
   837
		((CTDevOrientationStep*)iStep)->RecordTestResultL();
sl@0
   838
	}
sl@0
   839
sl@0
   840
sl@0
   841
//--------------------------------------------------------------
sl@0
   842
sl@0
   843
CTDevOrientationStep::CTDevOrientationStep() 
sl@0
   844
	{ 
sl@0
   845
	SetTestStepName(KTDevOrientationStep); 
sl@0
   846
	} 
sl@0
   847
	 
sl@0
   848
CTGraphicsBase* CTDevOrientationStep::CreateTestL()
sl@0
   849
	{ 
sl@0
   850
	CTGraphicsBase* theTest = NULL;
sl@0
   851
	CFbsDrawDevice* device = NULL;
sl@0
   852
	TInt numOfScreens = 0;
sl@0
   853
	TInt err = HAL::Get(HALData::EDisplayNumberOfScreens, numOfScreens);
sl@0
   854
	RArray<TInt> arrayDispModesPerScreen;
sl@0
   855
	
sl@0
   856
	CleanupClosePushL(arrayDispModesPerScreen);
sl@0
   857
	for (TUint scr=0;scr<numOfScreens;scr++)
sl@0
   858
		{
sl@0
   859
		TUint modeBits=0;
sl@0
   860
		// go through all the display modes and find out the supported ones by hardware/emulator
sl@0
   861
	    for (TUint32 ind = 0; ind <= (TUint32)EColorLast; ind++)
sl@0
   862
	    	{
sl@0
   863
	   	    TDisplayMode mode2 = (TDisplayMode)ind;
sl@0
   864
sl@0
   865
	    	TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(scr, mode2));
sl@0
   866
	   		if (err==KErrNone)  //support this mode
sl@0
   867
				{
sl@0
   868
				modeBits+=1<<ind;
sl@0
   869
				}// otherwise, unsupport this mode does nothing
sl@0
   870
	    	delete device;
sl@0
   871
	    
sl@0
   872
			device = NULL;
sl@0
   873
	     	}
sl@0
   874
	    arrayDispModesPerScreen.Append(modeBits);
sl@0
   875
		}
sl@0
   876
	
sl@0
   877
    // Create the test class 	
sl@0
   878
	if (arrayDispModesPerScreen.Count() > 0)
sl@0
   879
		{
sl@0
   880
		// there is at least one supported display modes
sl@0
   881
		theTest = new (ELeave) CTDevOrientation(this, arrayDispModesPerScreen);
sl@0
   882
 		}
sl@0
   883
 	else
sl@0
   884
 		{
sl@0
   885
		User::Leave(KErrNotSupported);
sl@0
   886
 		}
sl@0
   887
	 	
sl@0
   888
    CleanupStack::Pop(&arrayDispModesPerScreen);
sl@0
   889
	return 	theTest;		
sl@0
   890
	} 
sl@0
   891
sl@0
   892
sl@0
   893
void CTDevOrientationStep::TestSetupL()
sl@0
   894
	{
sl@0
   895
	TInt temp = 0;
sl@0
   896
	HAL::Get(KDefaultScreenNo, HALData::EDisplayColors, temp);//force HAL memory allocation
sl@0
   897
	
sl@0
   898
	}