Catchup NewGraphicsArchitecture branch with latest Nokia drop. NewGraphicsArchitecture
authorPat Downey <patd@symbian.org>
Tue, 13 Jul 2010 16:54:51 +0100
branchNewGraphicsArchitecture
changeset 112 5981337c8beb
parent 107 97c593d3e0a5 (current diff)
parent 109 7f6e7753e018 (diff)
child 114 a3a44bc20117
Catchup NewGraphicsArchitecture branch with latest Nokia drop.
--- a/graphicscomposition/surfaceupdate/src/surfaceupdateserver.cpp	Fri Jul 02 18:24:10 2010 +0100
+++ b/graphicscomposition/surfaceupdate/src/surfaceupdateserver.cpp	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -1014,26 +1014,15 @@
 		thus mustn't delete it. The pointer will be valid until server is operating, 
 		i.e. system is up.
 
-@panic KErrAccessDenied	If is called from process other than WSERV.	
 @return KErrNone if an operation is successful, any other system error codes otherwise
 */
 EXPORT_C TInt StartSurfaceUpdateServer(MSurfaceUpdateServerProvider*& aSurfaceUpdateServerProvider)
 	{
 #ifndef TEST_SURFACE_UPDATE
-	RProcess process;
-	TUidType uidType = process.Type();
-	const TInt32 KWservUid = 268450592;
-	const TUid& uid1 = uidType[2];
-
-	if(uid1.iUid != KWservUid) //only wserv process can start the server
-		{// some malicious client tries to launch the server
-		process.Panic(_L("Access denied"), KErrAccessDenied);
-		return KErrAccessDenied;
-		}	  
-	TPtrC serverName(KSurfaceUpdateServerName);
+    TPtrC serverName(KSurfaceUpdateServerName);
 #else
-	TPtrC serverName(KTestSurfaceUpdateServerName);
-#endif
+    TPtrC serverName(KTestSurfaceUpdateServerName);
+#endif    
 	TAny *provider = Dll::Tls();
 	if(provider)
 		{
--- a/graphicsdeviceinterface/screendriver/group/TScdvServer.mmp	Fri Jul 02 18:24:10 2010 +0100
+++ b/graphicsdeviceinterface/screendriver/group/TScdvServer.mmp	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -61,6 +61,7 @@
 library     lookuptable.lib
 library		fbscli.lib
 library		ws32.lib
+library		bitgdi.lib
  
 LIBRARY	    	testexecuteutils.lib tgraphicsharness.lib
 LIBRARY	    	testexecutelogclient.lib
--- a/graphicsdeviceinterface/screendriver/tsrc/TDirectScreenBitmap.cpp	Fri Jul 02 18:24:10 2010 +0100
+++ b/graphicsdeviceinterface/screendriver/tsrc/TDirectScreenBitmap.cpp	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -126,6 +126,7 @@
     	{
         TRequestStatus requestStatus;
         iDSBitmap->EndUpdate(requestStatus);	
+        User::WaitForRequest(requestStatus);
     	}
     return ret;
 	}
@@ -138,6 +139,7 @@
     	{
         TRequestStatus requestStatus;
         iDSBitmap->EndUpdate(iRect,requestStatus);	
+        User::WaitForRequest(requestStatus);
     	}
     return ret;
 	}
@@ -286,7 +288,7 @@
 
 //A largely visual test to demonstrate regional refreshing of DirectScreenBitmaps and the correct display function
 //of the Emulator.
-class CTDirectScreenBitmap : public CTGraphicsBase
+class CTDirectScreenBitmap : public CTGraphicsBase, public MDirectScreenAccess
 	{
 	public:	
 		~CTDirectScreenBitmap();
@@ -300,6 +302,9 @@
  		void LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr);
  		void TestContinuousRefreshingL();
  		void TestRefreshingTimeL();
+ 	
+ 	    void Restart(RDirectScreenAccess::TTerminationReasons aReason);
+ 	    void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
 	private:
 	    void TestRefreshingWindowsPerDisplayModeL(TDisplayMode aDisplayMode);
 		void TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode);
@@ -330,6 +335,12 @@
 	    TReal iMeasure ;
 	    TUint32 iTimeBefore;
 	    TUint32 iTimeAfter;
+	    RWsSession iSession;
+	    CWsScreenDevice* iScreenDevice;
+	    RWindow* iWin;
+	    RWindowGroup* iWinGroup;
+	    CDirectScreenAccess* iDSA;
+	    TInt iWindowHandle;
 
 	};
 
@@ -352,7 +363,7 @@
 	}; 
 
 CTDirectScreenBitmap::CTDirectScreenBitmap(CTestStep* aStep) :
-	CTGraphicsBase(aStep),iMeasure(0)
+	CTGraphicsBase(aStep),iMeasure(0), iSession()
 	{
 	}
 	
@@ -360,6 +371,18 @@
 	{
 	Close();
 	}
+
+void CTDirectScreenBitmap::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
+    {
+    iDSA->StartL();
+    CFbsBitGc* gc = iDSA->Gc();
+    RRegion* region = iDSA->DrawingRegion();
+    gc->SetClippingRegion(region);
+    }
+
+void CTDirectScreenBitmap::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
+    {
+    }
 	
 //Construct the DirectScreenBitmap and sub-rects for test of the refresh.	
 //Constructs a DirectScreenBitmap for EDoubleBuffer and EIncrementalUpdate
@@ -377,6 +400,27 @@
 		{
 		iDirectScreenBitmap = CDirectScreenBitmap::NewL();
 		}
+	iSession.Connect();
+	iScreenDevice = new (ELeave) CWsScreenDevice(iSession);
+	iScreenDevice->Construct();
+	
+	iWinGroup = new (ELeave) RWindowGroup(iSession);
+	iWinGroup->Construct(++iWindowHandle, iScreenDevice);
+	iWin = new (ELeave) RWindow(iSession);
+	iWin->Construct(*iWinGroup, ++iWindowHandle);
+	iWin->SetExtent(TPoint(0,0), aScreenRect.Size());
+	iWin->SetPosition(aScreenRect.iTl);
+	iWin->Activate();
+	iWin->BeginRedraw();
+	iWin->EndRedraw();
+	iDSA = CDirectScreenAccess::NewL(iSession, *iScreenDevice, *iWin, *this);
+	iSession.Flush();
+	iDSA->StartL();
+	
+	CFbsBitGc* gc = iDSA->Gc();
+	RRegion* region = iDSA->DrawingRegion();
+	gc->SetClippingRegion(region);
+	
 	iSettings = aSettings;
 	TInt create=iDirectScreenBitmap->Create(aScreenRect, aSettings);
 	if (create==KErrNone)
@@ -412,6 +456,19 @@
 	iInterface = NULL;
 	delete iRendering;
 	iRendering = NULL;
+	if (iDSA)
+	    {
+        iDSA->Cancel();
+        delete iDSA;
+        iDSA = NULL;
+	    }
+    delete iWin;
+    iWin = NULL;
+    delete iScreenDevice;
+    iScreenDevice = NULL;
+    delete iWinGroup;
+    iWinGroup = NULL;
+    iSession.Close();
 	}
 
 
