diff -r d72fc2aace31 -r 62bb7c97884c graphicstest/uibench/src/trenderorientation.cpp --- a/graphicstest/uibench/src/trenderorientation.cpp Tue Jul 20 13:27:44 2010 +0300 +++ b/graphicstest/uibench/src/trenderorientation.cpp Fri Jul 30 11:41:40 2010 +0300 @@ -30,9 +30,9 @@ // Values for the device orientation that we receive via P&S from the Theme Server // Must match those in renderorientationtracker.h, and, obviously, those used by the real theme server const TUid KThemeOrientationCategory = {0x20022E82}; // == KHbPsHardwareCoarseOrientationCategoryUid -const TUint KThemeOrientationKey = 0x4F726965; // == KHbPsHardwareCoarseOrientationKey +const TUint KThemeOrientationKey = 0x4F726965; // == KHbPsHardwareCoarseOrientationKey -void CWindowStuff::ConstructL() +void CTWindowSet::ConstructL() { User::LeaveIfError(iWs.Connect()); iWs.SetAutoFlush(ETrue); @@ -44,12 +44,12 @@ User::LeaveIfError(iChildWindow.Construct(iWindowGroup, reinterpret_cast(&iChildWindow))); } -CWindowStuff::~CWindowStuff() +CTWindowSet::~CTWindowSet() { Destroy(); } -void CWindowStuff::Destroy() +void CTWindowSet::Destroy() { iChildWindow.Close(); iWindowGroup.Close(); @@ -59,7 +59,7 @@ CTRenderOrientation::CTRenderOrientation() { // check that these two enums are aligned - __ASSERT_COMPILE(EDisplayOrientationAuto == ENumWindowThings); + __ASSERT_COMPILE(EDisplayOrientationAuto == ENumWindowSets); SetTestStepName(KTRenderOrientation); } @@ -68,16 +68,31 @@ { } +/** +Gets the Render Orientation as published by window server + +@return TRenderOrienation that was last publised by window server. + */ TRenderOrientation CTRenderOrientation::GetRenderOrientationL() { return GetOrientationL(iWsRenderOrientationProperty); } +/** +Gets the Theme Orientation as published by theme server + +@return TRenderOrienation that was last publised by theme server. + */ TRenderOrientation CTRenderOrientation::GetThemeOrientationL() { return GetOrientationL(iThemeOrientationProperty); } +/** +Gets the orientation as published to the given RProperty + +@return TRenderOrienation that was last publised to the given RProperty + */ TRenderOrientation CTRenderOrientation::GetOrientationL(RProperty& aProperty) { TInt orientation=EDisplayOrientationNormal; @@ -89,15 +104,40 @@ return static_cast(orientation); } +/** +Tests each usable TRenderOrientation KNumIterations times for the given test phase / use case. + +@param aStepName - the test step ID to use +@param aTestPhase - the internal test phase + */ void CTRenderOrientation::TestOrientationChangeL(const TDesC& aStepName, TTestPhase aTestPhase) { SetTestStepID(aStepName); - if(EThemeOrientationChange == aTestPhase) - { - TESTL(EDisplayOrientationNormal == GetThemeOrientationL()); - iWindowStuff[EFirstWindowThing].Session().IndicateAppOrientation(EDisplayOrientationAuto); - } + // more preamble to toggle between timing the wserv render orienation property + // and the theme server orientation property + RProperty *orientationProperty = NULL; + switch(aTestPhase) + { + case EThemeOrientationChangeOnly: + { + // render orientation ignores theme orientation + iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(EDisplayOrientationNormal); + // we want to subscribe and wait for the theme orientation published by the theme server + orientationProperty = &iThemeOrientationProperty; + break; + } + case EThemeOrientationChange: + { + TESTL(EDisplayOrientationNormal == GetThemeOrientationL()); + iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(EDisplayOrientationAuto); + } + // deliberate drop-through + default: + // we want to subscribe and wait for the render orientation published by WServ + orientationProperty = &iWsRenderOrientationProperty; + break; + } TInt renderOrientation = GetRenderOrientationL(); @@ -121,27 +161,30 @@ // % can be slow, do it outside of the timing TRenderOrientation testOrientation = static_cast(renderOrientation%EDisplayOrientationAuto); - iWsRenderOrientationProperty.Subscribe(iRenderOrientationStatus); + orientationProperty->Subscribe(iOrientationStatus); + // start the timeout timer iTimeoutTimer.After(iTimeoutStatus, KPublishTimeout); // start the results timer iProfiler->StartTimer(); - + switch(aTestPhase) { case EIndicatedOrientationChange: // Do the indicated orientation Change - iWindowStuff[EFirstWindowThing].Session().IndicateAppOrientation(testOrientation); + iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(testOrientation); break; case EWindowOrdinalChange: // move the relevant window group to the front // N.B. this will go wrong if the number of orientations and windows are not equal - iWindowStuff[testOrientation].WindowGroup().SetOrdinalPosition(0); + iWindowSet[testOrientation].WindowGroup().SetOrdinalPosition(0); break; case EThemeOrientationChange: // Needs the focus window to be in auto mode + // deliberate drop through + case EThemeOrientationChangeOnly: iThemeOrientationProperty.Set(testOrientation); break; @@ -150,12 +193,12 @@ } // Wait for the update to have been published ( or time out while waiting ) - User::WaitForRequest(iRenderOrientationStatus, iTimeoutStatus); + User::WaitForRequest(iOrientationStatus, iTimeoutStatus); iProfiler->MarkResultSetL(); ++iTimingsTaken; - if(KErrNone != iRenderOrientationStatus.Int()) + if(KErrNone != iOrientationStatus.Int()) { // timed out iWsRenderOrientationProperty.Cancel(); @@ -164,7 +207,10 @@ else { // Check that it is actually the expected orientation - TESTL(GetRenderOrientationL() == testOrientation); + if(EThemeOrientationChangeOnly == aTestPhase) + TESTL(GetThemeOrientationL() == testOrientation); + else + TESTL(GetRenderOrientationL() == testOrientation); } if(KRequestPending == iTimeoutStatus.Int()) @@ -187,13 +233,16 @@ TVerdict CTRenderOrientation::doTestStepL() { INFO_PRINTF1(_L("Testing: Indicated Orientation Change")); - TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0xxx1"), EIndicatedOrientationChange); + TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0201"), EIndicatedOrientationChange); INFO_PRINTF1(_L("Testing: Window Ordinal Position Change")); - TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0xxx2"), EWindowOrdinalChange); + TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0202"), EWindowOrdinalChange); INFO_PRINTF1(_L("Testing: Theme Orientation Change")); - TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0xxx3"), EThemeOrientationChange); + TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0203"), EThemeOrientationChange); + + INFO_PRINTF1(_L("Testing: Theme Orientation Change Only")); + TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0204"), EThemeOrientationChangeOnly); return TestStepResult(); } @@ -201,13 +250,18 @@ _LIT(KThemeServerPropertyDefine, "twsthemeserverpropertydefine.exe"); _LIT(KThemeServerPropertyDefineCmdDefine, "define"); _LIT(KThemeServerPropertyDefineCmdDelete, "delete"); - + +/** +Uses a test executable to define or delete a test version of the theme server rotation RProperty + */ void CTRenderOrientation::ThemeServerProperty(const TDesC& aCmd) { - /* This Process called with the argument KThemeServerPropertyDefineCmdDelete, deletes - the theme server RProperty. This is because an RProperty can only be defined and - deleted from within a process with the same UID3 as the RProperty catogory you are - trying to define/delete.*/ + /* This Process called with the argument KThemeServerPropertyDefineCmdDefine defines the + theme server RProperty, or with KThemeServerPropertyDefineCmdDelete, deletes + the theme server RProperty. + This is because an RProperty with this catagory UID can only be defined and deleted + from within a process with the same UID3 as the RProperty catogory you are trying to + define/delete */ RProcess themeServerPropertyDefine; TInt err = themeServerPropertyDefine.Create(KThemeServerPropertyDefine, aCmd); if (KErrNone != err) @@ -217,7 +271,7 @@ TEST(EFalse); } - //wait for themeServerPropertyDefine process to terminate + // wait for themeServerPropertyDefine process to terminate TRequestStatus themeServerPropertyDefineLogonStatus; themeServerPropertyDefine.Logon(themeServerPropertyDefineLogonStatus); themeServerPropertyDefine.Resume(); @@ -231,15 +285,18 @@ themeServerPropertyDefine.Close(); } +/* +Initialise for the testing + */ TVerdict CTRenderOrientation::doTestStepPreambleL() { - // Create in reverse order so that windowThing 0 is at the front - for(TInt windowThing = ENumWindowThings - 1; windowThing >= 0 ; --windowThing) + // Create in reverse order so that windowSet 0 is at the front/foreground + for(TInt windowSet = ENumWindowSets - 1; windowSet >= 0 ; --windowSet) { - iWindowStuff[windowThing].ConstructL(); - TRenderOrientation orientation = static_cast(windowThing%EDisplayOrientationAuto); - iWindowStuff[windowThing].Session().IndicateAppOrientation(orientation); - iWindowStuff[windowThing].WindowGroup().SetOrdinalPosition(0); + iWindowSet[windowSet].ConstructL(); + TRenderOrientation orientation = static_cast(windowSet%EDisplayOrientationAuto); + iWindowSet[windowSet].Session().IndicateAppOrientation(orientation); + iWindowSet[windowSet].WindowGroup().SetOrdinalPosition(0); } User::LeaveIfError(iWsRenderOrientationProperty.Attach(KRenderOrientationCategory, KRenderOrientationKey)); @@ -252,6 +309,9 @@ return CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); } +/* +Tidy up after the testing + */ TVerdict CTRenderOrientation::doTestStepPostambleL() { iTimeoutTimer.Close(); @@ -260,9 +320,9 @@ ThemeServerProperty(KThemeServerPropertyDefineCmdDelete); iWsRenderOrientationProperty.Close(); - for(TInt windowThing = 0; windowThing < ENumWindowThings; ++windowThing) + for(TInt windowThing = 0; windowThing < ENumWindowSets; ++windowThing) { - iWindowStuff[windowThing].Destroy(); + iWindowSet[windowThing].Destroy(); } return CTe_graphicsperformanceSuiteStepBase::doTestStepPostambleL();