Update contrib.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <bitdrawinterfaceid.h>
20 #include <graphics/gdi/gdiconsts.h>
21 #include "tscdvdevorientation.h"
23 void AutoPanic(TInt aPanic)
25 User::Panic(_L("Auto"),aPanic);
28 LOCAL_C TInt PanicThreadFunc(TAny *aPointerToAny)
30 CTrapCleanup* CleanUpStack=CTrapCleanup::New();
31 SPanicParams *pointerPanicParams=(SPanicParams *)aPointerToAny;
33 TRAP(ret,(*pointerPanicParams->functionName)(*pointerPanicParams->pointerDeviceOrientation,*pointerPanicParams->pointerDisplayMode,*pointerPanicParams->pointerScreenNo));
35 if (ret==EWsExitReasonBad)
36 AutoPanic(EAutoPanicPanicFailed);
40 CPanicTest::CPanicTest()
45 CPanicTest::~CPanicTest()
49 TInt CPanicTest::LaunchPanicThread(RThread &aThread, SPanicParams *aPointerPanicParams)
52 threadName.Format(TRefByValue<const TDesC>(_L("AutoPanicThread%d")),iThreadNumber++);
53 return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPointerPanicParams,EOwnerThread));
56 TInt CPanicTest::TestPanicL(SPanicParams *aPointerPanicParams, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished)
60 TInt err=LaunchPanicThread(thread, aPointerPanicParams);
61 if (err==KErrAlreadyExists)
63 // wait for kernel to clear up old threads
64 // and have several attempts at starting the thread
65 // if unsuccessful the first time
66 for (TInt i=0;i<3;i++)
68 User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs
69 err=LaunchPanicThread(thread, aPointerPanicParams);
70 if (err!=KErrAlreadyExists)
74 User::LeaveIfError(err);
76 User::SetJustInTime(EFalse);
78 User::WaitForRequest(stat);
79 User::SetJustInTime(ETrue);
81 TBool testFinished=EFalse;
82 TBool testPassed=EFalse;
83 if (thread.ExitType()==EExitPanic) // the function is panicked
85 // ignore code for transparency
86 if(aExitReason == thread.ExitReason()) // panic reason is equal to the scdv EScreenDriverPanicInvalidParameter
90 iActualPanicCode=thread.ExitReason();
91 testFinished=ETrue; // Finish tests
95 if((thread.ExitCategory().Compare(aCategory)!=0)
96 || (thread.ExitReason()!=aExitReason)
97 || (thread.ExitType()!=EExitPanic) //This last condition is always true!!!!!!
106 *aTestFinished=testFinished;
111 TInt CPanicTest::TestInvalidModePanicL(TPanicFunction aFunction, TScreenDriverPanic aExitReason,TDisplayMode* aPointerDispMode, TDeviceOrientation* aPointerDevOrientation,TInt* aPtrScreenNo, TBool* aTestFinished)
113 // function name, exit reason, and parameters
114 return TestPanicL(aFunction,aExitReason,KSCDVPanicCategory, aPointerDispMode, aPointerDevOrientation, aPtrScreenNo, aTestFinished);
117 TInt CPanicTest::TestPanicL(TPanicFunction aFunction, TInt aExitReason, const TDesC &aCategory, TDisplayMode* aPointerDispMode, TDeviceOrientation* aPointerDevOrientation,TInt* aPtrScreenNo, TBool* aTestFinished)
120 params.functionName=aFunction;
121 params.pointerDeviceOrientation = aPointerDevOrientation;
122 params.pointerDisplayMode = aPointerDispMode;
123 params.pointerScreenNo = aPtrScreenNo;
124 return TestPanicL(¶ms, aExitReason, aCategory, aTestFinished);
132 CTDevOrientation::CTDevOrientation(CTestStep *aTest, RArray<TInt> aArrayDispModes) :
133 CTGraphicsBase(aTest),iArrayDispModesPerScreen(aArrayDispModes)
135 INFO_PRINTF1(_L("Screen Device Orientation tests"));
138 CTDevOrientation::CTDevOrientation(CTestStep *aTest) :
139 CTGraphicsBase(aTest)
141 INFO_PRINTF1(_L("Screen Device Orientation tests"));
144 void CTDevOrientation::ConstructL()
146 iPanicTest = new (ELeave) CPanicTest();
149 CTDevOrientation::~CTDevOrientation()
151 iArrayOrientation.Close();
152 iArrayDispModesPerScreen.Close();
157 Create the screen device and surface interface objects for the specific screen and display mode
159 @return ETrue means valid screen device and surface interface objects are created, EFalse means a leave or an error
160 @param aScreenNo the screen no
161 @param aDisplayMode the specified display mode
162 @param aDrawScreenDevice
163 @param aSurfaceIdInterface
165 TBool CTDevOrientation::GetSurfaceIdInterfaceL(const TInt& aScreenNo,const TDisplayMode& aDisplayMode, CFbsDrawDevice*& aDrawScreenDevice, MSurfaceId*& aSurfaceIdInterface )
169 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress,address));
170 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, iPhysSize.iWidth));
171 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, iPhysSize.iHeight));
172 __ASSERT_DEBUG(iPhysSize.iWidth > 0 && iPhysSize.iHeight > 0 && address != NULL, User::Invariant());
174 aDrawScreenDevice = NULL;
175 TRAPD(err, aDrawScreenDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDisplayMode));
177 if(err == KErrNone) // as aDisplayMode is verified to be supported so this should be the case
179 __ASSERT_ALWAYS(aDrawScreenDevice != NULL, User::Invariant());
180 //Set other properties
181 aDrawScreenDevice->SetUserDisplayMode(aDisplayMode);
182 aDrawScreenDevice->SetAutoUpdate(EFalse);
183 if(!aSurfaceIdInterface)
185 err = aDrawScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (aSurfaceIdInterface));
187 if (err == KErrNone && aSurfaceIdInterface != NULL)
193 delete aDrawScreenDevice;
199 // Leave with error codes
200 INFO_PRINTF2(_L("CFbsDrawDevice::NewScreenDeviceL leaves with code =%d"), err);
206 Retrive the required bpp value and pixel format based on the specified display mode
208 @return ETrue means the display mode is supported
209 @param aDisplayMode the specified display mode
210 @param aBpp the required bpp value
211 @param aPixelFormat the required pixel format
213 TBool CTDevOrientation::ReqBppAndPixelFormat(TDisplayMode aDisplayMode, TInt& aBpp, TUint32& aPixelFormat)
215 // aBpp = TDisplayModeUtils::NumDisplayModeBitsPerPixel(aDisplayMode);
233 case EColor256: // 8 Bpp color mode
238 aPixelFormat = EUidPixelFormatXRGB_4444; //12 Bpp color mode
241 case EColor64K: // 16 Bpp color mode
242 aPixelFormat = EUidPixelFormatRGB_565;
245 case EColor16MU: //24 Bpp color mode
246 aPixelFormat = EUidPixelFormatXRGB_8888;
249 case EColor16MA: // 32 Bpp color mode
250 aPixelFormat = EUidPixelFormatARGB_8888;
254 aPixelFormat = EUidPixelFormatARGB_8888_PRE;
263 void CTDevOrientation::TestGetSurfaceWithValidDispModeL(const MSurfaceId* aSurfaceIdInterface, const TDisplayMode& aDisplayMode, TInt aScreenNo)
266 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
267 TSurfaceId surfaceId;
268 aSurfaceIdInterface->GetSurface(surfaceId);
269 INFO_PRINTF1(_L("Test GetSurface() returns valid surface Id with the specified display modes"));
270 //Check the screen no
271 TEST(surfaceId.iInternal[0] == aScreenNo);
273 TInt halMode = surfaceId.iInternal[1]; // 24bpp and 32bpp are currently considered the same by HAL
274 User::LeaveIfError(HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode));
275 TUint32 pixelFormat = 0;
277 if (ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat))
279 // Check the color depth
280 TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
281 // Check the pixel format
282 TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
283 // Check the surface type
284 TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
287 INFO_PRINTF1(_L("Unsupported display modes"));
291 Retrive all the availably supported device orientation modes by the hardware.
293 @return ETrue means there are valid device orientation modes supported, EFalse means no good mode supported
294 @param aSurfaceIdInterface MSurfaceId*
296 TBool CTDevOrientation::ChooseOrientationMode( MSurfaceId* aSurfaceIdInterface)
298 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
299 TUint orAvailable = aSurfaceIdInterface->DeviceOrientationsAvailable();
300 iArrayOrientation.Reset();
301 if ( orAvailable <= 15 || orAvailable > 0)
303 if (iArrayOrientation.Count() == 0) // Only fills the array once
305 // there is at least one mode available
306 // Find one availabe device orientation mode
307 for (TUint32 mode = (TUint32)EDeviceOrientationNormal; mode <= (TUint)EDeviceOrientation270CW; mode*=2)
309 if ( orAvailable & (TDeviceOrientation)mode)
311 iArrayOrientation.Append((TDeviceOrientation)mode);
319 // No available mode supported
324 void CTDevOrientation::TestGetDeviceOrientation( MSurfaceId* aSurfaceIdInterface)
326 if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
328 INFO_PRINTF1(_L("Test DeviceOrientationAvailabe() returns one or a combination of valid modes"));
331 INFO_PRINTF1(_L("Test DeviceOrientationAvailabe() gives no valid returns"));
335 void CTDevOrientation::TestDeviceOrientationSettingandGetting( MSurfaceId* aSurfaceIdInterface)
337 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
338 if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
340 for (TInt i = 0; i < iArrayOrientation.Count(); i++)
342 // Set the orientation
343 aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]);
344 INFO_PRINTF2(_L("Test SetDeviceOrientation() and GetDeviceOrientation() for DeviceOrientation Mode %d"), i);
345 //Get the orientation
346 TEST(iArrayOrientation[i] == aSurfaceIdInterface->DeviceOrientation());
351 // No avaialbe orientation modes
352 INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
356 void CTDevOrientation::TestHorizontalVerticalTwips(const CFbsDrawDevice* aDrawScreenDevice, MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode, TInt aScreenNo)
358 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
359 TInt horTwipsRef = aDrawScreenDevice->HorzTwipsPerThousandPixels();
360 TInt verTwipsRef = aDrawScreenDevice->VertTwipsPerThousandPixels();
362 TUint32 pixelFormat = 0;
364 // Find the required color depth and pixel format based on the aDisplayMode
365 TEST(ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat));
367 TSurfaceId surfaceId;
369 if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0 )
371 for (TInt i = 0; i < iArrayOrientation.Count(); i++)
373 // Set the orientation
374 if (aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]))
376 // Retrieve SurfaceId to test the second bit
377 aSurfaceIdInterface->GetSurface(surfaceId);
378 INFO_PRINTF1(_L("CFbsDrawDevice, Retrieve the surfaceId to test whether the second bit has been modified accordingly and other bits left unchanged"));
380 TEST(surfaceId.iInternal[0] == aScreenNo);
381 TInt halMode = surfaceId.iInternal[1] &~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
382 HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode);
384 TInt horTwipsRotated = aDrawScreenDevice->HorzTwipsPerThousandPixels();
385 TInt verTwipsRotated = aDrawScreenDevice->VertTwipsPerThousandPixels();
387 if (iArrayOrientation[i] & (EDeviceOrientation90CW | EDeviceOrientation270CW))
389 INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns swapped horizontal and vertical twip values"), i);
390 TEST(horTwipsRef == verTwipsRotated);
391 TEST(verTwipsRef == horTwipsRotated);
392 TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) != 0); //flipped
396 INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns no swapped horizontal and vertical twip values"), i);
397 TEST(verTwipsRef == verTwipsRotated);
398 TEST(horTwipsRef == horTwipsRotated);
399 TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) == 0); //no flipped
401 // Check the color depth unchanged
402 TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
403 TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
404 TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
407 INFO_PRINTF1(_L("No attributes have been changed after calling SetDeviceOrientation()"));
412 INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
417 void CTDevOrientation::TestSetDeviceOrientationWithValidMode(const CFbsDrawDevice* aDrawScreenDevice, MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode, TInt aScreenNo)
419 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
420 TSize sizeRef = aDrawScreenDevice->SizeInPixels();
422 TUint32 pixelFormat = 0;
424 // Find the required color depth and pixel format based on the aDisplayMode
425 TEST(ReqBppAndPixelFormat(aDisplayMode,bpp, pixelFormat));
427 TSurfaceId surfaceId;
429 if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0 )
431 for (TInt i = 0; i < iArrayOrientation.Count(); i++)
433 // Set the orientation
434 if (aSurfaceIdInterface->SetDeviceOrientation(iArrayOrientation[i]))
436 // Retrieve SurfaceId to test the second bit
437 aSurfaceIdInterface->GetSurface(surfaceId);
438 INFO_PRINTF1(_L("CFbsDrawDevice, Retrieve the surfaceId to test whether the second bit has been modified accordingly and other bits left unchanged"));
440 TEST(surfaceId.iInternal[0] == aScreenNo);
441 TInt halMode = surfaceId.iInternal[1] &~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
442 HAL::Get(surfaceId.iInternal[0], HALData::EDisplayBitsPerPixel, halMode);
443 // Retrieve the size in pixel after setting the device rotation
444 sizeRotated = aDrawScreenDevice->SizeInPixels();
446 if (iArrayOrientation[i] & (EDeviceOrientation90CW | EDeviceOrientation270CW))
448 INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns swapped screen Height and Width"), i);
449 TEST(sizeRef.iHeight == sizeRotated.iWidth);
450 TEST(sizeRef.iWidth == sizeRotated.iHeight);
451 TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) != 0); //has set to 8 --- flipped
455 INFO_PRINTF2(_L("Test DeviceOrientation Mode %d returns no swapped screen Height and Width"), i);
456 TEST(sizeRef.iWidth == sizeRotated.iWidth);
457 TEST(sizeRef.iHeight == sizeRotated.iHeight);
458 TEST((surfaceId.iInternal[1] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) == 0); //has set to 0 --- no flipped
460 // Check the color depth unchanged
461 TEST(bpp == halMode || bpp == 24 && halMode == 32 || bpp == 32 && halMode == 24);
462 TEST(surfaceId.iInternal[2] == pixelFormat);//Need to test the type as well
463 TEST(surfaceId.iInternal[3]>>24 == TSurfaceId::EScreenSurface );
466 INFO_PRINTF1(_L("No attributes have been changed after calling SetDeviceOrientation()"));
471 INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
476 // THIS METHOD IS EXPECTED TO PANIC
477 LOCAL_C TInt DoSetDeviceOrientationWithInvalidModeL(TDeviceOrientation aOrientation, TDisplayMode aDisplayMode, TInt aScreenNo)
479 CFbsDrawDevice* drawScreenDevice = NULL;
480 TRAPD(err, drawScreenDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDisplayMode));
481 CleanupStack::PushL(drawScreenDevice);
484 __ASSERT_ALWAYS(drawScreenDevice != NULL, User::Invariant());
485 //Set other properties
486 drawScreenDevice->SetUserDisplayMode(EColor16MA);
487 drawScreenDevice->SetAutoUpdate(EFalse);
488 MSurfaceId* surfaceIdInterface = NULL;
489 err = drawScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (surfaceIdInterface));
492 // Currently Panics the secondary thread
493 surfaceIdInterface->SetDeviceOrientation(aOrientation);
498 User::LeaveIfError(err);
500 CleanupStack::PopAndDestroy();
501 return(EWsExitReasonBad);
505 void CTDevOrientation::TestSetDeviceOrientationWithInvalidModeL(TDisplayMode aDisplayMode)
507 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes -1"));
508 // Invalid bit is set
509 TDeviceOrientation aInvalidMode = (TDeviceOrientation)-1;
510 // Check the test results in the secondary thread
511 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, (TDisplayMode*)&aDisplayMode, &aInvalidMode,&iCurrScreen));
513 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 0"));
514 aInvalidMode = (TDeviceOrientation)0;
515 // Check the test results in the secondary thread
516 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
518 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 3"));
519 aInvalidMode = (TDeviceOrientation)3;
520 // Check the test results in the secondary thread
521 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter,&aDisplayMode, &aInvalidMode,&iCurrScreen));
523 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 5"));
524 aInvalidMode = (TDeviceOrientation)5;
525 // Check the test results in the secondary thread
526 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
528 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 7"));
529 aInvalidMode = (TDeviceOrientation)7;
530 // Check the test results in the secondary thread
531 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
533 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 9"));
534 aInvalidMode = (TDeviceOrientation)9;
535 // Check the test results in the secondary thread
536 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
538 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 15"));
539 aInvalidMode = (TDeviceOrientation)15;
540 // Check the test results in the secondary thread
541 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
543 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 16"));
544 aInvalidMode = (TDeviceOrientation)16;
545 // Check the test results in the secondary thread
546 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter,&aDisplayMode, &aInvalidMode,&iCurrScreen));
548 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 17"));
549 aInvalidMode = (TDeviceOrientation)17;
550 // Check the test results in the secondary thread
551 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
553 INFO_PRINTF1(_L("Test SetDeviceOrientation() with invalid device orientation modes 32"));
554 aInvalidMode = (TDeviceOrientation)32;
555 // Check the test results in the secondary thread
556 TEST(iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode,&aInvalidMode,&iCurrScreen));
560 void CTDevOrientation::TestValidButUnavailableOrientationL(MSurfaceId* aSurfaceIdInterface, TDisplayMode aDisplayMode)
563 __ASSERT_ALWAYS(aSurfaceIdInterface != NULL, User::Invariant());
564 if (ChooseOrientationMode(aSurfaceIdInterface) && iArrayOrientation.Count() != 0)
565 {// Find a valid but unavailable device orientation
566 if (iArrayOrientation.Count() ==4)
568 INFO_PRINTF1(_L("All four possible device orientation modes are supported"));
571 { // There must be one valid but unsupported display modes
572 RArray<TDeviceOrientation> arrayValidUnsupOrientation;
573 CleanupClosePushL(arrayValidUnsupOrientation);
575 for (TUint32 mode = (TUint32)EDeviceOrientationNormal; mode <= (TUint32)EDeviceOrientation270CW; mode *= 2)
577 // Insert into the arry arrayValidUnsupOrientation
578 if (iArrayOrientation.Find((TDeviceOrientation)mode) == KErrNotFound)
580 arrayValidUnsupOrientation.Append((TDeviceOrientation)mode);
584 for (TInt i = 0; i < arrayValidUnsupOrientation.Count(); i++)
586 INFO_PRINTF2(_L("Test SetDeviceOrientation() with valid but unsupported display modes %d"), i);
587 // Also retrieve the current device orientation for reference
588 TDeviceOrientation devOrientationRef = aSurfaceIdInterface->DeviceOrientation();
589 TBool panicTestPass=iPanicTest->TestInvalidModePanicL(&(DoSetDeviceOrientationWithInvalidModeL),EScreenDriverPanicInvalidParameter, &aDisplayMode, &arrayValidUnsupOrientation[i],&iCurrScreen);
591 if (iPanicTest->iActualPanicCode==0)
593 INFO_PRINTF1(_L("Panic test failed to panic!?"));
597 INFO_PRINTF2(_L("Panic test: wrong code %i"),iPanicTest->iActualPanicCode);
600 // Call GetDeviceOrientation() again to check the orientation mode hasnt been changed
601 INFO_PRINTF1(_L("Test the current device orientation mode has not been changed when the second thread panics"));
602 TEST(devOrientationRef == aSurfaceIdInterface->DeviceOrientation());
604 CleanupStack::PopAndDestroy();
609 // No avaialbe orientation modes
610 INFO_PRINTF1(_L("No availabe device orientation modes supported by the device"));
613 /** Copies the given screendevice to a new screendevice
614 * Assertion is that if the old screen device is different rotation then the updated screen device gets the rotation of the old device.
615 * Try to force the devices to have different rotations before we start in order to detect that the update does occur.
618 void CTDevOrientation::TestSetDisplayMode(CFbsDrawDevice* aDrawScreenDevice,MSurfaceId* aSurfaceIdInterface)
620 // Create a new screendevice and surfaceId
621 CFbsDrawDevice* inputScreenDevice = NULL;
622 MSurfaceId* inputSurfaceIdInterface = NULL;
624 TRAPD(err, inputScreenDevice = CFbsDrawDevice::NewScreenDeviceL(iCurrScreen, aDrawScreenDevice->DisplayMode()));
625 if(err == KErrNone && !inputSurfaceIdInterface)
627 err = inputScreenDevice->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (inputSurfaceIdInterface));
629 TInt beforeOrientation=aSurfaceIdInterface->DeviceOrientation();
630 TInt inputOrientation=inputSurfaceIdInterface->DeviceOrientation();
631 TInt alternateOrientation=(inputOrientation>1)?(inputOrientation>>1):(inputOrientation<<1);
635 if (beforeOrientation==inputOrientation)
637 // Set orientation on aDrawScreenDevice
638 // (deviceOrientation*2) mod 8
639 INFO_PRINTF1(_L("Test SetDisplayMode() copys "));
640 if (aSurfaceIdInterface->DeviceOrientationsAvailable()&alternateOrientation)
642 TBool didIt=aSurfaceIdInterface->SetDeviceOrientation(TDeviceOrientation(alternateOrientation));
643 INFO_PRINTF1(_L("[done SetDeviceOrientation] SetDisplayMode() copys "));
644 TEST(!didIt|| aSurfaceIdInterface->DeviceOrientation() == alternateOrientation);
648 INFO_PRINTF1(_L("*** source device couldn't change orientation ***"));
651 INFO_PRINTF1(_L("Test SetDisplayMode() copys "));
652 aDrawScreenDevice->SetDisplayMode(inputScreenDevice);
653 INFO_PRINTF1(_L("[done SetDisplayMode] SetDisplayMode() copys "));
655 // Compare the orientation if they are the same... right...
656 if (inputSurfaceIdInterface->DeviceOrientationsAvailable()&inputOrientation)
658 TEST(aSurfaceIdInterface->DeviceOrientation() == inputOrientation);
661 { //target device doesn't support this orientation
662 INFO_PRINTF1(_L("*** target device couldn't change orientation to honour copied source device ***"));
663 TEST(aSurfaceIdInterface->DeviceOrientation() == beforeOrientation);
665 INFO_PRINTF1(_L("[done DeviceOrientation] SetDisplayMode() copys "));
669 INFO_PRINTF1(_L("Error in GetInterface()"));
671 delete inputScreenDevice;
674 void CTDevOrientation::RunTestCaseL(TInt aCurTestCase)
676 if (aCurTestCase < 9)
679 for (TInt count = 0; count < iArrayDispModesPerScreen.Count(); count++)
682 for (TInt ind = 0;iArrayDispModesPerScreen[count]>=(1<<ind); ind++)
684 TDisplayMode mode= (TDisplayMode)ind;
685 if (iArrayDispModesPerScreen[count]&(1<<ind))
687 INFO_PRINTF3(_L("The current screen number =%d The current display mode =%d"), count, ind);
688 CFbsDrawDevice* drawScreenDevice = NULL;
689 MSurfaceId* surfaceIdInterface = NULL;
690 if (!GetSurfaceIdInterfaceL(count,mode, drawScreenDevice, surfaceIdInterface))
692 INFO_PRINTF1(_L("** GCE INTERFACE NOT SUPPORTED ***"));
697 CleanupStack::PushL(drawScreenDevice);
698 ((CTDevOrientationStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
702 @SYMTestCaseID GRAPHICS-SCDV-0010
704 @SYMREQ REQ8228,REQ8223,REQ8227
705 @SYMTestPriority High
706 @SYMTestCaseDesc This test gets a screen surface and checks the expected values of the surfaceID
707 @SYMTestStatus Implemented
709 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::GetSurface()
710 @SYMTestExpectedResults This test passes with surfaceId has the expected values in each field.
713 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0010"));
714 TestGetSurfaceWithValidDispModeL(surfaceIdInterface,mode, count);
717 @SYMTestCaseID GRAPHICS-SCDV-0011
719 @SYMREQ REQ8228,REQ8223,REQ8227
720 @SYMTestPriority High
721 @SYMTestCaseDesc This test checks DeviceOrientationAvailable() returns a valid orientation mode or a combination of them
722 SYMTestStatus Implemented
724 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::DeviceOrientationAvailable()
725 @SYMTestExpectedResults This test passes after checking the return values of DeviceOrientationAvailable()
728 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0011"));
729 TestGetDeviceOrientation(surfaceIdInterface);
732 @SYMTestCaseID GRAPHICS-SCDV-0012
734 @SYMREQ REQ8228,REQ8223,REQ8227
735 @SYMTestPriority High
736 @SYMTestCaseDesc This test checks the change of screen size before and after calling SetDeviceOrientation with a valid orientation mode
737 @SYMTestStatus Implemented
739 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), CFbsDrawDevice::SizeInPixel()
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.
743 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0012"));
744 TestSetDeviceOrientationWithValidMode(drawScreenDevice, surfaceIdInterface,mode,count);
748 @SYMTestCaseID GRAPHICS-SCDV-0013
750 @SYMREQ REQ8228,REQ8223,REQ8227
751 @SYMTestPriority High
752 @SYMTestCaseDesc This test checks the change of horizontal and vertical twips before and after calling SetDeviceOrientation with a valid orientation mode
753 @SYMTestStatus Implemented
755 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), CFbsDrawDevice::HorzTwipsPerThousandPixels() and CFbsDrawDevice:: VertTwipsPerThousandPixels()
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.
759 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0013"));
760 TestHorizontalVerticalTwips(drawScreenDevice, surfaceIdInterface,mode, count);
763 @SYMTestCaseID GRAPHICS-SCDV-0014
765 @SYMREQ REQ8228,REQ8223,REQ8227
766 @SYMTestPriority High
767 @SYMTestCaseDesc This test checks the functionality of SetDeviceOrientation() and DeviceOrientation()
768 @SYMTestStatus Implemented
770 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation(), MSurfaceId::DeviceOrientation()
771 @SYMTestExpectedResults The orientation mode value passed into SetDeviceOrientation is identical to that returned from calling DeviceOrientation().
774 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0014"));
775 TestDeviceOrientationSettingandGetting(surfaceIdInterface);
778 @SYMTestCaseID GRAPHICS-SCDV-0015
780 @SYMREQ REQ8228,REQ8223,REQ8227
781 @SYMTestPriority High
782 @SYMTestCaseDesc This test checks SetDeviceOrientation does not accept an invalid device orientation mode
783 @SYMTestStatus Implemented
785 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation()
786 @SYMTestExpectedResults This test panic with code EScreenDriverPanicInvalidParameter.
789 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0015"));
790 TestSetDeviceOrientationWithInvalidModeL(mode);
793 @SYMTestCaseID GRAPHICS-SCDV-0016
795 @SYMREQ REQ8228,REQ8223,REQ8227
796 @SYMTestPriority High
797 @SYMTestCaseDesc This test checks SetDeviceOrientation does not accept a valid but unsupported device orientation mode
798 @SYMTestStatus Implemented
800 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), MSurfaceId::SetDeviceOrientation()
801 @SYMTestExpectedResults This test panic with code EScreenDriverPanicInvalidParameter.
804 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0016"));
805 TestValidButUnavailableOrientationL(surfaceIdInterface,mode);
808 @SYMTestCaseID GRAPHICS-SCDV-0017
810 @SYMREQ REQ8228,REQ8223,REQ8227
811 @SYMTestPriority High
812 @SYMTestCaseDesc This test compares the two draw devices after copying one to the other
813 @SYMTestStatus Implemented
815 @SYMTestActions Call CFbsDrawDevice::CreateScreenDeviceL(), CFbsDrawDevice::GetInterface(), CFbsDrawDevice::SetDisplayMode(), MSurfaceId::SetDeviceOrientation()
816 @SYMTestExpectedResults This test should pass all the device orientation checking.
819 ((CTDevOrientationStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCDV-0017"));
820 TestSetDisplayMode(drawScreenDevice,surfaceIdInterface);
823 ((CTDevOrientationStep*)iStep)->RecordTestResultL();
824 CleanupStack::PopAndDestroy();
833 ((CTDevOrientationStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
834 ((CTDevOrientationStep*)iStep)->CloseTMSGraphicsStep();
837 ((CTDevOrientationStep*)iStep)->RecordTestResultL();
841 //--------------------------------------------------------------
843 CTDevOrientationStep::CTDevOrientationStep()
845 SetTestStepName(KTDevOrientationStep);
848 CTGraphicsBase* CTDevOrientationStep::CreateTestL()
850 CTGraphicsBase* theTest = NULL;
851 CFbsDrawDevice* device = NULL;
852 TInt numOfScreens = 0;
853 TInt err = HAL::Get(HALData::EDisplayNumberOfScreens, numOfScreens);
854 RArray<TInt> arrayDispModesPerScreen;
856 CleanupClosePushL(arrayDispModesPerScreen);
857 for (TUint scr=0;scr<numOfScreens;scr++)
860 // go through all the display modes and find out the supported ones by hardware/emulator
861 for (TUint32 ind = 0; ind <= (TUint32)EColorLast; ind++)
863 TDisplayMode mode2 = (TDisplayMode)ind;
865 TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(scr, mode2));
866 if (err==KErrNone) //support this mode
869 }// otherwise, unsupport this mode does nothing
874 arrayDispModesPerScreen.Append(modeBits);
877 // Create the test class
878 if (arrayDispModesPerScreen.Count() > 0)
880 // there is at least one supported display modes
881 theTest = new (ELeave) CTDevOrientation(this, arrayDispModesPerScreen);
885 User::Leave(KErrNotSupported);
888 CleanupStack::Pop(&arrayDispModesPerScreen);
893 void CTDevOrientationStep::TestSetupL()
896 HAL::Get(KDefaultScreenNo, HALData::EDisplayColors, temp);//force HAL memory allocation