@@ -438,26 +495,26 @@
 		if (!(iSettings & CDirectScreenBitmap::EIncrementalUpdate))
 			{		
 			iInterface->EndDraw(iRequestStatus);	
-			User::After(WAIT_TIME);
+			User::WaitForRequest(iRequestStatus);
 			}
 		else
 			{		
-			iInterface->EndDraw(iTopLeft, iRequestStatus);	
-			User::After(WAIT_TIME);
+			iInterface->EndDraw(iTopLeft, iRequestStatus);
+            User::WaitForRequest(iRequestStatus);
 			iInterface->BeginDraw();
 			iInterface->EndDraw(iTopRight, iRequestStatus);	
-			User::After(WAIT_TIME);
+            User::WaitForRequest(iRequestStatus);
 			iInterface->BeginDraw();
-			iInterface->EndDraw(iBotLeft, iRequestStatus);	
-			User::After(WAIT_TIME);
+			iInterface->EndDraw(iBotLeft, iRequestStatus);
+            User::WaitForRequest(iRequestStatus);
 			iInterface->BeginDraw();
-			iInterface->EndDraw(iBotRight, iRequestStatus);	
-			User::After(WAIT_TIME);
+			iInterface->EndDraw(iBotRight, iRequestStatus);
+            User::WaitForRequest(iRequestStatus);
 			
 			iInterface->DrawColor(iMiddle,KRgbCyan);
 			iInterface->BeginDraw();
 			iInterface->EndDraw(iMiddle, iRequestStatus);
-			User::After(WAIT_TIME);
+            User::WaitForRequest(iRequestStatus);
 
 			}
 		__ASSERT_DEBUG(iInterface->ScreenClear(), User::Invariant());
--- a/graphicsdeviceinterface/screendriver/tsrc/scripts/scdvtest_t_DirectScreenBitmap.script	Fri Jul 02 18:24:10 2010 +0100
+++ b/graphicsdeviceinterface/screendriver/tsrc/scripts/scdvtest_t_DirectScreenBitmap.script	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -16,4 +16,4 @@
 PRINT Run TScdv Screen Driver test
 //
 LOAD_SUITE TScdvServer
-RUN_TEST_STEP 540 TScdvServer TDirectScreenBitmap
+RUN_TEST_STEP !Heap=0x400000 720 TScdvServer TDirectScreenBitmap
--- a/windowing/windowserver/nga/CLIENT/RDirect.CPP	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/CLIENT/RDirect.CPP	Tue Jul 13 16:54:51 2010 +0100
@@ -528,7 +528,7 @@
 	iAbort.Restart(iReason);
 	}
 
-void CDirectScreenAccess::UpdateSizeAndRotation(CFbsBitGc*/* aGc*/)
+void CDirectScreenAccess::UpdateSizeAndRotation(CFbsBitGc* aGc)
 	{
 	TPixelsAndRotation sizeAndRotation;
 	iWsScreenDevice->GetDefaultScreenSizeAndRotation(sizeAndRotation);
@@ -549,6 +549,8 @@
 			iScreenDevice->SetDrawDeviceOffset(appAreaInDsa.iTl);
 			}
 		}
+	
+	aGc->Activate(iScreenDevice);
 	}
 
 void CDirectScreenAccess::RunL()
--- a/windowing/windowserver/nga/SERVER/EVENT.CPP	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/SERVER/EVENT.CPP	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -623,6 +623,21 @@
 	TWsEvent event;
 	event.SetType(EEventDisplayChanged);
 	event.SetTimeNow();
+	
+	// fill in the handle otherwise CONE will discard the notification
+    CWsObjectIx* clientObjList = aWsClient->ObjectIndex();
+    const TWsObject* ptr=clientObjList->FirstObject();
+    const TWsObject* end=ptr+clientObjList->Length();
+    while(++ptr<end)    // first one should always have a NULL object
+        {
+        const CWsObject* obj=ptr->iObject;
+        if (obj && obj->Type()==WS_HANDLE_GROUP_WINDOW)
+            {
+            event.SetHandle(ptr->iHandle);
+            break;
+            }
+        }	
+	
 	TWsDisplayChangedEvent* dispEvent = event.DisplayChanged();
 	dispEvent->iDisplayNumber = aDisplayNumber;
 	dispEvent->iConfigurationChangeId = aConfigurationChangeId;
--- a/windowing/windowserver/nga/SERVER/openwfc/screen.cpp	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/SERVER/openwfc/screen.cpp	Tue Jul 13 16:54:51 2010 +0100
@@ -68,7 +68,26 @@
 	return (TDeviceOrientation)(1 << aGcOrientation);
 	}
 
-LOCAL_D TBool FindNextValue(TLex& aLex, TInt& aValue) // assumes the list cannot contain *negative* integers
+/** Convert a TGraphicsOrientation value into a TDigitiserOrientation.
+Note: The algorithm used makes use of the ordering of the values of the respective enums, 
+thus this is checked for (at compile time) at the start of the function.
+@param aGcOrientation A value from the TGraphicsOrientation enums.
+@return The equivalent value from the TDigitiserOrientation enums.
+*/
+inline HALData::TDigitiserOrientation GcToDigitiser(CFbsBitGc::TGraphicsOrientation aGcOrientation)
+	{
+	__ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+1==CFbsBitGc::EGraphicsOrientationRotated90);
+    __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+2==CFbsBitGc::EGraphicsOrientationRotated180);
+    __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+3==CFbsBitGc::EGraphicsOrientationRotated270);
+    __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+1==HALData::EDigitiserOrientation_090);
+    __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+2==HALData::EDigitiserOrientation_180);
+    __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+3==HALData::EDigitiserOrientation_270);
+    HALData::TDigitiserOrientation ret = static_cast<HALData::TDigitiserOrientation> 
+            (HALData::EDigitiserOrientation_000 + (aGcOrientation - CFbsBitGc::EGraphicsOrientationNormal));
+    return ret;
+	}
+
+LOCAL_C TBool FindNextValue(TLex& aLex, TInt& aValue) // assumes the list cannot contain *negative* integers
 	{
 	while (!aLex.Eos())
 		{
@@ -1122,6 +1141,15 @@
 			}
 		
 		//updaterotation should not fail after this point (no cleanup)
+		
+        //update the last set config with the new rotation change so we don't incorrectly
+        //change the layer extents
+        if (iDisplayControl)
+            {
+            TDisplayConfiguration config;
+            config.SetRotation(static_cast<TDisplayConfiguration::TRotation>(newRotation));           
+            iConfigChangeNotifier->UpdateLastSetConfiguration(config);
+            }   		
 			
 		TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation);
 		TWindowServerEvent::NotifyDrawer(crEvent);
@@ -1134,17 +1162,29 @@
 		}
 	
 	iRootWindow->AdjustCoordsDueToRotation();
-	if (rotating)
-		{
-		if(BlankScreenOnRotation())
-			{
-			iRootWindow->ClearDisplay();
-			}
-		
-		CWsTop::ClearAllRedrawStores();	
-		DiscardAllSchedules();
-		iRootWindow->InvalidateWholeScreen();
-		}
+    if (rotating || (iFlags & ERepeatSettingHalOrientation))
+        {
+        if (HAL::Set(iScreenNumber, HALData::EDigitiserOrientation, GcToDigitiser(gcOrientation)) != KErrNone)
+            {
+            iFlags |= ERepeatSettingHalOrientation;
+            }
+        else
+            {
+            iFlags &= ~ERepeatSettingHalOrientation;
+            }
+        }
+    
+    if (rotating)
+        {
+        if (BlankScreenOnRotation())
+            {
+            iRootWindow->ClearDisplay();
+            }
+        CWsTop::ClearAllRedrawStores();
+        DiscardAllSchedules();
+        iRootWindow->InvalidateWholeScreen();
+        }
+    
 	return ETrue;
 	}
 
@@ -1984,14 +2024,20 @@
 			{
 			TSize oldConfigRes;
 			oldConfig.GetResolution(oldConfigRes);
+            TDisplayConfiguration newConfig;
 			if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0)
 				{
-				TDisplayConfiguration newConfig;
 				iDisplayControl->GetConfiguration(newConfig);
 				RecalculateModeTwips(&newConfig);	//needs res and twips information
 				}
 			UpdateDynamicScreenModes();
 			
+			//update the last set config in the config change notifier to 
+			//prevent SetConfiguration() from being called again!
+			newConfig.ClearAll();
+			iDisplayControl->GetConfiguration(newConfig);
+			iConfigChangeNotifier->UpdateLastSetConfiguration(newConfig); 			
+			
 			TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode));
 			// This will remove all the DSA elements from the scene
 			AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation);
