First public contribution.
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include "wsdynamicresbasic.h"
20 #include <test/extendtef.h>
21 #include "globalsettings.h"
23 #include <w32stdgraphic.h>
24 #include "regionextend.h"
28 #include <graphics/surfaceconfiguration.h>
29 #include "surfaceutility.h"
30 #include <graphics/testscreencapture.h>
32 //verify which base code is available to the test
33 #include <dispchannel.h>
34 #if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER))
35 #define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
39 //#define VISIBLE_PAUSES 1000
40 #define OVERLAPPING_CELL 0 //'m' //0 indicates cells do not overlap
42 * CWsGceTestPlaceSurfExtra implementation
48 CWsDynamicResBasic::CWsDynamicResBasic()
52 CWsDynamicResBasic::~CWsDynamicResBasic()
56 void CWsDynamicResBasic::SetupL()
60 void CWsDynamicResBasic::TearDownL()
65 void CWsDynamicResBasic::TearDownFromDeleteL()
67 MyBase::TearDownFromDeleteL();
71 CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName )
73 //Create the surface manager here, before the test suite creates additional threads
74 if (GCEIsSupportedStatic())
76 TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL());
79 SUB_SUITE_OPT(CWsDynamicResBasic,NULL);
82 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L);
83 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L);
84 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L);
85 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L);
86 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L);
87 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L);
88 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L);
89 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L);
90 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L);
91 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L); //only run on screen 1
92 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L);
93 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L); //only run on screen 0
94 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L);
95 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L); //only run on screen 1
96 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L); //only run with no scaling
97 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L); //only run with anisotropic scaling
98 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L); //only run with integer scaling
99 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L);
101 ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L); //only run on screen 1
104 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L);
105 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L);
106 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L);
107 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L); //dont run with no scaling on screen 0
110 ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L);
111 ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L);
113 //DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling
114 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L);
115 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L); //only run on screen 1 (multiple resolutions)
116 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L);
119 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L);
120 ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L);
125 #define LOG_AND_PANIC_IF_NOT_GCE \
127 if (!GCEIsSupported()) \
129 INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \
130 User::Panic(_L("GCE.Wrong.Mode"),1); \
135 CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs):
136 CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0),
137 iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue)
139 CActiveScheduler::Add(this);
141 CWsDisplayEvent::~CWsDisplayEvent()
146 void CWsDisplayEvent::DoCancel()
148 iWs->EventReadyCancel();
151 void CWsDisplayEvent::Request()
153 iWs->EventReady(&iStatus);
157 void CWsDisplayEvent::RunL()
160 iWs->GetEvent(event);
162 if(iStatus == KErrNone)
166 case EEventScreenDeviceChanged:
168 iReceivedDeviceEventCount++;
172 iReceivedPointerEventCount++;
173 TPointerEvent* ptEvent = event.Pointer();
174 //make 1 pixels distance allowance, as non integer scalling from composition to app may occur
175 //1 pixels allowance because we never scale greater than 2 times
176 if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1
177 && ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1)
179 iPointerPosTestPass = EFalse;
182 case EEventDisplayChanged:
184 iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId;
185 iResListSpinner = event.DisplayChanged()->iResolutionListChangeId;
186 iReceivedEventCount++;
194 User::Leave(iStatus.Int());
199 CEventTimer* CEventTimer::NewL()
201 CEventTimer* self = new (ELeave) CEventTimer;
202 CleanupStack::PushL(self);
204 CleanupStack::Pop(self);
208 void CEventTimer::ConstructL()
210 User::LeaveIfError(iTimer.CreateLocal());
211 CActiveScheduler::Add(this);
214 CEventTimer::CEventTimer() : CActive(EPriorityStandard)
219 CEventTimer::~CEventTimer()
225 void CEventTimer::DoCancel()
228 CActiveScheduler::Stop();
231 void CEventTimer::RunL()
233 CActiveScheduler::Stop();
236 void CEventTimer::Wait(TInt aDelay)
238 iTimer.After(iStatus, aDelay);
240 CActiveScheduler::Start();
243 //Set display state to normal and to the first decent resolution
244 //A failed test could leave it in a bad state
245 void CWsDynamicResBasic::ResetScreens()
248 #ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
249 TInt displayState = ENormalResolution;
250 UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL);
252 MDisplayControl* interface = static_cast<MDisplayControl*>
253 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
254 ASSERT_TRUE(interface);
256 RArray<TInt> appModeIndexList;
257 TInt currMode=iScreenDevice->CurrentScreenMode();
258 iScreenDevice->GetScreenSizeModeList(&appModeIndexList);
259 if (appModeIndexList[0]!=currMode)
261 iScreenDevice->SetAppScreenMode(appModeIndexList[0]);
262 iScreenDevice->SetScreenMode(appModeIndexList[0]);
264 appModeIndexList.Close();
266 TInt resolutions = interface->NumberOfResolutions();
267 ASSERT_TRUE (resolutions > 0);
268 RArray<MDisplayControl::TResolution> resolutionList1;
269 TInt error = interface->GetResolutions(resolutionList1);
270 ASSERT_EQUALS(error,KErrNone);
271 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
272 TDisplayConfiguration config;
274 if (resolutionList1[goodRes].iPixelSize==TSize())
277 ASSERT_TRUE(resolutions>goodRes); //First res was blank, and no more to choose!
279 config.SetResolution(resolutionList1[goodRes].iPixelSize);
280 error=interface->SetConfiguration(config);
281 ASSERT_EQUALS(error,KErrNone);
282 resolutionList1.Close();
286 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0001L
287 @SYMTestCaseDesc WSERV Screen Device GetInterface returns known interface
292 @SYMTestPurpose Basic classic behaviour
294 Call GetInterface with a well known GUID
295 @SYMTestExpectedResults
298 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L()
300 LOG_AND_PANIC_IF_NOT_GCE;
301 MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test"));
303 MDisplayControlBase* interface1 = static_cast<MDisplayControlBase*>
304 (iScreenDevice->GetInterface(MDisplayControlBase::ETypeId));
305 ASSERT_TRUE(interface1);
307 MDisplayControl* interface2 = static_cast<MDisplayControl*>
308 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
309 ASSERT_TRUE(interface2);
311 MDisplayMappingBase* interface3 = static_cast<MDisplayMappingBase*>
312 (iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId));
313 ASSERT_TRUE(interface3);
315 MDisplayMapping* interface4 = static_cast<MDisplayMapping*>
316 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
317 ASSERT_TRUE(interface4);
321 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0002L
322 @SYMTestCaseDesc Basic test for NumberOfResolutions
327 @SYMTestPurpose NumberOfResolutions returns correctly
330 then call NumberOfResolutions.
331 @SYMTestExpectedResults
332 It shouldn't return KErrNotSupported
334 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L()
336 LOG_AND_PANIC_IF_NOT_GCE;
337 MDisplayControl* interface = static_cast<MDisplayControl*>
338 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
339 ASSERT_TRUE(interface);
340 TInt resolutions = interface->NumberOfResolutions();
341 ASSERT_TRUE (resolutions != KErrNotSupported);
345 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0003L
346 @SYMTestCaseDesc Basic test for GetResolutions
351 @SYMTestPurpose Check GetResolutions returns a valid TSize RArray
354 Call NumberOfResolutions
355 Create an array and garbage fill based on amount of resolutions
356 Call GetResolutions on this array
357 Create an array (dont garbage fill)
358 Call GetResolutions on this empty array
359 Create an array with smaller size than required
360 Call GetResolutions on this array
361 Create an array with larger size than required
362 Call GetResolutions on this array
363 @SYMTestExpectedResults
364 For both GetResolutions calls, it should allocate memory if needed, and fill
367 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L()
369 LOG_AND_PANIC_IF_NOT_GCE;
373 MDisplayControl* interface = static_cast<MDisplayControl*>
374 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
375 ASSERT_TRUE(interface);
377 TInt resolutions = interface->NumberOfResolutions();
378 ASSERT_TRUE (resolutions > 0);
380 RArray<MDisplayControl::TResolution> resolutionList1;
381 for (count=0;count<resolutions;count++)
383 resolutionList1.Append(MDisplayControl::TResolution(TSize(),TSize()));
385 error = interface->GetResolutions(resolutionList1);
386 ASSERT_EQUALS(error,KErrNone);
387 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
389 RArray<MDisplayControl::TResolution> resolutionList2;
390 error = interface->GetResolutions(resolutionList2);
391 ASSERT_EQUALS(error,KErrNone);
392 ASSERT_EQUALS(resolutionList2.Count(), resolutions);
394 RArray<MDisplayControl::TResolution> resolutionList3;
395 for (count=0;count<resolutions-1;count++)
397 resolutionList3.Append(MDisplayControl::TResolution(TSize(),TSize()));
399 error = interface->GetResolutions(resolutionList3);
400 ASSERT_EQUALS(error,KErrNone);
401 ASSERT_EQUALS(resolutionList3.Count(), resolutions);
403 RArray<MDisplayControl::TResolution> resolutionList4;
404 for (count=0;count<resolutions+2;count++)
406 resolutionList4.Append(MDisplayControl::TResolution(TSize(),TSize()));
408 error = interface->GetResolutions(resolutionList4);
409 ASSERT_EQUALS(error,KErrNone);
410 ASSERT_EQUALS(resolutionList4.Count(), resolutions);
412 for (count=0;count<resolutions;count++)
414 ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList2[count].iPixelSize);
415 ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList3[count].iPixelSize);
416 ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList4[count].iPixelSize);
418 ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList2[count].iTwipsSize);
419 ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList3[count].iTwipsSize);
420 ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList4[count].iTwipsSize);
422 if (!(resolutionList1[count].iFlags == resolutionList2[count].iFlags))
426 if (!(resolutionList1[count].iFlags == resolutionList3[count].iFlags))
430 if (!(resolutionList1[count].iFlags == resolutionList4[count].iFlags))
435 resolutionList1.Close();
436 resolutionList2.Close();
437 resolutionList3.Close();
438 resolutionList4.Close();
442 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0004L
443 @SYMTestCaseDesc Test for GetConfiguration
448 @SYMTestPurpose Check GetConfiguration returns a configuration object
451 GetConfiguration with standard TDisplayConfiguration
452 GetResolution from the TDisplayConfiguration object
453 GetConfiguration with TDisplayConfiguration object with a greater version/size
454 GetResolution from the TDisplayConfiguration object
455 GetConfiguration with TDisplayConfiguration object with a smaller version/size -- equal to TDisplayConfiguration1
456 GetResolution from the TDisplayConfiguration object
457 Check all the resolutions should be same
458 @SYMTestExpectedResults
461 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0004L()
463 LOG_AND_PANIC_IF_NOT_GCE;
465 MDisplayControl* interface = static_cast<MDisplayControl*>
466 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
467 ASSERT_TRUE(interface);
469 TDisplayConfiguration dispConfig;
470 interface->GetConfiguration(dispConfig);
471 ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution));
474 ASSERT_TRUE(dispConfig.GetResolution(size));
475 ASSERT_TRUE(dispConfig.GetResolutionTwips(twips));
477 TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10);
478 interface->GetConfiguration(dispConfig1);
479 ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution));
482 ASSERT_TRUE(dispConfig1.GetResolution(size1));
483 ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1));
485 TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version());
486 interface->GetConfiguration(dispConfig2);
487 ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution));
490 ASSERT_TRUE(dispConfig2.GetResolution(size2));
491 ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2));
493 ASSERT_EQUALS(size, size1);
494 ASSERT_EQUALS(size, size2);
495 ASSERT_EQUALS(twips, twips1);
496 ASSERT_EQUALS(twips, twips2);
500 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0005L
501 @SYMTestCaseDesc Test getting display change event from event queue
502 @SYMREQ REQ10329 REQ10330
506 @SYMTestPurpose Verify the correct behaviour of display change notification
508 Run through various ways of changing resolution
509 For each, check if event has been received
510 @SYMTestExpectedResults
511 Based on type of change, check event
512 @note Test uses HAL to simulate display disconnection. Not supported on production platforms.
514 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L()
516 LOG_AND_PANIC_IF_NOT_GCE;
518 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
519 ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
521 TInt screenNo = iScreenDevice->GetScreenNumber();
523 MDisplayControl* interface = static_cast<MDisplayControl*>
524 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
525 ASSERT_TRUE(interface);
526 interface->EnableDisplayChangeEvents(ETrue);
527 ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
529 CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
530 CleanupStack::PushL(displayEventAO);
531 displayEventAO->Request();
532 CEventTimer *timer = CEventTimer::NewL();
533 CleanupStack::PushL(timer);
534 TInt dispSpinnerValue = displayEventAO->ResListSpinner();
535 TInt configSpinnerValue = displayEventAO->ConfigSpinner();
538 TInt displayState = EDisconnect;
539 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
542 ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change
543 ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event
544 dispSpinnerValue = displayEventAO->ResListSpinner();
545 configSpinnerValue = displayEventAO->ConfigSpinner();
548 interface->EnableDisplayChangeEvents(ETrue);//enable again
549 ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
550 interface->EnableDisplayChangeEvents(EFalse);//disable
551 ASSERT_FALSE(interface->DisplayChangeEventsEnabled());
552 interface->EnableDisplayChangeEvents(EFalse);//disable again
553 interface->EnableDisplayChangeEvents(ETrue);//enable again
556 TDisplayConfiguration disconnectedConfig;
557 disconnectedConfig.SetResolution(TSize(10,11));
558 disconnectedConfig.SetResolutionTwips(TSize(12,13));
559 disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
560 interface->GetConfiguration(disconnectedConfig);
561 ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution));
562 ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips));
563 ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation));
565 displayState = ENormalResolution;
566 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
568 timer->Wait(1000000);
569 ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise
570 ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event
571 dispSpinnerValue = displayEventAO->ResListSpinner();
572 configSpinnerValue = displayEventAO->ConfigSpinner();
574 TDisplayConfiguration dispConfig, dispConfig2;
575 TSize resolution,resolution2;
576 interface->GetConfiguration(dispConfig2);
577 dispConfig2.GetResolution(resolution2);
578 RArray<MDisplayControl::TResolution> resolutions;
579 TInt err = interface->GetResolutions(resolutions);
580 ASSERT_EQUALS(err, KErrNone);
581 dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize);
582 err = interface->SetConfiguration(dispConfig);
583 ASSERT_EQUALS(err, KErrNone);
584 interface->GetConfiguration(dispConfig);
588 if(!(dispConfig2 == dispConfig))
590 ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled
594 ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue);
596 ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event
597 dispSpinnerValue = displayEventAO->ResListSpinner();
598 configSpinnerValue = displayEventAO->ConfigSpinner();
601 //here we flood the event queue with key events, so the next display change
602 //can't put event and queue and force the retry AO on server side to kick off
603 iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
604 for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++)
607 rawEvent.Set(TRawEvent::EKeyDown,scanCode);
608 iSession.SimulateRawEvent(rawEvent);
609 rawEvent.Set(TRawEvent::EKeyUp,scanCode);
610 iSession.SimulateRawEvent(rawEvent);
614 TInt eventCount1 = displayEventAO->ReceivedEventCount();
615 //we should still receive this
616 displayState = EDisconnect;
617 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
618 //let retry AO retry more times before we try to get it
619 User::After(1000000);
621 timer->Wait(10000000);
622 ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change
623 ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event
625 //This part is doomed as well. Now the received event count includes all the pointer, device and display change event
627 TInt eventCount2 = displayEventAO->ReceivedEventCount();
628 //make sure retry AO is stopped - we only receive 1 display event
629 ASSERT_EQUALS(eventCount1 + 1, eventCount2);
631 displayState = ENormalResolution;
632 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
634 CleanupStack::PopAndDestroy(2, displayEventAO);
638 //Adds the first rotation defined in the TResolution to the display configuration
639 void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution)
641 if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported))
643 aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
645 else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported))
647 aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW);
649 else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported))
651 aConfig.SetRotation(TDisplayConfiguration1::ERotation180);
653 else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported))
655 aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW);
657 ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation));
661 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0006L
662 @SYMTestCaseDesc Set Screen display res
667 @SYMTestPurpose Checking window and layer extents continue working
672 Draw many rectangles that shrink to demonstrate scaling issues
675 @SYMTestExpectedResults
676 Every resolution that is supported by current app mode should successfully be set
677 All rectangles and surface should be visible
678 As the window moves, the rectangles and surface should move with it, keeping visible
680 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L()
682 LOG_AND_PANIC_IF_NOT_GCE;
685 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution"));
687 iTestBack=RBlankWindow(iSession);
688 ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
689 iTestBack.SetRequiredDisplayMode(iDisplayMode);
690 iTestBack.SetColor(TRgb(255,0,0));
691 iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
692 iTestBack.Activate();
693 iTestBack.SetVisible(ETrue);
697 static void Draw(CWindowGc* aGc)
699 aGc->SetPenStyle(aGc->ESolidPen);
700 aGc->SetPenColor(TRgb(255,255,255));
701 aGc->SetBrushColor(TRgb(0,0,0));
710 TSurfaceId surfaceID;
711 TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200),
712 KSurfaceFormat, 200 * KBytesPerPixel));
713 ASSERT_EQUALS(err,KErrNone);
714 TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
715 ASSERT_EQUALS(err,KErrNone);
716 TSurfaceConfiguration surfConf;
717 surfConf.SetSurfaceId(surfaceID);
719 surfConf.SetExtent(TRect(2,84,82,166));
720 iCompare.SetBackgroundSurface(surfConf,EFalse);
722 if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
724 DrawCompare::Draw(gc);
726 iCompare.EndRedraw();
729 iSession.Finish(ETrue);
732 MDisplayControl* interface = static_cast<MDisplayControl*>
733 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
734 ASSERT_TRUE(interface);
736 TInt resolutions = interface->NumberOfResolutions();
737 ASSERT_TRUE (resolutions > 0);
739 RArray<MDisplayControl::TResolution> resolutionList1;
740 error = interface->GetResolutions(resolutionList1);
741 ASSERT_EQUALS(error,KErrNone);
742 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
744 TDisplayConfiguration dispConfigBefore;
745 interface->GetConfiguration(dispConfigBefore);
746 ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
749 //Got a mode to change to!
751 TBool ok=dispConfigBefore.GetResolution(resBefore);
752 ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag
753 TBool foundBeforeRes=EFalse;
754 for (TInt res=0;res<resolutionList1.Count();res++)
756 // if (resolutionList1[res].iPixelSize!=resBefore)
758 if (resolutionList1[res].iPixelSize!=TSize(0,0)) //this test is not about turning the display off
760 TDisplayConfiguration dispConfigReq;
761 dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
762 ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
764 SetRotation(dispConfigReq,resolutionList1[res]); //set rotation to first defined in res list
766 TInt errCode=interface->SetConfiguration(dispConfigReq);
767 //ASSERT_EQUALS(errCode,KErrNone);
768 if (errCode != KErrNone)
770 //Probably current size mode does not support the rotation of the passed in configuration
772 ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy
776 TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint());
777 iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
778 iSession.Finish(ETrue);
780 if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
782 DrawCompare::Draw(gc);
784 iCompare.EndRedraw();
788 UpdateTitleWindowL(s,2);
790 s.AppendNum(resolutionList1[res].iPixelSize.iWidth);
792 s.AppendNum(resolutionList1[res].iPixelSize.iHeight);
793 UpdateTitleWindowL(s,3);
795 iSession.Finish(ETrue);
799 iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
800 iSession.Finish(ETrue);
802 TPoint winpos=iCompare.AbsPosition();
803 TSize winsize=iCompare.Size();
804 // iInfoScreenDevice->ReleaseTwipsCache();
805 RepaintTitleWindowL();
806 for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
808 for (TInt i=0;i<15;i++)
811 iCompare.SetExtent(winpos,winsize);
812 iSession.Finish(ETrue);
815 if (z.iHeight && z.iWidth)
823 TDisplayConfiguration dispConfigAfter;
824 interface->GetConfiguration(dispConfigAfter);
826 TBool ok=dispConfigAfter.GetResolution(resAfter);
828 if (resolutionList1[res].iPixelSize!=resAfter)
830 INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight);
831 INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight);
835 if (resolutionList1[res].iPixelSize==resBefore)
837 foundBeforeRes=ETrue;
840 ASSERT_TRUE(foundBeforeRes);
841 //restore initial res
842 interface->SetConfiguration(dispConfigBefore);
844 TDisplayConfiguration dispConfigAfter;
845 interface->GetConfiguration(dispConfigAfter);
847 ok=dispConfigAfter.GetResolution(resAfter);
849 ASSERT_EQUALS(resBefore,resAfter);
853 INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped."));
855 resolutionList1.Close();
859 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0007L
860 @SYMTestCaseDesc Coordinates Mapping
864 @SYMTestPurpose Basic call to mapcoordinates
867 @SYMTestExpectedResults
868 targetRect should be correctly filled in with same rect as sourceRect
870 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L()
872 MDisplayMapping* interface = static_cast<MDisplayMapping*>
873 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
874 ASSERT_TRUE(interface);
875 TRect sourceRect(10, 10, 30, 50);
876 TRect targetRect(5,5,10,10);
877 TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect);
878 ASSERT_EQUALS(err, KErrNone);
879 ASSERT_EQUALS(sourceRect, targetRect);
883 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0008L
884 @SYMTestCaseDesc SetModes and mapCoordinates
888 @SYMTestPurpose Basic SetSizeMode and complex MapCoordinates function
891 Perform many rect conversions using MapCoordinates
892 @SYMTestExpectedResults
893 Ensure that through multiple conversions, accuracy is not lost
895 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L()
897 LOG_AND_PANIC_IF_NOT_GCE;
900 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode"));
902 iTestBack=RBlankWindow(iSession);
903 ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
904 iTestBack.SetRequiredDisplayMode(iDisplayMode);
905 iTestBack.SetColor(TRgb(255,0,0));
906 iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
907 iTestBack.Activate();
908 iTestBack.SetVisible(ETrue);
909 iSession.Finish(ETrue);
912 if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
914 gc->SetPenStyle(gc->ESolidPen);
915 gc->SetPenColor(TRgb(255,255,255));
916 gc->SetBrushColor(TRgb(0,0,0));
924 iCompare.EndRedraw();
927 iSession.Finish(ETrue);
930 MDisplayControl* interface = static_cast<MDisplayControl*>
931 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
932 ASSERT_TRUE(interface);
934 TInt resolutions = interface->NumberOfResolutions();
935 ASSERT_TRUE (resolutions > 0);
937 RArray<MDisplayControl::TResolution> resolutionList1;
938 error = interface->GetResolutions(resolutionList1);
939 ASSERT_EQUALS(error,KErrNone);
940 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
942 TDisplayConfiguration dispConfigBefore;
943 interface->GetConfiguration(dispConfigBefore);
944 ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
946 RArray<TInt> screenModeList;
947 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
948 ASSERT_TRUE (screenModeList.Count() > 1);
949 iScreenDevice->SetAppScreenMode(screenModeList[1]);
950 iScreenDevice->SetScreenMode(screenModeList[1]);
951 iSession.Finish(ETrue);
954 MDisplayMapping* interfaceM = static_cast<MDisplayMapping*>
955 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
956 TRect appRect(20, 40, 193, 110);
957 TRect uiRect(1,2,3,4);
958 TRect compRect(5,6,7,8);
959 TRect tempRect(10,11,12,13);
963 //quick get for a print
964 err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
965 err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
968 // INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY);
969 // INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY);
970 // INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY);
971 // INFO_PRINTF1(_L(" "));
973 //longer process to insure conversions both ways dont lose accuracy
974 err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
975 err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect);
976 ASSERT_EQUALS(tempRect,appRect);
978 err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
979 err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect);
980 ASSERT_EQUALS(tempRect,appRect);
982 err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
983 err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect);
984 err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect);
985 ASSERT_EQUALS(tempRect,uiRect);
989 if (appRect.IsEmpty())
995 TRect rect1(5,5,10,10);
996 TRect rect2(15,15,20,20);
997 TRect rect3(50,50,50,50);
999 err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2);
1000 err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
1001 ASSERT_EQUALS(rect1,rect2);
1003 err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2);
1004 err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
1005 ASSERT_EQUALS(rect1,rect3);
1007 err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2);
1008 err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3);
1009 ASSERT_EQUALS(rect1,rect3);
1011 err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2);
1012 err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3);
1013 ASSERT_EQUALS(rect1,rect3);
1016 err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2);
1017 ASSERT_EQUALS(rect1,rect2);
1019 err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2);
1020 err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3);
1021 ASSERT_EQUALS(rect1,rect3);
1023 err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2);
1024 err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3);
1025 ASSERT_EQUALS(rect1,rect3);
1028 err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2);
1029 ASSERT_EQUALS(rect1,rect2);
1031 err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2);
1032 err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3);
1033 ASSERT_EQUALS(rect1,rect3);
1036 err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2);
1037 ASSERT_EQUALS(rect1,rect2);
1040 err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2);
1041 ASSERT_EQUALS(err,KErrNotSupported);
1042 err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2);
1043 ASSERT_EQUALS(err,KErrNotSupported);
1044 err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2);
1045 ASSERT_EQUALS(err,KErrNotSupported);
1046 err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2);
1047 ASSERT_EQUALS(err,KErrNotSupported);
1048 err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2);
1049 ASSERT_EQUALS(err,KErrNotSupported);
1051 TDisplayConfiguration dispConfigAfter;
1052 interface->GetConfiguration(dispConfigAfter);
1054 screenModeList.Close();
1055 resolutionList1.Close();
1056 iScreenDevice->SetAppScreenMode(0);
1057 iScreenDevice->SetScreenMode(0);
1061 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0009L
1062 @SYMTestCaseDesc Set Screen display res using app mode
1066 @SYMTestPurpose SetScreenMode functions correctly
1068 Similar to 0006, but setting every available screen mode instead of resolution
1069 @SYMTestExpectedResults
1070 Every set should work, including modes that involve a rotation!
1072 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L()
1074 LOG_AND_PANIC_IF_NOT_GCE;
1077 iSession.Finish(ETrue);
1078 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode"));
1079 iSession.Finish(ETrue);
1081 iTestBack=RBlankWindow(iSession);
1082 ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
1083 iTestBack.SetRequiredDisplayMode(iDisplayMode);
1084 iTestBack.SetColor(TRgb(255,0,0));
1085 iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
1086 iTestBack.Activate();
1087 iTestBack.SetVisible(ETrue);
1088 iSession.Finish(ETrue);
1092 static void Draw(CWindowGc* aGc)
1094 aGc->SetPenStyle(aGc->ESolidPen);
1095 aGc->SetPenColor(TRgb(255,255,255));
1096 aGc->SetBrushColor(TRgb(0,0,0));
1105 TSurfaceId surfaceID;
1106 TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200),
1107 KSurfaceFormat, 200 * KBytesPerPixel));
1108 ASSERT_EQUALS(err,KErrNone);
1109 TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
1110 ASSERT_EQUALS(err,KErrNone);
1111 TSurfaceConfiguration surfConf;
1112 surfConf.SetSurfaceId(surfaceID);
1114 surfConf.SetExtent(TRect(2,84,82,166));
1115 iCompare.SetBackgroundSurface(surfConf,EFalse);
1117 if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
1119 DrawCompare::Draw(gc);
1121 iCompare.EndRedraw();
1124 iSession.Finish(ETrue);
1126 RArray<TInt> screenModeList;
1127 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
1128 MDisplayControl* interface = static_cast<MDisplayControl*>
1129 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
1130 ASSERT_TRUE(interface);
1132 TInt resolutions = interface->NumberOfResolutions();
1133 ASSERT_TRUE (resolutions > 0);
1135 RArray<MDisplayControl::TResolution> resolutionList1;
1136 error = interface->GetResolutions(resolutionList1);
1137 ASSERT_EQUALS(error,KErrNone);
1138 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
1140 TDisplayConfiguration dispConfigBefore;
1141 interface->GetConfiguration(dispConfigBefore);
1142 ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
1143 if (screenModeList.Count()>1)
1145 //Got a mode to change to!
1147 TBool ok=dispConfigBefore.GetResolution(resBefore);
1148 ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag
1149 for (TInt res=0;res<screenModeList.Count();res++)
1153 TDisplayConfiguration dispConfigReq;
1154 iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
1155 iInfoScreenDevice->SetScreenMode(screenModeList[res]);
1156 iSession.Finish(ETrue);
1159 TPixelsAndRotation pr;
1160 iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
1161 TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
1164 if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
1166 DrawCompare::Draw(gc);
1168 iCompare.EndRedraw();
1170 if (iTitle.WsHandle())
1174 infoWinPos=iTitle.AbsPosition();
1175 infoWinSize=iTitle.Size();
1176 infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
1177 iTitle.SetSize(infoWinSize);
1181 UpdateTitleWindowL(s,1);
1183 s.AppendNum(pr.iPixelSize.iWidth);
1185 s.AppendNum(pr.iPixelSize.iHeight);
1186 UpdateTitleWindowL(s,2);
1188 s.AppendNum(origin.iX);
1190 s.AppendNum(origin.iY);
1191 UpdateTitleWindowL(s,3);
1193 iSession.Finish(ETrue);
1196 TPoint winpos=iCompare.AbsPosition();
1197 TSize winsize=iCompare.Size();
1199 for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
1201 for (TInt i=0;i<15;i++)
1204 iCompare.SetExtent(winpos,winsize);
1205 iSession.Finish(ETrue);
1208 if (z.iHeight && z.iWidth)
1219 //restore initial res
1220 if (screenModeList.Count() > 1)
1221 { //set back to basics
1222 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
1223 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
1227 interface->SetConfiguration(dispConfigBefore);
1229 TDisplayConfiguration dispConfigAfter;
1230 interface->GetConfiguration(dispConfigAfter);
1232 ok=dispConfigAfter.GetResolution(resAfter);
1234 ASSERT_EQUALS(resBefore,resAfter);
1238 INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
1241 screenModeList.Close();
1242 resolutionList1.Close();
1246 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0010L
1247 @SYMTestCaseDesc Test app mode setting during attach/detach
1251 @SYMTestPurpose Make sure display resumes last app mode when reattached
1253 Save app mode and display configuration before detach and compare it with those after reattach.
1254 Repeat for a second app mode
1255 If available, repeat with dynamic app mode
1256 @SYMTestExpectedResults
1257 For normal app mode, on reconnect it should re apply the old configuration
1258 For dynamic app mode, on reconnect it should be 0x0
1260 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L()
1262 LOG_AND_PANIC_IF_NOT_GCE;
1264 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
1265 ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
1268 iSession.Finish(ETrue);
1269 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach"));
1270 iSession.Finish(ETrue);
1273 TInt screenNo = iScreenDevice->GetScreenNumber();
1274 RArray<TInt> screenModeList;
1275 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
1277 //Find 2 real app modes and 1 dynamic app mode
1278 TInt firstAvailableAppMode = -1;
1279 TInt secondAvailableAppMode = -1;
1280 TInt dynamicAppMode = -1;
1281 for (TInt ii = 0; ii < screenModeList.Count(); ii++)
1283 TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]);
1284 if (dynamic && dynamicAppMode == -1)
1286 dynamicAppMode = screenModeList[ii];
1290 if (firstAvailableAppMode == -1)
1292 firstAvailableAppMode = screenModeList[ii];
1294 else if (secondAvailableAppMode == -1)
1296 secondAvailableAppMode = screenModeList[ii];
1300 ASSERT_TRUE(firstAvailableAppMode!=-1);
1301 ASSERT_TRUE(secondAvailableAppMode!=-1);
1303 MDisplayControl* interface = static_cast<MDisplayControl*>
1304 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
1305 ASSERT_TRUE(interface);
1307 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
1308 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
1309 ASSERT_TRUE(mappingInterface);
1311 TInt resolutions = interface->NumberOfResolutions();
1312 ASSERT_TRUE (resolutions > 0);
1314 RArray<MDisplayControl::TResolution> resolutionList1;
1315 error = interface->GetResolutions(resolutionList1);
1316 ASSERT_EQUALS(error,KErrNone);
1317 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
1319 TDisplayConfiguration configBeforeDetach, configAfterReattach;
1320 TInt appModeBeforeDetach, appModeAfterReattach;
1323 //1st detach - attach sequence
1324 appModeBeforeDetach = firstAvailableAppMode;
1325 iScreenDevice->SetAppScreenMode(appModeBeforeDetach );
1326 iScreenDevice->SetScreenMode(appModeBeforeDetach );
1328 interface->GetConfiguration(configBeforeDetach);
1330 TInt displayState = EDisconnect;
1331 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1334 //dummy mapping should return KErrNotReady if display is disconnected
1335 TRect dummyRect(1,2,5,8);
1336 error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
1337 ASSERT_EQUALS(error, KErrNotReady);
1339 displayState = ENormalResolution;
1340 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1343 interface->GetConfiguration(configAfterReattach);
1344 ASSERT_TRUE(configBeforeDetach==configAfterReattach);
1345 appModeAfterReattach = iScreenDevice->CurrentScreenMode();
1346 ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
1347 //1st detach - attach sequence ends here
1350 configBeforeDetach.ClearAll();
1351 configAfterReattach.ClearAll();
1354 //2nd detach-attach sequence - non dynamic app mode
1355 iScreenDevice->SetAppScreenMode(secondAvailableAppMode);
1356 iScreenDevice->SetScreenMode(secondAvailableAppMode);
1358 appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
1359 interface->GetConfiguration(configBeforeDetach);
1360 displayState = EDisconnect;
1361 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1363 //dummy mapping should return KErrNotReady if display is disconnected
1364 error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
1365 ASSERT_EQUALS(error, KErrNotReady);
1367 displayState = ENoResolution;
1368 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1370 //dummy mapping should return KErrNotReady if display is disconnected
1371 error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
1372 ASSERT_EQUALS(error, KErrNotReady);
1374 displayState = ENormalResolution;
1375 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1378 interface->GetConfiguration(configAfterReattach);
1379 ASSERT_TRUE(configBeforeDetach==configAfterReattach);
1380 appModeAfterReattach = iScreenDevice->CurrentScreenMode();
1381 ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
1382 //2nd detach-attach sequence ends here
1385 configBeforeDetach.ClearAll();
1386 configAfterReattach.ClearAll();
1389 //3rd detach-attach sequence - dynamic app mode
1390 if (dynamicAppMode == -1)
1392 screenModeList.Close();
1393 resolutionList1.Close();
1394 INFO_PRINTF1(_L("No dynamic app mode, end test")); //not a fail if there isn't a dynamic app mode
1398 iScreenDevice->SetAppScreenMode(dynamicAppMode);
1399 iScreenDevice->SetScreenMode(dynamicAppMode);
1401 appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
1402 interface->GetConfiguration(configBeforeDetach);
1403 displayState = EDisconnect;
1404 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1406 //dummy mapping should return KErrNotReady if display is disconnected
1407 error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
1408 ASSERT_EQUALS(error, KErrNotReady);
1410 displayState = ENoResolution;
1411 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1413 //dummy mapping should return KErrNotReady if display is disconnected
1414 error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
1415 ASSERT_EQUALS(error, KErrNotReady);
1417 displayState = ENormalResolution;
1418 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
1421 interface->GetConfiguration(configAfterReattach);
1422 ASSERT_FALSE(configBeforeDetach==configAfterReattach);
1423 TSize afterReattachSize;
1424 ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize));
1425 ASSERT_EQUALS(afterReattachSize,TSize(0,0));
1426 ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize));
1427 ASSERT_EQUALS(afterReattachSize,TSize(0,0));
1429 appModeAfterReattach = iScreenDevice->CurrentScreenMode();
1430 ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
1431 //3rd detach-attach sequence ends here
1434 screenModeList.Close();
1435 resolutionList1.Close();
1440 CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard)
1443 CDSATestDrawing::~CDSATestDrawing()
1447 CDSATestDrawing* CDSATestDrawing::NewL()
1449 CDSATestDrawing *self = new(ELeave) CDSATestDrawing();
1450 CleanupStack::PushL(self);
1452 CleanupStack::Pop(self);
1456 void CDSATestDrawing::ConstructL()
1458 CTimer::ConstructL();
1459 CActiveScheduler::Add(this);
1462 void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA)
1474 iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size());
1477 iWin->BeginRedraw();
1478 CFbsBitGc* gc = iDSA->Gc();
1479 gc->SetBrushColor(TRgb(220,220,220));
1480 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1488 void CDSATestDrawing::RunL()
1494 void CDSATestDrawing::Draw()
1496 //Should not invalidate the window containing DSA drawing. That's the whole point!
1497 CFbsBitGc* gc = iDSA->Gc();
1498 gc->SetPenStyle(gc->ESolidPen);
1499 gc->SetPenColor(TRgb(255,0,0));
1500 gc->SetBrushStyle(gc->ENullBrush);
1502 gc->DrawRect(iRect);
1503 iDSA->ScreenDevice()->Update();
1506 void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
1509 StartDrawingL(NULL);
1512 void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
1518 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0011L
1519 @SYMTestCaseDesc Test DSA drawing in different App Mode
1520 @SYMREQ REQ10332 REQ10336
1523 @SYMTestPurpose Test DSA can restart and draw at correct place when screen mode changes
1525 A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing
1526 time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside
1527 the new drawing region.
1529 note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in
1530 @SYMTestExpectedResults
1531 All tests should pass.
1534 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L()
1536 LOG_AND_PANIC_IF_NOT_GCE;
1540 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing"));
1541 CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL();
1542 CleanupStack::PushL(dsaDraw);
1543 CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw);
1544 CleanupStack::PushL(dsa);
1545 dsaDraw->SetWindow(iCompare);
1546 dsaDraw->StartDrawingL(dsa);
1548 CEventTimer *timer = CEventTimer::NewL();
1549 CleanupStack::PushL(timer);
1551 RArray<TInt> screenModeList;
1552 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
1553 MDisplayControl* interface = static_cast<MDisplayControl*>
1554 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
1555 ASSERT_TRUE(interface);
1557 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
1558 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
1559 ASSERT_TRUE(mappingInterface);
1561 CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode());
1562 CleanupStack::PushL(pixelReadBackDevice);
1564 for (TInt res=0;res<screenModeList.Count();res++)
1566 iScreenDevice->SetAppScreenMode(screenModeList[res]);
1567 iScreenDevice->SetScreenMode(screenModeList[res]);
1568 dsa->ScreenDevice()->Update();
1570 //wait for DSA to restart
1571 timer->Wait(500000);
1572 TRect regionRect(dsa->DrawingRegion()->BoundingRect());
1574 TPoint winpos = iCompare.AbsPosition();
1575 TSize winsize = iCompare.Size();
1577 TPixelsAndRotation pr;
1578 iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
1579 TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
1581 if (iTitle.WsHandle())
1585 infoWinPos=iTitle.AbsPosition();
1586 infoWinSize=iTitle.Size();
1587 infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
1588 iTitle.SetSize(infoWinSize);
1592 UpdateTitleWindowL(s,1);
1594 s.AppendNum(pr.iPixelSize.iWidth);
1596 s.AppendNum(pr.iPixelSize.iHeight);
1597 UpdateTitleWindowL(s,2);
1599 s.AppendNum(origin.iX);
1601 s.AppendNum(origin.iY);
1602 UpdateTitleWindowL(s,3);
1604 INFO_PRINTF2(_L("---------test %i---------"), res);
1605 INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight);
1606 INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY);
1607 //INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY);
1608 INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX,
1609 dsa->DrawingRegion()->BoundingRect().iTl.iY);
1610 INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(),
1611 dsa->DrawingRegion()->BoundingRect().Height());
1612 //give time so DSA AO can start drawing
1613 timer->Wait(5000000);
1617 mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect);
1618 pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl);
1619 pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation));
1620 readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr);
1622 if(readBackRect.IsEmpty())
1624 INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour"));
1628 //Ruo: Oh I almost believe iBr is exclusive now
1629 TDisplayConfiguration dispConfigAfter2;
1630 interface->GetConfiguration(dispConfigAfter2);
1632 dispConfigAfter2.GetResolution(theSize);
1633 TDisplayConfiguration1::TRotation orient;
1634 dispConfigAfter2.GetRotation(orient);
1635 if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
1637 TInt temp = theSize.iHeight;
1638 theSize.iHeight = theSize.iWidth;
1639 theSize.iWidth = temp;
1641 TRect uiSize(TPoint(0,0), theSize);
1642 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
1643 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
1644 ASSERT_TRUE(mappingInterface);
1646 mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
1648 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
1649 CleanupStack::PushL(bmp2);
1650 User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
1653 static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
1657 TInt errr = csc->ComposeScreen(*bmp2);
1658 ASSERT_TRUE(errr == KErrNone);
1665 _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
1666 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
1670 readBackRect.iBr = readBackRect.iBr - TPoint(1,1);
1671 //check 4 outter corners
1673 TRgb cornerRgb(220, 220, 220);
1674 TRgb innerRgb(255, 0, 0);
1675 readBackRect.Grow(1, 1);
1676 TRect compSpaceReadBackRect;
1677 mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
1682 if (finalSize.Contains(compSpaceReadBackRect.iTl))
1684 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
1685 if(!(pixelRgb != cornerRgb))
1687 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1689 x.Format(KCompareFailed, res+1);
1690 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1691 CleanupStack::PopAndDestroy(bmp2);
1695 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
1697 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
1698 if(!(pixelRgb != cornerRgb))
1700 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1702 x.Format(KCompareFailed, res+1);
1703 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1704 CleanupStack::PopAndDestroy(bmp2);
1708 if (finalSize.Contains(compSpaceReadBackRect.iBr))
1710 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
1711 if(!(pixelRgb != cornerRgb))
1713 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1715 x.Format(KCompareFailed, res+1);
1716 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1717 CleanupStack::PopAndDestroy(bmp2);
1721 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
1723 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
1724 if(!(pixelRgb != cornerRgb))
1726 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1728 x.Format(KCompareFailed, res+1);
1729 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1730 CleanupStack::PopAndDestroy(bmp2);
1736 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
1737 ASSERT_TRUE(pixelRgb != cornerRgb);
1738 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
1739 ASSERT_TRUE(pixelRgb != cornerRgb);
1740 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
1741 ASSERT_TRUE(pixelRgb != cornerRgb);
1742 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
1743 ASSERT_TRUE(pixelRgb != cornerRgb);
1745 //check 4 inner corners
1746 readBackRect.Shrink(1,1);
1747 mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
1751 if (finalSize.Contains(compSpaceReadBackRect.iTl))
1753 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
1754 if(!(pixelRgb == cornerRgb))
1756 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1758 x.Format(KCompareFailed, res+1);
1759 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1760 CleanupStack::PopAndDestroy(bmp2);
1764 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
1766 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
1767 if(!(pixelRgb == cornerRgb))
1769 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1771 x.Format(KCompareFailed, res+1);
1772 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1773 CleanupStack::PopAndDestroy(bmp2);
1777 if (finalSize.Contains(compSpaceReadBackRect.iBr))
1779 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
1780 if(!(pixelRgb == cornerRgb))
1782 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1784 x.Format(KCompareFailed, res+1);
1785 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1786 CleanupStack::PopAndDestroy(bmp2);
1790 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
1792 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
1793 if(!(pixelRgb == cornerRgb))
1795 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1797 x.Format(KCompareFailed, res+1);
1798 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1799 CleanupStack::PopAndDestroy(bmp2);
1805 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
1806 ASSERT_TRUE(pixelRgb == cornerRgb);
1807 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
1808 ASSERT_TRUE(pixelRgb == cornerRgb);
1809 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
1810 ASSERT_TRUE(pixelRgb == cornerRgb);
1811 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
1812 ASSERT_TRUE(pixelRgb == cornerRgb);
1813 //check inner colour
1814 if(readBackRect.Width() < 3 || readBackRect.Height() < 3)
1816 INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour"));
1817 CleanupStack::PopAndDestroy(bmp2);
1821 readBackRect.Shrink(1,1);
1822 mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
1826 if (finalSize.Contains(compSpaceReadBackRect.iTl))
1828 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
1829 if(!(pixelRgb == innerRgb))
1831 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1833 x.Format(KCompareFailed, res+1);
1834 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1835 CleanupStack::PopAndDestroy(bmp2);
1839 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
1841 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
1842 if(!(pixelRgb == innerRgb))
1844 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1846 x.Format(KCompareFailed, res+1);
1847 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1848 CleanupStack::PopAndDestroy(bmp2);
1852 if (finalSize.Contains(compSpaceReadBackRect.iBr))
1854 bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
1855 if(!(pixelRgb == innerRgb))
1857 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1859 x.Format(KCompareFailed, res+1);
1860 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1861 CleanupStack::PopAndDestroy(bmp2);
1865 if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
1867 bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
1868 if(!(pixelRgb == innerRgb))
1870 _LIT(KCompareFailed, "Corner check failed on app mode: %d");
1872 x.Format(KCompareFailed, res+1);
1873 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
1874 CleanupStack::PopAndDestroy(bmp2);
1880 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
1881 ASSERT_TRUE(pixelRgb == innerRgb);
1882 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
1883 ASSERT_TRUE(pixelRgb == innerRgb);
1884 pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
1885 ASSERT_TRUE(pixelRgb == innerRgb);
1886 pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
1887 ASSERT_TRUE(pixelRgb == innerRgb);
1889 CleanupStack::PopAndDestroy(bmp2);
1891 screenModeList.Close();
1892 CleanupStack::PopAndDestroy(4, dsaDraw);
1896 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0012L
1897 @SYMTestCaseDesc Test Pointer event coordinates are correct in different screen modes.
1902 @SYMTestPurpose Test Pointer event coordinates are correct in different screen mode
1904 In each screen mode, the simulated pointer event should always at the same relative position
1905 inside iCompare window
1906 @SYMTestExpectedResults
1907 All test should pass
1908 **NOTE Can only be tested in screen 0 **
1910 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L()
1912 LOG_AND_PANIC_IF_NOT_GCE;
1914 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates"));
1917 CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
1918 CleanupStack::PushL(displayEventAO);
1919 displayEventAO->Request();
1920 CEventTimer *timer = CEventTimer::NewL();
1921 CleanupStack::PushL(timer);
1923 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
1924 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
1925 ASSERT_TRUE(mappingInterface);
1927 RArray<TInt> screenModeList;
1928 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
1929 iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
1931 for (TInt res=0;res<screenModeList.Count();res++)
1933 iScreenDevice->SetAppScreenMode(screenModeList[res]);
1934 iScreenDevice->SetScreenMode(screenModeList[res]);
1937 //win position in app space
1938 TPoint winPos = iCompare.AbsPosition();
1939 TSize winSize = iCompare.Size();
1941 //pointer event at the origin of window
1942 TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1));
1943 //the expected pointer position received by client to compare with the actual point received.
1944 //it's (1,1) because it's relative to window
1945 displayEventAO->SetExpectedPointPos(TPoint(1, 1));
1946 TRect rectInComp, rectBackInApp;
1947 mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp);
1948 //as we got the physical coordinates at where we simulate pointer event
1950 rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
1951 iSession.SimulateRawEvent(rawEvent);
1952 rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
1953 iSession.SimulateRawEvent(rawEvent);
1957 ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2);
1958 ASSERT_TRUE(displayEventAO->PointerTestPassed());
1960 //pointer event at 1/2 width and height inside the window
1961 TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1));
1962 displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos);
1963 mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp);
1964 //as we got the physical coordinates at where we simulate pointer event
1965 rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
1966 iSession.SimulateRawEvent(rawEvent);
1967 rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
1968 iSession.SimulateRawEvent(rawEvent);
1972 ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4);
1973 ASSERT_TRUE(displayEventAO->PointerTestPassed());
1975 screenModeList.Close();
1976 CleanupStack::PopAndDestroy(2, displayEventAO);
1980 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0013L
1981 @SYMTestCaseDesc Test the twips size after detach
1985 @SYMTestPurpose Make sure the twips size is undefined after detach.
1987 Save display configuration before detach and compare it with the display configuration after detach.
1988 @SYMTestExpectedResults
1989 all tests should pass
1991 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L()
1993 LOG_AND_PANIC_IF_NOT_GCE;
1995 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
1996 ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
1999 iSession.Finish(ETrue);
2000 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size"));
2001 iSession.Finish(ETrue);
2004 TInt screenNo = iScreenDevice->GetScreenNumber();
2005 RArray<TInt> screenModeList;
2006 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2007 MDisplayControl* interface = static_cast<MDisplayControl*>
2008 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2009 ASSERT_TRUE(interface);
2011 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
2012 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
2013 ASSERT_TRUE(mappingInterface);
2015 TInt resolutions = interface->NumberOfResolutions();
2016 ASSERT_TRUE (resolutions > 0);
2018 RArray<MDisplayControl::TResolution> resolutionList1;
2019 error = interface->GetResolutions(resolutionList1);
2020 ASSERT_EQUALS(error,KErrNone);
2021 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2023 TDisplayConfiguration configBeforeDetach;
2025 // detach the display
2026 interface->GetConfiguration(configBeforeDetach);
2027 TInt displayState = EDisconnect;
2028 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
2031 // retrieve the display configuration
2032 interface->GetConfiguration(configBeforeDetach);
2033 ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips));
2035 error = interface->GetResolutions(resolutionList1);
2036 ASSERT_EQUALS(error,KErrDisconnected);
2038 configBeforeDetach.ClearAll();
2040 screenModeList.Close();
2041 resolutionList1.Close();
2043 displayState = ENormalResolution;
2044 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
2049 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0014L
2050 @SYMTestCaseDesc Test GetConfiguration immediatly after SetConfiguration
2054 @SYMTestPurpose Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size
2056 successive SetConfiguration/GetConfiguration pair
2057 @SYMTestExpectedResults
2058 all tests should pass
2060 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L()
2062 MDisplayControl* interface = static_cast<MDisplayControl*>
2063 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2064 ASSERT_TRUE(interface);
2066 RArray<MDisplayControl::TResolution> resolutions;
2067 TInt err = interface->GetResolutions(resolutions);
2068 ASSERT_EQUALS(err, KErrNone);
2069 TDisplayConfiguration configSet, configGet;
2070 TSize twipsGet, resolutionGet;
2072 TInt screenNo = iScreenDevice->GetScreenNumber();
2073 iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
2074 for(TInt testIndex = 0; testIndex < 2; testIndex++)
2076 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
2077 INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
2080 displayState = ENormalResolution;
2081 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
2083 for (TInt i=0;i<resolutions.Count();i++)
2085 INFO_PRINTF2(_L("i = %i"), i);
2086 INFO_PRINTF3(_L("resolutions: %i x %i"), resolutions[i].iPixelSize.iWidth, resolutions[i].iPixelSize.iHeight);
2087 INFO_PRINTF3(_L("twips: %i x %i"), resolutions[i].iTwipsSize.iWidth, resolutions[i].iTwipsSize.iHeight);
2088 configSet.ClearAll();
2089 configGet.ClearAll();
2090 configSet.SetResolution(resolutions[i].iPixelSize);
2091 err = interface->SetConfiguration(configSet);
2094 //with scaling, KErrArgument means current config is not compatible with appmode.
2095 //In none scaling, it does mean an error,
2096 //but the purpose of this test is to see if twips size is buffered so we can read it back instantly
2097 //let other tests test the functionality of SetConfiguration.
2098 ASSERT_EQUALS(err, KErrArgument);
2100 INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip"));
2103 interface->GetConfiguration(configGet);
2104 ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
2105 ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution));
2106 configGet.GetResolutionTwips(twipsGet);
2107 configGet.GetResolution(resolutionGet);
2108 INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight);
2109 INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight);
2110 ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize);
2113 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
2114 INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
2116 displayState = EDisconnect;
2117 UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
2120 resolutions.Close();
2125 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0015L
2126 @SYMTestCaseDesc No Scaling doesnt return virtual resolutions
2131 @SYMTestPurpose no scaling should mean basic resolution selection
2134 Should not contain virtual resolutions
2136 Should not change resolution
2137 @SYMTestExpectedResults
2138 All test should pass
2139 **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
2141 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L()
2142 { //ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources
2143 MDisplayControl* interface = static_cast<MDisplayControl*>
2144 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2145 ASSERT_TRUE(interface);
2147 TInt resolutions = interface->NumberOfResolutions();
2148 TInt screenNumber = iScreenDevice->GetScreenNumber();
2149 if (screenNumber == 0)
2151 ASSERT_EQUALS(resolutions,1);
2153 else if (screenNumber == 1)
2155 ASSERT_EQUALS(resolutions,4);
2158 RArray<MDisplayControl::TResolution> resolutionList1;
2159 TInt error = interface->GetResolutions(resolutionList1);
2160 ASSERT_EQUALS(error,KErrNone);
2161 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2163 RArray<TInt> screenModeList;
2164 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2166 TDisplayConfiguration dispConfig1;
2167 interface->GetConfiguration(dispConfig1);
2169 ASSERT_TRUE(dispConfig1.GetResolution(size1));
2171 for (TInt ii = 0; ii < screenModeList.Count(); ii++)
2173 iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]);
2174 iInfoScreenDevice->SetScreenMode(screenModeList[ii]);
2175 iSession.Finish(ETrue);
2178 TDisplayConfiguration newConfig;
2179 interface->GetConfiguration(newConfig);
2181 ASSERT_TRUE(dispConfig1.GetResolution(newSize));
2182 ASSERT_EQUALS(size1,newSize);
2184 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
2185 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
2186 iSession.Finish(ETrue);
2189 screenModeList.Close();
2190 resolutionList1.Close();
2194 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0016L
2195 @SYMTestCaseDesc Anisotropic scaling
2200 @SYMTestPurpose Check using twips will cause virtual resolutions to possibly be different
2202 Check the virtual resolution for XXX is correctly XXX
2203 Check when setting the appmode, it choses the correct resolution
2204 @SYMTestExpectedResults
2206 **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
2208 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L()
2209 { //ONLY RUN WITH ANISOTROPIC WSINI.INI
2214 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0017L
2215 @SYMTestCaseDesc Integer scales correctly in policy
2220 @SYMTestPurpose Integer scaling should not create resolutions of non integer value!
2222 For every virtual resolution
2223 Check its an integer size of a real resolution
2224 @SYMTestExpectedResults
2225 All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy)
2226 **NOTE ONLY RUN WITH INTEGER WSINI.INI**
2228 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L()
2229 { //ONLY RUN WITH INTEGER WSINI.INI
2230 MDisplayControl* interface = static_cast<MDisplayControl*>
2231 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2232 ASSERT_TRUE(interface);
2234 TInt resolutions = interface->NumberOfResolutions();
2235 ASSERT_TRUE(resolutions>1);
2237 RArray<MDisplayControl::TResolution> resolutionList1;
2238 TInt error = interface->GetResolutions(resolutionList1);
2239 ASSERT_EQUALS(error,KErrNone);
2240 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2243 for (index=0;index<resolutions;index++)
2245 if (resolutionList1[index].iFlags.IsSet(MDisplayControlBase::TResolution::EIsVirtual))
2247 TBool foundMatch = EFalse;
2248 for (TInt index2=0;index2<resolutions;index2++)
2250 if (resolutionList1[index2].iFlags.IsClear(MDisplayControlBase::TResolution::EIsVirtual))
2252 for (TInt scale=1;scale<=4;scale++)
2255 compare.iWidth=resolutionList1[index].iPixelSize.iWidth/scale;
2256 compare.iHeight=resolutionList1[index].iPixelSize.iHeight/scale;
2257 if (resolutionList1[index2].iPixelSize == compare)
2269 ASSERT_TRUE(foundMatch);
2272 resolutionList1.Close();
2276 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0018L
2277 @SYMTestCaseDesc MDisplayMapping interface function test
2282 @SYMTestPurpose All the MDisplayMapping interface functions are consistent
2284 Check different mapping functions are consistent
2285 @SYMTestExpectedResults
2286 All test should pass
2288 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0018L()
2291 LOG_AND_PANIC_IF_NOT_GCE;
2294 iSession.Finish(ETrue);
2295 MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0020L"),_L("Mapping function consistency"));
2296 iSession.Finish(ETrue);
2298 MDisplayControl* interface = static_cast<MDisplayControl*>
2299 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2300 ASSERT_TRUE(interface);
2302 MDisplayMapping* mapInterface = static_cast<MDisplayMapping*>
2303 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
2304 ASSERT_TRUE(mapInterface);
2306 RArray<TInt> screenModeList;
2307 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2309 TRect maxWinExtent, refMaxWinExtent;
2310 TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips;
2311 TRect displayWinExtent, refDisplayWinExtent;
2312 for (TInt i = 0; i < screenModeList.Count(); i++)
2314 iInfoScreenDevice->SetAppScreenMode(screenModeList[i]);
2315 iInfoScreenDevice->SetScreenMode(screenModeList[i]);
2316 iSession.Finish(ETrue);
2319 INFO_PRINTF1(_L("---------------"));
2320 INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]);
2322 mapInterface->GetMaximumWindowExtent(maxWinExtent);
2323 INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY);
2324 INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height());
2327 TDisplayConfiguration config;
2328 interface->GetConfiguration(config);
2329 ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution));
2331 config.GetResolution(fullUiSize);
2332 error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent);
2333 ASSERT_EQUALS(error, KErrNone);
2334 INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY);
2335 INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height());
2336 ASSERT_EQUALS(maxWinExtent, refMaxWinExtent);
2337 INFO_PRINTF1(_L("Match"));
2339 mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips);
2340 INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight);
2341 INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight);
2342 TRect compositionRect;
2343 error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect);
2344 ASSERT_EQUALS(error, KErrNone);
2345 refSurfaceSize = compositionRect.Size();
2346 INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight);
2347 ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
2348 config.GetResolutionTwips(refSurfaceTwips);
2349 INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight);
2350 ASSERT_EQUALS(surfaceSize, refSurfaceSize);
2351 ASSERT_EQUALS(surfaceTwips, refSurfaceTwips);
2352 INFO_PRINTF1(_L("Match"));
2354 mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent);
2355 INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY);
2356 INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height());
2357 error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent);
2358 ASSERT_EQUALS(error, KErrNone);
2359 INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY);
2360 INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height());
2361 ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent);
2362 INFO_PRINTF1(_L("Match"));
2364 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
2365 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
2366 screenModeList.Close();
2370 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0021L
2371 @SYMTestCaseDesc SetResolution negative test
2376 @SYMTestPurpose Invalid configurations should return error and change nothing!
2378 Set config with rubbish resolution
2379 Set config with rubbish twips
2380 Set config with valid resolution, rubbish twips
2381 Set config with valid twips, rubbish resolution
2382 Set config with nothing defined
2383 @SYMTestExpectedResults
2384 Should all fail safely and not change any settings.
2385 Config with nothing defined in a scaled mode will reset the resolution to current modes
2386 equivilent virtual resolution
2387 **NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available**
2389 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode)
2390 { //aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic
2391 MDisplayControl* interface = static_cast<MDisplayControl*>
2392 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2393 ASSERT_TRUE(interface);
2395 TInt resolutions = interface->NumberOfResolutions();
2396 ASSERT_TRUE (resolutions > 1);
2398 RArray<MDisplayControl::TResolution> resolutionList1;
2399 TInt error = interface->GetResolutions(resolutionList1);
2400 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2402 TDisplayConfiguration original;
2403 original.SetResolution(resolutionList1[0].iPixelSize);
2404 error = interface->SetConfiguration(original);
2405 ASSERT_EQUALS(error,KErrNone);
2407 TDisplayConfiguration beforeConfig;
2408 TDisplayConfiguration afterConfig;
2409 interface->GetConfiguration(beforeConfig);
2412 for (differentRes = 1; differentRes < resolutions; differentRes++)
2414 if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize))
2419 ASSERT_TRUE(differentRes < resolutions); //otherwise it didnt find a resolution different to the one set
2421 TDisplayConfiguration test1;
2422 test1.SetResolution(TSize(5,6)); //rubbish resolution!
2423 error = interface->SetConfiguration(test1);
2425 ASSERT_EQUALS(error,KErrArgument);
2427 ASSERT_EQUALS(error,KErrArgument);
2429 interface->GetConfiguration(afterConfig);
2430 ASSERT_TRUE(beforeConfig == afterConfig);
2432 TDisplayConfiguration test2;
2433 test2.SetResolutionTwips(TSize(7,8)); //rubbish twips!
2434 error = interface->SetConfiguration(test2);
2435 ASSERT_EQUALS(error,KErrArgument);
2437 interface->GetConfiguration(afterConfig);
2438 ASSERT_TRUE(beforeConfig == afterConfig);
2440 TDisplayConfiguration test3;
2441 test3.SetResolution(resolutionList1[differentRes].iPixelSize); //ok resolution!
2442 test3.SetResolutionTwips(TSize(9,10)); //rubbish twips!
2443 error = interface->SetConfiguration(test3);
2444 //ASSERT_EQUALS(error,KErrArgument);
2445 if (error != KErrArgument)
2447 ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with confing not being validated
2448 INFO_PRINTF1(_L("config was not honoured!"));
2449 error = interface->SetConfiguration(original);
2450 ASSERT_EQUALS(error,KErrNone);
2458 interface->GetConfiguration(afterConfig);
2459 ASSERT_TRUE(beforeConfig == afterConfig);
2462 TDisplayConfiguration test4;
2463 test4.SetResolution(TSize(11,12)); //rubbish resolution!
2464 test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize); //ok twips!
2465 error = interface->SetConfiguration(test4);
2466 if (error != KErrArgument)
2468 ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with config not being validated
2469 INFO_PRINTF1(_L("config was not honoured!"));
2470 error = interface->SetConfiguration(original);
2471 ASSERT_EQUALS(error,KErrNone);
2479 interface->GetConfiguration(afterConfig);
2480 ASSERT_TRUE(beforeConfig == afterConfig);
2485 RArray<TInt> screenModeList;
2486 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2487 ASSERT_TRUE(screenModeList.Count()>1);
2488 //set default screen mode, sets resolution to best fit for this mode
2489 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
2490 iInfoScreenDevice->SetScreenMode(screenModeList[0]); //also sets its best resolution
2491 iSession.Finish(ETrue);
2494 TDisplayConfiguration newModeConfig;
2495 interface->GetConfiguration(newModeConfig);
2496 //get best fit resolution
2498 ASSERT_TRUE(newModeConfig.GetResolution(newModeRes));
2500 //find a different resolution
2502 for (i = 0; i < resolutions; i++)
2504 if (!(resolutionList1[i].iPixelSize == newModeRes))
2509 ASSERT_TRUE(i < resolutions); //otherwise it didnt find a resolution different to the one set
2510 TDisplayConfiguration newSetConfig;
2512 //set the different resolution
2513 newSetConfig.SetResolution(resolutionList1[i].iPixelSize);
2514 error = interface->SetConfiguration(newSetConfig);
2515 ASSERT_TRUE(error == KErrNone);
2518 TDisplayConfiguration checkConfig;
2520 //check its set this new resolution
2521 interface->GetConfiguration(checkConfig);
2523 checkConfig.GetResolution(checkSize);
2524 ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize);
2526 TDisplayConfiguration emptyConfig;
2527 TDisplayConfiguration newModeConfig2(newModeConfig);
2528 newModeConfig2.Clear(newModeConfig2.EResolutionTwips);
2529 //set empty config, which should reset resolution to current modes default
2530 error = interface->SetConfiguration(emptyConfig);//emptyConfig);
2531 ASSERT_TRUE(error == KErrNone);
2535 interface->GetConfiguration(checkConfig);
2536 ASSERT_TRUE (newModeConfig == checkConfig); //empty config reset res to modes default res
2538 screenModeList.Close();
2542 TDisplayConfiguration test5;
2543 error = interface->SetConfiguration(test5);
2544 ASSERT_EQUALS(error,KErrArgument);
2546 resolutionList1.Close();
2550 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0031L
2551 @SYMTestCaseDesc SetConfiguration in OOM (changing resolution)
2556 @SYMTestPurpose Safety check against OOM
2559 Set a resolution that will definately cause a change of resolution
2560 Increase length of time to failure, repeat
2561 Finish after 5 successful changes of resolution
2562 @SYMTestExpectedResults
2563 Set resolution should either return a fail and not have cause a change in resolution,
2564 or it should have returned no fail and have set the new resolution
2566 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L()
2568 MDisplayControl* interface = static_cast<MDisplayControl*>
2569 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2570 ASSERT_TRUE(interface);
2571 INFO_PRINTF1(_L("Interface obtained sucessfully."));
2573 TInt resolutions = interface->NumberOfResolutions();
2574 ASSERT_TRUE (resolutions > 0);
2575 INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully."));
2577 RArray<MDisplayControl::TResolution> resolutionList1;
2578 TInt error = interface->GetResolutions(resolutionList1);
2579 ASSERT_EQUALS(error,KErrNone);
2580 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2581 INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions."));
2584 TDisplayConfiguration dispConfigBefore;
2585 TDisplayConfiguration dispConfigAfter;
2587 dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize);
2588 interface->SetConfiguration(dispConfigBefore);
2589 interface->GetConfiguration(dispConfigBefore);
2590 ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
2591 INFO_PRINTF1(_L("dispConfigBefore is defined."));
2592 TSize dispResBefore;
2594 dispConfigBefore.GetResolution(dispResBefore);
2595 TDisplayConfiguration::TRotation dispRotBefore;
2596 TDisplayConfiguration::TRotation dispRotReq;
2597 dispConfigBefore.GetRotation(dispRotBefore);
2599 for (index = 0; index < resolutionList1.Count(); index++)
2601 INFO_PRINTF2(_L("Starting resolution %d."), index);
2602 if (resolutionList1[index].iPixelSize.iWidth == 0)
2607 TBool notComplete = ETrue;
2608 TInt completeCount = 0;
2611 TDisplayConfiguration dispConfigReq;
2612 dispConfigReq.SetResolution(resolutionList1[index].iPixelSize);
2613 ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
2614 SetRotation(dispConfigReq,resolutionList1[index]); //set rotation to first defined in res list
2615 dispConfigReq.GetRotation(dispRotReq);
2616 INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail);
2618 iSession.Finish(ETrue);
2619 iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
2620 TInt errCode=interface->SetConfiguration(dispConfigReq);
2621 iSession.HeapSetFail(RHeap::ENone,0);
2622 INFO_PRINTF1(_L("After Heap Failure."));
2623 iSession.Finish(ETrue);
2625 INFO_PRINTF1(_L("After Session Finish."));
2627 interface->GetConfiguration(dispConfigAfter);
2628 ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution));
2629 dispConfigAfter.GetResolution(dispResAfter);
2631 TBool worked = ETrue;
2632 if (errCode < KErrNone)
2635 ASSERT_EQUALS(dispResAfter,dispResBefore);
2636 if (dispRotReq != dispRotBefore)
2637 { //didnt expect it work-KErrGeneral can mean a memory allocation fail
2638 if (errCode == KErrArgument)
2639 { //if it didnt panic, that is a good enough pass in this instance
2646 ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize);
2651 if (completeCount == 5)
2653 notComplete = EFalse;
2660 interface->SetConfiguration(dispConfigBefore);
2661 INFO_PRINTF1(_L("After Setting Original Configuration."));
2665 ASSERT_TRUE(0); //worrying amount of fails
2669 resolutionList1.Close();
2673 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0032L
2674 @SYMTestCaseDesc SetAppMode in OOM
2675 @SYMREQ REQ10326 REQ10336
2679 @SYMTestPurpose Safety check against OOM
2683 Increase length of time to failure, repeat
2684 Finish after 5 successful changes of mode
2685 @SYMTestExpectedResults
2686 SetAppMode should either return a fail and not have cause a change in resolution,
2687 or it should have returned no fail and have set the new resolution
2689 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L()
2691 MDisplayControl* interface = static_cast<MDisplayControl*>
2692 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2693 ASSERT_TRUE(interface);
2695 TInt resolutions = interface->NumberOfResolutions();
2696 ASSERT_TRUE (resolutions > 0);
2697 RArray<TInt> screenModeList;
2698 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2699 ASSERT_TRUE (screenModeList.Count()>0);
2701 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
2702 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
2704 for (TInt index = 1; index < screenModeList.Count(); index++)
2705 { //skip index 0, as that wouldn't be changing mode
2707 TBool notComplete = ETrue;
2708 TInt completeCount = 0;
2711 RDebug::Printf("iInfoScreenDevice->SetAppScreenMode");
2712 iInfoScreenDevice->SetAppScreenMode(screenModeList[index]);
2713 iSession.Finish(ETrue);
2714 iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
2715 RDebug::Printf("iInfoScreenDevice->SetAppScreenMode");
2716 iInfoScreenDevice->SetScreenMode(screenModeList[index]);
2717 RDebug::Printf("SetScreenMode done");
2718 iSession.HeapSetFail(RHeap::ENone,0);
2719 iSession.Finish(ETrue);
2720 RDebug::Printf("Finish done");
2722 TInt newMode = iInfoScreenDevice->CurrentScreenMode();
2724 if (screenModeList[index] == newMode)
2727 if (completeCount == 5)
2729 INFO_PRINTF3(_L("Mode %i Succeeded with heapFail = %d"),index, heapFail);
2730 notComplete = EFalse;
2732 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
2733 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
2734 iSession.Finish(ETrue);
2744 ASSERT_TRUE(0); //worrying amount of fails
2748 screenModeList.Close();
2752 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0033L
2753 @SYMTestCaseDesc GetConfiguration in OOM
2758 @SYMTestPurpose Safety check against OOM
2763 Increase time till failure
2764 Success after 5 completed gets
2765 @SYMTestExpectedResults
2766 Should always succeed
2768 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L()
2770 MDisplayControl* interface = static_cast<MDisplayControl*>
2771 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2772 ASSERT_TRUE(interface);
2775 for (TInt i=0;i<5;i++)
2777 TDisplayConfiguration config;
2778 iSession.Finish(ETrue);
2779 iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
2780 interface->GetConfiguration(config);
2781 iSession.HeapSetFail(RHeap::ENone,0);
2782 iSession.Finish(ETrue);
2783 ASSERT_TRUE(config.IsDefined(config.ERotation));
2784 ASSERT_TRUE(config.IsDefined(config.EResolution));
2785 ASSERT_TRUE(config.IsDefined(config.EResolutionTwips));
2791 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0034L
2792 @SYMTestCaseDesc GetResolutions in OOM
2797 @SYMTestPurpose Safety check against OOM
2801 Check resolutions filled in
2802 Success after 5 completed gets
2803 @SYMTestExpectedResults
2806 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L()
2808 MDisplayControl* interface = static_cast<MDisplayControl*>
2809 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2810 ASSERT_TRUE(interface);
2812 TInt resolutions = interface->NumberOfResolutions();
2813 ASSERT_TRUE(resolutions>1);
2815 RArray<MDisplayControl::TResolution> resolutionList1;
2816 TInt error = interface->GetResolutions(resolutionList1);
2817 ASSERT_EQUALS(error,KErrNone);
2818 ASSERT_TRUE(resolutionList1.Count() > 0);
2821 TInt completeCount = 0;
2822 TBool notComplete = ETrue;
2825 RArray<MDisplayControl::TResolution> resolutionList2;
2826 iSession.Finish(ETrue);
2827 iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
2828 error = interface->GetResolutions(resolutionList2);
2829 iSession.HeapSetFail(RHeap::ENone,0);
2830 iSession.Finish(ETrue);
2833 ASSERT_EQUALS(error,KErrNoMemory);
2838 ASSERT_EQUALS(resolutionList2.Count(),resolutionList1.Count());
2839 for (TInt i=0;i<resolutionList2.Count();i++)
2841 ASSERT_EQUALS(resolutionList1[i].iPixelSize,resolutionList2[i].iPixelSize);
2842 ASSERT_EQUALS(resolutionList1[i].iTwipsSize,resolutionList2[i].iTwipsSize);
2843 if (!(resolutionList1[i].iFlags==resolutionList2[i].iFlags))
2851 resolutionList2.Close();
2852 if (completeCount == 5)
2854 notComplete = EFalse;
2858 ASSERT_TRUE(0); //worrying amount of fails
2861 resolutionList1.Close();
2865 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0041L
2866 @SYMTestCaseDesc Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different AppModes
2867 @SYMREQ REQ10332 REQ10336
2870 @SYMTestPurpose Check to see if Bitmaps and Surfaces are drawn correctly in different app modes
2872 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
2874 Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
2875 @SYMTestExpectedResults
2876 All tests should pass.
2879 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0041L(TBool aIsSurface)
2881 LOG_AND_PANIC_IF_NOT_GCE;
2884 iSession.Finish(ETrue);
2886 TRect screenSize(iInfoScreenDevice->SizeInPixels());
2887 screenSize.Shrink(5,5);
2889 RBlankWindow testWindow;
2892 testWindow=RBlankWindow(iSession);
2893 ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
2894 testWindow.SetColor(iBlue);
2895 testWindow.SetExtent(screenSize.iTl,screenSize.Size());
2896 testWindow.Activate();
2898 if (testWindow.WsHandle())
2903 testWindow.SetVisible(ETrue);
2906 iSession.Finish(ETrue);
2908 RArray<TInt> screenModeList;
2909 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
2910 MDisplayControl* interface = static_cast<MDisplayControl*>
2911 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
2912 ASSERT_TRUE(interface);
2914 TInt resolutions = interface->NumberOfResolutions();
2915 ASSERT_TRUE (resolutions > 0);
2917 RArray<MDisplayControl::TResolution> resolutionList1;
2918 error = interface->GetResolutions(resolutionList1);
2919 ASSERT_EQUALS(error,KErrNone);
2920 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
2922 TDisplayConfiguration dispConfigBefore;
2923 interface->GetConfiguration(dispConfigBefore);
2924 ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
2925 if (screenModeList.Count()>1)
2927 //Got a mode to change to!
2929 TBool ok=dispConfigBefore.GetResolution(resBefore);
2930 ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag
2931 for (TInt res=0;res<screenModeList.Count();res++)
2935 TDisplayConfiguration dispConfigReq;
2936 iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
2937 iInfoScreenDevice->SetScreenMode(screenModeList[res]);
2938 iSession.Finish(ETrue);
2942 TSize pr = iInfoScreenDevice->SizeInPixels();
2943 TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
2947 TSize surfaceSize = pr;
2948 surfaceSize.iWidth /= 2;
2949 surfaceSize.iWidth -= 20;
2950 surfaceSize.iHeight -= 20;
2951 TSurfaceId surfaceID;
2952 TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize,
2953 KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
2954 ASSERT_EQUALS(err,KErrNone);
2955 TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
2956 ASSERT_EQUALS(err,KErrNone);
2958 CFbsBitmap* equivalentBitmap=NULL;
2959 TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
2960 CleanupStack::PushL(equivalentBitmap);
2961 ASSERT_EQUALS(err,KErrNone);
2963 screenSize = iInfoScreenDevice->SizeInPixels();
2964 TSize testSize = iScreenDevice->SizeInPixels();
2965 screenSize.Shrink(5,5);
2969 testWindow.SetExtent(screenSize.iTl,screenSize.Size());
2971 if (testWindow.WsHandle())
2977 testWindow.SetVisible(ETrue);
2980 iSession.Finish(ETrue);
2985 surfWindow=RWindow(iSession);
2986 ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
2987 surfWindow.SetBackgroundSurface(surfaceID);
2988 surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
2989 surfWindow.Activate();
2991 if (surfWindow.WsHandle())
2993 surfWindow.Invalidate();
2995 surfWindow.BeginRedraw();
2996 ActivateWithWipe(iInfoGc,surfWindow,iRed);
2997 surfWindow.EndRedraw();
3002 surfWindow.SetVisible(ETrue);
3003 iInfoGc->Deactivate();
3006 iSession.Finish(ETrue);
3008 TRect bitmapDrawRect;
3009 bitmapDrawRect = surfaceSize;
3014 bmpWindow=RWindow(iSession);
3015 ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
3016 bmpWindow.SetBackgroundColor(iRed);
3017 bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
3018 bmpWindow.Activate();
3020 if (bmpWindow.WsHandle())
3022 bmpWindow.Invalidate();
3024 bmpWindow.BeginRedraw();
3025 ActivateWithWipe(iInfoGc,bmpWindow,iRed);
3026 // Not drawing, draw twice??
3027 iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
3028 bmpWindow.EndRedraw();
3033 bmpWindow.SetVisible(ETrue);
3034 iInfoGc->Deactivate();
3037 iSession.Finish(ETrue);
3043 if (bmpWindow.WsHandle())
3045 bmpWindow.Invalidate();
3047 bmpWindow.BeginRedraw();
3048 ActivateWithWipe(iInfoGc,bmpWindow,iRed);
3049 // Not drawing, draw twice??
3050 iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
3051 bmpWindow.EndRedraw();
3056 bmpWindow.SetVisible(ETrue);
3057 iInfoGc->Deactivate();
3060 iSession.Finish(ETrue);
3065 if (bmpWindow.WsHandle())
3067 bmpWindow.Invalidate();
3069 bmpWindow.BeginRedraw();
3070 ActivateWithWipe(iInfoGc,bmpWindow,iRed);
3071 // Not drawing, draw twice??
3072 iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
3073 bmpWindow.EndRedraw();
3077 bmpWindow.SetVisible(ETrue);
3078 iInfoGc->Deactivate();
3081 iSession.Finish(ETrue);
3083 RArray<TBitmapRegionPair> regionArray;
3085 RRegion equivRegion;
3086 TBitmapRegionPair bitmap1Region;
3087 bitmap1Region.bitmap = equivalentBitmap;
3088 bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
3089 equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
3090 bitmap1Region.region = &equivRegion;
3092 regionArray.Append(bitmap1Region);
3095 TDisplayConfiguration dispConfigAfter2;
3096 interface->GetConfiguration(dispConfigAfter2);
3098 dispConfigAfter2.GetResolution(theSize);
3099 TDisplayConfiguration1::TRotation orient;
3100 dispConfigAfter2.GetRotation(orient);
3101 if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
3103 TInt temp = theSize.iHeight;
3104 theSize.iHeight = theSize.iWidth;
3105 theSize.iWidth = temp;
3107 TRect uiSize(TPoint(0,0), theSize);
3108 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
3109 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
3110 ASSERT_TRUE(mappingInterface);
3112 mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
3115 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
3116 CleanupStack::PushL(bmp2);
3117 User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
3121 static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
3124 TInt errr = csc->ComposeScreen(*bmp2);
3125 ASSERT_TRUE(errr == KErrNone);
3132 _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
3133 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
3138 TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
3139 TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
3143 if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
3145 _LIT(KCompareFailed, "Compare Failed on app mode: %d");
3147 x.Format(KCompareFailed, res+1);
3148 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
3152 CleanupStack::PopAndDestroy(bmp2);
3154 equivRegion.Close();
3155 regionArray.Close();
3157 CleanupStack::PopAndDestroy(equivalentBitmap);
3163 //restore initial res
3164 if (screenModeList.Count() > 1)
3165 { //set back to basics
3166 iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
3167 iInfoScreenDevice->SetScreenMode(screenModeList[0]);
3171 interface->SetConfiguration(dispConfigBefore);
3173 TDisplayConfiguration dispConfigAfter;
3174 interface->GetConfiguration(dispConfigAfter);
3176 ok=dispConfigAfter.GetResolution(resAfter);
3178 ASSERT_EQUALS(resBefore,resAfter);
3182 INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
3185 screenModeList.Close();
3186 resolutionList1.Close();
3191 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0042L
3192 @SYMTestCaseDesc Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions
3196 @SYMTestPurpose Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions
3198 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
3200 Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
3201 @SYMTestExpectedResults
3202 All tests should pass.
3205 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface)
3207 LOG_AND_PANIC_IF_NOT_GCE;
3210 iSession.Finish(ETrue);
3212 TRect screenSize(iInfoScreenDevice->SizeInPixels());
3213 screenSize.Shrink(5,5);
3215 RBlankWindow testWindow;
3218 testWindow=RBlankWindow(iSession);
3219 ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
3220 testWindow.SetColor(iBlue);
3221 testWindow.SetExtent(screenSize.iTl,screenSize.Size());
3222 testWindow.Activate();
3224 if (testWindow.WsHandle())
3229 testWindow.SetVisible(ETrue);
3232 iSession.Finish(ETrue);
3234 RArray<TInt> screenModeList;
3235 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
3236 MDisplayControl* interface = static_cast<MDisplayControl*>
3237 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
3238 ASSERT_TRUE(interface);
3240 TInt resolutions = interface->NumberOfResolutions();
3241 ASSERT_TRUE (resolutions > 0);
3243 RArray<MDisplayControl::TResolution> resolutionList1;
3244 error = interface->GetResolutions(resolutionList1);
3245 ASSERT_EQUALS(error,KErrNone);
3246 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
3248 TDisplayConfiguration dispConfigBefore;
3249 interface->GetConfiguration(dispConfigBefore);
3251 iInfoScreenDevice->SetAppScreenMode(screenModeList[1]);
3252 iInfoScreenDevice->SetScreenMode(screenModeList[1]);
3258 //Got a mode to change to!
3260 TBool ok=dispConfigBefore.GetResolution(resBefore);
3261 ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag
3262 for (TInt res=0;res<resolutionList1.Count();res++)
3264 if (resolutionList1[res].iPixelSize!=TSize(0,0)) //this test is not about turning the display off
3266 TDisplayConfiguration dispConfigReq;
3267 dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
3268 ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
3270 SetRotation(dispConfigReq,resolutionList1[res]); //set rotation to first defined in res list
3275 TInt errCode=interface->SetConfiguration(dispConfigReq);
3276 //ASSERT_EQUALS(errCode,KErrNone);
3277 if (errCode != KErrNone)
3279 //Probably current size mode does not support the rotation of the passed in configuration
3281 ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy
3286 TSize pr = iInfoScreenDevice->SizeInPixels();
3287 TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
3291 TSize surfaceSize = pr;
3292 surfaceSize.iWidth /= 2;
3293 surfaceSize.iWidth -= 20;
3294 surfaceSize.iHeight -= 20;
3295 TSurfaceId surfaceID;
3296 TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize,
3297 KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
3298 ASSERT_EQUALS(err,KErrNone);
3299 TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
3300 ASSERT_EQUALS(err,KErrNone);
3302 CFbsBitmap* equivalentBitmap=NULL;
3303 TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
3304 CleanupStack::PushL(equivalentBitmap);
3305 ASSERT_EQUALS(err,KErrNone);
3307 screenSize = iInfoScreenDevice->SizeInPixels();
3308 screenSize.Shrink(5,5);
3312 testWindow.SetExtent(screenSize.iTl,screenSize.Size());
3314 if (testWindow.WsHandle())
3320 testWindow.SetVisible(ETrue);
3323 iSession.Finish(ETrue);
3328 surfWindow=RWindow(iSession);
3329 ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
3330 surfWindow.SetBackgroundSurface(surfaceID);
3331 surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
3332 surfWindow.Activate();
3334 if (surfWindow.WsHandle())
3336 surfWindow.Invalidate();
3338 surfWindow.BeginRedraw();
3339 ActivateWithWipe(iInfoGc,surfWindow,iRed);
3340 surfWindow.EndRedraw();
3345 surfWindow.SetVisible(ETrue);
3346 iInfoGc->Deactivate();
3349 iSession.Finish(ETrue);
3351 TRect bitmapDrawRect;
3352 bitmapDrawRect = surfaceSize;
3357 bmpWindow=RWindow(iSession);
3358 ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
3359 bmpWindow.SetBackgroundColor(iRed);
3360 bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
3361 bmpWindow.Activate();
3363 if (bmpWindow.WsHandle())
3365 bmpWindow.Invalidate();
3367 bmpWindow.BeginRedraw();
3368 ActivateWithWipe(iInfoGc,bmpWindow,iRed);
3369 // Not drawing, draw twice??
3370 iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
3371 bmpWindow.EndRedraw();
3376 bmpWindow.SetVisible(ETrue);
3377 iInfoGc->Deactivate();
3380 iSession.Finish(ETrue);
3386 if (bmpWindow.WsHandle())
3388 bmpWindow.Invalidate();
3390 bmpWindow.BeginRedraw();
3391 ActivateWithWipe(iInfoGc,bmpWindow,iRed);
3392 // Not drawing, draw twice??
3393 iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
3394 bmpWindow.EndRedraw();
3399 bmpWindow.SetVisible(ETrue);
3400 iInfoGc->Deactivate();
3403 iSession.Finish(ETrue);
3408 RArray<TBitmapRegionPair> regionArray;
3410 RRegion equivRegion;
3411 TBitmapRegionPair bitmap1Region;
3412 bitmap1Region.bitmap = equivalentBitmap;
3413 bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
3414 equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
3415 bitmap1Region.region = &equivRegion;
3417 regionArray.Append(bitmap1Region);
3420 TDisplayConfiguration dispConfigAfter2;
3421 interface->GetConfiguration(dispConfigAfter2);
3423 dispConfigAfter2.GetResolution(theSize);
3424 TDisplayConfiguration1::TRotation orient;
3425 dispConfigAfter2.GetRotation(orient);
3428 TInt temp = theSize.iHeight;
3429 theSize.iHeight = theSize.iWidth;
3430 theSize.iWidth = temp;
3432 TRect uiSize(TPoint(0,0), theSize);
3433 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
3434 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
3435 ASSERT_TRUE(mappingInterface);
3437 mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
3442 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
3443 CleanupStack::PushL(bmp2);
3444 TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU);
3445 ASSERT_EQUALS(bmpErr, KErrNone);
3449 static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
3452 TInt errr = csc->ComposeScreen(*bmp2);
3459 _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
3460 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
3463 TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
3464 TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
3468 if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
3470 _LIT(KCompareFailed, "Compare Failed on resolution: %d");
3472 x.Format(KCompareFailed, res+1);
3473 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
3476 CleanupStack::PopAndDestroy(bmp2);
3478 equivRegion.Close();
3479 regionArray.Close();
3481 CleanupStack::PopAndDestroy(equivalentBitmap);
3486 //restore initial res
3487 iInfoScreenDevice->SetAppScreenMode(0);
3488 iInfoScreenDevice->SetScreenMode(0);
3492 INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
3495 screenModeList.Close();
3496 resolutionList1.Close();
3501 Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray
3502 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.
3505 @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code
3506 @param aRect1 A rectangle representing the middle window in the comparison triple
3507 @param aRect2 A rectangle represneting the right window in the comparison triple
3508 @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
3511 TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap,
3512 const TRect& aRect1, const TRect& aRect2,
3513 RArray<TBitmapRegionPair>& aBitmapRegionPairArray, TBool aIsSurface)
3515 MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
3516 (iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
3517 ASSERT_TRUE(mappingInterface);
3523 TInt errorPixels =0;
3524 TInt diffPixels = 0;
3525 RRegion ignoreDueToResizing;
3526 TInt regionCount = aBitmapRegionPairArray.Count();
3527 for (TInt i=regionCount-1; i>=0; i--)
3529 if (aBitmapRegionPairArray[i].bitmap->SizeInPixels()
3530 != aBitmapRegionPairArray[i].drawRect.Size())
3532 RArray<TPoint> corners;
3533 corners.Append(aBitmapRegionPairArray[i].drawRect.iTl);
3534 corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1,
3535 aBitmapRegionPairArray[i].drawRect.iTl.iY));
3536 corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
3537 aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
3538 corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1));
3539 for (TInt j=0; j<corners.Count(); j++)
3541 TBool inOther=EFalse;
3542 for (TInt k=0; k<i; k++)
3544 if (aBitmapRegionPairArray[k].region->Contains(corners[j]))
3553 aBitmap.GetPixel(color1, aRect2.iTl + corners[j]);
3554 aBitmap.GetPixel(color2, aRect1.iTl + corners[j]);
3555 TRgb color3 = GreatestColor(color1);
3556 TRgb color4 = GreatestColor(color2);
3557 if (color3 != color4)
3559 // 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.
3560 if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0))
3564 if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0))
3575 // testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to
3576 RArray<TPoint> testPoints;
3577 testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center());
3578 testPoints.Append(TPoint(
3579 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
3580 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
3581 testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
3582 aBitmapRegionPairArray[i].drawRect.Center().iY));
3583 testPoints.Append(TPoint(0,
3584 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
3585 testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX
3586 -1, aBitmapRegionPairArray[i].drawRect.Center().iY));
3587 testPoints.Append(TPoint(
3588 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1,
3589 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
3590 TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size();
3591 if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20)
3593 testPoints.Append(TPoint(
3594 aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY));
3595 testPoints.Append(TPoint(
3596 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0));
3598 testPoints.Append(TPoint(
3599 aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
3600 testPoints.Append(TPoint(
3601 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
3602 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1));
3604 if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34
3605 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43)
3607 testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
3609 testPoints.Append(TPoint(5, 5));
3610 testPoints.Append(TPoint(
3611 aBitmapRegionPairArray[i].drawRect.iBr.iX - 6,
3612 aBitmapRegionPairArray[i].drawRect.iTl.iY + 5));
3613 testPoints.Append(TPoint(
3614 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
3615 testPoints.Append(TPoint(
3616 aBitmapRegionPairArray[i].drawRect.iTl.iX + 5,
3617 aBitmapRegionPairArray[i].drawRect.iBr.iY -6));
3618 testPoints.Append(TPoint(5,
3619 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
3620 testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
3622 testPoints.Append(TPoint(
3623 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
3624 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
3628 testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
3630 testPoints.Append(TPoint(5, 5));
3631 testPoints.Append(TPoint(
3632 aBitmapRegionPairArray[i].drawRect.iBr.iX - 3,
3633 aBitmapRegionPairArray[i].drawRect.iTl.iY + 3));
3634 testPoints.Append(TPoint(
3635 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
3636 testPoints.Append(TPoint(
3637 aBitmapRegionPairArray[i].drawRect.iTl.iX + 2,
3638 aBitmapRegionPairArray[i].drawRect.iBr.iY -4));
3639 testPoints.Append(TPoint(5,
3640 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
3641 testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
3643 testPoints.Append(TPoint(
3644 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
3645 aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
3648 for (int jj=0; jj<testPoints.Count(); jj+=2)
3650 TBool inOther=EFalse;
3651 if (!aBitmapRegionPairArray[i].region->Contains(testPoints[jj]))
3655 for (TInt k=0; k<i; k++)
3657 if (aBitmapRegionPairArray[k].region->Contains(testPoints[jj]))
3666 TPoint currentPoint = testPoints[jj];
3667 TRect bound = aBitmapRegionPairArray[i].region->BoundingRect();
3670 aBitmapRegionPairArray[i].region->Contains(testPoints[jj]);
3671 aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]);
3672 aBitmapRegionPairArray[i].bitmap->GetPixel(color2,
3674 TRgb color5 = GreatestColor(color1);
3675 TRgb color6 = GreatestColor(color2);
3676 if (color5 != color6)
3678 // 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.
3679 if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0))
3683 if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0))
3696 ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region);
3697 aBitmapRegionPairArray.Remove(i);
3701 RRegion superRegion;
3703 regionCount = aBitmapRegionPairArray.Count();
3705 for (TInt i=0; i<regionCount; i++)
3707 superRegion.Union(*(aBitmapRegionPairArray[i].region));
3709 TRect boundingRect = superRegion.BoundingRect();
3710 superRegion.Close();
3711 TInt width = boundingRect.Width();
3712 TInt height = boundingRect.Height();
3713 TInt xStart = boundingRect.iTl.iX;
3714 TInt yStart = boundingRect.iTl.iY;
3716 TSize superSize = aBitmap.SizeInPixels();
3718 TInt nonWhiteCount = 0;
3719 for (TInt iii = 0; iii<superSize.iWidth; iii++)
3721 for (TInt jjj=0; jjj<superSize.iHeight; jjj++)
3723 aBitmap.GetPixel(HHH1, TPoint(iii,jjj));
3724 if (HHH1 != TRgb (255, 255, 255))
3731 if (aBitmapRegionPairArray.Count()>0)
3733 RDebug::Printf("Checking");
3735 for (TInt i=0; i<width; i++)
3737 for (TInt j=0; j<height; j++)
3739 TInt arrayIndex = 0;
3740 TBool pointInArray= EFalse;
3741 TPoint currentPoint(xStart + i, yStart + j);
3742 if (!ignoreDueToResizing.Contains(currentPoint))
3746 if (aBitmapRegionPairArray[arrayIndex].region->Contains(currentPoint))
3750 TPoint checkPoint = currentPoint + aRect2.iTl;
3752 mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
3753 aBitmap.GetPixel(color1, readBackRect.iTl);
3757 TPoint checkPoint = currentPoint + aRect1.iTl;
3759 mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
3760 aBitmap.GetPixel(color1, readBackRect.iTl);
3763 aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2, currentPoint
3764 - aBitmapRegionPairArray[arrayIndex].drawRect.iTl);
3766 TRgb color7 = GreatestColor(color1);
3767 TRgb color8 = GreatestColor(color2);
3769 if (color7 != color8)
3774 pointInArray = ETrue;
3778 while (!pointInArray && !(arrayIndex
3779 >= aBitmapRegionPairArray.Count()));
3783 aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX
3784 + xStart, j +aRect2.iTl.iY +yStart));
3785 aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX
3786 +xStart, j +aRect1.iTl.iY+yStart));
3787 // Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match
3788 TRgb color3 = GreatestColor(color1);
3789 TRgb color4 = GreatestColor(color2);
3791 if (color3 != color4)
3793 // 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.
3794 if (GreatestColor(color2) == TRgb(0, 1, 0)
3795 && GreatestColor(color1) == TRgb(1, 1, 0))
3800 if (GreatestColor(color2) == TRgb(1, 1, 0)
3801 && GreatestColor(color1) == TRgb(0, 1,
3818 ignoreDueToResizing.Close();
3819 if (errorPixels+diffPixels < 2)
3832 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.
3834 @param aColor the color to be approximated
3835 @return an approximation of aColor.
3837 TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const
3839 TInt test = aColor.Difference(TRgb(0, 0, 0));
3840 // Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing
3841 if (aColor == TRgb(32, 32, 32))
3843 return TRgb(0, 0, 0);
3845 if (aColor == TRgb(0, 0, 0))
3847 return TRgb(0, 0, 0);
3850 test2.SetInternal(0xFFFEDF01);
3851 if (aColor == test2)
3853 return TRgb(1, 1, 0);
3858 return TRgb(0, 0, 0);
3860 if (aColor.Green() > aColor.Blue())
3862 if (aColor.Green() > aColor.Red())
3864 return TRgb(0, 1, 0);
3867 if (aColor.Green() == aColor.Red())
3869 return TRgb(1, 1, 0);
3872 if (aColor.Green() > aColor.Red())
3874 if (aColor.Green() > aColor.Blue())
3876 return TRgb(0, 1, 0);
3879 if (aColor.Green() == aColor.Blue())
3881 return TRgb(0, 1, 1);
3885 if (aColor.Red() > aColor.Green())
3887 if (aColor.Red() > aColor.Blue())
3889 return TRgb(1, 0, 0);
3892 if (aColor.Red() == aColor.Blue())
3894 return TRgb(1, 0, 1);
3897 if (aColor.Red() > aColor.Blue())
3899 if (aColor.Red() > aColor.Green())
3901 return TRgb(1, 0, 0);
3904 if (aColor.Red() == aColor.Green())
3906 return TRgb(1, 1, 0);
3910 if (aColor.Blue() > aColor.Red())
3912 if (aColor.Blue() > aColor.Green())
3914 return TRgb(0, 0, 1);
3917 if (aColor.Blue() == aColor.Green())
3919 return TRgb(0, 1, 1);
3922 if (aColor.Blue() > aColor.Green())
3924 if (aColor.Blue() > aColor.Red())
3926 return TRgb(0, 0, 1);
3929 if (aColor.Blue() == aColor.Red())
3931 return TRgb(1, 0, 1);
3935 // Should never reach here, but the compiler cannot be sure
3936 return TRgb(0, 0, 0);
3940 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0051L
3941 @SYMTestCaseDesc Getting if a mode is dynamic
3946 @SYMTestPurpose Check functions work correctly
3948 Do IsModeDynamic for a wrong mode number
3949 Do IsModeDynamic for a mode that isnt dynamic
3950 Do IsModeDynamic for a mode that is dynamic
3951 Do IsCurrentModeDynamic when current mode is not dynamic
3952 Do IsCurrentModeDynamic when current mode is dynamic
3953 MODE 10 must be dynamic
3954 @SYMTestExpectedResults
3955 All should return as expected.
3957 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L()
3959 RArray<TInt> screenModeList;
3960 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
3961 iInfoScreenDevice->SetAppScreenMode(0);
3962 iInfoScreenDevice->SetScreenMode(0);
3965 ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25));
3966 ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1));
3967 ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10));
3968 ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic());
3969 iInfoScreenDevice->SetAppScreenMode(10);
3970 iInfoScreenDevice->SetScreenMode(10);
3973 ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
3974 screenModeList.Close();
3975 iInfoScreenDevice->SetAppScreenMode(0);
3976 iInfoScreenDevice->SetScreenMode(0);
3979 /* Takes any 0x0 resolutions out of the res list, useful for some tests
3981 void ResListCleanup(RArray<MDisplayControl::TResolution>& aResList)
3983 for (TInt ii=0; ii<aResList.Count(); ii++)
3985 if (aResList[ii].iPixelSize.iWidth == 0 ||
3986 aResList[ii].iPixelSize.iHeight == 0)
3988 aResList.Remove(ii);
3995 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0052L
3996 @SYMTestCaseDesc Getting if a mode is dynamic
4001 @SYMTestPurpose Check functions work correctly
4003 For every standard screen mode
4004 Check twips and pixel conversions are correct based on screen mode values
4005 Set dynamic app mode
4006 For every resolution
4007 Check twips and pixel conversions are correct based on physical screen values
4008 @SYMTestExpectedResults
4009 All should return as expected.
4010 NOTE- there must be a dynamic screen mode available
4011 NOTE- only run on a screen with multiple resolutions available
4013 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0052L()
4015 MDisplayControl* interface = static_cast<MDisplayControl*>
4016 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
4017 ASSERT_TRUE(interface);
4019 TInt resolutions = interface->NumberOfResolutions();
4020 ASSERT_TRUE (resolutions > 1);
4022 RArray<MDisplayControl::TResolution> resolutionList1;
4023 TInt error = interface->GetResolutions(resolutionList1);
4024 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
4025 ResListCleanup(resolutionList1); //remove any 0x0
4026 ASSERT_TRUE (resolutionList1.Count() > 1); //without multiple proper res this test is pointless
4028 TDisplayConfiguration newResolution;
4029 newResolution.SetResolution(resolutionList1[0].iPixelSize);
4030 error = interface->SetConfiguration(newResolution);
4031 ASSERT_EQUALS(error,KErrNone);
4034 RArray<TInt> screenModes;
4035 error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes);
4036 ASSERT_TRUE(error>KErrNone);
4037 TInt dynamicMode1 = -1;
4038 TInt dynamicMode2 = -1;
4039 TPixelsTwipsAndRotation modeAttributes;
4041 //for every app mode, check calculations update correctly
4042 for (TInt ii=0;ii<screenModes.Count();ii++)
4044 TInt screenMode = screenModes[ii];
4045 if (iInfoScreenDevice->IsModeDynamic(screenMode))
4047 CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
4048 CleanupStack::PushL(rotations);
4049 TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations);
4050 ASSERT_EQUALS(error,KErrNone);
4051 ASSERT_TRUE(rotations->Count()>0);
4052 for (TInt jj = 0; jj < rotations->Count(); jj++)
4054 if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal ||
4055 (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180)
4057 dynamicMode1 = screenMode;
4059 else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 ||
4060 (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270)
4062 dynamicMode2 = screenMode;
4065 CleanupStack::PopAndDestroy(rotations);
4066 continue; //dont want to test dynamic modes
4069 INFO_PRINTF2(_L("ScreenMode %d"),screenMode);
4070 newResolution.ClearAll();
4072 iInfoScreenDevice->SetAppScreenMode(screenMode);
4073 iInfoScreenDevice->SetScreenMode(screenMode);
4077 info = iInfoScreenDevice->GetCurrentScreenModeAttributes();
4078 //These 2 asserts relate to DEF136304 - disconnect on startup causes invalid
4079 //twips values. They need to be calculated when the screen is connected
4080 ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000);
4081 ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000);
4083 //test that conversions correlate to values reported by config
4084 TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
4085 info.iScreenTwipsSize.iWidth);
4086 ASSERT_EQUALS (test,info.iScreenSize.iWidth);
4088 test = iInfoScreenDevice->VerticalTwipsToPixels(
4089 info.iScreenTwipsSize.iHeight);
4090 ASSERT_EQUALS (test,info.iScreenSize.iHeight);
4092 test = iInfoScreenDevice->HorizontalPixelsToTwips(
4093 info.iScreenSize.iWidth);
4094 ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth);
4096 test = iInfoScreenDevice->VerticalPixelsToTwips(
4097 info.iScreenSize.iHeight);
4098 ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight);
4101 if (dynamicMode1 == -1 && dynamicMode2 == -1) //expected to find at least 1 dynamic mode
4106 for (TInt jj=0;jj<2;jj++) //for dynamic mode 1 and 2
4108 TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2;
4111 //set dynamic app mode
4112 iInfoScreenDevice->SetAppScreenMode(dynMode);
4113 iInfoScreenDevice->SetScreenMode(dynMode);
4116 ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode));
4117 ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
4118 ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode());
4119 for (TInt ii=0;ii<resolutionList1.Count();ii++)
4121 INFO_PRINTF2(_L("ResIndex %d"),ii);
4122 newResolution.ClearAll();
4124 newResolution.SetResolution(resolutionList1[ii].iPixelSize);
4125 newResolution.SetResolutionTwips(resolutionList1[ii].iTwipsSize);
4126 SetRotation(newResolution,resolutionList1[ii]);
4127 TDisplayConfiguration1::TRotation tempSetRot;
4128 newResolution.GetRotation(tempSetRot);
4130 error = interface->SetConfiguration(newResolution);
4134 if (tempSetRot == TDisplayConfiguration1::ERotation90CW ||
4135 tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation
4137 ASSERT_EQUALS(error,KErrArgument);
4143 if (tempSetRot == TDisplayConfiguration1::ERotationNormal ||
4144 tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation
4146 ASSERT_EQUALS(error,KErrArgument);
4150 ASSERT_EQUALS(error,KErrNone);
4151 interface->GetConfiguration(newResolution);
4155 //test that conversions correlate to values reported by config
4156 TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
4157 resolutionList1[ii].iTwipsSize.iWidth);
4158 ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth);
4160 test = iInfoScreenDevice->VerticalTwipsToPixels(
4161 resolutionList1[ii].iTwipsSize.iHeight);
4162 ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight);
4164 test = iInfoScreenDevice->HorizontalPixelsToTwips(
4165 resolutionList1[ii].iPixelSize.iWidth);
4166 ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth);
4168 test = iInfoScreenDevice->VerticalPixelsToTwips(
4169 resolutionList1[ii].iPixelSize.iHeight);
4170 ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight);
4174 resolutionList1.Close();
4175 screenModes.Close();
4179 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0053L
4180 @SYMTestCaseDesc SetScreenSizeAndRotation
4185 @SYMTestPurpose Check functions work correctly
4187 Perform calls to SetScreenSizeAndRotation with the various structure types
4188 MODE 10 must be dynamic
4189 @SYMTestExpectedResults
4190 Cannt fail, used for debugging and coverage.
4192 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L()
4194 MDisplayControl* interface = static_cast<MDisplayControl*>
4195 (iScreenDevice->GetInterface(MDisplayControl::ETypeId));
4196 ASSERT_TRUE(interface);
4198 TInt resolutions = interface->NumberOfResolutions();
4199 ASSERT_TRUE (resolutions > 1);
4201 RArray<MDisplayControl::TResolution> resolutionList1;
4202 TInt error = interface->GetResolutions(resolutionList1);
4203 ASSERT_EQUALS(resolutionList1.Count(), resolutions);
4205 //set default app mode and default resolution
4206 iInfoScreenDevice->SetAppScreenMode(0);
4207 iInfoScreenDevice->SetScreenMode(0);
4210 TDisplayConfiguration original;
4211 original.SetResolution(resolutionList1[0].iPixelSize);
4212 interface->SetConfiguration(original);
4216 TPixelsAndRotation setup0;
4217 setup0.iPixelSize = TSize(30,40);
4218 setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
4220 TPixelsTwipsAndRotation setup1;
4221 setup1.iPixelSize = TSize(50,60);
4222 setup1.iTwipsSize = TSize(70,80);
4223 setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
4225 iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
4226 iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
4228 //set dynamic app mode
4229 iInfoScreenDevice->SetAppScreenMode(10);
4230 iInfoScreenDevice->SetScreenMode(10);
4234 iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
4235 iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
4237 const CWsScreenDevice* newDevice = iScreenDevice;
4238 const MDisplayControl* interface2 = (MDisplayControl*)
4239 newDevice->GetInterface(MDisplayControl::ETypeId);
4240 TInt version = interface2->PreferredDisplayVersion(); //for coverage!
4243 //set default app mode and default resolution
4244 iInfoScreenDevice->SetAppScreenMode(1);
4245 iInfoScreenDevice->SetScreenMode(1);
4248 interface->SetConfiguration(original);
4252 resolutionList1.Close();
4256 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0101L
4257 @SYMTestCaseDesc Quick demonstration of app modes sizes and positions on screen
4260 @SYMTestType CT (manual visual test)
4261 @SYMTestPurpose To show app modes
4264 Draw a blue box showing the full size and position of the app mode.
4265 Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
4267 Green borders at the edge of the appmode, to show we are drawing up to the edges of the
4269 @SYMTestExpectedResults
4270 Blue window should represent appmode (with offset and size)
4271 Red windows should be visible across screen
4272 Green border (made of windows) around the appmode (blue window)
4274 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L()
4276 RArray<TInt> screenModeList;
4277 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
4279 if (screenModeList.Count()>1)
4281 //Got modes to change between!
4283 for (TInt res=0;res<screenModeList.Count();res++)
4285 TDisplayConfiguration dispConfigReq;
4286 iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
4287 iInfoScreenDevice->SetScreenMode(screenModeList[res]);
4291 TSize appSize = iInfoScreenDevice->SizeInPixels();
4292 RWindow backWindow(iSession);
4293 ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
4294 backWindow.SetRequiredDisplayMode(iDisplayMode);
4295 backWindow.SetBackgroundColor(iCyan);
4296 backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40)); //shows size of the apparea
4297 backWindow.Activate();
4299 TSurfaceId surfaceID;
4300 TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200),
4301 KSurfaceFormat, 200 * KBytesPerPixel));
4302 ASSERT_EQUALS(err,KErrNone);
4303 TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
4304 ASSERT_EQUALS(err,KErrNone);
4305 TSurfaceConfiguration surfConf;
4306 surfConf.SetSurfaceId(surfaceID);
4308 backWindow.SetBackgroundSurface(surfaceID);
4310 DrawPlainUI(backWindow,ETrue,iBlue);
4314 RWindow longWindow1(iSession);
4315 ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
4316 longWindow1.SetRequiredDisplayMode(iDisplayMode);
4317 longWindow1.SetBackgroundColor(iRed);
4318 longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea
4319 longWindow1.Activate();
4320 DrawPlainUI(longWindow1,ETrue,iRed);
4322 iBackground.SetColor(TRgb(0x001000*res|0x800000));
4323 iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
4327 RWindow longWindow2(iSession);
4328 ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
4329 longWindow2.SetRequiredDisplayMode(iDisplayMode);
4330 longWindow2.SetBackgroundColor(iRed);
4331 longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea
4332 longWindow2.Activate();
4333 DrawPlainUI(longWindow2,ETrue,iRed);
4336 RWindow borderTop(iSession);
4337 ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
4338 borderTop.SetRequiredDisplayMode(iDisplayMode);
4339 borderTop.SetBackgroundColor(iGreen);
4340 borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border
4341 borderTop.Activate();
4342 DrawPlainUI(borderTop,ETrue,iGreen);
4344 RWindow borderLeft(iSession);
4345 ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
4346 borderLeft.SetRequiredDisplayMode(iDisplayMode);
4347 borderLeft.SetBackgroundColor(iGreen);
4348 borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border
4349 borderLeft.Activate();
4350 DrawPlainUI(borderLeft,ETrue,iGreen);
4352 RWindow borderRight(iSession);
4353 ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
4354 borderRight.SetRequiredDisplayMode(iDisplayMode);
4355 borderRight.SetBackgroundColor(iGreen);
4356 borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border
4357 borderRight.Activate();
4358 DrawPlainUI(borderRight,ETrue,iGreen);
4360 RWindow borderBottom(iSession);
4361 ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
4362 borderBottom.SetRequiredDisplayMode(iDisplayMode);
4363 borderBottom.SetBackgroundColor(iGreen);
4364 borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border
4365 borderBottom.Activate();
4366 DrawPlainUI(borderBottom,ETrue,iGreen);
4372 longWindow1.Close();
4373 longWindow2.Close();
4376 borderRight.Close();
4377 borderBottom.Close();
4385 INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped."));
4388 screenModeList.Close();
4389 iInfoScreenDevice->SetAppScreenMode(0);
4390 iInfoScreenDevice->SetScreenMode(0);
4391 iSession.Finish(ETrue);
4393 INFO_PRINTF1(_L("Drawing to borderBottom completed."));
4397 @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0102L
4398 @SYMTestCaseDesc Quick demonstration of square app modes in all 4 rotations
4401 @SYMTestType CT (manual visual test)
4402 @SYMTestPurpose To show square app mode in all 4 rotations
4404 Draw a blue box showing the full size and position of the app mode.
4405 Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
4407 Green borders at the edge of the appmode, to show we are drawing up to the edges of the
4409 @SYMTestExpectedResults
4410 Blue window should represent appmode (with offset and size)
4411 Red windows should be visible across screen
4412 Green border (made of windows) around the appmode (blue window)
4414 void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L()
4416 RArray<TInt> screenModeList;
4417 iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
4422 for (res=0;res<screenModeList.Count();res++)
4424 iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
4425 iInfoScreenDevice->SetScreenMode(screenModeList[res]);
4427 iSession.Finish(ETrue);
4431 TPixelsAndRotation pr;
4432 iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
4433 if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth)
4435 //found square appmode
4440 for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++)
4442 iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation);
4445 TDisplayConfiguration dispConfigReq;
4446 TSize appSize = iInfoScreenDevice->SizeInPixels();
4447 RWindow backWindow(iSession);
4448 ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
4449 backWindow.SetRequiredDisplayMode(iDisplayMode);
4450 backWindow.SetBackgroundColor(iBlue);
4451 backWindow.SetExtent(TPoint(0,0),appSize); //shows size of the apparea
4452 backWindow.Activate();
4453 DrawPlainUI(backWindow,ETrue,iBlue);
4457 RWindow longWindow1(iSession);
4458 ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
4459 longWindow1.SetRequiredDisplayMode(iDisplayMode);
4460 longWindow1.SetBackgroundColor(iRed);
4461 longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea
4462 longWindow1.Activate();
4463 DrawPlainUI(longWindow1,ETrue,iRed);
4465 iBackground.SetColor(TRgb(0x001000*res|0x800000));
4466 iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
4470 RWindow longWindow2(iSession);
4471 ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
4472 longWindow2.SetRequiredDisplayMode(iDisplayMode);
4473 longWindow2.SetBackgroundColor(iRed);
4474 longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea
4475 longWindow2.Activate();
4476 DrawPlainUI(longWindow2,ETrue,iRed);
4479 RWindow borderTop(iSession);
4480 ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
4481 borderTop.SetRequiredDisplayMode(iDisplayMode);
4482 borderTop.SetBackgroundColor(iGreen);
4483 borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border
4484 borderTop.Activate();
4485 DrawPlainUI(borderTop,ETrue,iGreen);
4487 RWindow borderLeft(iSession);
4488 ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
4489 borderLeft.SetRequiredDisplayMode(iDisplayMode);
4490 borderLeft.SetBackgroundColor(iGreen);
4491 borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border
4492 borderLeft.Activate();
4493 DrawPlainUI(borderLeft,ETrue,iGreen);
4495 RWindow borderRight(iSession);
4496 ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
4497 borderRight.SetRequiredDisplayMode(iDisplayMode);
4498 borderRight.SetBackgroundColor(iGreen);
4499 borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border
4500 borderRight.Activate();
4501 DrawPlainUI(borderRight,ETrue,iGreen);
4503 RWindow borderBottom(iSession);
4504 ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
4505 borderBottom.SetRequiredDisplayMode(iDisplayMode);
4506 borderBottom.SetBackgroundColor(iGreen);
4507 borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border
4508 borderBottom.Activate();
4509 DrawPlainUI(borderBottom,ETrue,iGreen);
4515 longWindow1.Close();
4516 longWindow2.Close();
4519 borderRight.Close();
4520 borderBottom.Close();
4528 screenModeList.Close();
4529 iInfoScreenDevice->SetAppScreenMode(0);
4530 iInfoScreenDevice->SetScreenMode(0);
4531 iSession.Finish(ETrue);