os/graphics/windowing/windowserver/test/tcsc/cwsgcecsc.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tcsc/cwsgcecsc.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,656 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// @file
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <w32std.h>
    1.22 +#include <e32std.h>
    1.23 +#include "cwsgcecsc.h"
    1.24 +#include "extendtef.h"
    1.25 +#include "teflogextensions.h"
    1.26 +#include "testscreencapture.h"
    1.27 +
    1.28 +
    1.29 +#if defined(__X86GCC__)
    1.30 +extern "C" TInt atexit(void (*function)(void))
    1.31 +	{
    1.32 +	return KErrNone;
    1.33 +	}
    1.34 +#endif
    1.35 +
    1.36 +void TefUnitFailLeaveL()
    1.37 +	{
    1.38 +	User::Leave(KErrTEFUnitFail);
    1.39 +	}
    1.40 +
    1.41 +CWSGceCsc::CWSGceCsc()
    1.42 +	{
    1.43 +	}
    1.44 +
    1.45 +CWSGceCsc::~CWSGceCsc()
    1.46 +	{
    1.47 +	}
    1.48 +
    1.49 +/**
    1.50 +Common set up code for all tests.
    1.51 +
    1.52 +Creates the session and window group for further windows, plus a simple white
    1.53 +background to obscure any unwanted stuff behind the test. Sets up the surface
    1.54 +update session and surface manager, to work with surfaces. Creates a screen
    1.55 +device for use in the tests.
    1.56 +*/
    1.57 +void CWSGceCsc::SetupL()
    1.58 +	{
    1.59 +	CWsGceCscBase::SetupL();
    1.60 +	}
    1.61 +
    1.62 +/**
    1.63 +Common tear down code for all tests.
    1.64 +
    1.65 +Windows, group and session created are closed. Screen device is destroyed.
    1.66 +Surfaces, manager and update session are closed.
    1.67 +*/
    1.68 +void CWSGceCsc::TearDownL()
    1.69 +	{
    1.70 +	CWsGceCscBase::TearDownL();
    1.71 +	}
    1.72 +
    1.73 +CTestSuite* CWSGceCsc::CreateSuiteL( const TDesC& aName)
    1.74 +	{
    1.75 +	SUB_SUITE;
    1.76 +	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_101L);
    1.77 +	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_102L);
    1.78 +	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_103L);
    1.79 +	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_104L);
    1.80 +	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_105L);
    1.81 +	END_SUITE;
    1.82 +	}
    1.83 +
    1.84 +/**
    1.85 + @SYMTestCaseID			GRAPHICS_WSERV_CSC_101L
    1.86 + 
    1.87 + @SYMTestCaseDesc		Compare the screen composition using the new and legacy API
    1.88 + 						
    1.89 + @SYMPREQ				CSC
    1.90 + 
    1.91 + @SYMTestStatus			Implemented
    1.92 + 
    1.93 + @SYMTestPriority		1
    1.94 + 
    1.95 + @SYMTestPurpose		To check that the screen composition retrieved using the new and legacy APIs
    1.96 +
    1.97 + @SYMTestActions		Initialization.
    1.98 +						Construct a background opaque window.
    1.99 +						Create two bitmaps with the size equal with the composition.
   1.100 +						Draw something on the screen.
   1.101 +						Use legacy API CopyScreenToBitmap() to copy the screen to first bitmap.
   1.102 +						Use the the new API to copy the composition of the screen.
   1.103 +						Compare the results.
   1.104 + 
   1.105 + @SYMTestExpectedResults  The bitmap should be identical	 
   1.106 +*/
   1.107 +void CWSGceCsc::GRAPHICS_WSERV_CSC_101L()
   1.108 +	{
   1.109 +	TRect screen(iScreenDevice->SizeInPixels());
   1.110 +	RWindow nonSurfacedWindow(iSession);
   1.111 +	iTestName.Format(_L("GRAPHICS_WSERV_CSC_101L"));
   1.112 +
   1.113 +	INFO_PRINTF2(_L("%S"),&iTestName);
   1.114 +	iDisplayMode = iScreenDevice->DisplayMode();	// Get default display mode
   1.115 +
   1.116 +	ConstructOpaqueWindowLC(nonSurfacedWindow, 
   1.117 +			                iCyan, 
   1.118 +		                    0, 
   1.119 +                            TPoint(0, 0),
   1.120 +                            screen.Size());
   1.121 +	iSession.Flush();
   1.122 +	Pause(1000);
   1.123 +
   1.124 +	MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.125 +    ASSERT_NOT_NULL(csc);
   1.126 +
   1.127 +	TSize compositionScreenSize;
   1.128 +	
   1.129 +	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
   1.130 +	
   1.131 +    CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
   1.132 +    CleanupStack::PushL(bmp1);
   1.133 +    User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
   1.134 +    
   1.135 +    CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
   1.136 +    CleanupStack::PushL(bmp2);
   1.137 +	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
   1.138 +	
   1.139 +	iSession.Flush();
   1.140 +	Pause(200);
   1.141 +	
   1.142 +	iScreenDevice->CopyScreenToBitmap(bmp1);
   1.143 +	User::LeaveIfError(csc->ComposeScreen(*bmp2));
   1.144 +	
   1.145 +	SetBackgroundColorWindow(nonSurfacedWindow, iRed);
   1.146 +	iSession.Flush();
   1.147 +	
   1.148 +	Pause(500);
   1.149 +	
   1.150 +	iGc->Activate(nonSurfacedWindow);
   1.151 +	iGc->BitBlt(TPoint(0, 0), bmp1);
   1.152 +	iGc->Deactivate();
   1.153 +	iSession.Flush();
   1.154 +	Pause(500);
   1.155 +	
   1.156 +	SetBackgroundColorWindow(nonSurfacedWindow, iWhite);
   1.157 +	iSession.Flush();
   1.158 +	Pause(500);
   1.159 +	
   1.160 +	iGc->Activate(nonSurfacedWindow);
   1.161 +	iGc->BitBlt(TPoint(0, 0), bmp2);
   1.162 +	iGc->Deactivate();
   1.163 +	iSession.Flush();
   1.164 +	Pause(500);
   1.165 +
   1.166 +    ASSERT_TRUE(Compare(*bmp1, *bmp2));    
   1.167 +	
   1.168 +	if (GCEIsSupported())
   1.169 +		{
   1.170 +		iUtility->DestroyAll();
   1.171 +		}
   1.172 +	
   1.173 +	CleanupStack::PopAndDestroy(bmp2);
   1.174 +	CleanupStack::PopAndDestroy(bmp1);
   1.175 +	CleanupStack::PopAndDestroy(&nonSurfacedWindow);
   1.176 +	iSession.Flush();
   1.177 +	Pause(1000);
   1.178 +	}
   1.179 +
   1.180 +void CWSGceCsc::DrawBasicPattern (RWindow& aWin)
   1.181 +    {
   1.182 +    TSize rectSize(100, 100);
   1.183 +    aWin.Invalidate();
   1.184 +    aWin.BeginRedraw();
   1.185 +    iGc->Activate(aWin);
   1.186 +    iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.187 +    iGc->SetBrushColor(KRgbDarkRed);
   1.188 +    iGc->DrawRect(TRect(TPoint(35, 5), rectSize));
   1.189 +    iGc->SetBrushColor(KRgbBlack);
   1.190 +    iGc->DrawRect(TRect(TPoint(55, 15), rectSize));
   1.191 +    iGc->SetBrushColor(KRgbDarkBlue);
   1.192 +    iGc->DrawRect(TRect(TPoint(75, 35), rectSize));
   1.193 +    iGc->SetBrushColor(KRgbYellow);
   1.194 +    iGc->DrawRect(TRect(TPoint(95, 55), rectSize));
   1.195 +    iGc->Deactivate();
   1.196 +    aWin.EndRedraw();
   1.197 +    iSession.Flush();
   1.198 +    Pause(500);
   1.199 +    }
   1.200 +
   1.201 +/**
   1.202 + @SYMTestCaseID			GRAPHICS_WSERV_CSC_102L
   1.203 + 
   1.204 + @SYMTestCaseDesc		Compare the screen composition using the new and legacy API
   1.205 + 						
   1.206 + @SYMPREQ				CSC
   1.207 + 
   1.208 + @SYMTestStatus			Implemented
   1.209 + 
   1.210 + @SYMTestPriority		1
   1.211 + 
   1.212 + @SYMTestPurpose		To check that the screen composition retrieved using the new and legacy APIs 
   1.213 +
   1.214 + @SYMTestActions		Initialization.
   1.215 + 						Draw a pattern on the screen
   1.216 + 						Retrieve to a bitmap the UI content using the legacy API
   1.217 + 						Blank the screen.
   1.218 + 						Display the retrieved content to a surface
   1.219 + 						Retrieve the composited content
   1.220 + 						Compare the UI content with the composited content
   1.221 + 						NOTE:assumes current screen mode is at 0 offset
   1.222 + 
   1.223 + @SYMTestExpectedResults  The UI content should be identical with the composited content	 
   1.224 +*/
   1.225 +void CWSGceCsc::GRAPHICS_WSERV_CSC_102L()
   1.226 +	{
   1.227 +	TRect screen(iScreenDevice->SizeInPixels());
   1.228 +	RWindow testWindow(iSession);
   1.229 +	RWindow surfacedTestWindow(iSession);
   1.230 +	TSurfaceId surfaceID;
   1.231 +
   1.232 +    MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.233 +    ASSERT_NOT_NULL(csc);
   1.234 +	
   1.235 +	TSize compositionScreenSize;
   1.236 +	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
   1.237 +	
   1.238 +	iTestName.Format(_L("GRAPHICS_WSERV_CSC_102"));
   1.239 +	INFO_PRINTF2(_L("%S"),&iTestName);
   1.240 +	
   1.241 +	iDisplayMode = iScreenDevice->DisplayMode();
   1.242 +
   1.243 +	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
   1.244 +			                                        KSurfaceFormat, 
   1.245 +			                                        compositionScreenSize.iWidth * KBytesPerPixel));
   1.246 +	ASSERT_EQUALS(err,KErrNone);
   1.247 +	
   1.248 +	ConstructOpaqueWindowLC(testWindow, 
   1.249 +			                iWhite, 
   1.250 +		                    0, 
   1.251 +                            TPoint(0, 0),
   1.252 +                            compositionScreenSize);
   1.253 +
   1.254 +	iSession.Flush();
   1.255 +	Pause(100);
   1.256 +	
   1.257 +	CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
   1.258 +	CleanupStack::PushL(bmp1);
   1.259 +	User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
   1.260 +	
   1.261 +	CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
   1.262 +	CleanupStack::PushL(bmp2);
   1.263 +	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
   1.264 +	
   1.265 +	iSession.Flush();
   1.266 +	Pause(500);
   1.267 +
   1.268 +	SetBackgroundColorWindow(testWindow, iWhite);
   1.269 +	DrawBasicPattern (testWindow);
   1.270 +	
   1.271 +	iScreenDevice->CopyScreenToBitmap(bmp1);
   1.272 +	iSession.Flush();
   1.273 +    Pause(100);
   1.274 +    
   1.275 +	ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
   1.276 +			                        iRed,
   1.277 +		                            0,
   1.278 +		                            TPoint(0, 0),
   1.279 +		                            compositionScreenSize,
   1.280 +		                            surfaceID);
   1.281 +	
   1.282 +	TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
   1.283 +	ASSERT_EQUALS(err,KErrNone);
   1.284 +	iSession.Flush();
   1.285 +    Pause(500);
   1.286 +    
   1.287 +	TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
   1.288 +	ASSERT_EQUALS(err,KErrNone);
   1.289 +	iSession.Flush();
   1.290 +    Pause(500);
   1.291 +
   1.292 +	User::LeaveIfError(csc->ComposeScreen(*bmp2));
   1.293 +    
   1.294 +    ASSERT_TRUE(Compare(*bmp1, *bmp2));    
   1.295 +	
   1.296 +	iUtility->DestroyAll();
   1.297 +	CleanupStack::PopAndDestroy(&surfacedTestWindow);
   1.298 +	CleanupStack::PopAndDestroy(bmp2);
   1.299 +	CleanupStack::PopAndDestroy(bmp1);
   1.300 +	CleanupStack::PopAndDestroy(&testWindow);
   1.301 +	iSession.Flush();
   1.302 +	Pause(1000);
   1.303 +	}
   1.304 +
   1.305 +/**
   1.306 + @SYMTestCaseID			GRAPHICS_WSERV_CSC_103L
   1.307 + 
   1.308 + @SYMTestCaseDesc		Test TranslateExtent
   1.309 + 						
   1.310 + @SYMPREQ				CSC
   1.311 + 
   1.312 + @SYMTestStatus			Implemented
   1.313 + 
   1.314 + @SYMTestPriority		1
   1.315 + 
   1.316 + @SYMTestPurpose		To check that the correct translated extent is returned to the client 
   1.317 +
   1.318 + @SYMTestActions		Initialization
   1.319 + 						Change to app mode with offset and 90 degrees rotation
   1.320 + 						Translate a rectangle corresponding to the original app mode
   1.321 + 						Compare the expected rectangle with the translated rectangle
   1.322 + 
   1.323 + @SYMTestExpectedResults  The translated rectangle should take into account the offset and rotation
   1.324 +							and be equal to the expected rectangle
   1.325 +*/
   1.326 +void CWSGceCsc::GRAPHICS_WSERV_CSC_103L()
   1.327 +	{
   1.328 +	TRect screen(iScreenDevice->SizeInPixels());
   1.329 +	RWindow testWindow(iSession);
   1.330 +	
   1.331 +	iTestName.Format(_L("GRAPHICS_WSERV_CSC_103L"));
   1.332 +	INFO_PRINTF2(_L("%S"),&iTestName);
   1.333 +	
   1.334 +	iDisplayMode = iScreenDevice->DisplayMode();
   1.335 +	
   1.336 +	ConstructOpaqueWindowLC(testWindow, 
   1.337 +			                iWhite, 
   1.338 +		                    0, 
   1.339 +                            TPoint(0, 0),
   1.340 +                            screen.Size());
   1.341 +	iSession.Flush();
   1.342 +	Pause(1000);
   1.343 +
   1.344 +	// Get the screen modes
   1.345 +	RArray<TInt> modeList;
   1.346 +	TInt err = iScreenDevice->GetScreenSizeModeList(&modeList);
   1.347 +	ASSERT_TRUE(err > 1);  //2 modes expected
   1.348 +	ASSERT_TRUE(modeList.Count() > 1); //2 modes expected
   1.349 +	
   1.350 +	// The initial extent and the expected translated extent
   1.351 +	TRect initial(TPoint(10,10), TSize(20,30));
   1.352 +	TRect extent(initial);
   1.353 +	TRect expected(TPoint(15,15), TSize(20,30));
   1.354 +	
   1.355 +	// Change app mode to 5 pixels offset
   1.356 +	iScreenDevice->SetAppScreenMode(modeList[1]);
   1.357 +	iScreenDevice->SetScreenMode(modeList[1]);
   1.358 +	iSession.Flush();
   1.359 +	Pause(100);
   1.360 +
   1.361 +	TPoint origin = iScreenDevice->GetCurrentScreenModeScaledOrigin();
   1.362 +	if(origin != TPoint(0,0))
   1.363 +		{
   1.364 +		// Calculate the new extent
   1.365 +	    MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.366 +	    ASSERT_NOT_NULL(csc);
   1.367 +		csc->TranslateExtent(initial, extent);	
   1.368 +		ASSERT_TRUE(extent == expected); 
   1.369 +		}
   1.370 +	else
   1.371 +		{
   1.372 +		INFO_PRINTF1(_L("Non zero offset not supported"));
   1.373 +		}
   1.374 +    // Change app mode
   1.375 +    iScreenDevice->SetAppScreenMode(modeList[0]);
   1.376 +    iScreenDevice->SetScreenMode(modeList[0]);
   1.377 +    iSession.Flush();
   1.378 +    Pause(100);
   1.379 +
   1.380 +    modeList.Close();
   1.381 +	CleanupStack::PopAndDestroy(&testWindow);
   1.382 +	iSession.Flush();
   1.383 +	Pause(1000);
   1.384 +	}
   1.385 +
   1.386 +/**
   1.387 + @SYMTestCaseID			GRAPHICS_WSERV_CSC_104L
   1.388 + 
   1.389 + @SYMTestCaseDesc		Compare the screen composition using bitmaps with different display modes
   1.390 + 						
   1.391 + @SYMPREQ				CSC
   1.392 + 
   1.393 + @SYMTestStatus			Implemented
   1.394 + 
   1.395 + @SYMTestPriority		1
   1.396 + 
   1.397 + @SYMTestPurpose		To check that bitmaps with different display modes  
   1.398 +
   1.399 + @SYMTestActions		Initialization.
   1.400 + 						Draw a pattern on the screen
   1.401 + 						Retrieve to a bitmap the UI content using the legacy API
   1.402 + 						Blank the screen.
   1.403 + 						Display the retrieved content to a surface
   1.404 + 						Retrieve the composited content to a 2nd bitmap
   1.405 + 						Compare the UI content with the composited content
   1.406 + 
   1.407 + @SYMTestExpectedResults  The bitmaps format should not match and should return KErrArgument 
   1.408 +*/
   1.409 +void CWSGceCsc::GRAPHICS_WSERV_CSC_104L()
   1.410 +	{
   1.411 +	TRect screen(iScreenDevice->SizeInPixels());
   1.412 +	RWindow testWindow(iSession);
   1.413 +	RWindow surfacedTestWindow(iSession);
   1.414 +	TSurfaceId surfaceID;
   1.415 +
   1.416 +    MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.417 +    ASSERT_NOT_NULL(csc);
   1.418 +	
   1.419 +	TSize compositionScreenSize;
   1.420 +	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
   1.421 +	
   1.422 +	iTestName.Format(_L("GRAPHICS_WSERV_CSC_102"));
   1.423 +	INFO_PRINTF2(_L("%S"),&iTestName);
   1.424 +	
   1.425 +	iDisplayMode = iScreenDevice->DisplayMode();
   1.426 +
   1.427 +	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
   1.428 +			                                        KSurfaceFormat, 
   1.429 +			                                        compositionScreenSize.iWidth * KBytesPerPixel));
   1.430 +	ASSERT_EQUALS(err,KErrNone);
   1.431 +	
   1.432 +	ConstructOpaqueWindowLC(testWindow, 
   1.433 +			                iWhite, 
   1.434 +		                    0, 
   1.435 +                            TPoint(0, 0),
   1.436 +                            compositionScreenSize);
   1.437 +
   1.438 +	iSession.Flush();
   1.439 +	Pause(100);
   1.440 +	
   1.441 +	CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
   1.442 +	CleanupStack::PushL(bmp1);
   1.443 +	User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
   1.444 +	
   1.445 +	// Invalid bitmap display mode
   1.446 +	CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
   1.447 +	CleanupStack::PushL(bmp2);
   1.448 +	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor256));
   1.449 +	
   1.450 +	iSession.Flush();
   1.451 +	Pause(500);
   1.452 +
   1.453 +	// Draw a pattern using WServ
   1.454 +	SetBackgroundColorWindow(testWindow, iWhite);
   1.455 +
   1.456 +	TSize rectSize(100, 100);
   1.457 +	testWindow.Invalidate();
   1.458 +	testWindow.BeginRedraw();
   1.459 +	iGc->Activate(testWindow);
   1.460 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.461 +	iGc->SetBrushColor(KRgbDarkRed);
   1.462 +	iGc->DrawRect(TRect(TPoint(35, 5), rectSize));
   1.463 +	iGc->SetBrushColor(KRgbBlack);
   1.464 +	iGc->DrawRect(TRect(TPoint(55, 15), rectSize));
   1.465 +	iGc->SetBrushColor(KRgbDarkBlue);
   1.466 +	iGc->DrawRect(TRect(TPoint(75, 35), rectSize));
   1.467 +	iGc->SetBrushColor(KRgbYellow);
   1.468 +	iGc->DrawRect(TRect(TPoint(95, 55), rectSize));
   1.469 +	iGc->Deactivate();
   1.470 +	testWindow.EndRedraw();
   1.471 +	iSession.Flush();
   1.472 +	Pause(500);
   1.473 +	
   1.474 +	iScreenDevice->CopyScreenToBitmap(bmp1);
   1.475 +	iSession.Flush();
   1.476 +    Pause(100);
   1.477 +    
   1.478 +	ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
   1.479 +			                        iRed,
   1.480 +		                            0,
   1.481 +		                            TPoint(0, 0),
   1.482 +		                            compositionScreenSize,
   1.483 +		                            surfaceID);
   1.484 +	
   1.485 +	TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
   1.486 +	ASSERT_EQUALS(err,KErrNone);
   1.487 +	iSession.Flush();
   1.488 +    Pause(500);
   1.489 +    
   1.490 +	TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
   1.491 +	ASSERT_EQUALS(err,KErrNone);
   1.492 +	iSession.Flush();
   1.493 +    Pause(500);
   1.494 +
   1.495 +    // negative test, it should fail wit KErrArgument
   1.496 +	TInt ret = csc->ComposeScreen(*bmp2);
   1.497 +	ASSERT_EQUALS(ret, KErrArgument);
   1.498 +	
   1.499 +	iUtility->DestroyAll();
   1.500 +	CleanupStack::PopAndDestroy(&surfacedTestWindow);
   1.501 +	CleanupStack::PopAndDestroy(bmp2);
   1.502 +	CleanupStack::PopAndDestroy(bmp1);
   1.503 +	CleanupStack::PopAndDestroy(&testWindow);
   1.504 +	iSession.Flush();
   1.505 +	Pause(1000);
   1.506 +	}
   1.507 +
   1.508 +/**
   1.509 + @SYMTestCaseID         GRAPHICS_WSERV_CSC_105L
   1.510 + @SYMTestCaseDesc       Correct bitmap size returned when in small screen mode
   1.511 + @SYMDEF                DEF139191                   
   1.512 + @SYMPREQ               CSC
   1.513 + @SYMTestStatus         Implemented
   1.514 + @SYMTestPriority       1
   1.515 + @SYMTestPurpose        Checking GetCompositedSize is correct on gce & acceptable behaviour in non gce mode
   1.516 + @SYMTestActions        For every available screen mode
   1.517 +                        Get size from GetCompositedSize
   1.518 +                        Draw some coloured rectangles on screen
   1.519 +                        If gce, do a full screen surface, and paste the coloured rectangles into the surface
   1.520 +                        ComposeScreen - bitmap 1 should be the same as bitmap 2
   1.521 +                        Note - non GCE mode - GetCompositedSize returns unrotated appmode size, so only
   1.522 +                            compares the intersection of that with actual screen size
   1.523 +                        Note - gce mode - GetCompositedSize returns actual rotated screen size, so 
   1.524 +                            does a complete screen comparison
   1.525 + @SYMTestExpectedResults  All asserts should complete. Comparison should succeed!
   1.526 +*/
   1.527 +void CWSGceCsc::GRAPHICS_WSERV_CSC_105L()
   1.528 +    {
   1.529 +    iTestName.Format(_L("GRAPHICS_WSERV_CSC_105"));
   1.530 +    INFO_PRINTF2(_L("%S"),&iTestName);
   1.531 +    TInt err;
   1.532 +    //get list of modes
   1.533 +    RArray<TInt> screenModes;
   1.534 +    err = iScreenDevice->GetScreenSizeModeList(&screenModes);
   1.535 +    ASSERT_TRUE (err > 0);
   1.536 +    //get first mode info
   1.537 +    TPixelsAndRotation firstModeInfo;
   1.538 +    iScreenDevice->GetScreenModeSizeAndRotation(screenModes[0],firstModeInfo);
   1.539 +
   1.540 +    //make sure csc is available
   1.541 +    MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.542 +    ASSERT_NOT_NULL(csc);
   1.543 +
   1.544 +    TBool differentSizes = EFalse;
   1.545 +    TSizeMode currentModeInfo;
   1.546 +    TSize compositionScreenSize;
   1.547 +    //for every screen mode
   1.548 +    for (TInt ii = 0; ii < screenModes.Count(); ++ii && !differentSizes)
   1.549 +        {
   1.550 +        //set mode
   1.551 +        iScreenDevice->SetAppScreenMode(screenModes[ii]);
   1.552 +        iScreenDevice->SetScreenMode(screenModes[ii]);
   1.553 +        iSession.Flush();
   1.554 +        Pause(100);
   1.555 +        //get mode info
   1.556 +        currentModeInfo = iScreenDevice->GetCurrentScreenModeAttributes();
   1.557 +        if (currentModeInfo.iScreenSize.iWidth != firstModeInfo.iPixelSize.iWidth ||
   1.558 +                currentModeInfo.iScreenSize.iHeight != firstModeInfo.iPixelSize.iHeight ||
   1.559 +                currentModeInfo.iRotation != firstModeInfo.iRotation)
   1.560 +            {   //note that we have modes of different sizes / rotations
   1.561 +            differentSizes = ETrue;
   1.562 +            }
   1.563 +
   1.564 +        RWindow testWindow(iSession);
   1.565 +        RWindow surfacedTestWindow(iSession);
   1.566 +        TSurfaceId surfaceID;
   1.567 +
   1.568 +        err = csc->GetCompositedSize(compositionScreenSize);
   1.569 +        ASSERT_EQUALS (err,KErrNone);
   1.570 +        iDisplayMode = iScreenDevice->DisplayMode();
   1.571 +        
   1.572 +        if (GCEIsSupported())
   1.573 +            {   //create a surface
   1.574 +            TRAP(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
   1.575 +                                                       KSurfaceFormat, 
   1.576 +                                                       compositionScreenSize.iWidth * KBytesPerPixel));
   1.577 +            ASSERT_EQUALS(err,KErrNone);
   1.578 +            }
   1.579 +        
   1.580 +        //create a basic window
   1.581 +        ConstructOpaqueWindowLC(testWindow, 
   1.582 +                iWhite, 
   1.583 +                0, 
   1.584 +                -currentModeInfo.iOrigin,
   1.585 +                compositionScreenSize);  //negative origin to ensure it fills screen, not app mode area
   1.586 +        iSession.Flush();
   1.587 +        Pause(100);
   1.588 +        
   1.589 +        //bitmap 1 to compare against
   1.590 +        CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
   1.591 +        CleanupStack::PushL(bmp1);
   1.592 +        User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
   1.593 +        //bitmap 2 to pass into csc
   1.594 +        CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
   1.595 +        CleanupStack::PushL(bmp2);
   1.596 +        User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
   1.597 +        
   1.598 +        //draw coloured rectangles in the test window
   1.599 +        SetBackgroundColorWindow(testWindow, iWhite);
   1.600 +        DrawBasicPattern (testWindow);
   1.601 +        
   1.602 +        //copy screen to bitmap 1
   1.603 +        err = iScreenDevice->CopyScreenToBitmap(bmp1);
   1.604 +        ASSERT_EQUALS (err,KErrNone);
   1.605 +        iSession.Flush();
   1.606 +        Pause(100);
   1.607 +        
   1.608 +        if (GCEIsSupported())
   1.609 +            {   //place a window with a surface into the screen
   1.610 +            ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
   1.611 +                    iRed,
   1.612 +                    0,
   1.613 +                    -currentModeInfo.iOrigin,
   1.614 +                    compositionScreenSize,
   1.615 +                    surfaceID);  //negative origin to ensure it fills screen,not app mode area
   1.616 +
   1.617 +            //make surface boring cyan
   1.618 +            TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
   1.619 +            ASSERT_EQUALS(err,KErrNone);
   1.620 +            iSession.Flush();
   1.621 +            Pause(300);
   1.622 +            
   1.623 +            //paste bitmap 1 contents into the surface
   1.624 +            TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
   1.625 +            ASSERT_EQUALS(err,KErrNone);
   1.626 +            iSession.Flush();
   1.627 +            Pause(300);
   1.628 +            }
   1.629 +        
   1.630 +        //use csc to get a copy of the screen
   1.631 +        err = csc->ComposeScreen(*bmp2);
   1.632 +        ASSERT_EQUALS (err, KErrNone);
   1.633 +        
   1.634 +        //should match the original bitmap copy of the screen
   1.635 +        ASSERT_TRUE(Compare(*bmp1, *bmp2));    
   1.636 +        
   1.637 +        if (GCEIsSupported())
   1.638 +            {
   1.639 +            iUtility->DestroyAll();
   1.640 +            CleanupStack::PopAndDestroy(&surfacedTestWindow);
   1.641 +            }
   1.642 +        else
   1.643 +            {
   1.644 +            surfacedTestWindow.Close();
   1.645 +            }
   1.646 +        CleanupStack::PopAndDestroy(bmp2);
   1.647 +        CleanupStack::PopAndDestroy(bmp1);
   1.648 +        CleanupStack::PopAndDestroy(&testWindow);
   1.649 +        iSession.Flush();
   1.650 +        Pause(300);
   1.651 +        }
   1.652 +    if (!differentSizes)
   1.653 +        {
   1.654 +        INFO_PRINTF1(_L("Didn't find screen modes of different sizes - test inconclusive"));
   1.655 +        }
   1.656 +    iScreenDevice->SetAppScreenMode(screenModes[0]);
   1.657 +    iScreenDevice->SetScreenMode(screenModes[0]);
   1.658 +    screenModes.Close();
   1.659 +    }