@@ -2036,6 +2082,88 @@
 	return reply;
 	}
 
+TInt CScreen::UpdateConfiguration(const TDisplayConfiguration& aConfigInput)
+    {
+    TInt reply = KErrNone;
+    if(iDisplayControl)
+        {
+        TDisplayConfiguration config(aConfigInput);
+        TRect sizeModePosition;
+        if (iDisplayPolicy)
+            {   //validate config and update to a valid hardware config
+            reply = iDisplayPolicy->GetSizeModeConfiguration(iScreenSizeMode,config,sizeModePosition);
+            if (reply >= KErrNone)
+                {//set appmode in policy
+                if (iDisplayMapping)
+                    {
+                    iDisplayMapping->SetSizeModeExtent(sizeModePosition,MWsDisplayMapping::KOffsetAll);
+                    }
+                }
+            }
+        else
+            {   //exessive strategy: limit rotation agains curr app mode.
+                //really we want the system to accept the rotation change regardless of the app mode.
+            TDisplayConfiguration::TRotation newRot;
+            if (aConfigInput.GetRotation(newRot))
+                {   //This should cast between rotation enumertaions "properly"
+                if (!(iModes[0][iScreenSizeMode]->iAlternativeRotations&(1<<newRot)))
+                    {
+                    reply=KErrArgument;
+                    }
+                }
+            }
+
+        MWsScene::TSceneRotation oldRotation;
+        oldRotation = iScene->SceneRotation();
+        TSize newUiSize;
+        config.GetResolution(newUiSize);
+        if(iFlags&EHasDynamicSizeModes)
+            {
+            reply = iFallbackMap->Resize(newUiSize);
+            }
+
+        RecalculateModeTwips(&config);   //needs res and twips information
+        UpdateDynamicScreenModes();               
+        
+        TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode));
+        // This will remove all the DSA elements from the scene
+        AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation);
+        
+        //SetDigitiserAreas needs revisiting if/when we support dynamic resolutions
+        //on a screen with touch input.
+        //SetDigitiserAreas(newUiSize);
+        
+        //failure here should only be because of DSA orientation change failure, which shouldn't happen, either.
+        //Or there may be no change to do.
+        (void)UpdateOrientation(&oldRotation);
+        
+        iWindowElementSet->ResubmitAllElementExtents();
+        if(iDsaDevice && iDsaDevice->GraphicsAccelerator())
+            {
+            iDsaDevice->ChangeScreenDevice(iDsaDevice); // orientation has changed, therefore we need to re-initialise the screen device's graphics accelerator
+            }
+        
+        iRootWindow->AdjustCoordsDueToRotation();
+
+        //TODO jonas: we'd like to not have to clear at all... make the actual change to compositor etc lazily!
+        if(BlankScreenOnRotation())
+            {
+            iRootWindow->ClearDisplay();
+            }
+
+        CWsTop::ClearAllRedrawStores();
+        DiscardAllSchedules();
+        iRootWindow->InvalidateWholeScreen();
+        CWsWindowGroup::SetScreenDeviceValidStates(this);
+        TWindowServerEvent::SendScreenDeviceChangedEvents(this);
+        }
+    else
+        {
+        reply = KErrNotSupported;
+        }
+    return reply;   
+    }
+
 void CScreen::UpdateDynamicScreenModes()
 	{
 	WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl);
--- a/windowing/windowserver/nga/SERVER/openwfc/screen.h	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/SERVER/openwfc/screen.h	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -75,12 +75,13 @@
 	{
 public:
 	enum {EGetScanLineBufLen=0x100};	// Buffer of for returning result of GetScanLine
-	enum TDisplayScreen
+	enum TDisplayScreenFlags
 		{
 		EBlankScreenOnRotation = 0x1,
  		EAutoClear = 0x2,
  		EHasDynamicSizeModes = 0x04,
 		EChangeTracking = 0x8,
+		ERepeatSettingHalOrientation = 0x20
 		};
 	
 	/**
@@ -249,6 +250,7 @@
 	void ClearDsaSurface(const TRect& area, const TRgb& color);
 	void PositionUiElements(const TRect& aExtent,	const TRect& aViewport);
 	TInt SetConfiguration(const TDisplayConfiguration& aConfig);
+	TInt UpdateConfiguration(const TDisplayConfiguration& aConfig);
 	void UpdateDynamicScreenModes();
 	void RecalculateModeTwips(const TDisplayConfiguration* aConfig = NULL);
 	inline void IncreaseDisplaySpinner();
--- a/windowing/windowserver/nga/SERVER/wsdisplaychangeao.cpp	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/SERVER/wsdisplaychangeao.cpp	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -243,6 +243,27 @@
 	Cancel();
 	}
 
+void CWsConfigChangeNotifier::UpdateLastSetConfiguration(TDisplayConfiguration& aNewConfig)
+    {
+    TSize resolution(0,0);
+    if (aNewConfig.GetResolution(resolution))
+        {
+        iLastSetConfig.SetResolution(resolution);
+        }
+    
+    TSize resolutionTwips(0,0);
+    if (aNewConfig.GetResolutionTwips(resolutionTwips))
+        {
+        iLastSetConfig.SetResolutionTwips(resolutionTwips);   
+        }
+    
+    TDisplayConfiguration1::TRotation rotation;
+    if (aNewConfig.GetRotation(rotation))
+        {
+        iLastSetConfig.SetRotation(rotation);
+        }
+    }
+
 void CWsConfigChangeNotifier::RunL()
 	{
 	if(iStatus == KErrNone)
@@ -259,6 +280,29 @@
 			iRetry->CancelRetry();
 			
 			iOwner->IncreaseConfigSpinner();
+			
+            //if the config change comes from a render stage then ensure screen device size 
+            //is also updated
+            TSize currentRes;
+            currentConfig.GetResolution(currentRes);
+            TBool disconnected = (currentRes.iHeight == 0 || currentRes.iWidth == 0) ? ETrue : EFalse;
+            
+            //if the config change is due to CScreen::SetConfiguration() being called then we
+            //don't want to update it again. Only update if the configs are different and the
+            //display is connected...
+            TDisplayConfiguration lastSetConfig(iLastSetConfig);
+            if (!((currentConfig == lastSetConfig) || (disconnected)))
+                {
+                TDisplayConfiguration1::TRotation rotation;
+                if (lastSetConfig.GetRotation(rotation))
+                    {
+                    //use the latest rotation value to ensure we don't get any
+                    //inconsistencies with the layer extents
+                    currentConfig.SetRotation(rotation);
+                    }
+                iOwner->UpdateConfiguration(currentConfig);
+                }
+
 			//put config change event on queue
 			RPointerArray<CWsClient> clientArray;
 			CleanupClosePushL(clientArray);
@@ -282,12 +326,12 @@
 				iRetry->Retry(KRetryInitialDelay);
 				}
 			}
+		iNextLevelInterface->GetConfiguration(iLastSetConfig);
 		}
 	else if(iStatus != KErrCancel && iStatus != KErrNotSupported)
 		{
 		IssueNotificationRequest();
 		}
-	
 	}
 
 
--- a/windowing/windowserver/nga/SERVER/wsdisplaychangeao.h	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/nga/SERVER/wsdisplaychangeao.h	Tue Jul 13 16:54:51 2010 +0100
@@ -1,5 +1,5 @@
 /**
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -60,6 +60,7 @@
 		static CWsConfigChangeNotifier* NewL(MWsDisplayControl* aNextLevelInterface, CScreen *aOwner);
 		void IssueNotificationRequest();
 		void CancelNotificationRequest();
+		void UpdateLastSetConfiguration(TDisplayConfiguration& aNewConfig);
 		~CWsConfigChangeNotifier();
 	protected:
 		void ConstructL();
@@ -75,6 +76,8 @@
 		CEventQueueRetry *iRetry;
 		
 		TDisplayConfiguration iLastConfig;
+		// last set screen device SetConfiguration call
+		TDisplayConfiguration iLastSetConfig;
 	};
 
 #endif
--- a/windowing/windowserver/tauto/TSCRMODE.CPP	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/tauto/TSCRMODE.CPP	Tue Jul 13 16:54:51 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -22,6 +22,8 @@
 */
 
 #include "TSCRMODE.H"
+#include <hal.h>
+#include <hal_data.h>
 
 const TInt KBlankWinPosX=10;
 const TInt KBlankWinPosY=20;
@@ -30,21 +32,19 @@
 
 const TInt KScreenMode0=0;
 const TInt KScreenMode1=1;
-_LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode");
 
 
 CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep)
