sl@0: // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: #include "wsdynamicresbasic.h" sl@0: #include sl@0: #include "globalsettings.h" sl@0: #include sl@0: #include sl@0: #include "regionextend.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "surfaceutility.h" sl@0: #include sl@0: sl@0: //verify which base code is available to the test sl@0: #include sl@0: #if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER)) sl@0: #define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: #endif sl@0: sl@0: sl@0: //#define VISIBLE_PAUSES 1000 sl@0: #define OVERLAPPING_CELL 0 //'m' //0 indicates cells do not overlap sl@0: /* sl@0: * CWsGceTestPlaceSurfExtra implementation sl@0: * sl@0: * sl@0: * sl@0: * sl@0: */ sl@0: CWsDynamicResBasic::CWsDynamicResBasic() sl@0: { sl@0: } sl@0: sl@0: CWsDynamicResBasic::~CWsDynamicResBasic() sl@0: { sl@0: } sl@0: sl@0: void CWsDynamicResBasic::SetupL() sl@0: { sl@0: MyBase::SetupL(); sl@0: } sl@0: void CWsDynamicResBasic::TearDownL() sl@0: { sl@0: MyBase::TearDownL(); sl@0: sl@0: } sl@0: void CWsDynamicResBasic::TearDownFromDeleteL() sl@0: { sl@0: MyBase::TearDownFromDeleteL(); sl@0: } sl@0: sl@0: sl@0: CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName ) sl@0: { sl@0: //Create the surface manager here, before the test suite creates additional threads sl@0: if (GCEIsSupportedStatic()) sl@0: { sl@0: TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL()); sl@0: } sl@0: sl@0: SUB_SUITE_OPT(CWsDynamicResBasic,NULL); sl@0: sl@0: //BASIC sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L); //only run on screen 1 sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L); //only run on screen 0 sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L); //only run on screen 1 sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L); //only run with no scaling sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L); //only run with anisotropic scaling sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L); //only run with integer scaling sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L); sl@0: sl@0: ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L); //only run on screen 1 sl@0: sl@0: //OOM sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L); //dont run with no scaling on screen 0 sl@0: sl@0: //SCREEN CAPTURE sl@0: ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L); sl@0: ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L); sl@0: sl@0: //DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L); //only run on screen 1 (multiple resolutions) sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L); sl@0: sl@0: //DEFECT sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L); sl@0: sl@0: END_SUITE; sl@0: } sl@0: sl@0: #define LOG_AND_PANIC_IF_NOT_GCE \ sl@0: { \ sl@0: if (!GCEIsSupported()) \ sl@0: { \ sl@0: INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ sl@0: User::Panic(_L("GCE.Wrong.Mode"),1); \ sl@0: return; \ sl@0: } \ sl@0: } sl@0: sl@0: CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs): sl@0: CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0), sl@0: iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: CWsDisplayEvent::~CWsDisplayEvent() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CWsDisplayEvent::DoCancel() sl@0: { sl@0: iWs->EventReadyCancel(); sl@0: } sl@0: sl@0: void CWsDisplayEvent::Request() sl@0: { sl@0: iWs->EventReady(&iStatus); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CWsDisplayEvent::RunL() sl@0: { sl@0: TWsEvent event; sl@0: iWs->GetEvent(event); sl@0: sl@0: if(iStatus == KErrNone) sl@0: { sl@0: switch(event.Type()) sl@0: { sl@0: case EEventScreenDeviceChanged: sl@0: { sl@0: iReceivedDeviceEventCount++; sl@0: } sl@0: case EEventPointer: sl@0: { sl@0: iReceivedPointerEventCount++; sl@0: TPointerEvent* ptEvent = event.Pointer(); sl@0: //make 1 pixels distance allowance, as non integer scalling from composition to app may occur sl@0: //1 pixels allowance because we never scale greater than 2 times sl@0: if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1 sl@0: && ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1) sl@0: { sl@0: iPointerPosTestPass = EFalse; sl@0: } sl@0: } sl@0: case EEventDisplayChanged: sl@0: { sl@0: iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId; sl@0: iResListSpinner = event.DisplayChanged()->iResolutionListChangeId; sl@0: iReceivedEventCount++; sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: User::Leave(iStatus.Int()); sl@0: sl@0: Request(); sl@0: } sl@0: sl@0: CEventTimer* CEventTimer::NewL() sl@0: { sl@0: CEventTimer* self = new (ELeave) CEventTimer; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CEventTimer::ConstructL() sl@0: { sl@0: User::LeaveIfError(iTimer.CreateLocal()); sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CEventTimer::CEventTimer() : CActive(EPriorityStandard) sl@0: { sl@0: sl@0: } sl@0: sl@0: CEventTimer::~CEventTimer() sl@0: { sl@0: Cancel(); sl@0: iTimer.Close(); sl@0: } sl@0: sl@0: void CEventTimer::DoCancel() sl@0: { sl@0: iTimer.Cancel(); sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: void CEventTimer::RunL() sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: void CEventTimer::Wait(TInt aDelay) sl@0: { sl@0: iTimer.After(iStatus, aDelay); sl@0: SetActive(); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: //Set display state to normal and to the first decent resolution sl@0: //A failed test could leave it in a bad state sl@0: void CWsDynamicResBasic::ResetScreens() sl@0: { sl@0: Pause(1000); sl@0: #ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: TInt displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: #endif sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: RArray appModeIndexList; sl@0: TInt currMode=iScreenDevice->CurrentScreenMode(); sl@0: iScreenDevice->GetScreenSizeModeList(&appModeIndexList); sl@0: if (appModeIndexList[0]!=currMode) sl@0: { sl@0: iScreenDevice->SetAppScreenMode(appModeIndexList[0]); sl@0: iScreenDevice->SetScreenMode(appModeIndexList[0]); sl@0: } sl@0: appModeIndexList.Close(); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: TDisplayConfiguration config; sl@0: TInt goodRes=0; sl@0: if (resolutionList1[goodRes].iPixelSize==TSize()) sl@0: { sl@0: goodRes++; sl@0: ASSERT_TRUE(resolutions>goodRes); //First res was blank, and no more to choose! sl@0: } sl@0: config.SetResolution(resolutionList1[goodRes].iPixelSize); sl@0: error=interface->SetConfiguration(config); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0001L sl@0: @SYMTestCaseDesc WSERV Screen Device GetInterface returns known interface sl@0: @SYMREQ REQ10325 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Basic classic behaviour sl@0: @SYMTestActions sl@0: Call GetInterface with a well known GUID sl@0: @SYMTestExpectedResults sl@0: Returns a pointer sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test")); sl@0: sl@0: MDisplayControlBase* interface1 = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControlBase::ETypeId)); sl@0: ASSERT_TRUE(interface1); sl@0: sl@0: MDisplayControl* interface2 = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface2); sl@0: sl@0: MDisplayMappingBase* interface3 = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId)); sl@0: ASSERT_TRUE(interface3); sl@0: sl@0: MDisplayMapping* interface4 = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(interface4); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0002L sl@0: @SYMTestCaseDesc Basic test for NumberOfResolutions sl@0: @SYMREQ REQ10328 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose NumberOfResolutions returns correctly sl@0: @SYMTestActions sl@0: GetInterface sl@0: then call NumberOfResolutions. sl@0: @SYMTestExpectedResults sl@0: It shouldn't return KErrNotSupported sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions != KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0003L sl@0: @SYMTestCaseDesc Basic test for GetResolutions sl@0: @SYMREQ REQ10328 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Check GetResolutions returns a valid TSize RArray sl@0: @SYMTestActions sl@0: GetInterface sl@0: Call NumberOfResolutions sl@0: Create an array and garbage fill based on amount of resolutions sl@0: Call GetResolutions on this array sl@0: Create an array (dont garbage fill) sl@0: Call GetResolutions on this empty array sl@0: Create an array with smaller size than required sl@0: Call GetResolutions on this array sl@0: Create an array with larger size than required sl@0: Call GetResolutions on this array sl@0: @SYMTestExpectedResults sl@0: For both GetResolutions calls, it should allocate memory if needed, and fill sl@0: with correct sizes sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: TInt count; sl@0: TInt error; sl@0: sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: for (count=0;countGetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: RArray resolutionList2; sl@0: error = interface->GetResolutions(resolutionList2); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList2.Count(), resolutions); sl@0: sl@0: RArray resolutionList3; sl@0: for (count=0;countGetResolutions(resolutionList3); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList3.Count(), resolutions); sl@0: sl@0: RArray resolutionList4; sl@0: for (count=0;countGetResolutions(resolutionList4); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList4.Count(), resolutions); sl@0: sl@0: for (count=0;count sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TDisplayConfiguration dispConfig; sl@0: interface->GetConfiguration(dispConfig); sl@0: ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution)); sl@0: TSize size; sl@0: TSize twips; sl@0: ASSERT_TRUE(dispConfig.GetResolution(size)); sl@0: ASSERT_TRUE(dispConfig.GetResolutionTwips(twips)); sl@0: sl@0: TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10); sl@0: interface->GetConfiguration(dispConfig1); sl@0: ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution)); sl@0: TSize size1; sl@0: TSize twips1; sl@0: ASSERT_TRUE(dispConfig1.GetResolution(size1)); sl@0: ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1)); sl@0: sl@0: TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version()); sl@0: interface->GetConfiguration(dispConfig2); sl@0: ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution)); sl@0: TSize size2; sl@0: TSize twips2; sl@0: ASSERT_TRUE(dispConfig2.GetResolution(size2)); sl@0: ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2)); sl@0: sl@0: ASSERT_EQUALS(size, size1); sl@0: ASSERT_EQUALS(size, size2); sl@0: ASSERT_EQUALS(twips, twips1); sl@0: ASSERT_EQUALS(twips, twips2); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0005L sl@0: @SYMTestCaseDesc Test getting display change event from event queue sl@0: @SYMREQ REQ10329 REQ10330 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Verify the correct behaviour of display change notification sl@0: @SYMTestActions sl@0: Run through various ways of changing resolution sl@0: For each, check if event has been received sl@0: @SYMTestExpectedResults sl@0: Based on type of change, check event sl@0: @note Test uses HAL to simulate display disconnection. Not supported on production platforms. sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); sl@0: #else sl@0: TInt screenNo = iScreenDevice->GetScreenNumber(); sl@0: sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: interface->EnableDisplayChangeEvents(ETrue); sl@0: ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); sl@0: sl@0: CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); sl@0: CleanupStack::PushL(displayEventAO); sl@0: displayEventAO->Request(); sl@0: CEventTimer *timer = CEventTimer::NewL(); sl@0: CleanupStack::PushL(timer); sl@0: TInt dispSpinnerValue = displayEventAO->ResListSpinner(); sl@0: TInt configSpinnerValue = displayEventAO->ConfigSpinner(); sl@0: sl@0: iSession.Flush(); sl@0: TInt displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: sl@0: timer->Wait(100000); sl@0: ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change sl@0: ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event sl@0: dispSpinnerValue = displayEventAO->ResListSpinner(); sl@0: configSpinnerValue = displayEventAO->ConfigSpinner(); sl@0: sl@0: sl@0: interface->EnableDisplayChangeEvents(ETrue);//enable again sl@0: ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); sl@0: interface->EnableDisplayChangeEvents(EFalse);//disable sl@0: ASSERT_FALSE(interface->DisplayChangeEventsEnabled()); sl@0: interface->EnableDisplayChangeEvents(EFalse);//disable again sl@0: interface->EnableDisplayChangeEvents(ETrue);//enable again sl@0: iSession.Flush(); sl@0: sl@0: TDisplayConfiguration disconnectedConfig; sl@0: disconnectedConfig.SetResolution(TSize(10,11)); sl@0: disconnectedConfig.SetResolutionTwips(TSize(12,13)); sl@0: disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); sl@0: interface->GetConfiguration(disconnectedConfig); sl@0: ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution)); sl@0: ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips)); sl@0: ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation)); sl@0: sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: sl@0: timer->Wait(1000000); sl@0: ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise sl@0: ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event sl@0: dispSpinnerValue = displayEventAO->ResListSpinner(); sl@0: configSpinnerValue = displayEventAO->ConfigSpinner(); sl@0: sl@0: TDisplayConfiguration dispConfig, dispConfig2; sl@0: TSize resolution,resolution2; sl@0: interface->GetConfiguration(dispConfig2); sl@0: dispConfig2.GetResolution(resolution2); sl@0: RArray resolutions; sl@0: TInt err = interface->GetResolutions(resolutions); sl@0: ASSERT_EQUALS(err, KErrNone); sl@0: dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize); sl@0: err = interface->SetConfiguration(dispConfig); sl@0: ASSERT_EQUALS(err, KErrNone); sl@0: interface->GetConfiguration(dispConfig); sl@0: sl@0: timer->Wait(100000); sl@0: sl@0: if(!(dispConfig2 == dispConfig)) sl@0: { sl@0: ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue); sl@0: } sl@0: ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event sl@0: dispSpinnerValue = displayEventAO->ResListSpinner(); sl@0: configSpinnerValue = displayEventAO->ConfigSpinner(); sl@0: resolutions.Close(); sl@0: sl@0: //here we flood the event queue with key events, so the next display change sl@0: //can't put event and queue and force the retry AO on server side to kick off sl@0: iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); sl@0: for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++) sl@0: { sl@0: TRawEvent rawEvent; sl@0: rawEvent.Set(TRawEvent::EKeyDown,scanCode); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: rawEvent.Set(TRawEvent::EKeyUp,scanCode); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: } sl@0: iSession.Flush(); sl@0: sl@0: TInt eventCount1 = displayEventAO->ReceivedEventCount(); sl@0: //we should still receive this sl@0: displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: //let retry AO retry more times before we try to get it sl@0: User::After(1000000); sl@0: sl@0: timer->Wait(10000000); sl@0: ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change sl@0: ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event sl@0: sl@0: //This part is doomed as well. Now the received event count includes all the pointer, device and display change event sl@0: /* sl@0: TInt eventCount2 = displayEventAO->ReceivedEventCount(); sl@0: //make sure retry AO is stopped - we only receive 1 display event sl@0: ASSERT_EQUALS(eventCount1 + 1, eventCount2); sl@0: */ sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: sl@0: CleanupStack::PopAndDestroy(2, displayEventAO); sl@0: #endif sl@0: } sl@0: sl@0: //Adds the first rotation defined in the TResolution to the display configuration sl@0: void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution) sl@0: { sl@0: if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported)) sl@0: { sl@0: aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); sl@0: } sl@0: else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported)) sl@0: { sl@0: aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW); sl@0: } sl@0: else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported)) sl@0: { sl@0: aConfig.SetRotation(TDisplayConfiguration1::ERotation180); sl@0: } sl@0: else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported)) sl@0: { sl@0: aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW); sl@0: } sl@0: ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0006L sl@0: @SYMTestCaseDesc Set Screen display res sl@0: @SYMREQ REQ10326 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Checking window and layer extents continue working sl@0: @SYMTestActions sl@0: Get resolution list sl@0: For every resolution sl@0: Set resolution sl@0: Draw many rectangles that shrink to demonstrate scaling issues sl@0: Draw surface sl@0: Move window around sl@0: @SYMTestExpectedResults sl@0: Every resolution that is supported by current app mode should successfully be set sl@0: All rectangles and surface should be visible sl@0: As the window moves, the rectangles and surface should move with it, keeping visible sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: TInt error; sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution")); sl@0: sl@0: iTestBack=RBlankWindow(iSession); sl@0: ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); sl@0: iTestBack.SetRequiredDisplayMode(iDisplayMode); sl@0: iTestBack.SetColor(TRgb(255,0,0)); sl@0: iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); sl@0: iTestBack.Activate(); sl@0: iTestBack.SetVisible(ETrue); sl@0: sl@0: struct DrawCompare sl@0: { sl@0: static void Draw(CWindowGc* aGc) sl@0: { sl@0: aGc->SetPenStyle(aGc->ESolidPen); sl@0: aGc->SetPenColor(TRgb(255,255,255)); sl@0: aGc->SetBrushColor(TRgb(0,0,0)); sl@0: TRect r(2,2,82,82); sl@0: while(r.Width()>0) sl@0: { sl@0: aGc->DrawRect(r); sl@0: r.Shrink(2,2); sl@0: } sl@0: } sl@0: }; sl@0: TSurfaceId surfaceID; sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), sl@0: KSurfaceFormat, 200 * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TSurfaceConfiguration surfConf; sl@0: surfConf.SetSurfaceId(surfaceID); sl@0: sl@0: surfConf.SetExtent(TRect(2,84,82,166)); sl@0: iCompare.SetBackgroundSurface(surfConf,EFalse); sl@0: sl@0: if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) sl@0: { sl@0: DrawCompare::Draw(gc); sl@0: gc->Deactivate(); sl@0: iCompare.EndRedraw(); sl@0: sl@0: } sl@0: iSession.Finish(ETrue); sl@0: Pause(1000); sl@0: sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration dispConfigBefore; sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) sl@0: if (resolutions>1) sl@0: { sl@0: //Got a mode to change to! sl@0: TSize resBefore; sl@0: TBool ok=dispConfigBefore.GetResolution(resBefore); sl@0: ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag sl@0: TBool foundBeforeRes=EFalse; sl@0: for (TInt res=0;resSetConfiguration(dispConfigReq); sl@0: //ASSERT_EQUALS(errCode,KErrNone); sl@0: if (errCode != KErrNone) sl@0: { sl@0: //Probably current size mode does not support the rotation of the passed in configuration sl@0: sl@0: ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy sl@0: continue; sl@0: } sl@0: Pause(300); sl@0: TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint()); sl@0: iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) sl@0: { sl@0: DrawCompare::Draw(gc); sl@0: gc->Deactivate(); sl@0: iCompare.EndRedraw(); sl@0: } sl@0: TBuf16<20> s; sl@0: s.AppendNum(res); sl@0: UpdateTitleWindowL(s,2); sl@0: s.Zero(); sl@0: s.AppendNum(resolutionList1[res].iPixelSize.iWidth); sl@0: s.Append('x'); sl@0: s.AppendNum(resolutionList1[res].iPixelSize.iHeight); sl@0: UpdateTitleWindowL(s,3); sl@0: sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: outerrect.iBr.iX-=5; sl@0: outerrect.iBr.iY-=5; sl@0: iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: TPoint winpos=iCompare.AbsPosition(); sl@0: TSize winsize=iCompare.Size(); sl@0: // iInfoScreenDevice->ReleaseTwipsCache(); sl@0: RepaintTitleWindowL(); sl@0: for (TSize z=TSize(1,1);z!=TSize(-1,-1);) sl@0: { sl@0: for (TInt i=0;i<15;i++) sl@0: { sl@0: winpos+=z; sl@0: iCompare.SetExtent(winpos,winsize); sl@0: iSession.Finish(ETrue); sl@0: Pause(100); sl@0: } sl@0: if (z.iHeight && z.iWidth) sl@0: z=TSize(0,-1); sl@0: else sl@0: if (z.iHeight) sl@0: z=TSize(-1,0); sl@0: else sl@0: z=TSize(-1,-1); sl@0: } sl@0: TDisplayConfiguration dispConfigAfter; sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: TSize resAfter; sl@0: TBool ok=dispConfigAfter.GetResolution(resAfter); sl@0: ASSERT_TRUE(ok); sl@0: if (resolutionList1[res].iPixelSize!=resAfter) sl@0: { sl@0: INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight); sl@0: INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight); sl@0: } sl@0: } sl@0: } sl@0: if (resolutionList1[res].iPixelSize==resBefore) sl@0: { sl@0: foundBeforeRes=ETrue; sl@0: } sl@0: } sl@0: ASSERT_TRUE(foundBeforeRes); sl@0: //restore initial res sl@0: interface->SetConfiguration(dispConfigBefore); sl@0: Pause(1000); sl@0: TDisplayConfiguration dispConfigAfter; sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: TSize resAfter; sl@0: ok=dispConfigAfter.GetResolution(resAfter); sl@0: ASSERT_TRUE(ok); sl@0: ASSERT_EQUALS(resBefore,resAfter); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped.")); sl@0: } sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0007L sl@0: @SYMTestCaseDesc Coordinates Mapping sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Basic call to mapcoordinates sl@0: @SYMTestActions sl@0: Call mapCoordinates sl@0: @SYMTestExpectedResults sl@0: targetRect should be correctly filled in with same rect as sourceRect sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L() sl@0: { sl@0: MDisplayMapping* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: TRect sourceRect(10, 10, 30, 50); sl@0: TRect targetRect(5,5,10,10); sl@0: TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect); sl@0: ASSERT_EQUALS(err, KErrNone); sl@0: ASSERT_EQUALS(sourceRect, targetRect); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0008L sl@0: @SYMTestCaseDesc SetModes and mapCoordinates sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Basic SetSizeMode and complex MapCoordinates function sl@0: @SYMTestActions sl@0: Set a new size mode sl@0: Perform many rect conversions using MapCoordinates sl@0: @SYMTestExpectedResults sl@0: Ensure that through multiple conversions, accuracy is not lost sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: TInt error; sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode")); sl@0: sl@0: iTestBack=RBlankWindow(iSession); sl@0: ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); sl@0: iTestBack.SetRequiredDisplayMode(iDisplayMode); sl@0: iTestBack.SetColor(TRgb(255,0,0)); sl@0: iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); sl@0: iTestBack.Activate(); sl@0: iTestBack.SetVisible(ETrue); sl@0: iSession.Finish(ETrue); sl@0: sl@0: sl@0: if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) sl@0: { sl@0: gc->SetPenStyle(gc->ESolidPen); sl@0: gc->SetPenColor(TRgb(255,255,255)); sl@0: gc->SetBrushColor(TRgb(0,0,0)); sl@0: TRect r(2,2,22,22); sl@0: while(r.Width()>0) sl@0: { sl@0: gc->DrawRect(r); sl@0: r.Shrink(2,2); sl@0: } sl@0: gc->Deactivate(); sl@0: iCompare.EndRedraw(); sl@0: sl@0: } sl@0: iSession.Finish(ETrue); sl@0: Pause(1000); sl@0: sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration dispConfigBefore; sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: ASSERT_TRUE (screenModeList.Count() > 1); sl@0: iScreenDevice->SetAppScreenMode(screenModeList[1]); sl@0: iScreenDevice->SetScreenMode(screenModeList[1]); sl@0: iSession.Finish(ETrue); sl@0: Pause(1000); sl@0: sl@0: MDisplayMapping* interfaceM = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: TRect appRect(20, 40, 193, 110); sl@0: TRect uiRect(1,2,3,4); sl@0: TRect compRect(5,6,7,8); sl@0: TRect tempRect(10,11,12,13); sl@0: TInt err; sl@0: while (ETrue) sl@0: { sl@0: //quick get for a print sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); sl@0: sl@0: // print sl@0: // INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY); sl@0: // INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY); sl@0: // INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY); sl@0: // INFO_PRINTF1(_L(" ")); sl@0: sl@0: //longer process to insure conversions both ways dont lose accuracy sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect); sl@0: ASSERT_EQUALS(tempRect,appRect); sl@0: sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect); sl@0: ASSERT_EQUALS(tempRect,appRect); sl@0: sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect); sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect); sl@0: ASSERT_EQUALS(tempRect,uiRect); sl@0: sl@0: appRect.iBr.iX--; sl@0: appRect.iBr.iY--; sl@0: if (appRect.IsEmpty()) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TRect rect1(5,5,10,10); sl@0: TRect rect2(15,15,20,20); sl@0: TRect rect3(50,50,50,50); sl@0: //1 sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect2); sl@0: sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: //2 sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2); sl@0: ASSERT_EQUALS(rect1,rect2); sl@0: sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: //3 sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2); sl@0: ASSERT_EQUALS(rect1,rect2); sl@0: sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2); sl@0: err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3); sl@0: ASSERT_EQUALS(rect1,rect3); sl@0: sl@0: //4 sl@0: err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2); sl@0: ASSERT_EQUALS(rect1,rect2); sl@0: sl@0: //invalid sl@0: err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2); sl@0: ASSERT_EQUALS(err,KErrNotSupported); sl@0: err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2); sl@0: ASSERT_EQUALS(err,KErrNotSupported); sl@0: err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2); sl@0: ASSERT_EQUALS(err,KErrNotSupported); sl@0: err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2); sl@0: ASSERT_EQUALS(err,KErrNotSupported); sl@0: err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2); sl@0: ASSERT_EQUALS(err,KErrNotSupported); sl@0: sl@0: TDisplayConfiguration dispConfigAfter; sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: iScreenDevice->SetAppScreenMode(0); sl@0: iScreenDevice->SetScreenMode(0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0009L sl@0: @SYMTestCaseDesc Set Screen display res using app mode sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose SetScreenMode functions correctly sl@0: @SYMTestActions sl@0: Similar to 0006, but setting every available screen mode instead of resolution sl@0: @SYMTestExpectedResults sl@0: Every set should work, including modes that involve a rotation! sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: TInt error; sl@0: iSession.Finish(ETrue); sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode")); sl@0: iSession.Finish(ETrue); sl@0: sl@0: iTestBack=RBlankWindow(iSession); sl@0: ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); sl@0: iTestBack.SetRequiredDisplayMode(iDisplayMode); sl@0: iTestBack.SetColor(TRgb(255,0,0)); sl@0: iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); sl@0: iTestBack.Activate(); sl@0: iTestBack.SetVisible(ETrue); sl@0: iSession.Finish(ETrue); sl@0: sl@0: struct DrawCompare sl@0: { sl@0: static void Draw(CWindowGc* aGc) sl@0: { sl@0: aGc->SetPenStyle(aGc->ESolidPen); sl@0: aGc->SetPenColor(TRgb(255,255,255)); sl@0: aGc->SetBrushColor(TRgb(0,0,0)); sl@0: TRect r(2,2,82,82); sl@0: while(r.Width()>0) sl@0: { sl@0: aGc->DrawRect(r); sl@0: r.Shrink(2,2); sl@0: } sl@0: } sl@0: }; sl@0: TSurfaceId surfaceID; sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), sl@0: KSurfaceFormat, 200 * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TSurfaceConfiguration surfConf; sl@0: surfConf.SetSurfaceId(surfaceID); sl@0: sl@0: surfConf.SetExtent(TRect(2,84,82,166)); sl@0: iCompare.SetBackgroundSurface(surfConf,EFalse); sl@0: sl@0: if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) sl@0: { sl@0: DrawCompare::Draw(gc); sl@0: gc->Deactivate(); sl@0: iCompare.EndRedraw(); sl@0: sl@0: } sl@0: iSession.Finish(ETrue); sl@0: Pause(1000); sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration dispConfigBefore; sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) sl@0: if (screenModeList.Count()>1) sl@0: { sl@0: //Got a mode to change to! sl@0: TSize resBefore; sl@0: TBool ok=dispConfigBefore.GetResolution(resBefore); sl@0: ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag sl@0: for (TInt res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[res]); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: TPixelsAndRotation pr; sl@0: iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); sl@0: TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); sl@0: Pause(300); sl@0: sl@0: if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) sl@0: { sl@0: DrawCompare::Draw(gc); sl@0: gc->Deactivate(); sl@0: iCompare.EndRedraw(); sl@0: } sl@0: if (iTitle.WsHandle()) sl@0: { sl@0: TPoint infoWinPos; sl@0: TSize infoWinSize; sl@0: infoWinPos=iTitle.AbsPosition(); sl@0: infoWinSize=iTitle.Size(); sl@0: infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; sl@0: iTitle.SetSize(infoWinSize); sl@0: } sl@0: TBuf16<20> s; sl@0: s.AppendNum(res); sl@0: UpdateTitleWindowL(s,1); sl@0: s.Zero(); sl@0: s.AppendNum(pr.iPixelSize.iWidth); sl@0: s.Append('x'); sl@0: s.AppendNum(pr.iPixelSize.iHeight); sl@0: UpdateTitleWindowL(s,2); sl@0: s.Zero(); sl@0: s.AppendNum(origin.iX); sl@0: s.Append(','); sl@0: s.AppendNum(origin.iY); sl@0: UpdateTitleWindowL(s,3); sl@0: sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: TPoint winpos=iCompare.AbsPosition(); sl@0: TSize winsize=iCompare.Size(); sl@0: sl@0: for (TSize z=TSize(1,1);z!=TSize(-1,-1);) sl@0: { sl@0: for (TInt i=0;i<15;i++) sl@0: { sl@0: winpos+=z; sl@0: iCompare.SetExtent(winpos,winsize); sl@0: iSession.Finish(ETrue); sl@0: Pause(100); sl@0: } sl@0: if (z.iHeight && z.iWidth) sl@0: z=TSize(0,-1); sl@0: else sl@0: if (z.iHeight) sl@0: z=TSize(-1,0); sl@0: else sl@0: z=TSize(-1,-1); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: //restore initial res sl@0: if (screenModeList.Count() > 1) sl@0: { //set back to basics sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: Pause(300); sl@0: } sl@0: sl@0: interface->SetConfiguration(dispConfigBefore); sl@0: Pause(1000); sl@0: TDisplayConfiguration dispConfigAfter; sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: TSize resAfter; sl@0: ok=dispConfigAfter.GetResolution(resAfter); sl@0: ASSERT_TRUE(ok); sl@0: ASSERT_EQUALS(resBefore,resAfter); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); sl@0: } sl@0: sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0010L sl@0: @SYMTestCaseDesc Test app mode setting during attach/detach sl@0: @SYMREQ REQ10330 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Make sure display resumes last app mode when reattached sl@0: @SYMTestActions sl@0: Save app mode and display configuration before detach and compare it with those after reattach. sl@0: Repeat for a second app mode sl@0: If available, repeat with dynamic app mode sl@0: @SYMTestExpectedResults sl@0: For normal app mode, on reconnect it should re apply the old configuration sl@0: For dynamic app mode, on reconnect it should be 0x0 sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); sl@0: #else sl@0: TInt error; sl@0: iSession.Finish(ETrue); sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach")); sl@0: iSession.Finish(ETrue); sl@0: sl@0: Pause(1000); sl@0: TInt screenNo = iScreenDevice->GetScreenNumber(); sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: sl@0: //Find 2 real app modes and 1 dynamic app mode sl@0: TInt firstAvailableAppMode = -1; sl@0: TInt secondAvailableAppMode = -1; sl@0: TInt dynamicAppMode = -1; sl@0: for (TInt ii = 0; ii < screenModeList.Count(); ii++) sl@0: { sl@0: TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]); sl@0: if (dynamic && dynamicAppMode == -1) sl@0: { sl@0: dynamicAppMode = screenModeList[ii]; sl@0: } sl@0: if (!dynamic) sl@0: { sl@0: if (firstAvailableAppMode == -1) sl@0: { sl@0: firstAvailableAppMode = screenModeList[ii]; sl@0: } sl@0: else if (secondAvailableAppMode == -1) sl@0: { sl@0: secondAvailableAppMode = screenModeList[ii]; sl@0: } sl@0: } sl@0: } sl@0: ASSERT_TRUE(firstAvailableAppMode!=-1); sl@0: ASSERT_TRUE(secondAvailableAppMode!=-1); sl@0: sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration configBeforeDetach, configAfterReattach; sl@0: TInt appModeBeforeDetach, appModeAfterReattach; sl@0: sl@0: // sl@0: //1st detach - attach sequence sl@0: appModeBeforeDetach = firstAvailableAppMode; sl@0: iScreenDevice->SetAppScreenMode(appModeBeforeDetach ); sl@0: iScreenDevice->SetScreenMode(appModeBeforeDetach ); sl@0: Pause(200); sl@0: interface->GetConfiguration(configBeforeDetach); sl@0: sl@0: TInt displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: sl@0: //dummy mapping should return KErrNotReady if display is disconnected sl@0: TRect dummyRect(1,2,5,8); sl@0: error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); sl@0: ASSERT_EQUALS(error, KErrNotReady); sl@0: sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: sl@0: interface->GetConfiguration(configAfterReattach); sl@0: ASSERT_TRUE(configBeforeDetach==configAfterReattach); sl@0: appModeAfterReattach = iScreenDevice->CurrentScreenMode(); sl@0: ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); sl@0: //1st detach - attach sequence ends here sl@0: // sl@0: sl@0: configBeforeDetach.ClearAll(); sl@0: configAfterReattach.ClearAll(); sl@0: sl@0: // sl@0: //2nd detach-attach sequence - non dynamic app mode sl@0: iScreenDevice->SetAppScreenMode(secondAvailableAppMode); sl@0: iScreenDevice->SetScreenMode(secondAvailableAppMode); sl@0: Pause(200); sl@0: appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); sl@0: interface->GetConfiguration(configBeforeDetach); sl@0: displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: //dummy mapping should return KErrNotReady if display is disconnected sl@0: error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); sl@0: ASSERT_EQUALS(error, KErrNotReady); sl@0: sl@0: displayState = ENoResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: //dummy mapping should return KErrNotReady if display is disconnected sl@0: error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); sl@0: ASSERT_EQUALS(error, KErrNotReady); sl@0: sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: sl@0: interface->GetConfiguration(configAfterReattach); sl@0: ASSERT_TRUE(configBeforeDetach==configAfterReattach); sl@0: appModeAfterReattach = iScreenDevice->CurrentScreenMode(); sl@0: ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); sl@0: //2nd detach-attach sequence ends here sl@0: // sl@0: sl@0: configBeforeDetach.ClearAll(); sl@0: configAfterReattach.ClearAll(); sl@0: sl@0: // sl@0: //3rd detach-attach sequence - dynamic app mode sl@0: if (dynamicAppMode == -1) sl@0: { sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: INFO_PRINTF1(_L("No dynamic app mode, end test")); //not a fail if there isn't a dynamic app mode sl@0: return; sl@0: } sl@0: sl@0: iScreenDevice->SetAppScreenMode(dynamicAppMode); sl@0: iScreenDevice->SetScreenMode(dynamicAppMode); sl@0: Pause(200); sl@0: appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); sl@0: interface->GetConfiguration(configBeforeDetach); sl@0: displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: //dummy mapping should return KErrNotReady if display is disconnected sl@0: error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); sl@0: ASSERT_EQUALS(error, KErrNotReady); sl@0: sl@0: displayState = ENoResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: //dummy mapping should return KErrNotReady if display is disconnected sl@0: error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); sl@0: ASSERT_EQUALS(error, KErrNotReady); sl@0: sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: sl@0: interface->GetConfiguration(configAfterReattach); sl@0: ASSERT_FALSE(configBeforeDetach==configAfterReattach); sl@0: TSize afterReattachSize; sl@0: ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize)); sl@0: ASSERT_EQUALS(afterReattachSize,TSize(0,0)); sl@0: ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize)); sl@0: ASSERT_EQUALS(afterReattachSize,TSize(0,0)); sl@0: sl@0: appModeAfterReattach = iScreenDevice->CurrentScreenMode(); sl@0: ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); sl@0: //3rd detach-attach sequence ends here sl@0: // sl@0: sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: #endif sl@0: } sl@0: sl@0: sl@0: CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard) sl@0: {} sl@0: sl@0: CDSATestDrawing::~CDSATestDrawing() sl@0: { sl@0: Cancel(); sl@0: } sl@0: CDSATestDrawing* CDSATestDrawing::NewL() sl@0: { sl@0: CDSATestDrawing *self = new(ELeave) CDSATestDrawing(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CDSATestDrawing::ConstructL() sl@0: { sl@0: CTimer::ConstructL(); sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA) sl@0: { sl@0: sl@0: if(aDSA) sl@0: { sl@0: iDSA = aDSA; sl@0: } sl@0: sl@0: if(iDSA) sl@0: { sl@0: iDSA->StartL(); sl@0: sl@0: iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size()); sl@0: sl@0: iWin->Invalidate(); sl@0: iWin->BeginRedraw(); sl@0: CFbsBitGc* gc = iDSA->Gc(); sl@0: gc->SetBrushColor(TRgb(220,220,220)); sl@0: gc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc->Clear(); sl@0: iWin->EndRedraw(); sl@0: After(500000); sl@0: } sl@0: sl@0: } sl@0: sl@0: void CDSATestDrawing::RunL() sl@0: { sl@0: Draw(); sl@0: After(500000); sl@0: } sl@0: sl@0: void CDSATestDrawing::Draw() sl@0: { sl@0: //Should not invalidate the window containing DSA drawing. That's the whole point! sl@0: CFbsBitGc* gc = iDSA->Gc(); sl@0: gc->SetPenStyle(gc->ESolidPen); sl@0: gc->SetPenColor(TRgb(255,0,0)); sl@0: gc->SetBrushStyle(gc->ENullBrush); sl@0: iRect.Shrink(1, 1); sl@0: gc->DrawRect(iRect); sl@0: iDSA->ScreenDevice()->Update(); sl@0: sl@0: } sl@0: void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) sl@0: { sl@0: sl@0: StartDrawingL(NULL); sl@0: } sl@0: sl@0: void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0011L sl@0: @SYMTestCaseDesc Test DSA drawing in different App Mode sl@0: @SYMREQ REQ10332 REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Test DSA can restart and draw at correct place when screen mode changes sl@0: @SYMTestActions sl@0: A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing sl@0: time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside sl@0: the new drawing region. sl@0: sl@0: note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in sl@0: @SYMTestExpectedResults sl@0: All tests should pass. sl@0: sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: sl@0: Pause(1000); sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing")); sl@0: CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL(); sl@0: CleanupStack::PushL(dsaDraw); sl@0: CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw); sl@0: CleanupStack::PushL(dsa); sl@0: dsaDraw->SetWindow(iCompare); sl@0: dsaDraw->StartDrawingL(dsa); sl@0: sl@0: CEventTimer *timer = CEventTimer::NewL(); sl@0: CleanupStack::PushL(timer); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: sl@0: CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode()); sl@0: CleanupStack::PushL(pixelReadBackDevice); sl@0: sl@0: for (TInt res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iScreenDevice->SetScreenMode(screenModeList[res]); sl@0: dsa->ScreenDevice()->Update(); sl@0: Pause(300); sl@0: //wait for DSA to restart sl@0: timer->Wait(500000); sl@0: TRect regionRect(dsa->DrawingRegion()->BoundingRect()); sl@0: sl@0: TPoint winpos = iCompare.AbsPosition(); sl@0: TSize winsize = iCompare.Size(); sl@0: sl@0: TPixelsAndRotation pr; sl@0: iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); sl@0: TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); sl@0: Pause(300); sl@0: if (iTitle.WsHandle()) sl@0: { sl@0: TPoint infoWinPos; sl@0: TSize infoWinSize; sl@0: infoWinPos=iTitle.AbsPosition(); sl@0: infoWinSize=iTitle.Size(); sl@0: infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; sl@0: iTitle.SetSize(infoWinSize); sl@0: } sl@0: TBuf16<20> s; sl@0: s.AppendNum(res); sl@0: UpdateTitleWindowL(s,1); sl@0: s.Zero(); sl@0: s.AppendNum(pr.iPixelSize.iWidth); sl@0: s.Append('x'); sl@0: s.AppendNum(pr.iPixelSize.iHeight); sl@0: UpdateTitleWindowL(s,2); sl@0: s.Zero(); sl@0: s.AppendNum(origin.iX); sl@0: s.Append(','); sl@0: s.AppendNum(origin.iY); sl@0: UpdateTitleWindowL(s,3); sl@0: sl@0: INFO_PRINTF2(_L("---------test %i---------"), res); sl@0: INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight); sl@0: INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY); sl@0: //INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY); sl@0: INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX, sl@0: dsa->DrawingRegion()->BoundingRect().iTl.iY); sl@0: INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(), sl@0: dsa->DrawingRegion()->BoundingRect().Height()); sl@0: //give time so DSA AO can start drawing sl@0: timer->Wait(5000000); sl@0: sl@0: sl@0: TRect readBackRect; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect); sl@0: pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl); sl@0: pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation)); sl@0: readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr); sl@0: sl@0: if(readBackRect.IsEmpty()) sl@0: { sl@0: INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour")); sl@0: continue; sl@0: } sl@0: sl@0: //Ruo: Oh I almost believe iBr is exclusive now sl@0: TDisplayConfiguration dispConfigAfter2; sl@0: interface->GetConfiguration(dispConfigAfter2); sl@0: TSize theSize; sl@0: dispConfigAfter2.GetResolution(theSize); sl@0: TDisplayConfiguration1::TRotation orient; sl@0: dispConfigAfter2.GetRotation(orient); sl@0: if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) sl@0: { sl@0: TInt temp = theSize.iHeight; sl@0: theSize.iHeight = theSize.iWidth; sl@0: theSize.iWidth = temp; sl@0: } sl@0: TRect uiSize(TPoint(0,0), theSize); sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: TRect finalSize; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); sl@0: sl@0: CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); sl@0: MTestScreenCapture sl@0: * csc = sl@0: static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: sl@0: if (csc) sl@0: { sl@0: TInt errr = csc->ComposeScreen(*bmp2); sl@0: ASSERT_TRUE(errr == KErrNone); sl@0: } sl@0: else sl@0: { sl@0: if (!cSCLogged) sl@0: { sl@0: cSCLogged = ETrue; sl@0: _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); sl@0: } sl@0: } sl@0: sl@0: readBackRect.iBr = readBackRect.iBr - TPoint(1,1); sl@0: //check 4 outter corners sl@0: TRgb pixelRgb; sl@0: TRgb cornerRgb(220, 220, 220); sl@0: TRgb innerRgb(255, 0, 0); sl@0: readBackRect.Grow(1, 1); sl@0: TRect compSpaceReadBackRect; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); sl@0: sl@0: sl@0: if (csc) sl@0: { sl@0: if (finalSize.Contains(compSpaceReadBackRect.iTl)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); sl@0: if(!(pixelRgb != cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); sl@0: if(!(pixelRgb != cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(compSpaceReadBackRect.iBr)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); sl@0: if(!(pixelRgb != cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); sl@0: if(!(pixelRgb != cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: } sl@0: sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); sl@0: ASSERT_TRUE(pixelRgb != cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); sl@0: ASSERT_TRUE(pixelRgb != cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); sl@0: ASSERT_TRUE(pixelRgb != cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); sl@0: ASSERT_TRUE(pixelRgb != cornerRgb); sl@0: sl@0: //check 4 inner corners sl@0: readBackRect.Shrink(1,1); sl@0: mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); sl@0: sl@0: if (csc) sl@0: { sl@0: if (finalSize.Contains(compSpaceReadBackRect.iTl)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); sl@0: if(!(pixelRgb == cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); sl@0: if(!(pixelRgb == cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(compSpaceReadBackRect.iBr)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); sl@0: if(!(pixelRgb == cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); sl@0: if(!(pixelRgb == cornerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: } sl@0: sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); sl@0: ASSERT_TRUE(pixelRgb == cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); sl@0: ASSERT_TRUE(pixelRgb == cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); sl@0: ASSERT_TRUE(pixelRgb == cornerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); sl@0: ASSERT_TRUE(pixelRgb == cornerRgb); sl@0: //check inner colour sl@0: if(readBackRect.Width() < 3 || readBackRect.Height() < 3) sl@0: { sl@0: INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour")); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: sl@0: readBackRect.Shrink(1,1); sl@0: mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); sl@0: sl@0: if (csc) sl@0: { sl@0: if (finalSize.Contains(compSpaceReadBackRect.iTl)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); sl@0: if(!(pixelRgb == innerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); sl@0: if(!(pixelRgb == innerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(compSpaceReadBackRect.iBr)) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); sl@0: if(!(pixelRgb == innerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) sl@0: { sl@0: bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); sl@0: if(!(pixelRgb == innerRgb)) sl@0: { sl@0: _LIT(KCompareFailed, "Corner check failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: continue; sl@0: } sl@0: } sl@0: } sl@0: sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); sl@0: ASSERT_TRUE(pixelRgb == innerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); sl@0: ASSERT_TRUE(pixelRgb == innerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); sl@0: ASSERT_TRUE(pixelRgb == innerRgb); sl@0: pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); sl@0: ASSERT_TRUE(pixelRgb == innerRgb); sl@0: sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: } sl@0: screenModeList.Close(); sl@0: CleanupStack::PopAndDestroy(4, dsaDraw); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0012L sl@0: @SYMTestCaseDesc Test Pointer event coordinates are correct in different screen modes. sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Test Pointer event coordinates are correct in different screen mode sl@0: @SYMTestActions sl@0: In each screen mode, the simulated pointer event should always at the same relative position sl@0: inside iCompare window sl@0: @SYMTestExpectedResults sl@0: All test should pass sl@0: **NOTE Can only be tested in screen 0 ** sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates")); sl@0: Pause(300); sl@0: sl@0: CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); sl@0: CleanupStack::PushL(displayEventAO); sl@0: displayEventAO->Request(); sl@0: CEventTimer *timer = CEventTimer::NewL(); sl@0: CleanupStack::PushL(timer); sl@0: sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); sl@0: sl@0: for (TInt res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iScreenDevice->SetScreenMode(screenModeList[res]); sl@0: Pause(300); sl@0: sl@0: //win position in app space sl@0: TPoint winPos = iCompare.AbsPosition(); sl@0: TSize winSize = iCompare.Size(); sl@0: sl@0: //pointer event at the origin of window sl@0: TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1)); sl@0: //the expected pointer position received by client to compare with the actual point received. sl@0: //it's (1,1) because it's relative to window sl@0: displayEventAO->SetExpectedPointPos(TPoint(1, 1)); sl@0: TRect rectInComp, rectBackInApp; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp); sl@0: //as we got the physical coordinates at where we simulate pointer event sl@0: TRawEvent rawEvent; sl@0: rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: iSession.Flush(); sl@0: timer->Wait(1000); sl@0: sl@0: ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2); sl@0: ASSERT_TRUE(displayEventAO->PointerTestPassed()); sl@0: sl@0: //pointer event at 1/2 width and height inside the window sl@0: TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1)); sl@0: displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos); sl@0: mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp); sl@0: //as we got the physical coordinates at where we simulate pointer event sl@0: rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); sl@0: iSession.SimulateRawEvent(rawEvent); sl@0: iSession.Flush(); sl@0: timer->Wait(1000); sl@0: sl@0: ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4); sl@0: ASSERT_TRUE(displayEventAO->PointerTestPassed()); sl@0: } sl@0: screenModeList.Close(); sl@0: CleanupStack::PopAndDestroy(2, displayEventAO); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0013L sl@0: @SYMTestCaseDesc Test the twips size after detach sl@0: @SYMREQ REQ10329 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Make sure the twips size is undefined after detach. sl@0: @SYMTestActions sl@0: Save display configuration before detach and compare it with the display configuration after detach. sl@0: @SYMTestExpectedResults sl@0: all tests should pass sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L() sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); sl@0: #else sl@0: TInt error; sl@0: iSession.Finish(ETrue); sl@0: MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size")); sl@0: iSession.Finish(ETrue); sl@0: sl@0: Pause(1000); sl@0: TInt screenNo = iScreenDevice->GetScreenNumber(); sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration configBeforeDetach; sl@0: sl@0: // detach the display sl@0: interface->GetConfiguration(configBeforeDetach); sl@0: TInt displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: Pause(300); sl@0: sl@0: // retrieve the display configuration sl@0: interface->GetConfiguration(configBeforeDetach); sl@0: ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips)); sl@0: sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrDisconnected); sl@0: sl@0: configBeforeDetach.ClearAll(); sl@0: sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: #endif sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0014L sl@0: @SYMTestCaseDesc Test GetConfiguration immediatly after SetConfiguration sl@0: @SYMREQ REQ10328 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size sl@0: @SYMTestActions sl@0: successive SetConfiguration/GetConfiguration pair sl@0: @SYMTestExpectedResults sl@0: all tests should pass sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: RArray resolutions; sl@0: TInt err = interface->GetResolutions(resolutions); sl@0: ASSERT_EQUALS(err, KErrNone); sl@0: TDisplayConfiguration configSet, configGet; sl@0: TSize twipsGet, resolutionGet; sl@0: sl@0: TInt screenNo = iScreenDevice->GetScreenNumber(); sl@0: iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); sl@0: for(TInt testIndex = 0; testIndex < 2; testIndex++) sl@0: {//run twice sl@0: #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); sl@0: #else sl@0: TInt displayState; sl@0: displayState = ENormalResolution; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: #endif sl@0: for (TInt i=0;iSetConfiguration(configSet); sl@0: if(err != KErrNone) sl@0: { sl@0: //with scaling, KErrArgument means current config is not compatible with appmode. sl@0: //In none scaling, it does mean an error, sl@0: //but the purpose of this test is to see if twips size is buffered so we can read it back instantly sl@0: //let other tests test the functionality of SetConfiguration. sl@0: ASSERT_EQUALS(err, KErrArgument); sl@0: sl@0: INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip")); sl@0: continue; sl@0: } sl@0: interface->GetConfiguration(configGet); sl@0: ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); sl@0: ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution)); sl@0: configGet.GetResolutionTwips(twipsGet); sl@0: configGet.GetResolution(resolutionGet); sl@0: INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight); sl@0: INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight); sl@0: ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize); sl@0: Pause(300); sl@0: } sl@0: #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER sl@0: INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); sl@0: #else sl@0: displayState = EDisconnect; sl@0: UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); sl@0: #endif sl@0: } sl@0: resolutions.Close(); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0015L sl@0: @SYMTestCaseDesc No Scaling doesnt return virtual resolutions sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose no scaling should mean basic resolution selection sl@0: @SYMTestActions sl@0: Get resolution list sl@0: Should not contain virtual resolutions sl@0: Set every app mode sl@0: Should not change resolution sl@0: @SYMTestExpectedResults sl@0: All test should pass sl@0: **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L() sl@0: { //ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: TInt screenNumber = iScreenDevice->GetScreenNumber(); sl@0: if (screenNumber == 0) sl@0: { sl@0: ASSERT_EQUALS(resolutions,1); sl@0: } sl@0: else if (screenNumber == 1) sl@0: { sl@0: ASSERT_EQUALS(resolutions,4); sl@0: } sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: sl@0: TDisplayConfiguration dispConfig1; sl@0: interface->GetConfiguration(dispConfig1); sl@0: TSize size1; sl@0: ASSERT_TRUE(dispConfig1.GetResolution(size1)); sl@0: sl@0: for (TInt ii = 0; ii < screenModeList.Count(); ii++) sl@0: { sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[ii]); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: TDisplayConfiguration newConfig; sl@0: interface->GetConfiguration(newConfig); sl@0: TSize newSize; sl@0: ASSERT_TRUE(dispConfig1.GetResolution(newSize)); sl@0: ASSERT_EQUALS(size1,newSize); sl@0: } sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0016L sl@0: @SYMTestCaseDesc Anisotropic scaling sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Check using twips will cause virtual resolutions to possibly be different sl@0: @SYMTestActions sl@0: Check the virtual resolution for XXX is correctly XXX sl@0: Check when setting the appmode, it choses the correct resolution sl@0: @SYMTestExpectedResults sl@0: Tests should pass sl@0: **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L() sl@0: { //ONLY RUN WITH ANISOTROPIC WSINI.INI sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0017L sl@0: @SYMTestCaseDesc Integer scales correctly in policy sl@0: @SYMREQ REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Integer scaling should not create resolutions of non integer value! sl@0: @SYMTestActions sl@0: For every virtual resolution sl@0: Check its an integer size of a real resolution sl@0: @SYMTestExpectedResults sl@0: All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy) sl@0: **NOTE ONLY RUN WITH INTEGER WSINI.INI** sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L() sl@0: { //ONLY RUN WITH INTEGER WSINI.INI sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE(resolutions>1); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TInt index; sl@0: for (index=0;index sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: MDisplayMapping* mapInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mapInterface); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: sl@0: TRect maxWinExtent, refMaxWinExtent; sl@0: TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips; sl@0: TRect displayWinExtent, refDisplayWinExtent; sl@0: for (TInt i = 0; i < screenModeList.Count(); i++) sl@0: { sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[i]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[i]); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: INFO_PRINTF1(_L("---------------")); sl@0: INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]); sl@0: sl@0: mapInterface->GetMaximumWindowExtent(maxWinExtent); sl@0: INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY); sl@0: INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height()); sl@0: sl@0: sl@0: TDisplayConfiguration config; sl@0: interface->GetConfiguration(config); sl@0: ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution)); sl@0: TSize fullUiSize; sl@0: config.GetResolution(fullUiSize); sl@0: error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent); sl@0: ASSERT_EQUALS(error, KErrNone); sl@0: INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY); sl@0: INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height()); sl@0: ASSERT_EQUALS(maxWinExtent, refMaxWinExtent); sl@0: INFO_PRINTF1(_L("Match")); sl@0: sl@0: mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips); sl@0: INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight); sl@0: INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight); sl@0: TRect compositionRect; sl@0: error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect); sl@0: ASSERT_EQUALS(error, KErrNone); sl@0: refSurfaceSize = compositionRect.Size(); sl@0: INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight); sl@0: ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); sl@0: config.GetResolutionTwips(refSurfaceTwips); sl@0: INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight); sl@0: ASSERT_EQUALS(surfaceSize, refSurfaceSize); sl@0: ASSERT_EQUALS(surfaceTwips, refSurfaceTwips); sl@0: INFO_PRINTF1(_L("Match")); sl@0: sl@0: mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent); sl@0: INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY); sl@0: INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height()); sl@0: error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent); sl@0: ASSERT_EQUALS(error, KErrNone); sl@0: INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY); sl@0: INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height()); sl@0: ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent); sl@0: INFO_PRINTF1(_L("Match")); sl@0: } sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: screenModeList.Close(); sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0021L sl@0: @SYMTestCaseDesc SetResolution negative test sl@0: @SYMREQ REQ10326 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Invalid configurations should return error and change nothing! sl@0: @SYMTestActions sl@0: Set config with rubbish resolution sl@0: Set config with rubbish twips sl@0: Set config with valid resolution, rubbish twips sl@0: Set config with valid twips, rubbish resolution sl@0: Set config with nothing defined sl@0: @SYMTestExpectedResults sl@0: Should all fail safely and not change any settings. sl@0: Config with nothing defined in a scaled mode will reset the resolution to current modes sl@0: equivilent virtual resolution sl@0: **NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available** sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode) sl@0: { //aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 1); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration original; sl@0: original.SetResolution(resolutionList1[0].iPixelSize); sl@0: error = interface->SetConfiguration(original); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: sl@0: TDisplayConfiguration beforeConfig; sl@0: TDisplayConfiguration afterConfig; sl@0: interface->GetConfiguration(beforeConfig); sl@0: sl@0: TInt differentRes; sl@0: for (differentRes = 1; differentRes < resolutions; differentRes++) sl@0: { sl@0: if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize)) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: ASSERT_TRUE(differentRes < resolutions); //otherwise it didnt find a resolution different to the one set sl@0: sl@0: TDisplayConfiguration test1; sl@0: test1.SetResolution(TSize(5,6)); //rubbish resolution! sl@0: error = interface->SetConfiguration(test1); sl@0: sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: iSession.Flush(); sl@0: interface->GetConfiguration(afterConfig); sl@0: ASSERT_TRUE(beforeConfig == afterConfig); sl@0: sl@0: TDisplayConfiguration test2; sl@0: test2.SetResolutionTwips(TSize(7,8)); //rubbish twips! sl@0: error = interface->SetConfiguration(test2); sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: iSession.Flush(); sl@0: interface->GetConfiguration(afterConfig); sl@0: ASSERT_TRUE(beforeConfig == afterConfig); sl@0: sl@0: TDisplayConfiguration test3; sl@0: test3.SetResolution(resolutionList1[differentRes].iPixelSize); //ok resolution! sl@0: test3.SetResolutionTwips(TSize(9,10)); //rubbish twips! sl@0: error = interface->SetConfiguration(test3); sl@0: //ASSERT_EQUALS(error,KErrArgument); sl@0: if (error != KErrArgument) sl@0: { sl@0: ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with confing not being validated sl@0: INFO_PRINTF1(_L("config was not honoured!")); sl@0: error = interface->SetConfiguration(original); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: } sl@0: else sl@0: { sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: interface->GetConfiguration(afterConfig); sl@0: ASSERT_TRUE(beforeConfig == afterConfig); sl@0: } sl@0: sl@0: TDisplayConfiguration test4; sl@0: test4.SetResolution(TSize(11,12)); //rubbish resolution! sl@0: test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize); //ok twips! sl@0: error = interface->SetConfiguration(test4); sl@0: if (error != KErrArgument) sl@0: { sl@0: ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with config not being validated sl@0: INFO_PRINTF1(_L("config was not honoured!")); sl@0: error = interface->SetConfiguration(original); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: } sl@0: else sl@0: { sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: interface->GetConfiguration(afterConfig); sl@0: ASSERT_TRUE(beforeConfig == afterConfig); sl@0: } sl@0: sl@0: if (aScaleMode) sl@0: { sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: ASSERT_TRUE(screenModeList.Count()>1); sl@0: //set default screen mode, sets resolution to best fit for this mode sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); //also sets its best resolution sl@0: iSession.Finish(ETrue); sl@0: Pause(200); sl@0: sl@0: TDisplayConfiguration newModeConfig; sl@0: interface->GetConfiguration(newModeConfig); sl@0: //get best fit resolution sl@0: TSize newModeRes; sl@0: ASSERT_TRUE(newModeConfig.GetResolution(newModeRes)); sl@0: sl@0: //find a different resolution sl@0: TInt i; sl@0: for (i = 0; i < resolutions; i++) sl@0: { sl@0: if (!(resolutionList1[i].iPixelSize == newModeRes)) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: ASSERT_TRUE(i < resolutions); //otherwise it didnt find a resolution different to the one set sl@0: TDisplayConfiguration newSetConfig; sl@0: sl@0: //set the different resolution sl@0: newSetConfig.SetResolution(resolutionList1[i].iPixelSize); sl@0: error = interface->SetConfiguration(newSetConfig); sl@0: ASSERT_TRUE(error == KErrNone); sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: TDisplayConfiguration checkConfig; sl@0: sl@0: //check its set this new resolution sl@0: interface->GetConfiguration(checkConfig); sl@0: TSize checkSize; sl@0: checkConfig.GetResolution(checkSize); sl@0: ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize); sl@0: sl@0: TDisplayConfiguration emptyConfig; sl@0: TDisplayConfiguration newModeConfig2(newModeConfig); sl@0: newModeConfig2.Clear(newModeConfig2.EResolutionTwips); sl@0: //set empty config, which should reset resolution to current modes default sl@0: error = interface->SetConfiguration(emptyConfig);//emptyConfig); sl@0: ASSERT_TRUE(error == KErrNone); sl@0: iSession.Finish(); sl@0: Pause(200); sl@0: sl@0: interface->GetConfiguration(checkConfig); sl@0: ASSERT_TRUE (newModeConfig == checkConfig); //empty config reset res to modes default res sl@0: sl@0: screenModeList.Close(); sl@0: } sl@0: else sl@0: { sl@0: TDisplayConfiguration test5; sl@0: error = interface->SetConfiguration(test5); sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: } sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0031L sl@0: @SYMTestCaseDesc SetConfiguration in OOM (changing resolution) sl@0: @SYMREQ REQ10326 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Safety check against OOM sl@0: @SYMTestActions sl@0: Set OOM failure sl@0: Set a resolution that will definately cause a change of resolution sl@0: Increase length of time to failure, repeat sl@0: Finish after 5 successful changes of resolution sl@0: @SYMTestExpectedResults sl@0: Set resolution should either return a fail and not have cause a change in resolution, sl@0: or it should have returned no fail and have set the new resolution sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: INFO_PRINTF1(_L("Interface obtained sucessfully.")); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully.")); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions.")); sl@0: sl@0: TInt index; sl@0: TDisplayConfiguration dispConfigBefore; sl@0: TDisplayConfiguration dispConfigAfter; sl@0: sl@0: dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize); sl@0: interface->SetConfiguration(dispConfigBefore); sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); sl@0: INFO_PRINTF1(_L("dispConfigBefore is defined.")); sl@0: TSize dispResBefore; sl@0: TSize dispResAfter; sl@0: dispConfigBefore.GetResolution(dispResBefore); sl@0: TDisplayConfiguration::TRotation dispRotBefore; sl@0: TDisplayConfiguration::TRotation dispRotReq; sl@0: dispConfigBefore.GetRotation(dispRotBefore); sl@0: sl@0: for (index = 0; index < resolutionList1.Count(); index++) sl@0: { sl@0: INFO_PRINTF2(_L("Starting resolution %d."), index); sl@0: if (resolutionList1[index].iPixelSize.iWidth == 0) sl@0: { sl@0: continue; sl@0: } sl@0: TInt heapFail = 1; sl@0: TBool notComplete = ETrue; sl@0: TInt completeCount = 0; sl@0: while (notComplete) sl@0: { sl@0: TDisplayConfiguration dispConfigReq; sl@0: dispConfigReq.SetResolution(resolutionList1[index].iPixelSize); sl@0: ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution)); sl@0: SetRotation(dispConfigReq,resolutionList1[index]); //set rotation to first defined in res list sl@0: dispConfigReq.GetRotation(dispRotReq); sl@0: INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail); sl@0: sl@0: iSession.Finish(ETrue); sl@0: iSession.HeapSetFail(RHeap::EDeterministic,heapFail); sl@0: TInt errCode=interface->SetConfiguration(dispConfigReq); sl@0: iSession.HeapSetFail(RHeap::ENone,0); sl@0: INFO_PRINTF1(_L("After Heap Failure.")); sl@0: iSession.Finish(ETrue); sl@0: Pause (100); sl@0: INFO_PRINTF1(_L("After Session Finish.")); sl@0: sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution)); sl@0: dispConfigAfter.GetResolution(dispResAfter); sl@0: sl@0: TBool worked = ETrue; sl@0: if (errCode < KErrNone) sl@0: { sl@0: worked = EFalse; sl@0: ASSERT_EQUALS(dispResAfter,dispResBefore); sl@0: if (dispRotReq != dispRotBefore) sl@0: { //didnt expect it work-KErrGeneral can mean a memory allocation fail sl@0: if (errCode == KErrArgument) sl@0: { //if it didnt panic, that is a good enough pass in this instance sl@0: worked = ETrue; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize); sl@0: } sl@0: if (worked) sl@0: { sl@0: completeCount++; sl@0: if (completeCount == 5) sl@0: { sl@0: notComplete = EFalse; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: completeCount = 0; sl@0: } sl@0: interface->SetConfiguration(dispConfigBefore); sl@0: INFO_PRINTF1(_L("After Setting Original Configuration.")); sl@0: heapFail++; sl@0: if (heapFail == 80) sl@0: { sl@0: ASSERT_TRUE(0); //worrying amount of fails sl@0: } sl@0: } sl@0: } sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0032L sl@0: @SYMTestCaseDesc SetAppMode in OOM sl@0: @SYMREQ REQ10326 REQ10336 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Safety check against OOM sl@0: @SYMTestActions sl@0: Set OOM failure sl@0: Set new app mode sl@0: Increase length of time to failure, repeat sl@0: Finish after 5 successful changes of mode sl@0: @SYMTestExpectedResults sl@0: SetAppMode should either return a fail and not have cause a change in resolution, sl@0: or it should have returned no fail and have set the new resolution sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: ASSERT_TRUE (screenModeList.Count()>0); sl@0: sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: sl@0: for (TInt index = 1; index < screenModeList.Count(); index++) sl@0: { //skip index 0, as that wouldn't be changing mode sl@0: TInt heapFail = 1; sl@0: TBool notComplete = ETrue; sl@0: TInt completeCount = 0; sl@0: while (notComplete) sl@0: { sl@0: RDebug::Printf("iInfoScreenDevice->SetAppScreenMode"); sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[index]); sl@0: iSession.Finish(ETrue); sl@0: iSession.HeapSetFail(RHeap::EDeterministic,heapFail); sl@0: RDebug::Printf("iInfoScreenDevice->SetAppScreenMode"); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[index]); sl@0: RDebug::Printf("SetScreenMode done"); sl@0: iSession.HeapSetFail(RHeap::ENone,0); sl@0: iSession.Finish(ETrue); sl@0: RDebug::Printf("Finish done"); sl@0: Pause(50); sl@0: TInt newMode = iInfoScreenDevice->CurrentScreenMode(); sl@0: sl@0: if (screenModeList[index] == newMode) sl@0: { sl@0: completeCount++; sl@0: if (completeCount == 5) sl@0: { sl@0: INFO_PRINTF3(_L("Mode %i Succeeded with heapFail = %d"),index, heapFail); sl@0: notComplete = EFalse; sl@0: } sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: iSession.Finish(ETrue); sl@0: Pause(50); sl@0: } sl@0: else sl@0: { sl@0: completeCount = 0; sl@0: } sl@0: heapFail++; sl@0: if (heapFail == 80) sl@0: { sl@0: ASSERT_TRUE(0); //worrying amount of fails sl@0: } sl@0: } sl@0: } sl@0: screenModeList.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0033L sl@0: @SYMTestCaseDesc GetConfiguration in OOM sl@0: @SYMREQ REQ10328 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Safety check against OOM sl@0: @SYMTestActions sl@0: Set OOM failure sl@0: GetConfiguration sl@0: Check config sl@0: Increase time till failure sl@0: Success after 5 completed gets sl@0: @SYMTestExpectedResults sl@0: Should always succeed sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt heapFail = 1; sl@0: for (TInt i=0;i<5;i++) sl@0: { sl@0: TDisplayConfiguration config; sl@0: iSession.Finish(ETrue); sl@0: iSession.HeapSetFail(RHeap::EDeterministic,heapFail); sl@0: interface->GetConfiguration(config); sl@0: iSession.HeapSetFail(RHeap::ENone,0); sl@0: iSession.Finish(ETrue); sl@0: ASSERT_TRUE(config.IsDefined(config.ERotation)); sl@0: ASSERT_TRUE(config.IsDefined(config.EResolution)); sl@0: ASSERT_TRUE(config.IsDefined(config.EResolutionTwips)); sl@0: heapFail++; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0034L sl@0: @SYMTestCaseDesc GetResolutions in OOM sl@0: @SYMREQ REQ10328 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Safety check against OOM sl@0: @SYMTestActions sl@0: Set OOM failure sl@0: GetResolutions sl@0: Check resolutions filled in sl@0: Success after 5 completed gets sl@0: @SYMTestExpectedResults sl@0: Should never panic! sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE(resolutions>1); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_TRUE(resolutionList1.Count() > 0); sl@0: sl@0: TInt heapFail = 1; sl@0: TInt completeCount = 0; sl@0: TBool notComplete = ETrue; sl@0: while (notComplete) sl@0: { sl@0: RArray resolutionList2; sl@0: iSession.Finish(ETrue); sl@0: iSession.HeapSetFail(RHeap::EDeterministic,heapFail); sl@0: error = interface->GetResolutions(resolutionList2); sl@0: iSession.HeapSetFail(RHeap::ENone,0); sl@0: iSession.Finish(ETrue); sl@0: if (errorSizeInPixels()); sl@0: screenSize.Shrink(5,5); sl@0: sl@0: RBlankWindow testWindow; sl@0: if (iInfoGc) sl@0: { sl@0: testWindow=RBlankWindow(iSession); sl@0: ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: testWindow.SetColor(iBlue); sl@0: testWindow.SetExtent(screenSize.iTl,screenSize.Size()); sl@0: testWindow.Activate(); sl@0: sl@0: if (testWindow.WsHandle()) sl@0: { sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: testWindow.SetVisible(ETrue); sl@0: } sl@0: sl@0: iSession.Finish(ETrue); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration dispConfigBefore; sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) sl@0: if (screenModeList.Count()>1) sl@0: { sl@0: //Got a mode to change to! sl@0: TSize resBefore; sl@0: TBool ok=dispConfigBefore.GetResolution(resBefore); sl@0: ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag sl@0: for (TInt res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[res]); sl@0: iSession.Finish(ETrue); sl@0: Pause(300); sl@0: sl@0: sl@0: TSize pr = iInfoScreenDevice->SizeInPixels(); sl@0: TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); sl@0: Pause(300); sl@0: TSize winpos; sl@0: sl@0: TSize surfaceSize = pr; sl@0: surfaceSize.iWidth /= 2; sl@0: surfaceSize.iWidth -= 20; sl@0: surfaceSize.iHeight -= 20; sl@0: TSurfaceId surfaceID; sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, sl@0: KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: CFbsBitmap* equivalentBitmap=NULL; sl@0: TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); sl@0: CleanupStack::PushL(equivalentBitmap); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: screenSize = iInfoScreenDevice->SizeInPixels(); sl@0: TSize testSize = iScreenDevice->SizeInPixels(); sl@0: screenSize.Shrink(5,5); sl@0: sl@0: if (iInfoGc) sl@0: { sl@0: testWindow.SetExtent(screenSize.iTl,screenSize.Size()); sl@0: sl@0: if (testWindow.WsHandle()) sl@0: { sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: testWindow.SetVisible(ETrue); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: RWindow surfWindow; sl@0: if (iInfoGc) sl@0: { sl@0: surfWindow=RWindow(iSession); sl@0: ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: surfWindow.SetBackgroundSurface(surfaceID); sl@0: surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); sl@0: surfWindow.Activate(); sl@0: sl@0: if (surfWindow.WsHandle()) sl@0: { sl@0: surfWindow.Invalidate(); sl@0: sl@0: surfWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,surfWindow,iRed); sl@0: surfWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: surfWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: sl@0: iSession.Finish(ETrue); sl@0: sl@0: TRect bitmapDrawRect; sl@0: bitmapDrawRect = surfaceSize; sl@0: sl@0: RWindow bmpWindow; sl@0: if (iInfoGc) sl@0: { sl@0: bmpWindow=RWindow(iSession); sl@0: ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: bmpWindow.SetBackgroundColor(iRed); sl@0: bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); sl@0: bmpWindow.Activate(); sl@0: sl@0: if (bmpWindow.WsHandle()) sl@0: { sl@0: bmpWindow.Invalidate(); sl@0: sl@0: bmpWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,bmpWindow,iRed); sl@0: // Not drawing, draw twice?? sl@0: iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); sl@0: bmpWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: bmpWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: sl@0: if (iInfoGc) sl@0: { sl@0: sl@0: if (bmpWindow.WsHandle()) sl@0: { sl@0: bmpWindow.Invalidate(); sl@0: sl@0: bmpWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,bmpWindow,iRed); sl@0: // Not drawing, draw twice?? sl@0: iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); sl@0: bmpWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: bmpWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: if (iInfoGc) sl@0: { sl@0: sl@0: if (bmpWindow.WsHandle()) sl@0: { sl@0: bmpWindow.Invalidate(); sl@0: sl@0: bmpWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,bmpWindow,iRed); sl@0: // Not drawing, draw twice?? sl@0: iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); sl@0: bmpWindow.EndRedraw(); sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: bmpWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: RArray regionArray; sl@0: sl@0: RRegion equivRegion; sl@0: TBitmapRegionPair bitmap1Region; sl@0: bitmap1Region.bitmap = equivalentBitmap; sl@0: bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); sl@0: equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); sl@0: bitmap1Region.region = &equivRegion; sl@0: sl@0: regionArray.Append(bitmap1Region); sl@0: sl@0: sl@0: TDisplayConfiguration dispConfigAfter2; sl@0: interface->GetConfiguration(dispConfigAfter2); sl@0: TSize theSize; sl@0: dispConfigAfter2.GetResolution(theSize); sl@0: TDisplayConfiguration1::TRotation orient; sl@0: dispConfigAfter2.GetRotation(orient); sl@0: if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) sl@0: { sl@0: TInt temp = theSize.iHeight; sl@0: theSize.iHeight = theSize.iWidth; sl@0: theSize.iWidth = temp; sl@0: } sl@0: TRect uiSize(TPoint(0,0), theSize); sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: TRect finalSize; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); sl@0: sl@0: sl@0: CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); sl@0: sl@0: MTestScreenCapture sl@0: * csc = sl@0: static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: if (csc) sl@0: { sl@0: TInt errr = csc->ComposeScreen(*bmp2); sl@0: ASSERT_TRUE(errr == KErrNone); sl@0: } sl@0: else sl@0: { sl@0: if (!cSCLogged) sl@0: { sl@0: cSCLogged = ETrue; sl@0: _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); sl@0: } sl@0: } sl@0: sl@0: sl@0: TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); sl@0: TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); sl@0: sl@0: if (csc) sl@0: { sl@0: if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) sl@0: { sl@0: _LIT(KCompareFailed, "Compare Failed on app mode: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: sl@0: equivRegion.Close(); sl@0: regionArray.Close(); sl@0: sl@0: CleanupStack::PopAndDestroy(equivalentBitmap); sl@0: surfWindow.Close(); sl@0: bmpWindow.Close(); sl@0: } sl@0: } sl@0: } sl@0: //restore initial res sl@0: if (screenModeList.Count() > 1) sl@0: { //set back to basics sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[0]); sl@0: Pause(300); sl@0: } sl@0: sl@0: interface->SetConfiguration(dispConfigBefore); sl@0: Pause(1000); sl@0: TDisplayConfiguration dispConfigAfter; sl@0: interface->GetConfiguration(dispConfigAfter); sl@0: TSize resAfter; sl@0: ok=dispConfigAfter.GetResolution(resAfter); sl@0: ASSERT_TRUE(ok); sl@0: ASSERT_EQUALS(resBefore,resAfter); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); sl@0: } sl@0: testWindow.Close(); sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0042L sl@0: @SYMTestCaseDesc Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions sl@0: @SYMREQ REQ10332 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPurpose Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions sl@0: @SYMTestActions sl@0: A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly sl@0: sl@0: Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing sl@0: @SYMTestExpectedResults sl@0: All tests should pass. sl@0: sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface) sl@0: { sl@0: LOG_AND_PANIC_IF_NOT_GCE; sl@0: ResetScreens(); sl@0: TInt error; sl@0: iSession.Finish(ETrue); sl@0: sl@0: TRect screenSize(iInfoScreenDevice->SizeInPixels()); sl@0: screenSize.Shrink(5,5); sl@0: sl@0: RBlankWindow testWindow; sl@0: if (iInfoGc) sl@0: { sl@0: testWindow=RBlankWindow(iSession); sl@0: ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: testWindow.SetColor(iBlue); sl@0: testWindow.SetExtent(screenSize.iTl,screenSize.Size()); sl@0: testWindow.Activate(); sl@0: sl@0: if (testWindow.WsHandle()) sl@0: { sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: testWindow.SetVisible(ETrue); sl@0: } sl@0: sl@0: iSession.Finish(ETrue); sl@0: sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 0); sl@0: sl@0: RArray resolutionList1; sl@0: error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: TDisplayConfiguration dispConfigBefore; sl@0: interface->GetConfiguration(dispConfigBefore); sl@0: sl@0: iInfoScreenDevice->SetAppScreenMode(screenModeList[1]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[1]); sl@0: iSession.Finish(); sl@0: Pause(50); sl@0: sl@0: if (resolutions>1) sl@0: { sl@0: //Got a mode to change to! sl@0: TSize resBefore; sl@0: TBool ok=dispConfigBefore.GetResolution(resBefore); sl@0: ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag sl@0: for (TInt res=0;resSetConfiguration(dispConfigReq); sl@0: //ASSERT_EQUALS(errCode,KErrNone); sl@0: if (errCode != KErrNone) sl@0: { sl@0: //Probably current size mode does not support the rotation of the passed in configuration sl@0: sl@0: ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy sl@0: continue; sl@0: } sl@0: sl@0: sl@0: TSize pr = iInfoScreenDevice->SizeInPixels(); sl@0: TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); sl@0: Pause(300); sl@0: TSize winpos; sl@0: sl@0: TSize surfaceSize = pr; sl@0: surfaceSize.iWidth /= 2; sl@0: surfaceSize.iWidth -= 20; sl@0: surfaceSize.iHeight -= 20; sl@0: TSurfaceId surfaceID; sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, sl@0: KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: CFbsBitmap* equivalentBitmap=NULL; sl@0: TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); sl@0: CleanupStack::PushL(equivalentBitmap); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: screenSize = iInfoScreenDevice->SizeInPixels(); sl@0: screenSize.Shrink(5,5); sl@0: sl@0: if (iInfoGc) sl@0: { sl@0: testWindow.SetExtent(screenSize.iTl,screenSize.Size()); sl@0: sl@0: if (testWindow.WsHandle()) sl@0: { sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: testWindow.SetVisible(ETrue); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: RWindow surfWindow; sl@0: if (iInfoGc) sl@0: { sl@0: surfWindow=RWindow(iSession); sl@0: ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: surfWindow.SetBackgroundSurface(surfaceID); sl@0: surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); sl@0: surfWindow.Activate(); sl@0: sl@0: if (surfWindow.WsHandle()) sl@0: { sl@0: surfWindow.Invalidate(); sl@0: sl@0: surfWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,surfWindow,iRed); sl@0: surfWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: surfWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: sl@0: iSession.Finish(ETrue); sl@0: sl@0: TRect bitmapDrawRect; sl@0: bitmapDrawRect = surfaceSize; sl@0: sl@0: RWindow bmpWindow; sl@0: if (iInfoGc) sl@0: { sl@0: bmpWindow=RWindow(iSession); sl@0: ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); sl@0: bmpWindow.SetBackgroundColor(iRed); sl@0: bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); sl@0: bmpWindow.Activate(); sl@0: sl@0: if (bmpWindow.WsHandle()) sl@0: { sl@0: bmpWindow.Invalidate(); sl@0: sl@0: bmpWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,bmpWindow,iRed); sl@0: // Not drawing, draw twice?? sl@0: iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); sl@0: bmpWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: bmpWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: sl@0: if (iInfoGc) sl@0: { sl@0: sl@0: if (bmpWindow.WsHandle()) sl@0: { sl@0: bmpWindow.Invalidate(); sl@0: sl@0: bmpWindow.BeginRedraw(); sl@0: ActivateWithWipe(iInfoGc,bmpWindow,iRed); sl@0: // Not drawing, draw twice?? sl@0: iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); sl@0: bmpWindow.EndRedraw(); sl@0: sl@0: iSession.Flush(); sl@0: iSession.Finish(); sl@0: } sl@0: bmpWindow.SetVisible(ETrue); sl@0: iInfoGc->Deactivate(); sl@0: } sl@0: Pause(200); sl@0: iSession.Finish(ETrue); sl@0: sl@0: sl@0: sl@0: sl@0: RArray regionArray; sl@0: sl@0: RRegion equivRegion; sl@0: TBitmapRegionPair bitmap1Region; sl@0: bitmap1Region.bitmap = equivalentBitmap; sl@0: bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); sl@0: equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); sl@0: bitmap1Region.region = &equivRegion; sl@0: sl@0: regionArray.Append(bitmap1Region); sl@0: sl@0: sl@0: TDisplayConfiguration dispConfigAfter2; sl@0: interface->GetConfiguration(dispConfigAfter2); sl@0: TSize theSize; sl@0: dispConfigAfter2.GetResolution(theSize); sl@0: TDisplayConfiguration1::TRotation orient; sl@0: dispConfigAfter2.GetRotation(orient); sl@0: if (orient & 0x1) sl@0: { sl@0: TInt temp = theSize.iHeight; sl@0: theSize.iHeight = theSize.iWidth; sl@0: theSize.iWidth = temp; sl@0: } sl@0: TRect uiSize(TPoint(0,0), theSize); sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: TRect finalSize; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); sl@0: sl@0: sl@0: sl@0: sl@0: CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU); sl@0: ASSERT_EQUALS(bmpErr, KErrNone); sl@0: sl@0: MTestScreenCapture sl@0: * csc = sl@0: static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: if (csc) sl@0: { sl@0: TInt errr = csc->ComposeScreen(*bmp2); sl@0: } sl@0: else sl@0: { sl@0: if (!cSCLogged) sl@0: { sl@0: cSCLogged = ETrue; sl@0: _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); sl@0: } sl@0: } sl@0: TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); sl@0: TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); sl@0: sl@0: if (csc) sl@0: { sl@0: if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) sl@0: { sl@0: _LIT(KCompareFailed, "Compare Failed on resolution: %d"); sl@0: TBuf<256> x; sl@0: x.Format(KCompareFailed, res+1); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: sl@0: equivRegion.Close(); sl@0: regionArray.Close(); sl@0: sl@0: CleanupStack::PopAndDestroy(equivalentBitmap); sl@0: surfWindow.Close(); sl@0: bmpWindow.Close(); sl@0: } sl@0: } sl@0: //restore initial res sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); sl@0: } sl@0: testWindow.Close(); sl@0: screenModeList.Close(); sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray sl@0: It does this by in the case of non-scaled bitmaps, performing a pixel by pixel comparison between what has been drawn to the CSC created bitmap and either the pixels of the bitmap if they are contained within the related region or the pixels of the simulation screen. In the case of scalingm only certain pixels are compared from the CSC bitmap to the comparison drawing as the scaling algorithm is hard to replicate. sl@0: sl@0: sl@0: @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code sl@0: @param aRect1 A rectangle representing the middle window in the comparison triple sl@0: @param aRect2 A rectangle represneting the right window in the comparison triple sl@0: @param aBitmapRegionPairArray An array of the different regions that are being drawn on the screen. They should be placed in order such that the closest to the foreground is first and the furthest away is last in the queue. Each member of the array is a misleadingly titled TBitmapRegion pair, the bitmap member of this should be the bitmap that is being drawn to the region of the screen, if the region is just a blank color then a blank color bitmap should be drawn. The region should be the region that the bitmap is being drawn to and should be the same as the clipping region which is set jsut before the bitmap is drawn to screen. Finally the draw rect is the basic rectangle the bitmap is being drawn to and is mainly used to test if the bitmap is being scaled sl@0: @return True sl@0: */ sl@0: TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap, sl@0: const TRect& aRect1, const TRect& aRect2, sl@0: RArray& aBitmapRegionPairArray, TBool aIsSurface) sl@0: { sl@0: MDisplayMapping* mappingInterface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); sl@0: ASSERT_TRUE(mappingInterface); sl@0: sl@0: sl@0: TRgb color1; sl@0: TRgb color2; sl@0: sl@0: TInt errorPixels =0; sl@0: TInt diffPixels = 0; sl@0: RRegion ignoreDueToResizing; sl@0: TInt regionCount = aBitmapRegionPairArray.Count(); sl@0: for (TInt i=regionCount-1; i>=0; i--) sl@0: { sl@0: if (aBitmapRegionPairArray[i].bitmap->SizeInPixels() sl@0: != aBitmapRegionPairArray[i].drawRect.Size()) sl@0: { sl@0: RArray corners; sl@0: corners.Append(aBitmapRegionPairArray[i].drawRect.iTl); sl@0: corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1, sl@0: aBitmapRegionPairArray[i].drawRect.iTl.iY)); sl@0: corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, sl@0: aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); sl@0: corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1)); sl@0: for (TInt j=0; jContains(corners[j])) sl@0: { sl@0: inOther = ETrue; sl@0: } sl@0: } sl@0: if (inOther) sl@0: { sl@0: continue; sl@0: } sl@0: aBitmap.GetPixel(color1, aRect2.iTl + corners[j]); sl@0: aBitmap.GetPixel(color2, aRect1.iTl + corners[j]); sl@0: TRgb color3 = GreatestColor(color1); sl@0: TRgb color4 = GreatestColor(color2); sl@0: if (color3 != color4) sl@0: { sl@0: // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. sl@0: if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0)) sl@0: { sl@0: } sl@0: else sl@0: if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0)) sl@0: { sl@0: } sl@0: else sl@0: { sl@0: corners.Close(); sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: } sl@0: // testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to sl@0: RArray testPoints; sl@0: testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center()); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); sl@0: testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, sl@0: aBitmapRegionPairArray[i].drawRect.Center().iY)); sl@0: testPoints.Append(TPoint(0, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); sl@0: testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX sl@0: -1, aBitmapRegionPairArray[i].drawRect.Center().iY)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); sl@0: TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size(); sl@0: if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20) sl@0: { sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0)); sl@0: sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1)); sl@0: sl@0: if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34 sl@0: && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43) sl@0: { sl@0: testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl sl@0: + TPoint(5, 5)); sl@0: testPoints.Append(TPoint(5, 5)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.iBr.iX - 6, sl@0: aBitmapRegionPairArray[i].drawRect.iTl.iY + 5)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.iTl.iX + 5, sl@0: aBitmapRegionPairArray[i].drawRect.iBr.iY -6)); sl@0: testPoints.Append(TPoint(5, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); sl@0: testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr sl@0: - TPoint(6, 6)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); sl@0: } sl@0: else sl@0: { sl@0: testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl sl@0: + TPoint(2, 3)); sl@0: testPoints.Append(TPoint(5, 5)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.iBr.iX - 3, sl@0: aBitmapRegionPairArray[i].drawRect.iTl.iY + 3)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].drawRect.iTl.iX + 2, sl@0: aBitmapRegionPairArray[i].drawRect.iBr.iY -4)); sl@0: testPoints.Append(TPoint(5, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); sl@0: testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr sl@0: - TPoint(3, 4)); sl@0: testPoints.Append(TPoint( sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, sl@0: aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); sl@0: } sl@0: } sl@0: for (int jj=0; jjContains(testPoints[jj])) sl@0: { sl@0: continue; sl@0: } sl@0: for (TInt k=0; kContains(testPoints[jj])) sl@0: { sl@0: inOther = ETrue; sl@0: } sl@0: } sl@0: if (inOther) sl@0: { sl@0: continue; sl@0: } sl@0: TPoint currentPoint = testPoints[jj]; sl@0: TRect bound = aBitmapRegionPairArray[i].region->BoundingRect(); sl@0: TBool sl@0: contat = sl@0: aBitmapRegionPairArray[i].region->Contains(testPoints[jj]); sl@0: aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]); sl@0: aBitmapRegionPairArray[i].bitmap->GetPixel(color2, sl@0: testPoints[jj+1]); sl@0: TRgb color5 = GreatestColor(color1); sl@0: TRgb color6 = GreatestColor(color2); sl@0: if (color5 != color6) sl@0: { sl@0: // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. sl@0: if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0)) sl@0: { sl@0: } sl@0: else sl@0: if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0)) sl@0: { sl@0: } sl@0: else sl@0: { sl@0: testPoints.Close(); sl@0: return EFalse; sl@0: } sl@0: } sl@0: } sl@0: sl@0: testPoints.Close(); sl@0: corners.Close(); sl@0: ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region); sl@0: aBitmapRegionPairArray.Remove(i); sl@0: } sl@0: } sl@0: sl@0: RRegion superRegion; sl@0: sl@0: regionCount = aBitmapRegionPairArray.Count(); sl@0: sl@0: for (TInt i=0; i0) sl@0: { sl@0: RDebug::Printf("Checking"); sl@0: TInt countchecks=0; sl@0: for (TInt i=0; iContains(currentPoint)) sl@0: { sl@0: if (aIsSurface) sl@0: { sl@0: TPoint checkPoint = currentPoint + aRect2.iTl; sl@0: TRect readBackRect; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); sl@0: aBitmap.GetPixel(color1, readBackRect.iTl); sl@0: } sl@0: else sl@0: { sl@0: TPoint checkPoint = currentPoint + aRect1.iTl; sl@0: TRect readBackRect; sl@0: mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); sl@0: aBitmap.GetPixel(color1, readBackRect.iTl); sl@0: } sl@0: sl@0: aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2, currentPoint sl@0: - aBitmapRegionPairArray[arrayIndex].drawRect.iTl); sl@0: sl@0: TRgb color7 = GreatestColor(color1); sl@0: TRgb color8 = GreatestColor(color2); sl@0: sl@0: if (color7 != color8) sl@0: { sl@0: diffPixels++; sl@0: //return EFalse; sl@0: } sl@0: pointInArray = ETrue; sl@0: } sl@0: arrayIndex++; sl@0: } sl@0: while (!pointInArray && !(arrayIndex sl@0: >= aBitmapRegionPairArray.Count())); sl@0: sl@0: if (!pointInArray) sl@0: { sl@0: aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX sl@0: + xStart, j +aRect2.iTl.iY +yStart)); sl@0: aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX sl@0: +xStart, j +aRect1.iTl.iY+yStart)); sl@0: // Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match sl@0: TRgb color3 = GreatestColor(color1); sl@0: TRgb color4 = GreatestColor(color2); sl@0: sl@0: if (color3 != color4) sl@0: { sl@0: // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. sl@0: if (GreatestColor(color2) == TRgb(0, 1, 0) sl@0: && GreatestColor(color1) == TRgb(1, 1, 0)) sl@0: { sl@0: continue; sl@0: } sl@0: else sl@0: if (GreatestColor(color2) == TRgb(1, 1, 0) sl@0: && GreatestColor(color1) == TRgb(0, 1, sl@0: 0)) sl@0: { sl@0: continue; sl@0: } sl@0: else sl@0: { sl@0: errorPixels++; sl@0: //return EFalse; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: ignoreDueToResizing.Close(); sl@0: if (errorPixels+diffPixels < 2) sl@0: { sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: /* sl@0: Creates a rough apprxoiamtion to the color pass in. This is used because of issues with the bitmap drwaing in the comparison window. If these issues are fixed then this method can be changed to simply return aColor. sl@0: sl@0: @param aColor the color to be approximated sl@0: @return an approximation of aColor. sl@0: */ sl@0: TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const sl@0: { sl@0: TInt test = aColor.Difference(TRgb(0, 0, 0)); sl@0: // Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing sl@0: if (aColor == TRgb(32, 32, 32)) sl@0: { sl@0: return TRgb(0, 0, 0); sl@0: } sl@0: if (aColor == TRgb(0, 0, 0)) sl@0: { sl@0: return TRgb(0, 0, 0); sl@0: } sl@0: TRgb test2; sl@0: test2.SetInternal(0xFFFEDF01); sl@0: if (aColor == test2) sl@0: { sl@0: return TRgb(1, 1, 0); sl@0: } sl@0: sl@0: if (test < 70) sl@0: { sl@0: return TRgb(0, 0, 0); sl@0: } sl@0: if (aColor.Green() > aColor.Blue()) sl@0: { sl@0: if (aColor.Green() > aColor.Red()) sl@0: { sl@0: return TRgb(0, 1, 0); sl@0: } sl@0: else sl@0: if (aColor.Green() == aColor.Red()) sl@0: { sl@0: return TRgb(1, 1, 0); sl@0: } sl@0: } sl@0: if (aColor.Green() > aColor.Red()) sl@0: { sl@0: if (aColor.Green() > aColor.Blue()) sl@0: { sl@0: return TRgb(0, 1, 0); sl@0: } sl@0: else sl@0: if (aColor.Green() == aColor.Blue()) sl@0: { sl@0: return TRgb(0, 1, 1); sl@0: } sl@0: } sl@0: sl@0: if (aColor.Red() > aColor.Green()) sl@0: { sl@0: if (aColor.Red() > aColor.Blue()) sl@0: { sl@0: return TRgb(1, 0, 0); sl@0: } sl@0: else sl@0: if (aColor.Red() == aColor.Blue()) sl@0: { sl@0: return TRgb(1, 0, 1); sl@0: } sl@0: } sl@0: if (aColor.Red() > aColor.Blue()) sl@0: { sl@0: if (aColor.Red() > aColor.Green()) sl@0: { sl@0: return TRgb(1, 0, 0); sl@0: } sl@0: else sl@0: if (aColor.Red() == aColor.Green()) sl@0: { sl@0: return TRgb(1, 1, 0); sl@0: } sl@0: } sl@0: sl@0: if (aColor.Blue() > aColor.Red()) sl@0: { sl@0: if (aColor.Blue() > aColor.Green()) sl@0: { sl@0: return TRgb(0, 0, 1); sl@0: } sl@0: else sl@0: if (aColor.Blue() == aColor.Green()) sl@0: { sl@0: return TRgb(0, 1, 1); sl@0: } sl@0: } sl@0: if (aColor.Blue() > aColor.Green()) sl@0: { sl@0: if (aColor.Blue() > aColor.Red()) sl@0: { sl@0: return TRgb(0, 0, 1); sl@0: } sl@0: else sl@0: if (aColor.Blue() == aColor.Red()) sl@0: { sl@0: return TRgb(1, 0, 1); sl@0: } sl@0: } sl@0: sl@0: // Should never reach here, but the compiler cannot be sure sl@0: return TRgb(0, 0, 0); sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0051L sl@0: @SYMTestCaseDesc Getting if a mode is dynamic sl@0: @SYMREQ REQ11554 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Check functions work correctly sl@0: @SYMTestActions sl@0: Do IsModeDynamic for a wrong mode number sl@0: Do IsModeDynamic for a mode that isnt dynamic sl@0: Do IsModeDynamic for a mode that is dynamic sl@0: Do IsCurrentModeDynamic when current mode is not dynamic sl@0: Do IsCurrentModeDynamic when current mode is dynamic sl@0: MODE 10 must be dynamic sl@0: @SYMTestExpectedResults sl@0: All should return as expected. sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L() sl@0: { sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25)); sl@0: ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1)); sl@0: ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10)); sl@0: ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic()); sl@0: iInfoScreenDevice->SetAppScreenMode(10); sl@0: iInfoScreenDevice->SetScreenMode(10); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); sl@0: screenModeList.Close(); sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: } sl@0: sl@0: /* Takes any 0x0 resolutions out of the res list, useful for some tests sl@0: */ sl@0: void ResListCleanup(RArray& aResList) sl@0: { sl@0: for (TInt ii=0; ii sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 1); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: ResListCleanup(resolutionList1); //remove any 0x0 sl@0: ASSERT_TRUE (resolutionList1.Count() > 1); //without multiple proper res this test is pointless sl@0: sl@0: TDisplayConfiguration newResolution; sl@0: newResolution.SetResolution(resolutionList1[0].iPixelSize); sl@0: error = interface->SetConfiguration(newResolution); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: sl@0: TSizeMode info; sl@0: RArray screenModes; sl@0: error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes); sl@0: ASSERT_TRUE(error>KErrNone); sl@0: TInt dynamicMode1 = -1; sl@0: TInt dynamicMode2 = -1; sl@0: TPixelsTwipsAndRotation modeAttributes; sl@0: sl@0: //for every app mode, check calculations update correctly sl@0: for (TInt ii=0;iiIsModeDynamic(screenMode)) sl@0: { sl@0: CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); sl@0: CleanupStack::PushL(rotations); sl@0: TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations); sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: ASSERT_TRUE(rotations->Count()>0); sl@0: for (TInt jj = 0; jj < rotations->Count(); jj++) sl@0: { sl@0: if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal || sl@0: (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180) sl@0: { sl@0: dynamicMode1 = screenMode; sl@0: } sl@0: else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 || sl@0: (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270) sl@0: { sl@0: dynamicMode2 = screenMode; sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(rotations); sl@0: continue; //dont want to test dynamic modes sl@0: } sl@0: sl@0: INFO_PRINTF2(_L("ScreenMode %d"),screenMode); sl@0: newResolution.ClearAll(); sl@0: sl@0: iInfoScreenDevice->SetAppScreenMode(screenMode); sl@0: iInfoScreenDevice->SetScreenMode(screenMode); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: info = iInfoScreenDevice->GetCurrentScreenModeAttributes(); sl@0: //These 2 asserts relate to DEF136304 - disconnect on startup causes invalid sl@0: //twips values. They need to be calculated when the screen is connected sl@0: ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000); sl@0: ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000); sl@0: sl@0: //test that conversions correlate to values reported by config sl@0: TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( sl@0: info.iScreenTwipsSize.iWidth); sl@0: ASSERT_EQUALS (test,info.iScreenSize.iWidth); sl@0: sl@0: test = iInfoScreenDevice->VerticalTwipsToPixels( sl@0: info.iScreenTwipsSize.iHeight); sl@0: ASSERT_EQUALS (test,info.iScreenSize.iHeight); sl@0: sl@0: test = iInfoScreenDevice->HorizontalPixelsToTwips( sl@0: info.iScreenSize.iWidth); sl@0: ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth); sl@0: sl@0: test = iInfoScreenDevice->VerticalPixelsToTwips( sl@0: info.iScreenSize.iHeight); sl@0: ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight); sl@0: } sl@0: sl@0: if (dynamicMode1 == -1 && dynamicMode2 == -1) //expected to find at least 1 dynamic mode sl@0: { sl@0: ASSERT_TRUE(0); sl@0: } sl@0: sl@0: for (TInt jj=0;jj<2;jj++) //for dynamic mode 1 and 2 sl@0: { sl@0: TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2; sl@0: if (dynMode == -1) sl@0: continue; sl@0: //set dynamic app mode sl@0: iInfoScreenDevice->SetAppScreenMode(dynMode); sl@0: iInfoScreenDevice->SetScreenMode(dynMode); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode)); sl@0: ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); sl@0: ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode()); sl@0: for (TInt ii=0;iiSetConfiguration(newResolution); sl@0: sl@0: if (jj == 0) sl@0: { sl@0: if (tempSetRot == TDisplayConfiguration1::ERotation90CW || sl@0: tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation sl@0: { sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: continue; sl@0: } sl@0: } sl@0: else //jj == 1 sl@0: { sl@0: if (tempSetRot == TDisplayConfiguration1::ERotationNormal || sl@0: tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation sl@0: { sl@0: ASSERT_EQUALS(error,KErrArgument); sl@0: continue; sl@0: } sl@0: } sl@0: ASSERT_EQUALS(error,KErrNone); sl@0: interface->GetConfiguration(newResolution); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: //test that conversions correlate to values reported by config sl@0: TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( sl@0: resolutionList1[ii].iTwipsSize.iWidth); sl@0: ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth); sl@0: sl@0: test = iInfoScreenDevice->VerticalTwipsToPixels( sl@0: resolutionList1[ii].iTwipsSize.iHeight); sl@0: ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight); sl@0: sl@0: test = iInfoScreenDevice->HorizontalPixelsToTwips( sl@0: resolutionList1[ii].iPixelSize.iWidth); sl@0: ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth); sl@0: sl@0: test = iInfoScreenDevice->VerticalPixelsToTwips( sl@0: resolutionList1[ii].iPixelSize.iHeight); sl@0: ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight); sl@0: } sl@0: } sl@0: sl@0: resolutionList1.Close(); sl@0: screenModes.Close(); sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0053L sl@0: @SYMTestCaseDesc SetScreenSizeAndRotation sl@0: @SYMREQ REQ11554 sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Check functions work correctly sl@0: @SYMTestActions sl@0: Perform calls to SetScreenSizeAndRotation with the various structure types sl@0: MODE 10 must be dynamic sl@0: @SYMTestExpectedResults sl@0: Cannt fail, used for debugging and coverage. sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L() sl@0: { sl@0: MDisplayControl* interface = static_cast sl@0: (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); sl@0: ASSERT_TRUE(interface); sl@0: sl@0: TInt resolutions = interface->NumberOfResolutions(); sl@0: ASSERT_TRUE (resolutions > 1); sl@0: sl@0: RArray resolutionList1; sl@0: TInt error = interface->GetResolutions(resolutionList1); sl@0: ASSERT_EQUALS(resolutionList1.Count(), resolutions); sl@0: sl@0: //set default app mode and default resolution sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: TDisplayConfiguration original; sl@0: original.SetResolution(resolutionList1[0].iPixelSize); sl@0: interface->SetConfiguration(original); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: TPixelsAndRotation setup0; sl@0: setup0.iPixelSize = TSize(30,40); sl@0: setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal; sl@0: sl@0: TPixelsTwipsAndRotation setup1; sl@0: setup1.iPixelSize = TSize(50,60); sl@0: setup1.iTwipsSize = TSize(70,80); sl@0: setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal; sl@0: sl@0: iInfoScreenDevice->SetScreenSizeAndRotation(setup0); sl@0: iInfoScreenDevice->SetScreenSizeAndRotation(setup1); sl@0: sl@0: //set dynamic app mode sl@0: iInfoScreenDevice->SetAppScreenMode(10); sl@0: iInfoScreenDevice->SetScreenMode(10); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: iInfoScreenDevice->SetScreenSizeAndRotation(setup0); sl@0: iInfoScreenDevice->SetScreenSizeAndRotation(setup1); sl@0: sl@0: const CWsScreenDevice* newDevice = iScreenDevice; sl@0: const MDisplayControl* interface2 = (MDisplayControl*) sl@0: newDevice->GetInterface(MDisplayControl::ETypeId); sl@0: TInt version = interface2->PreferredDisplayVersion(); //for coverage! sl@0: (void)version; sl@0: sl@0: //set default app mode and default resolution sl@0: iInfoScreenDevice->SetAppScreenMode(1); sl@0: iInfoScreenDevice->SetScreenMode(1); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: interface->SetConfiguration(original); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: resolutionList1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0101L sl@0: @SYMTestCaseDesc Quick demonstration of app modes sizes and positions on screen sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT (manual visual test) sl@0: @SYMTestPurpose To show app modes sl@0: @SYMTestActions sl@0: For every app mode sl@0: Draw a blue box showing the full size and position of the app mode. sl@0: Draw thin red lines demonstrating a window can be drawn outside of the app area to fill sl@0: the screen. sl@0: Green borders at the edge of the appmode, to show we are drawing up to the edges of the sl@0: appmode. sl@0: @SYMTestExpectedResults sl@0: Blue window should represent appmode (with offset and size) sl@0: Red windows should be visible across screen sl@0: Green border (made of windows) around the appmode (blue window) sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L() sl@0: { sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: sl@0: if (screenModeList.Count()>1) sl@0: { sl@0: //Got modes to change between! sl@0: TSize resBefore; sl@0: for (TInt res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[res]); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: TSize appSize = iInfoScreenDevice->SizeInPixels(); sl@0: RWindow backWindow(iSession); sl@0: ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); sl@0: backWindow.SetRequiredDisplayMode(iDisplayMode); sl@0: backWindow.SetBackgroundColor(iCyan); sl@0: backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40)); //shows size of the apparea sl@0: backWindow.Activate(); sl@0: sl@0: TSurfaceId surfaceID; sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), sl@0: KSurfaceFormat, 200 * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: TSurfaceConfiguration surfConf; sl@0: surfConf.SetSurfaceId(surfaceID); sl@0: sl@0: backWindow.SetBackgroundSurface(surfaceID); sl@0: sl@0: DrawPlainUI(backWindow,ETrue,iBlue); sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: sl@0: RWindow longWindow1(iSession); sl@0: ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); sl@0: longWindow1.SetRequiredDisplayMode(iDisplayMode); sl@0: longWindow1.SetBackgroundColor(iRed); sl@0: longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea sl@0: longWindow1.Activate(); sl@0: DrawPlainUI(longWindow1,ETrue,iRed); sl@0: sl@0: iBackground.SetColor(TRgb(0x001000*res|0x800000)); sl@0: iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: RWindow longWindow2(iSession); sl@0: ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); sl@0: longWindow2.SetRequiredDisplayMode(iDisplayMode); sl@0: longWindow2.SetBackgroundColor(iRed); sl@0: longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea sl@0: longWindow2.Activate(); sl@0: DrawPlainUI(longWindow2,ETrue,iRed); sl@0: sl@0: //borders sl@0: RWindow borderTop(iSession); sl@0: ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); sl@0: borderTop.SetRequiredDisplayMode(iDisplayMode); sl@0: borderTop.SetBackgroundColor(iGreen); sl@0: borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border sl@0: borderTop.Activate(); sl@0: DrawPlainUI(borderTop,ETrue,iGreen); sl@0: sl@0: RWindow borderLeft(iSession); sl@0: ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); sl@0: borderLeft.SetRequiredDisplayMode(iDisplayMode); sl@0: borderLeft.SetBackgroundColor(iGreen); sl@0: borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border sl@0: borderLeft.Activate(); sl@0: DrawPlainUI(borderLeft,ETrue,iGreen); sl@0: sl@0: RWindow borderRight(iSession); sl@0: ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); sl@0: borderRight.SetRequiredDisplayMode(iDisplayMode); sl@0: borderRight.SetBackgroundColor(iGreen); sl@0: borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border sl@0: borderRight.Activate(); sl@0: DrawPlainUI(borderRight,ETrue,iGreen); sl@0: sl@0: RWindow borderBottom(iSession); sl@0: ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); sl@0: borderBottom.SetRequiredDisplayMode(iDisplayMode); sl@0: borderBottom.SetBackgroundColor(iGreen); sl@0: borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border sl@0: borderBottom.Activate(); sl@0: DrawPlainUI(borderBottom,ETrue,iGreen); sl@0: sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: backWindow.Close(); sl@0: longWindow1.Close(); sl@0: longWindow2.Close(); sl@0: borderTop.Close(); sl@0: borderLeft.Close(); sl@0: borderRight.Close(); sl@0: borderBottom.Close(); sl@0: sl@0: iSession.Finish(); sl@0: Pause(50); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped.")); sl@0: } sl@0: sl@0: screenModeList.Close(); sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: iSession.Finish(ETrue); sl@0: Pause(100); sl@0: INFO_PRINTF1(_L("Drawing to borderBottom completed.")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0102L sl@0: @SYMTestCaseDesc Quick demonstration of square app modes in all 4 rotations sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2102 sl@0: @SYMTestType CT (manual visual test) sl@0: @SYMTestPurpose To show square app mode in all 4 rotations sl@0: @SYMTestActions sl@0: Draw a blue box showing the full size and position of the app mode. sl@0: Draw thin red lines demonstrating a window can be drawn outside of the app area to fill sl@0: the screen. sl@0: Green borders at the edge of the appmode, to show we are drawing up to the edges of the sl@0: appmode. sl@0: @SYMTestExpectedResults sl@0: Blue window should represent appmode (with offset and size) sl@0: Red windows should be visible across screen sl@0: Green border (made of windows) around the appmode (blue window) sl@0: */ sl@0: void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L() sl@0: { sl@0: RArray screenModeList; sl@0: iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); sl@0: sl@0: sl@0: TSize resBefore; sl@0: TInt res; sl@0: for (res=0;resSetAppScreenMode(screenModeList[res]); sl@0: iInfoScreenDevice->SetScreenMode(screenModeList[res]); sl@0: sl@0: iSession.Finish(ETrue); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: sl@0: TPixelsAndRotation pr; sl@0: iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); sl@0: if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth) sl@0: { sl@0: //found square appmode sl@0: break; sl@0: } sl@0: } sl@0: sl@0: for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++) sl@0: { sl@0: iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation); sl@0: iSession.Flush(); sl@0: Pause(50); sl@0: TDisplayConfiguration dispConfigReq; sl@0: TSize appSize = iInfoScreenDevice->SizeInPixels(); sl@0: RWindow backWindow(iSession); sl@0: ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); sl@0: backWindow.SetRequiredDisplayMode(iDisplayMode); sl@0: backWindow.SetBackgroundColor(iBlue); sl@0: backWindow.SetExtent(TPoint(0,0),appSize); //shows size of the apparea sl@0: backWindow.Activate(); sl@0: DrawPlainUI(backWindow,ETrue,iBlue); sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: sl@0: RWindow longWindow1(iSession); sl@0: ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); sl@0: longWindow1.SetRequiredDisplayMode(iDisplayMode); sl@0: longWindow1.SetBackgroundColor(iRed); sl@0: longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea sl@0: longWindow1.Activate(); sl@0: DrawPlainUI(longWindow1,ETrue,iRed); sl@0: sl@0: iBackground.SetColor(TRgb(0x001000*res|0x800000)); sl@0: iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: RWindow longWindow2(iSession); sl@0: ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); sl@0: longWindow2.SetRequiredDisplayMode(iDisplayMode); sl@0: longWindow2.SetBackgroundColor(iRed); sl@0: longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea sl@0: longWindow2.Activate(); sl@0: DrawPlainUI(longWindow2,ETrue,iRed); sl@0: sl@0: //borders sl@0: RWindow borderTop(iSession); sl@0: ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); sl@0: borderTop.SetRequiredDisplayMode(iDisplayMode); sl@0: borderTop.SetBackgroundColor(iGreen); sl@0: borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border sl@0: borderTop.Activate(); sl@0: DrawPlainUI(borderTop,ETrue,iGreen); sl@0: sl@0: RWindow borderLeft(iSession); sl@0: ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); sl@0: borderLeft.SetRequiredDisplayMode(iDisplayMode); sl@0: borderLeft.SetBackgroundColor(iGreen); sl@0: borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border sl@0: borderLeft.Activate(); sl@0: DrawPlainUI(borderLeft,ETrue,iGreen); sl@0: sl@0: RWindow borderRight(iSession); sl@0: ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); sl@0: borderRight.SetRequiredDisplayMode(iDisplayMode); sl@0: borderRight.SetBackgroundColor(iGreen); sl@0: borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border sl@0: borderRight.Activate(); sl@0: DrawPlainUI(borderRight,ETrue,iGreen); sl@0: sl@0: RWindow borderBottom(iSession); sl@0: ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); sl@0: borderBottom.SetRequiredDisplayMode(iDisplayMode); sl@0: borderBottom.SetBackgroundColor(iGreen); sl@0: borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border sl@0: borderBottom.Activate(); sl@0: DrawPlainUI(borderBottom,ETrue,iGreen); sl@0: sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: backWindow.Close(); sl@0: longWindow1.Close(); sl@0: longWindow2.Close(); sl@0: borderTop.Close(); sl@0: borderLeft.Close(); sl@0: borderRight.Close(); sl@0: borderBottom.Close(); sl@0: sl@0: iSession.Finish(); sl@0: Pause(50); sl@0: sl@0: } sl@0: sl@0: sl@0: screenModeList.Close(); sl@0: iInfoScreenDevice->SetAppScreenMode(0); sl@0: iInfoScreenDevice->SetScreenMode(0); sl@0: iSession.Finish(ETrue); sl@0: Pause(100); sl@0: }