sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @file sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "cwsgcecsc.h" sl@0: #include "extendtef.h" sl@0: #include "teflogextensions.h" sl@0: #include "testscreencapture.h" sl@0: sl@0: sl@0: #if defined(__X86GCC__) sl@0: extern "C" TInt atexit(void (*function)(void)) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: #endif sl@0: sl@0: void TefUnitFailLeaveL() sl@0: { sl@0: User::Leave(KErrTEFUnitFail); sl@0: } sl@0: sl@0: CWSGceCsc::CWSGceCsc() sl@0: { sl@0: } sl@0: sl@0: CWSGceCsc::~CWSGceCsc() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Common set up code for all tests. sl@0: sl@0: Creates the session and window group for further windows, plus a simple white sl@0: background to obscure any unwanted stuff behind the test. Sets up the surface sl@0: update session and surface manager, to work with surfaces. Creates a screen sl@0: device for use in the tests. sl@0: */ sl@0: void CWSGceCsc::SetupL() sl@0: { sl@0: CWsGceCscBase::SetupL(); sl@0: } sl@0: sl@0: /** sl@0: Common tear down code for all tests. sl@0: sl@0: Windows, group and session created are closed. Screen device is destroyed. sl@0: Surfaces, manager and update session are closed. sl@0: */ sl@0: void CWSGceCsc::TearDownL() sl@0: { sl@0: CWsGceCscBase::TearDownL(); sl@0: } sl@0: sl@0: CTestSuite* CWSGceCsc::CreateSuiteL( const TDesC& aName) sl@0: { sl@0: SUB_SUITE; sl@0: ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_101L); sl@0: ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_102L); sl@0: ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_103L); sl@0: ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_104L); sl@0: ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_105L); sl@0: END_SUITE; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_CSC_101L sl@0: sl@0: @SYMTestCaseDesc Compare the screen composition using the new and legacy API sl@0: sl@0: @SYMPREQ CSC sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs sl@0: sl@0: @SYMTestActions Initialization. sl@0: Construct a background opaque window. sl@0: Create two bitmaps with the size equal with the composition. sl@0: Draw something on the screen. sl@0: Use legacy API CopyScreenToBitmap() to copy the screen to first bitmap. sl@0: Use the the new API to copy the composition of the screen. sl@0: Compare the results. sl@0: sl@0: @SYMTestExpectedResults The bitmap should be identical sl@0: */ sl@0: void CWSGceCsc::GRAPHICS_WSERV_CSC_101L() sl@0: { sl@0: TRect screen(iScreenDevice->SizeInPixels()); sl@0: RWindow nonSurfacedWindow(iSession); sl@0: iTestName.Format(_L("GRAPHICS_WSERV_CSC_101L")); sl@0: sl@0: INFO_PRINTF2(_L("%S"),&iTestName); sl@0: iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode sl@0: sl@0: ConstructOpaqueWindowLC(nonSurfacedWindow, sl@0: iCyan, sl@0: 0, sl@0: TPoint(0, 0), sl@0: screen.Size()); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: sl@0: MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: ASSERT_NOT_NULL(csc); sl@0: sl@0: TSize compositionScreenSize; sl@0: sl@0: User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); sl@0: sl@0: CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp1); sl@0: User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: iSession.Flush(); sl@0: Pause(200); sl@0: sl@0: iScreenDevice->CopyScreenToBitmap(bmp1); sl@0: User::LeaveIfError(csc->ComposeScreen(*bmp2)); sl@0: sl@0: SetBackgroundColorWindow(nonSurfacedWindow, iRed); sl@0: iSession.Flush(); sl@0: sl@0: Pause(500); sl@0: sl@0: iGc->Activate(nonSurfacedWindow); sl@0: iGc->BitBlt(TPoint(0, 0), bmp1); sl@0: iGc->Deactivate(); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: SetBackgroundColorWindow(nonSurfacedWindow, iWhite); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: iGc->Activate(nonSurfacedWindow); sl@0: iGc->BitBlt(TPoint(0, 0), bmp2); sl@0: iGc->Deactivate(); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: ASSERT_TRUE(Compare(*bmp1, *bmp2)); sl@0: sl@0: if (GCEIsSupported()) sl@0: { sl@0: iUtility->DestroyAll(); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: CleanupStack::PopAndDestroy(bmp1); sl@0: CleanupStack::PopAndDestroy(&nonSurfacedWindow); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: } sl@0: sl@0: void CWSGceCsc::DrawBasicPattern (RWindow& aWin) sl@0: { sl@0: TSize rectSize(100, 100); sl@0: aWin.Invalidate(); sl@0: aWin.BeginRedraw(); sl@0: iGc->Activate(aWin); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(KRgbDarkRed); sl@0: iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); sl@0: iGc->SetBrushColor(KRgbBlack); sl@0: iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); sl@0: iGc->SetBrushColor(KRgbDarkBlue); sl@0: iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); sl@0: iGc->SetBrushColor(KRgbYellow); sl@0: iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); sl@0: iGc->Deactivate(); sl@0: aWin.EndRedraw(); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_CSC_102L sl@0: sl@0: @SYMTestCaseDesc Compare the screen composition using the new and legacy API sl@0: sl@0: @SYMPREQ CSC sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs sl@0: sl@0: @SYMTestActions Initialization. sl@0: Draw a pattern on the screen sl@0: Retrieve to a bitmap the UI content using the legacy API sl@0: Blank the screen. sl@0: Display the retrieved content to a surface sl@0: Retrieve the composited content sl@0: Compare the UI content with the composited content sl@0: NOTE:assumes current screen mode is at 0 offset sl@0: sl@0: @SYMTestExpectedResults The UI content should be identical with the composited content sl@0: */ sl@0: void CWSGceCsc::GRAPHICS_WSERV_CSC_102L() sl@0: { sl@0: TRect screen(iScreenDevice->SizeInPixels()); sl@0: RWindow testWindow(iSession); sl@0: RWindow surfacedTestWindow(iSession); sl@0: TSurfaceId surfaceID; sl@0: sl@0: MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: ASSERT_NOT_NULL(csc); sl@0: sl@0: TSize compositionScreenSize; sl@0: User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); sl@0: sl@0: iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); sl@0: INFO_PRINTF2(_L("%S"),&iTestName); sl@0: sl@0: iDisplayMode = iScreenDevice->DisplayMode(); sl@0: sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, sl@0: KSurfaceFormat, sl@0: compositionScreenSize.iWidth * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: ConstructOpaqueWindowLC(testWindow, sl@0: iWhite, sl@0: 0, sl@0: TPoint(0, 0), sl@0: compositionScreenSize); sl@0: sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp1); sl@0: User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: SetBackgroundColorWindow(testWindow, iWhite); sl@0: DrawBasicPattern (testWindow); sl@0: sl@0: iScreenDevice->CopyScreenToBitmap(bmp1); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, sl@0: iRed, sl@0: 0, sl@0: TPoint(0, 0), sl@0: compositionScreenSize, sl@0: surfaceID); sl@0: sl@0: TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: User::LeaveIfError(csc->ComposeScreen(*bmp2)); sl@0: sl@0: ASSERT_TRUE(Compare(*bmp1, *bmp2)); sl@0: sl@0: iUtility->DestroyAll(); sl@0: CleanupStack::PopAndDestroy(&surfacedTestWindow); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: CleanupStack::PopAndDestroy(bmp1); sl@0: CleanupStack::PopAndDestroy(&testWindow); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_CSC_103L sl@0: sl@0: @SYMTestCaseDesc Test TranslateExtent sl@0: sl@0: @SYMPREQ CSC sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestPurpose To check that the correct translated extent is returned to the client sl@0: sl@0: @SYMTestActions Initialization sl@0: Change to app mode with offset and 90 degrees rotation sl@0: Translate a rectangle corresponding to the original app mode sl@0: Compare the expected rectangle with the translated rectangle sl@0: sl@0: @SYMTestExpectedResults The translated rectangle should take into account the offset and rotation sl@0: and be equal to the expected rectangle sl@0: */ sl@0: void CWSGceCsc::GRAPHICS_WSERV_CSC_103L() sl@0: { sl@0: TRect screen(iScreenDevice->SizeInPixels()); sl@0: RWindow testWindow(iSession); sl@0: sl@0: iTestName.Format(_L("GRAPHICS_WSERV_CSC_103L")); sl@0: INFO_PRINTF2(_L("%S"),&iTestName); sl@0: sl@0: iDisplayMode = iScreenDevice->DisplayMode(); sl@0: sl@0: ConstructOpaqueWindowLC(testWindow, sl@0: iWhite, sl@0: 0, sl@0: TPoint(0, 0), sl@0: screen.Size()); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: sl@0: // Get the screen modes sl@0: RArray modeList; sl@0: TInt err = iScreenDevice->GetScreenSizeModeList(&modeList); sl@0: ASSERT_TRUE(err > 1); //2 modes expected sl@0: ASSERT_TRUE(modeList.Count() > 1); //2 modes expected sl@0: sl@0: // The initial extent and the expected translated extent sl@0: TRect initial(TPoint(10,10), TSize(20,30)); sl@0: TRect extent(initial); sl@0: TRect expected(TPoint(15,15), TSize(20,30)); sl@0: sl@0: // Change app mode to 5 pixels offset sl@0: iScreenDevice->SetAppScreenMode(modeList[1]); sl@0: iScreenDevice->SetScreenMode(modeList[1]); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: TPoint origin = iScreenDevice->GetCurrentScreenModeScaledOrigin(); sl@0: if(origin != TPoint(0,0)) sl@0: { sl@0: // Calculate the new extent sl@0: MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: ASSERT_NOT_NULL(csc); sl@0: csc->TranslateExtent(initial, extent); sl@0: ASSERT_TRUE(extent == expected); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Non zero offset not supported")); sl@0: } sl@0: // Change app mode sl@0: iScreenDevice->SetAppScreenMode(modeList[0]); sl@0: iScreenDevice->SetScreenMode(modeList[0]); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: modeList.Close(); sl@0: CleanupStack::PopAndDestroy(&testWindow); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_CSC_104L sl@0: sl@0: @SYMTestCaseDesc Compare the screen composition using bitmaps with different display modes sl@0: sl@0: @SYMPREQ CSC sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestPurpose To check that bitmaps with different display modes sl@0: sl@0: @SYMTestActions Initialization. sl@0: Draw a pattern on the screen sl@0: Retrieve to a bitmap the UI content using the legacy API sl@0: Blank the screen. sl@0: Display the retrieved content to a surface sl@0: Retrieve the composited content to a 2nd bitmap sl@0: Compare the UI content with the composited content sl@0: sl@0: @SYMTestExpectedResults The bitmaps format should not match and should return KErrArgument sl@0: */ sl@0: void CWSGceCsc::GRAPHICS_WSERV_CSC_104L() sl@0: { sl@0: TRect screen(iScreenDevice->SizeInPixels()); sl@0: RWindow testWindow(iSession); sl@0: RWindow surfacedTestWindow(iSession); sl@0: TSurfaceId surfaceID; sl@0: sl@0: MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: ASSERT_NOT_NULL(csc); sl@0: sl@0: TSize compositionScreenSize; sl@0: User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); sl@0: sl@0: iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); sl@0: INFO_PRINTF2(_L("%S"),&iTestName); sl@0: sl@0: iDisplayMode = iScreenDevice->DisplayMode(); sl@0: sl@0: TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, sl@0: KSurfaceFormat, sl@0: compositionScreenSize.iWidth * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: sl@0: ConstructOpaqueWindowLC(testWindow, sl@0: iWhite, sl@0: 0, sl@0: TPoint(0, 0), sl@0: compositionScreenSize); sl@0: sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp1); sl@0: User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: // Invalid bitmap display mode sl@0: CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor256)); sl@0: sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: // Draw a pattern using WServ sl@0: SetBackgroundColorWindow(testWindow, iWhite); sl@0: sl@0: TSize rectSize(100, 100); sl@0: testWindow.Invalidate(); sl@0: testWindow.BeginRedraw(); sl@0: iGc->Activate(testWindow); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(KRgbDarkRed); sl@0: iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); sl@0: iGc->SetBrushColor(KRgbBlack); sl@0: iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); sl@0: iGc->SetBrushColor(KRgbDarkBlue); sl@0: iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); sl@0: iGc->SetBrushColor(KRgbYellow); sl@0: iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); sl@0: iGc->Deactivate(); sl@0: testWindow.EndRedraw(); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: iScreenDevice->CopyScreenToBitmap(bmp1); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, sl@0: iRed, sl@0: 0, sl@0: TPoint(0, 0), sl@0: compositionScreenSize, sl@0: surfaceID); sl@0: sl@0: TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(500); sl@0: sl@0: // negative test, it should fail wit KErrArgument sl@0: TInt ret = csc->ComposeScreen(*bmp2); sl@0: ASSERT_EQUALS(ret, KErrArgument); sl@0: sl@0: iUtility->DestroyAll(); sl@0: CleanupStack::PopAndDestroy(&surfacedTestWindow); sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: CleanupStack::PopAndDestroy(bmp1); sl@0: CleanupStack::PopAndDestroy(&testWindow); sl@0: iSession.Flush(); sl@0: Pause(1000); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_WSERV_CSC_105L sl@0: @SYMTestCaseDesc Correct bitmap size returned when in small screen mode sl@0: @SYMDEF DEF139191 sl@0: @SYMPREQ CSC sl@0: @SYMTestStatus Implemented sl@0: @SYMTestPriority 1 sl@0: @SYMTestPurpose Checking GetCompositedSize is correct on gce & acceptable behaviour in non gce mode sl@0: @SYMTestActions For every available screen mode sl@0: Get size from GetCompositedSize sl@0: Draw some coloured rectangles on screen sl@0: If gce, do a full screen surface, and paste the coloured rectangles into the surface sl@0: ComposeScreen - bitmap 1 should be the same as bitmap 2 sl@0: Note - non GCE mode - GetCompositedSize returns unrotated appmode size, so only sl@0: compares the intersection of that with actual screen size sl@0: Note - gce mode - GetCompositedSize returns actual rotated screen size, so sl@0: does a complete screen comparison sl@0: @SYMTestExpectedResults All asserts should complete. Comparison should succeed! sl@0: */ sl@0: void CWSGceCsc::GRAPHICS_WSERV_CSC_105L() sl@0: { sl@0: iTestName.Format(_L("GRAPHICS_WSERV_CSC_105")); sl@0: INFO_PRINTF2(_L("%S"),&iTestName); sl@0: TInt err; sl@0: //get list of modes sl@0: RArray screenModes; sl@0: err = iScreenDevice->GetScreenSizeModeList(&screenModes); sl@0: ASSERT_TRUE (err > 0); sl@0: //get first mode info sl@0: TPixelsAndRotation firstModeInfo; sl@0: iScreenDevice->GetScreenModeSizeAndRotation(screenModes[0],firstModeInfo); sl@0: sl@0: //make sure csc is available sl@0: MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); sl@0: ASSERT_NOT_NULL(csc); sl@0: sl@0: TBool differentSizes = EFalse; sl@0: TSizeMode currentModeInfo; sl@0: TSize compositionScreenSize; sl@0: //for every screen mode sl@0: for (TInt ii = 0; ii < screenModes.Count(); ++ii && !differentSizes) sl@0: { sl@0: //set mode sl@0: iScreenDevice->SetAppScreenMode(screenModes[ii]); sl@0: iScreenDevice->SetScreenMode(screenModes[ii]); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: //get mode info sl@0: currentModeInfo = iScreenDevice->GetCurrentScreenModeAttributes(); sl@0: if (currentModeInfo.iScreenSize.iWidth != firstModeInfo.iPixelSize.iWidth || sl@0: currentModeInfo.iScreenSize.iHeight != firstModeInfo.iPixelSize.iHeight || sl@0: currentModeInfo.iRotation != firstModeInfo.iRotation) sl@0: { //note that we have modes of different sizes / rotations sl@0: differentSizes = ETrue; sl@0: } sl@0: sl@0: RWindow testWindow(iSession); sl@0: RWindow surfacedTestWindow(iSession); sl@0: TSurfaceId surfaceID; sl@0: sl@0: err = csc->GetCompositedSize(compositionScreenSize); sl@0: ASSERT_EQUALS (err,KErrNone); sl@0: iDisplayMode = iScreenDevice->DisplayMode(); sl@0: sl@0: if (GCEIsSupported()) sl@0: { //create a surface sl@0: TRAP(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, sl@0: KSurfaceFormat, sl@0: compositionScreenSize.iWidth * KBytesPerPixel)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: } sl@0: sl@0: //create a basic window sl@0: ConstructOpaqueWindowLC(testWindow, sl@0: iWhite, sl@0: 0, sl@0: -currentModeInfo.iOrigin, sl@0: compositionScreenSize); //negative origin to ensure it fills screen, not app mode area sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: //bitmap 1 to compare against sl@0: CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp1); sl@0: User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); sl@0: //bitmap 2 to pass into csc sl@0: CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bmp2); sl@0: User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); sl@0: sl@0: //draw coloured rectangles in the test window sl@0: SetBackgroundColorWindow(testWindow, iWhite); sl@0: DrawBasicPattern (testWindow); sl@0: sl@0: //copy screen to bitmap 1 sl@0: err = iScreenDevice->CopyScreenToBitmap(bmp1); sl@0: ASSERT_EQUALS (err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(100); sl@0: sl@0: if (GCEIsSupported()) sl@0: { //place a window with a surface into the screen sl@0: ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, sl@0: iRed, sl@0: 0, sl@0: -currentModeInfo.iOrigin, sl@0: compositionScreenSize, sl@0: surfaceID); //negative origin to ensure it fills screen,not app mode area sl@0: sl@0: //make surface boring cyan sl@0: TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(300); sl@0: sl@0: //paste bitmap 1 contents into the surface sl@0: TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); sl@0: ASSERT_EQUALS(err,KErrNone); sl@0: iSession.Flush(); sl@0: Pause(300); sl@0: } sl@0: sl@0: //use csc to get a copy of the screen sl@0: err = csc->ComposeScreen(*bmp2); sl@0: ASSERT_EQUALS (err, KErrNone); sl@0: sl@0: //should match the original bitmap copy of the screen sl@0: ASSERT_TRUE(Compare(*bmp1, *bmp2)); sl@0: sl@0: if (GCEIsSupported()) sl@0: { sl@0: iUtility->DestroyAll(); sl@0: CleanupStack::PopAndDestroy(&surfacedTestWindow); sl@0: } sl@0: else sl@0: { sl@0: surfacedTestWindow.Close(); sl@0: } sl@0: CleanupStack::PopAndDestroy(bmp2); sl@0: CleanupStack::PopAndDestroy(bmp1); sl@0: CleanupStack::PopAndDestroy(&testWindow); sl@0: iSession.Flush(); sl@0: Pause(300); sl@0: } sl@0: if (!differentSizes) sl@0: { sl@0: INFO_PRINTF1(_L("Didn't find screen modes of different sizes - test inconclusive")); sl@0: } sl@0: iScreenDevice->SetAppScreenMode(screenModes[0]); sl@0: iScreenDevice->SetScreenMode(screenModes[0]); sl@0: screenModes.Close(); sl@0: }