-	{
-	}
+	{}
 
 //
 // Static func to check windows
 //
 
-LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
+LOCAL_C TInt DoPanicTest(TInt aInt, TAny* aScreenNumber)
 	{
 	RWsSession ws;
-	CWsScreenDevice *screen=NULL;
+	CWsScreenDevice* screen=NULL;
 	if (ws.Connect()==KErrNone)
 		{
 		screen = new (ELeave) CWsScreenDevice(ws);
@@ -93,7 +93,7 @@
 				case 14:
 				case 15:
 					{
-					CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
+					CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
 					screen->GetRotationsList(aInt==12?1003:-2,rotations);
 					}
 					break;
@@ -129,6 +129,7 @@
 	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow));
 	aWindow.SetExtent(aPos, aSize);
 	User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode));
+	aWindow.SetBackgroundColor(TRgb(255,127,0));		//Orange
 	aWindow.Activate();
 	}
 
@@ -197,7 +198,7 @@
 	const TInt KYScaleFactor=3;
 //
 	// Draw rectangle onto TestWin
- 	CWindowGc *gc=TheClient->iGc;
+ 	CWindowGc* gc=TheClient->iGc;
 	gc->Activate(*(TestWin->Win()));
 	gc->SetBrushColor(KRgbBlack);
 	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
@@ -208,9 +209,9 @@
 	TSize bitSize(KLineLength,1);
 	TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor),
 					  TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor));
-	CFbsBitGc *bitGc=NULL;
-	CFbsBitmapDevice *device=NULL;
-	CFbsBitmap *bitmap=NULL;
+	CFbsBitGc* bitGc=NULL;
+	CFbsBitmapDevice* device=NULL;
+	CFbsBitmap* bitmap=NULL;
 	bitmap=new(ELeave) CFbsBitmap();
 	CleanupStack::PushL(bitmap);
 	User::LeaveIfError(bitmap->Create(bitSize,EGray16));
@@ -233,7 +234,7 @@
 	CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed"));
 	}
 
-void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor)
+void CTScrMode::ValidateWin(TestWindow* aWin, TRgb aColor)
 	{
 	aWin->Win()->Invalidate();
 	RedrawWin(*aWin->Win(),aColor);
@@ -261,8 +262,8 @@
 
 void CTScrMode::ScreenRotationsL()
 	{
-	CWsScreenDevice *screen=TheClient->iScreen;
-	CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
+	CWsScreenDevice* screen=TheClient->iScreen;
+	CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
 	CFbsBitGc::TGraphicsOrientation currentRotation;
 	TPixelsAndRotation sizeAndRotation;
 	TPixelsTwipsAndRotation sizeAndRotation2;
@@ -278,32 +279,39 @@
 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
 		TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth);
-		if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth)
-			INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth  - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth);
-
 		TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight);
-		if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight)
-			INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight  - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight);
-
+		if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth
+					|| sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight)
+			{
+			_LIT(KLog,"Height and/or Width don't match (%d,%d)!=(%d,%d) for mode %d");
+			LOG_MESSAGE6(KLog,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
+							,sizeAndRotation2.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iHeight,ii);
+			}
 		count=rotations->Count();
 		TEST(count>=1);
 		if (count<1)
-			INFO_PRINTF3(_L("rotations->Count() return value  - Expected: %d or more, Actual: %d"), 1, count);
-
-		TBool retVal;
-
+			{
+			_LIT(KLog,"No rotations supported for mode %d");
+			LOG_MESSAGE2(KLog,ii);
+			}
+		TBool match;
 		if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight)
 			{
 			TEST(count<=2);
 			if (count>2)
-				INFO_PRINTF3(_L("rotations->Count() return value  - Expected: %d or less, Actual: %d"), 2, count);
-
+				{
+				_LIT(KLog,"Non-square mode %d supports more than 2 rotations (actual rotations=%d)");
+				LOG_MESSAGE3(KLog,ii,count);
+				}
 			if (count==2)
 				{
-				retVal = (*rotations)[0]+2==(*rotations)[1];
-				TEST(retVal);		//Must only have rotations 180 degrees apart
-				if (!retVal)
-					INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1]  - Expected: %d, Actual: %d"), ETrue, retVal);
+				match=((*rotations)[0]+2==(*rotations)[1]);
+				TEST(match);		//Must only have rotations 180 degrees apart
+				if (!match)
+					{
+					_LIT(KLog,"In non-square mode %d the two rotations do not differ by 180degrees, rot1=%d, rot2=%d");
+					LOG_MESSAGE4(KLog,ii,(*rotations)[0],(*rotations)[1]);
+					}
 				}
 			}
 		found=EFalse;
@@ -311,78 +319,107 @@
 			{
 			if ((*rotations)[jj]==sizeAndRotation.iRotation)
 				{
-				retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
-				TEST(retVal);
-				if (!retVal)
-					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
-
+				match=((*rotations)[jj]==sizeAndRotation2.iRotation);
+				TEST(match);
+				if (!match)
+					{
+					_LIT(KLog,"Rotations don't match %d!=%d for mode %d");
+					LOG_MESSAGE4(KLog,sizeAndRotation.iRotation,sizeAndRotation2.iRotation,ii);
+					}
 				found=ETrue;
 				break;
 				}
 			}
 		TEST(found);
 		if (!found)
-				INFO_PRINTF3(_L("found  - Expected: %d, Actual: %d"), ETrue, found);
+			{
+			_LIT(KLog,"In mode %d the current rotation (%d) is not one of the allowable rotations");
+			LOG_MESSAGE3(KLog,ii,sizeAndRotation.iRotation);
+			}
 
 		if (count>1)
 			{
 			currentRotation=sizeAndRotation.iRotation;
 			for (jj=0;jj<count;++jj)
 				{
-				screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj]));
+				screen->SetCurrentRotations(mode,reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>((*rotations)[jj]));
 				screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
 				screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
-				retVal = (*rotations)[jj]==sizeAndRotation.iRotation;
-				TEST(retVal);
-				if (!retVal)
-					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
-
-				retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
-				TEST(retVal);
-				if (!retVal)
-					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
-
+				match=(((*rotations)[jj]==sizeAndRotation.iRotation) && ((*rotations)[jj]==sizeAndRotation2.iRotation));
+				TEST(match);
+				if (!match)
+					{
+					_LIT(KLog,"Rotations don't match %d!=%d (both should be %d) after switching to rotation number %d of mode %d");
+					LOG_MESSAGE6(KLog,sizeAndRotation.iRotation,sizeAndRotation2.iRotation,(*rotations)[jj],jj,ii);
+					}
 				}
-			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
+			screen->SetCurrentRotations(mode,reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>(currentRotation));
 			screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
 			screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
-
-			retVal = currentRotation==sizeAndRotation.iRotation;
-			TEST(retVal);
-			if (!retVal)
-				INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
-
-			retVal = currentRotation==sizeAndRotation2.iRotation;
-			TEST(retVal);
-			if (!retVal)
-				INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
+			match=((currentRotation==sizeAndRotation.iRotation) && (currentRotation==sizeAndRotation2.iRotation));
+			TEST(match);
+			if (!match)
+					{
+					_LIT(KLog,"Rotations don't match %d!=%d (both should be %d) after switching to the original rotation of mode %d");
+					LOG_MESSAGE5(KLog,sizeAndRotation.iRotation,sizeAndRotation2.iRotation,currentRotation,ii);
+					}
 			}
 		}
-	CleanupStack::PopAndDestroy();
+	CleanupStack::PopAndDestroy(rotations);
 	}
+/**
+  Validate that the screen orienation matchs wiht the screeen orientation stored/set by Wserv in the HAL storage attribute. 
+  @param aGcOrientation Input orientation to valudate.
+ */
+void CTScrMode::CheckHalSetting(TInt aGcOrientation)
+    {
+    HALData::TDigitiserOrientation halOrientationExp = static_cast<HALData::TDigitiserOrientation>
+            (HALData::EDigitiserOrientation_000 + (aGcOrientation - CFbsBitGc::EGraphicsOrientationNormal));
+    TInt halOrientation;
+    TInt err = HAL::Get(iTest->iScreenNumber, HALData::EDigitiserOrientation, halOrientation);
+    // Validate if it's supported by HAL
+    if (err != KErrNotSupported)
+        {
+        if (err != KErrNone)
+            {
+            _LIT(KLog,"Getting HAL orientation attribute returned error %d when no error expected");
+            LOG_MESSAGE2(KLog,err);
+            }
+        TEST(err==KErrNone);
+        if (halOrientationExp != halOrientation)
+            {
+            _LIT(KLog,"HAL orientation is %d when expected to be %d");
+            LOG_MESSAGE3(KLog,halOrientation,halOrientationExp);
+            }
+        TEST(halOrientationExp==halOrientation);
+        }
+    else
+        {
+        _LIT(KLog,"HAL-Orientation HALData::EDigitiserOrientation isn't supported by Driver");
+        LOG_MESSAGE(KLog);
+        }
+    }
 
 void CTScrMode::MoreScreenRotationsL()
 	{
-	RWindow shield4Gray(TheClient->iWs);
-	// The default display mode needs to be updated to EColor64K for Oghma integ
-	SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K);
-//
-	CWsScreenDevice *screen=TheClient->iScreen;
-	//CFbsBitGc::TGraphicsOrientation currentRotation;
+	RWindow shield64Color(TheClient->iWs);
+	SetupTestRWindowLC(shield64Color,TPoint(),TSize(100000,100000),EColor64K);
+	CWsScreenDevice* screen=TheClient->iScreen;
 	TPixelsAndRotation sizeAndRotation;
 	TInt currentRotation;
 	TInt currentMode=FindCurrentMode();
 	TInt numModes=TheClient->iScreenModes.Count();
 	TInt currentScreenMode;
 	TInt count;
-	TInt ii,jj;
-	CArrayFixFlat<TInt> *currentRotations=new(ELeave) CArrayFixFlat<TInt>(1);
+	TInt ii;
+	TInt jj;
+	CArrayFixFlat<TInt>* currentRotations=new(ELeave) CArrayFixFlat<TInt>(1);
 	CleanupStack::PushL(currentRotations);
 	currentRotations->ResizeL(numModes);
-	CArrayFixFlat<TInt> *originalRotation=new(ELeave) CArrayFixFlat<TInt>(1);
+	CArrayFixFlat<TInt>* originalRotation=new(ELeave) CArrayFixFlat<TInt>(1);
 	CleanupStack::PushL(originalRotation);
 	originalRotation->ResizeL(numModes);
-	CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
+	CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
 	CleanupStack::PushL(rotations);
 	for (ii=0;ii<numModes;++ii)
 		{
@@ -391,21 +428,27 @@
 		(*currentRotations)[ii]=sizeAndRotation.iRotation;
 		(*originalRotation)[ii]=sizeAndRotation.iRotation;
 		}
+	_LIT(KModeSwitchFail,"Change to screen mode %d, resulted in screen being in mode %d");
+	_LIT(KRotDiff,"Rotations dont match %d!=%d for mode %d");
 	for (ii=0;ii<numModes;++ii)
 		{
 		TInt mode=TheClient->iScreenModes[ii];
 		screen->SetScreenMode(mode);
-		currentScreenMode = screen->CurrentScreenMode();
-		TEST(currentScreenMode == mode);
-		if (currentScreenMode != mode)
-			INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
+		currentScreenMode=screen->CurrentScreenMode();
+		TEST(currentScreenMode==mode);
+		if (currentScreenMode!=mode)
+			LOG_MESSAGE3(KModeSwitchFail,mode,currentScreenMode);
 
 		screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
-		currentRotation=(*currentRotations)[ii];
-		TEST(sizeAndRotation.iRotation==currentRotation);
-
+		currentRotation=sizeAndRotation.iRotation;
+		TEST((*currentRotations)[ii]==currentRotation);
+		if ((*currentRotations)[ii]!=currentRotation)
+			LOG_MESSAGE4(KRotDiff,(*currentRotations)[ii],currentRotation,ii);
 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
 		TEST(sizeAndRotation.iRotation==currentRotation);
+		if (sizeAndRotation.iRotation!=currentRotation)
+			LOG_MESSAGE4(KRotDiff,sizeAndRotation.iRotation,currentRotation,ii);
+		CheckHalSetting(currentRotation);
 
 		User::LeaveIfError(screen->GetRotationsList(mode,rotations));
 		count=rotations->Count();
@@ -419,7 +462,7 @@
 			if (jj==count)
 				jj=0;
 			currentRotation=(*rotations)[jj];
-			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
+			screen->SetCurrentRotations(mode,reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>(currentRotation));
 			(*currentRotations)[ii]=currentRotation;
 			}
 		}
@@ -427,37 +470,44 @@
 		{
 		TInt mode=TheClient->iScreenModes[ii];
 		screen->SetScreenMode(mode);
-		currentScreenMode = screen->CurrentScreenMode();
-		TEST(currentScreenMode == mode);
-		if (currentScreenMode != mode)
-			INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
+		currentScreenMode=screen->CurrentScreenMode();
+		TEST(currentScreenMode==mode);
+		if (currentScreenMode!=mode)
+			LOG_MESSAGE3(KModeSwitchFail,mode,currentScreenMode);
 
+		_LIT(KRotDiff,"Switching to mode %d with rotations %d caused the rotation to become %d");
 		screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
 		currentRotation=(*currentRotations)[ii];
 		TEST(sizeAndRotation.iRotation==currentRotation);
-		if (sizeAndRotation.iRotation != currentRotation)
-			INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
-
+		if (sizeAndRotation.iRotation!=currentRotation)
+			{
+			_LIT(KRotDiff,"Switching to mode %d with rotations %d caused the rotation to become %d");
+			LOG_MESSAGE4(KRotDiff,mode,currentRotation,sizeAndRotation.iRotation);
+			}
 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
 		TEST(sizeAndRotation.iRotation==currentRotation);
-		if (sizeAndRotation.iRotation != currentRotation)
-			INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
+		if (sizeAndRotation.iRotation!=currentRotation)
+			LOG_MESSAGE4(KRotDiff,sizeAndRotation.iRotation,currentRotation,ii);
+		CheckHalSetting(currentRotation);
 
 		if (currentRotation!=(*originalRotation)[ii])
-			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii]));
+			{
+			screen->SetCurrentRotations(mode,reinterpret_cast<CFbsBitGc::TGraphicsOrientation&>((*originalRotation)[ii]));
+			CheckHalSetting(currentRotation);
+			}
 		}
 	screen->SetScreenMode(currentMode);
-	currentScreenMode = screen->CurrentScreenMode();
-	TEST(currentScreenMode == currentMode);
-	if (currentScreenMode != currentMode)
-		INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode);
+	currentScreenMode=screen->CurrentScreenMode();
+	TEST(currentScreenMode==currentMode);
+	if (currentScreenMode!=currentMode)
+		LOG_MESSAGE3(KModeSwitchFail,currentMode,currentScreenMode);
 
-	CleanupStack::PopAndDestroy(4,&shield4Gray);
+	CleanupStack::PopAndDestroy(4,&shield64Color);
 	}
 
 TInt CTScrMode::FindCurrentMode()
 	{
-	CWsScreenDevice *screen=TheClient->iScreen;
+	CWsScreenDevice* screen=TheClient->iScreen;
 	TPixelsTwipsAndRotation sizeAndRotation;
 	TPixelsTwipsAndRotation sizeAndRotation2;
 	TInt numModes=TheClient->iScreenModes.Count();
@@ -487,7 +537,7 @@
 
 TBool CTScrMode::RectClearBugL()
 	{
-	CWsScreenDevice *screen=TheClient->iScreen;
+	CWsScreenDevice* screen=TheClient->iScreen;
 	TPixelsTwipsAndRotation sizeAndRotation1;
 	TPixelsTwipsAndRotation sizeAndRotation2;
 	TInt screenMode=FindCurrentMode();
@@ -510,7 +560,7 @@
 		INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode);
 		screen->SetScreenMode(largeMode);
 	}
-	CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204));
+	CBlankWindow* blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204));
 	CleanupStack::PushL(blankWin);
 	blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc);
 	TheClient->iGc->Activate(*blankWin->Win());		//blankWin->Win()->Invalidate();
@@ -691,7 +741,7 @@
 void CTScrMode::GetScreenDisplayMode()
 	{
 	TInt color,gray;
-	CWsScreenDevice *screen=TheClient->iScreen;
+	CWsScreenDevice* screen=TheClient->iScreen;
 	TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode
 	screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1
 
@@ -1106,6 +1156,11 @@
 
 void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/)
 	{
+	_LIT(KTest1,"Orientation1");
+	_LIT(KTest2,"Orientation2");
+	_LIT(KTest3,"Rect Clear Defect");
+	_LIT(KTest4,"ScreenModeChange");
+	_LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode");
 	TBuf<32> buf;
 	TBool checkWindowParam=EFalse;
 	TInt count=0;
@@ -1113,61 +1168,53 @@
 	TBool enable=EFalse;
 	TBool disable=EFalse;
 	TInt retVal;
-	
-	((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
+
 	switch(++iTest->iState)
 		{
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0296
 
-  @SYMDEF  			DEF081259
-
-  @SYMTestCaseDesc Test screen modes can be set while the screen is rotated
-  					through 180 degrees.
+  @SYMTestCaseDesc Test that sizes and rotations returned by the various 
+					GetScreenModeSizeAndRotation function are consistent.
+					Also test that the rotations can be set within each mode.
 
   @SYMTestPriority High
 
   @SYMTestStatus Implemented
 
-  @SYMTestActions Rotate the screen through 180 degrees while setting each
-  					of the screen modes available
+  @SYMTestActions Read the size and rotation of each mode 
+  					and set all allowable rotations.
 
-  @SYMTestExpectedResults The screen is rotated and screen modes set correctly
-
+  @SYMTestExpectedResults The rotations and sizes are consistent 
+  							and the rotations get set correctly.
 */
-		case 1:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296"));
-			iTest->LogSubTest(_L("Orientation1"));
-			ScreenRotationsL();
-			break;
+	case 1:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296"));
+		iTest->LogSubTest(KTest1);
+		ScreenRotationsL();
+		break;
+
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0297
 
-  @SYMDEF  			DEF081259
-
-  @SYMTestCaseDesc Change the screen orientation then test screen modes can
-  					be set while the screen is rotated through 180 degrees.
+  @SYMTestCaseDesc That right rotation is achieved when screen mode is changed.
 
   @SYMTestPriority High
 
   @SYMTestStatus Implemented
 
-  @SYMTestActions Rotate the screen through 180 degrees while setting each
-  					of the screen modes available
+  @SYMTestActions Change the screen modes and rotations in each screen mode (where possible).
 
-  @SYMTestExpectedResults The screen is rotated and screen modes set correctly
-
+  @SYMTestExpectedResults The screen ends up in the right rotation
 */
-		case 2:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297"));
-			iTest->LogSubTest(_L("Orientation2"));
-			MoreScreenRotationsL();
-			iSubState=0;
-			break;
+	case 2:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297"));
+		iTest->LogSubTest(KTest2);
+		MoreScreenRotationsL();
+		iSubState=0;
+		break;
+
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0298
 
   @SYMDEF  			DEF081259
@@ -1182,16 +1229,14 @@
   					not present
 
   @SYMTestExpectedResults The defect is not present
+*/
+	case 3:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298"));
+		iTest->LogSubTest(KTest3);
+		RectClearBugL();
+		break;
 
-*/
-		case 3:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298"));
-			iTest->LogSubTest(_L("Rect Clear Defect"));
-			RectClearBugL();
-			break;
-		case 4:
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0299
 
   @SYMDEF  			DEF081259
@@ -1209,14 +1254,14 @@
   @SYMTestExpectedResults The windows function correctly
 
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299"));
+	case 4:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299"));
+		iTest->LogSubTest(KTest4);
+		ScreenModeChange1L();
+		ScreenModeChange2L();
+		break;
 
-			iTest->LogSubTest(_L("ScreenModeChange"));
-			ScreenModeChange1L();
-			ScreenModeChange2L();
-			break;
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0300
 
   @SYMDEF  			DEF081259
@@ -1231,18 +1276,15 @@
 
   @SYMTestExpectedResults The display mode retrieved is the same as the
   							one set.
+*/
+	case 5:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300"));
+		iTest->LogSubTest(KScreenModeDisplayMode);
+		GetScreenDisplayMode();
+		break;
 
-*/
-		case 5:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300"));
-			iTest->LogSubTest(KScreenModeDisplayMode);
-			GetScreenDisplayMode();
-			break;
-
-	
 #if defined(SCREEN_MODE_TESTING)
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0301
 
   @SYMDEF  			DEF081259
@@ -1259,203 +1301,206 @@
   					redraw the screen
 
   @SYMTestExpectedResults The screen is drawn correctly for each setting
+*/
+	case 101:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301"));
+		iSubState = 0;
+		buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
+		INFO_PRINTF1(buf);
+		checkWindowParam=ETrue;
+		mode=1;
+		if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			count+=3;
+		else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
+			count+=6;
+		if (iSecondConnection->DeviceMessageCount()!=count)
+			{
+			TLogMessageText buf;
+			_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
+			buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
+			TheClient->iWs.LogMessage(buf);
+			TheClient->iWs.Flush();
+			}
+		retVal = iSecondConnection->DeviceMessageCount();
+		TEST(retVal==count);
+		if (retVal!=count)
+			INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
+		
+		CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
+		if (enable)
+			iSecondConnection->EnableMessages();
+		if (disable)
+			iSecondConnection->DisableMessages();
+		TheClient->iScreen->SetScreenMode(mode);
+		TheClient->iWs.Flush();
+		iSubState++;
+		break;
 
-*/
-		case 101:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301"));
-			iSubState = 0;
-			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
-			INFO_PRINTF1(buf);
-			checkWindowParam=ETrue;
-			mode=1;
-			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				count+=3;
-			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
-				count+=6;
-			if (iSecondConnection->DeviceMessageCount()!=count)
-				{
-				TLogMessageText buf;
-				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
-				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
-				TheClient->iWs.LogMessage(buf);
-				TheClient->iWs.Flush();
-				}
-			retVal = iSecondConnection->DeviceMessageCount();
-			TEST(retVal==count);
-			if (retVal!=count)
-				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
-			
-			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
-			if (enable)
-				iSecondConnection->EnableMessages();
-			if (disable)
-				iSecondConnection->DisableMessages();
-			TheClient->iScreen->SetScreenMode(mode);
-			TheClient->iWs.Flush();
-			iSubState++;
-			break;
-		case 102:
 /**
   @SYMTestCaseID GRAPHICS-WSERV-0521
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521"));
-			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
-			INFO_PRINTF1(buf);
-			checkWindowParam=EFalse;
-			enable=ETrue;
-			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				count+=3;
-			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
-				count+=6;
-			if (iSecondConnection->DeviceMessageCount()!=count)
-				{
-				TLogMessageText buf;
-				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
-				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
-				TheClient->iWs.LogMessage(buf);
-				TheClient->iWs.Flush();
-				}
-			retVal = iSecondConnection->DeviceMessageCount();
-			TEST(retVal==count);
-			if (retVal!=count)
-				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
+	case 102:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521"));
+		buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
+		INFO_PRINTF1(buf);
+		checkWindowParam=EFalse;
+		enable=ETrue;
+		if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			count+=3;
+		else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
+			count+=6;
+		if (iSecondConnection->DeviceMessageCount()!=count)
+			{
+			TLogMessageText buf;
+			_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
+			buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
+			TheClient->iWs.LogMessage(buf);
+			TheClient->iWs.Flush();
+			}
+		retVal = iSecondConnection->DeviceMessageCount();
+		TEST(retVal==count);
+		if (retVal!=count)
+			INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
 
-			if (enable)
-				iSecondConnection->EnableMessages();
-			if (disable)
-				iSecondConnection->DisableMessages();
-			TheClient->iScreen->SetScreenMode(mode);
-			TheClient->iWs.Flush();
-			iSubState++;
-			break;
-		case 103:
+		if (enable)
+			iSecondConnection->EnableMessages();
+		if (disable)
+			iSecondConnection->DisableMessages();
+		TheClient->iScreen->SetScreenMode(mode);
+		TheClient->iWs.Flush();
+		iSubState++;
+		break;
+
 /**
   @SYMTestCaseID GRAPHICS-WSERV-0522
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522"));
-			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
-			INFO_PRINTF1(buf);
-			count=1;
-			mode=1;
-			checkWindowParam=ETrue;
-			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				count+=3;
-			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
-				count+=6;
-			if (iSecondConnection->DeviceMessageCount()!=count)
-				{
-				TLogMessageText buf;
-				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
-				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
-				TheClient->iWs.LogMessage(buf);
-				TheClient->iWs.Flush();
-				}
-			retVal = iSecondConnection->DeviceMessageCount();
-			TEST(retVal==count);
-			if (retVal!=count)
-				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
+	case 103:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522"));
+		buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
+		INFO_PRINTF1(buf);
+		count=1;
+		mode=1;
+		checkWindowParam=ETrue;
+		if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			count+=3;
+		else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
+			count+=6;
+		if (iSecondConnection->DeviceMessageCount()!=count)
+			{
+			TLogMessageText buf;
+			_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
+			buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
+			TheClient->iWs.LogMessage(buf);
+			TheClient->iWs.Flush();
+			}
+		retVal = iSecondConnection->DeviceMessageCount();
+		TEST(retVal==count);
+		if (retVal!=count)
+			INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
 
-			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
-			if (enable)
-				iSecondConnection->EnableMessages();
-			if (disable)
-				iSecondConnection->DisableMessages();
-			TheClient->iScreen->SetScreenMode(mode);
-			TheClient->iWs.Flush();
-			iSubState++;
-			break;
-		case 104:
+		CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
+		if (enable)
+			iSecondConnection->EnableMessages();
+		if (disable)
+			iSecondConnection->DisableMessages();
+		TheClient->iScreen->SetScreenMode(mode);
+		TheClient->iWs.Flush();
+		iSubState++;
+		break;
+
 /**
   @SYMTestCaseID GRAPHICS-WSERV-0523
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523"));
-			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
-			INFO_PRINTF1(buf);
-			checkWindowParam=ETrue;
-			count=2;
-			disable=ETrue;
-			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				count+=3;
-			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
-				count+=6;
-			if (iSecondConnection->DeviceMessageCount()!=count)
-				{
-				TLogMessageText buf;
-				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
-				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
-				TheClient->iWs.LogMessage(buf);
-				TheClient->iWs.Flush();
-				}
-			retVal = iSecondConnection->DeviceMessageCount();
-			TEST(retVal==count);
-			if (retVal!=count)
-				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
+	case 104:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523"));
+		buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
+		INFO_PRINTF1(buf);
+		checkWindowParam=ETrue;
+		count=2;
+		disable=ETrue;
+		if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			count+=3;
+		else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
+			count+=6;
+		if (iSecondConnection->DeviceMessageCount()!=count)
+			{
+			TLogMessageText buf;
+			_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
+			buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
+			TheClient->iWs.LogMessage(buf);
+			TheClient->iWs.Flush();
+			}
+		retVal = iSecondConnection->DeviceMessageCount();
+		TEST(retVal==count);
+		if (retVal!=count)
+			INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
 
-			if (enable)
-				iSecondConnection->EnableMessages();
-			if (disable)
-				iSecondConnection->DisableMessages();
-			TheClient->iScreen->SetScreenMode(mode);
-			TheClient->iWs.Flush();
-			iSubState++;
-			break;
-		case 105:
+		if (enable)
+			iSecondConnection->EnableMessages();
+		if (disable)
+			iSecondConnection->DisableMessages();
+		TheClient->iScreen->SetScreenMode(mode);
+		TheClient->iWs.Flush();
+		iSubState++;
+		break;
+
 /**
   @SYMTestCaseID GRAPHICS-WSERV-0524
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524"));
-			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
-			INFO_PRINTF1(buf);
-			checkWindowParam=EFalse;
-			count=2;
-			enable=ETrue;
-			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				count+=3;
-			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
-				count+=6;
-			if (iSecondConnection->DeviceMessageCount()!=count)
-				{
-				TLogMessageText buf;
-				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
-				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
-				TheClient->iWs.LogMessage(buf);
-				TheClient->iWs.Flush();
-				}
-			retVal = iSecondConnection->DeviceMessageCount();
-			TEST(retVal==count);
-			if (retVal!=count)
-				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
+	case 105:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524"));
+		buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
+		INFO_PRINTF1(buf);
+		checkWindowParam=EFalse;
+		count=2;
+		enable=ETrue;
+		if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			count+=3;
+		else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
+			count+=6;
+		if (iSecondConnection->DeviceMessageCount()!=count)
+			{
+			TLogMessageText buf;
+			_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
+			buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
+			TheClient->iWs.LogMessage(buf);
+			TheClient->iWs.Flush();
+			}
+		retVal = iSecondConnection->DeviceMessageCount();
+		TEST(retVal==count);
+		if (retVal!=count)
+			INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
 
-			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
-			if (enable)
-				iSecondConnection->EnableMessages();
-			if (disable)
-				iSecondConnection->DisableMessages();
-			TheClient->iScreen->SetScreenMode(mode);
-			TheClient->iWs.Flush();
+		CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
+		if (enable)
+			iSecondConnection->EnableMessages();
+		if (disable)
+			iSecondConnection->DisableMessages();
+		TheClient->iScreen->SetScreenMode(mode);
+		TheClient->iWs.Flush();
 
 
-			iSecondConnection->DisableMessages();
-			if (iCurEnforcement==ESizeEnforcementNone)
-				{	// Do it again with different enforcement mode
-				SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
-				ResetCounter(100);
-				}
-			else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
-				{	// Do it again with different enforcement mode
-				SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation);
-				ResetCounter(100);
-				}
-			else
-				{
-				SetScreenModeEnforcement(ESizeEnforcementNone);
-				delete iSecondConnection;
-				iSecondConnection=NULL;
-				}
-			TheClient->iWs.Flush();
-			break;
+		iSecondConnection->DisableMessages();
+		if (iCurEnforcement==ESizeEnforcementNone)
+			{	// Do it again with different enforcement mode
+			SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
+			ResetCounter(100);
+			}
+		else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
+			{	// Do it again with different enforcement mode
+			SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation);
+			ResetCounter(100);
+			}
+		else
+			{
+			SetScreenModeEnforcement(ESizeEnforcementNone);
+			delete iSecondConnection;
+			iSecondConnection=NULL;
+			}
+		TheClient->iWs.Flush();
+		break;
+
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0302
 
   @SYMDEF  			DEF099638
@@ -1470,27 +1515,23 @@
   @SYMTestActions Set different screen modes and scale a drawing
 
   @SYMTestExpectedResults The drawing is redrawn to scale
-
 */
-		case 110:
-			{
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302"));
-			// Ensure that the TestWin and BaseWin will be drawn properly in all screen modes
-			SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
-			TheClient->SetTestClientScreenMode(0);
-			INFO_PRINTF1(_L("Scaled drawing - screen mode 0"));
-			ScaledDrawingL();
-			TheClient->SetTestClientScreenMode(1);
-			INFO_PRINTF1(_L("Scaled drawing - screen mode 1"));
-			ScaledDrawingL();
-			// Restore screen mode and enforcement mode				
-			TheClient->SetTestClientScreenMode(0);
-			SetScreenModeEnforcement(iOldEnfMode);
-			break;
-			}
+	case 110:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302"));
+		// Ensure that the TestWin and BaseWin will be drawn properly in all screen modes
+		SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
+		TheClient->SetTestClientScreenMode(0);
+		INFO_PRINTF1(_L("Scaled drawing - screen mode 0"));
+		ScaledDrawingL();
+		TheClient->SetTestClientScreenMode(1);
+		INFO_PRINTF1(_L("Scaled drawing - screen mode 1"));
+		ScaledDrawingL();
+		// Restore screen mode and enforcement mode				
+		TheClient->SetTestClientScreenMode(0);
+		SetScreenModeEnforcement(iOldEnfMode);
+		break;
 
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0303
 
   @SYMDEF  			DEF081259
@@ -1505,16 +1546,15 @@
   					expected
 
   @SYMTestExpectedResults Panics respond as expected
+*/
+	case 111:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303"));
+		INFO_PRINTF1(_L("Panic"));
+		TestPanicsL();
+		break;
+#endif
 
-*/
-		case 111:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303"));
-			INFO_PRINTF1(_L("Panic"));
-			TestPanicsL();
-			break;
-#endif
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0304
 
   @SYMDEF  			DEF081259
@@ -1530,15 +1570,14 @@
   					mode and redraw the windows
 
   @SYMTestExpectedResults The windows are redrawn without error
+*/
+	case 112:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304"));
+		INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem
+		InvisibleWndAndInfiniteRedrawBugL();
+		break;
 
-*/
-		case 112:
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304"));
-			INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem
-			InvisibleWndAndInfiniteRedrawBugL();
-			break;
 /**
-
   @SYMTestCaseID GRAPHICS-WSERV-0358
 
   @SYMDEF  			PDEF096151
@@ -1561,26 +1600,26 @@
                   Cleans up the above
 
   @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic
+*/
+	case 113:
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358"));
+		INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device"));
+		SetScreenModeAfterScreenDeviceDeletedL();
+		break;
 
-*/
- 		case 113:
- 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358"));
-			INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device"));
-			SetScreenModeAfterScreenDeviceDeletedL();
-			break;
-		case 114:
-			INFO_PRINTF1(_L("Rotate/screen mode test"));
 /**
   @SYMTestCaseID GRAPHICS-WSERV-0525
 */
-			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525"));
-			TestRotateAndScreenModeL();
-			break;
-		default:
-            ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
-			if (iTest->iState==115 || iTest->iState>1000)
-				TestComplete();
-			break;
+	case 114:
+		INFO_PRINTF1(_L("Rotate/screen mode test"));
+		((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525"));
+		TestRotateAndScreenModeL();
+		break;
+	default:
+		((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
+		if (iTest->iState==115 || iTest->iState>1000)
+			TestComplete();
+		break;
 		}
 	((CTScrModeStep*)iStep)->RecordTestResultL();
 	}
@@ -1598,7 +1637,7 @@
 	delete iClient;
 	}
 
-void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep)
+void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase* aTest, CTestStep* aTestStep)
 	{
 	iClient=new(ELeave) CTClient;
 	iClient->SetScreenNumber(aScreenNumber);
@@ -1657,7 +1696,7 @@
 // CSecondConnectionGroup
 //
 
-CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep)
+CSecondConnectionGroup::CSecondConnectionGroup(CTClient* aClient, CSecondConnection* aSecondConnection, CTestBase* aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep)
 	{}
 
 void CSecondConnectionGroup::ScreenDeviceChanged()
--- a/windowing/windowserver/tauto/TSCRMODE.H	Fri Jul 02 18:24:10 2010 +0100
+++ b/windowing/windowserver/tauto/TSCRMODE.H	Tue Jul 13 16:54:51 2010 +0100
@@ -1,5 +1,4 @@
-
-// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -34,11 +33,11 @@
 class CSecondConnectionGroup : public CTWindowGroup
 	{
 public:
-	CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep);
+	CSecondConnectionGroup(CTClient* aClient, CSecondConnection* aSecondConnection, CTestBase* aTest, CTestStep* aTestStep);
 	void ScreenDeviceChanged();
 private:
-	CTestBase *iTest;
-	CSecondConnection *iSecondConnection;
+	CTestBase* iTest;
+	CSecondConnection* iSecondConnection;
 	CTestStep* iTestStep;
 	};
 
@@ -46,18 +45,18 @@
 	{
 public:
 	~CSecondConnection();
-	void ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep);
+	void ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase* aTest, CTestStep* aTestStep);
 	void EnableMessages();
 	void DisableMessages();
 	TInt DeviceMessageCount() const;
 	void ScreenDeviceChanged();
 	void SetWindow2Visibility(TBool aVisible);
 public:
-	CSecondConnectionGroup *iGroup;
+	CSecondConnectionGroup* iGroup;
 private:
-	CTClient *iClient;
-	CTBlankWindow *iWindow;
-	CTBlankWindow *iWindow2;
+	CTClient* iClient;
+	CTBlankWindow* iWindow;
+	CTBlankWindow* iWindow2;
 	TInt iMessageCount;
 	};
 	
@@ -85,7 +84,7 @@
 	void ScaledDrawingL();
 	void SetScreenModeEnforcement(TScreenModeEnforcement aMode);
 	void CheckWindows(TBool aWinIsVis);
-	void ValidateWin(TestWindow *aWin, TRgb aColor);
+	void ValidateWin(TestWindow* aWin, TRgb aColor);
 	void RedrawWin(RWindow &aWin, TRgb aColor);
 	void ScreenRotationsL();
 	void MoreScreenRotationsL();
@@ -101,9 +100,10 @@
 private:
 	void DrawTestBmpL(CFbsBitmap* aTestBitmap);
 	void TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont,TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M);
+	void CheckHalSetting(TInt aGcOrientation);
 private:
 	TInt iSubState;
-	CSecondConnection *iSecondConnection;
+	CSecondConnection* iSecondConnection;
 	TSize iWinSize;
 	TPoint iWinPos;
 	TInt iWinState;
@@ -111,8 +111,6 @@
 	TScreenModeEnforcement iCurEnforcement;
 	};
 
-
-	
 class CTScrModeStep : public CTGraphicsStep
 	{
 public: