windowing/windowserver/tcsc/cwsgcecsc.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-2009 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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <w32std.h>
       
    19 #include <e32std.h>
       
    20 #include "cwsgcecsc.h"
       
    21 #include "extendtef.h"
       
    22 #include "teflogextensions.h"
       
    23 #include "testscreencapture.h"
       
    24 
       
    25 
       
    26 #if defined(__X86GCC__)
       
    27 extern "C" TInt atexit(void (*function)(void))
       
    28 	{
       
    29 	return KErrNone;
       
    30 	}
       
    31 #endif
       
    32 
       
    33 void TefUnitFailLeaveL()
       
    34 	{
       
    35 	User::Leave(KErrTEFUnitFail);
       
    36 	}
       
    37 
       
    38 CWSGceCsc::CWSGceCsc()
       
    39 	{
       
    40 	}
       
    41 
       
    42 CWSGceCsc::~CWSGceCsc()
       
    43 	{
       
    44 	}
       
    45 
       
    46 /**
       
    47 Common set up code for all tests.
       
    48 
       
    49 Creates the session and window group for further windows, plus a simple white
       
    50 background to obscure any unwanted stuff behind the test. Sets up the surface
       
    51 update session and surface manager, to work with surfaces. Creates a screen
       
    52 device for use in the tests.
       
    53 */
       
    54 void CWSGceCsc::SetupL()
       
    55 	{
       
    56 	CWsGceCscBase::SetupL();
       
    57 	}
       
    58 
       
    59 /**
       
    60 Common tear down code for all tests.
       
    61 
       
    62 Windows, group and session created are closed. Screen device is destroyed.
       
    63 Surfaces, manager and update session are closed.
       
    64 */
       
    65 void CWSGceCsc::TearDownL()
       
    66 	{
       
    67 	CWsGceCscBase::TearDownL();
       
    68 	}
       
    69 
       
    70 CTestSuite* CWSGceCsc::CreateSuiteL( const TDesC& aName)
       
    71 	{
       
    72 	SUB_SUITE;
       
    73 	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_101L);
       
    74 	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_102L);
       
    75 	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_103L);
       
    76 	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_104L);
       
    77 	ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_105L);
       
    78 	END_SUITE;
       
    79 	}
       
    80 
       
    81 /**
       
    82  @SYMTestCaseID			GRAPHICS_WSERV_CSC_101L
       
    83  
       
    84  @SYMTestCaseDesc		Compare the screen composition using the new and legacy API
       
    85  						
       
    86  @SYMPREQ				CSC
       
    87  
       
    88  @SYMTestStatus			Implemented
       
    89  
       
    90  @SYMTestPriority		1
       
    91  
       
    92  @SYMTestPurpose		To check that the screen composition retrieved using the new and legacy APIs
       
    93 
       
    94  @SYMTestActions		Initialization.
       
    95 						Construct a background opaque window.
       
    96 						Create two bitmaps with the size equal with the composition.
       
    97 						Draw something on the screen.
       
    98 						Use legacy API CopyScreenToBitmap() to copy the screen to first bitmap.
       
    99 						Use the the new API to copy the composition of the screen.
       
   100 						Compare the results.
       
   101  
       
   102  @SYMTestExpectedResults  The bitmap should be identical	 
       
   103 */
       
   104 void CWSGceCsc::GRAPHICS_WSERV_CSC_101L()
       
   105 	{
       
   106 	TRect screen(iScreenDevice->SizeInPixels());
       
   107 	RWindow nonSurfacedWindow(iSession);
       
   108 	iTestName.Format(_L("GRAPHICS_WSERV_CSC_101L"));
       
   109 
       
   110 	INFO_PRINTF2(_L("%S"),&iTestName);
       
   111 	iDisplayMode = iScreenDevice->DisplayMode();	// Get default display mode
       
   112 
       
   113 	ConstructOpaqueWindowLC(nonSurfacedWindow, 
       
   114 			                iCyan, 
       
   115 		                    0, 
       
   116                             TPoint(0, 0),
       
   117                             screen.Size());
       
   118 	iSession.Flush();
       
   119 	Pause(1000);
       
   120 
       
   121 	MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
   122     ASSERT_NOT_NULL(csc);
       
   123 
       
   124 	TSize compositionScreenSize;
       
   125 	
       
   126 	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
       
   127 	
       
   128     CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
       
   129     CleanupStack::PushL(bmp1);
       
   130     User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
       
   131     
       
   132     CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
       
   133     CleanupStack::PushL(bmp2);
       
   134 	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
       
   135 	
       
   136 	iSession.Flush();
       
   137 	Pause(200);
       
   138 	
       
   139 	iScreenDevice->CopyScreenToBitmap(bmp1);
       
   140 	User::LeaveIfError(csc->ComposeScreen(*bmp2));
       
   141 	
       
   142 	SetBackgroundColorWindow(nonSurfacedWindow, iRed);
       
   143 	iSession.Flush();
       
   144 	
       
   145 	Pause(500);
       
   146 	
       
   147 	iGc->Activate(nonSurfacedWindow);
       
   148 	iGc->BitBlt(TPoint(0, 0), bmp1);
       
   149 	iGc->Deactivate();
       
   150 	iSession.Flush();
       
   151 	Pause(500);
       
   152 	
       
   153 	SetBackgroundColorWindow(nonSurfacedWindow, iWhite);
       
   154 	iSession.Flush();
       
   155 	Pause(500);
       
   156 	
       
   157 	iGc->Activate(nonSurfacedWindow);
       
   158 	iGc->BitBlt(TPoint(0, 0), bmp2);
       
   159 	iGc->Deactivate();
       
   160 	iSession.Flush();
       
   161 	Pause(500);
       
   162 
       
   163     ASSERT_TRUE(Compare(*bmp1, *bmp2));    
       
   164 	
       
   165 	if (GCEIsSupported())
       
   166 		{
       
   167 		iUtility->DestroyAll();
       
   168 		}
       
   169 	
       
   170 	CleanupStack::PopAndDestroy(bmp2);
       
   171 	CleanupStack::PopAndDestroy(bmp1);
       
   172 	CleanupStack::PopAndDestroy(&nonSurfacedWindow);
       
   173 	iSession.Flush();
       
   174 	Pause(1000);
       
   175 	}
       
   176 
       
   177 void CWSGceCsc::DrawBasicPattern (RWindow& aWin)
       
   178     {
       
   179     TSize rectSize(100, 100);
       
   180     aWin.Invalidate();
       
   181     aWin.BeginRedraw();
       
   182     iGc->Activate(aWin);
       
   183     iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   184     iGc->SetBrushColor(KRgbDarkRed);
       
   185     iGc->DrawRect(TRect(TPoint(35, 5), rectSize));
       
   186     iGc->SetBrushColor(KRgbBlack);
       
   187     iGc->DrawRect(TRect(TPoint(55, 15), rectSize));
       
   188     iGc->SetBrushColor(KRgbDarkBlue);
       
   189     iGc->DrawRect(TRect(TPoint(75, 35), rectSize));
       
   190     iGc->SetBrushColor(KRgbYellow);
       
   191     iGc->DrawRect(TRect(TPoint(95, 55), rectSize));
       
   192     iGc->Deactivate();
       
   193     aWin.EndRedraw();
       
   194     iSession.Flush();
       
   195     Pause(500);
       
   196     }
       
   197 
       
   198 /**
       
   199  @SYMTestCaseID			GRAPHICS_WSERV_CSC_102L
       
   200  
       
   201  @SYMTestCaseDesc		Compare the screen composition using the new and legacy API
       
   202  						
       
   203  @SYMPREQ				CSC
       
   204  
       
   205  @SYMTestStatus			Implemented
       
   206  
       
   207  @SYMTestPriority		1
       
   208  
       
   209  @SYMTestPurpose		To check that the screen composition retrieved using the new and legacy APIs 
       
   210 
       
   211  @SYMTestActions		Initialization.
       
   212  						Draw a pattern on the screen
       
   213  						Retrieve to a bitmap the UI content using the legacy API
       
   214  						Blank the screen.
       
   215  						Display the retrieved content to a surface
       
   216  						Retrieve the composited content
       
   217  						Compare the UI content with the composited content
       
   218  						NOTE:assumes current screen mode is at 0 offset
       
   219  
       
   220  @SYMTestExpectedResults  The UI content should be identical with the composited content	 
       
   221 */
       
   222 void CWSGceCsc::GRAPHICS_WSERV_CSC_102L()
       
   223 	{
       
   224 	TRect screen(iScreenDevice->SizeInPixels());
       
   225 	RWindow testWindow(iSession);
       
   226 	RWindow surfacedTestWindow(iSession);
       
   227 	TSurfaceId surfaceID;
       
   228 
       
   229     MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
   230     ASSERT_NOT_NULL(csc);
       
   231 	
       
   232 	TSize compositionScreenSize;
       
   233 	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
       
   234 	
       
   235 	iTestName.Format(_L("GRAPHICS_WSERV_CSC_102"));
       
   236 	INFO_PRINTF2(_L("%S"),&iTestName);
       
   237 	
       
   238 	iDisplayMode = iScreenDevice->DisplayMode();
       
   239 
       
   240 	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
       
   241 			                                        KSurfaceFormat, 
       
   242 			                                        compositionScreenSize.iWidth * KBytesPerPixel));
       
   243 	ASSERT_EQUALS(err,KErrNone);
       
   244 	
       
   245 	ConstructOpaqueWindowLC(testWindow, 
       
   246 			                iWhite, 
       
   247 		                    0, 
       
   248                             TPoint(0, 0),
       
   249                             compositionScreenSize);
       
   250 
       
   251 	iSession.Flush();
       
   252 	Pause(100);
       
   253 	
       
   254 	CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
       
   255 	CleanupStack::PushL(bmp1);
       
   256 	User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
       
   257 	
       
   258 	CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
       
   259 	CleanupStack::PushL(bmp2);
       
   260 	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
       
   261 	
       
   262 	iSession.Flush();
       
   263 	Pause(500);
       
   264 
       
   265 	SetBackgroundColorWindow(testWindow, iWhite);
       
   266 	DrawBasicPattern (testWindow);
       
   267 	
       
   268 	iScreenDevice->CopyScreenToBitmap(bmp1);
       
   269 	iSession.Flush();
       
   270     Pause(100);
       
   271     
       
   272 	ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
       
   273 			                        iRed,
       
   274 		                            0,
       
   275 		                            TPoint(0, 0),
       
   276 		                            compositionScreenSize,
       
   277 		                            surfaceID);
       
   278 	
       
   279 	TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
       
   280 	ASSERT_EQUALS(err,KErrNone);
       
   281 	iSession.Flush();
       
   282     Pause(500);
       
   283     
       
   284 	TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
       
   285 	ASSERT_EQUALS(err,KErrNone);
       
   286 	iSession.Flush();
       
   287     Pause(500);
       
   288 
       
   289 	User::LeaveIfError(csc->ComposeScreen(*bmp2));
       
   290     
       
   291     ASSERT_TRUE(Compare(*bmp1, *bmp2));    
       
   292 	
       
   293 	iUtility->DestroyAll();
       
   294 	CleanupStack::PopAndDestroy(&surfacedTestWindow);
       
   295 	CleanupStack::PopAndDestroy(bmp2);
       
   296 	CleanupStack::PopAndDestroy(bmp1);
       
   297 	CleanupStack::PopAndDestroy(&testWindow);
       
   298 	iSession.Flush();
       
   299 	Pause(1000);
       
   300 	}
       
   301 
       
   302 /**
       
   303  @SYMTestCaseID			GRAPHICS_WSERV_CSC_103L
       
   304  
       
   305  @SYMTestCaseDesc		Test TranslateExtent
       
   306  						
       
   307  @SYMPREQ				CSC
       
   308  
       
   309  @SYMTestStatus			Implemented
       
   310  
       
   311  @SYMTestPriority		1
       
   312  
       
   313  @SYMTestPurpose		To check that the correct translated extent is returned to the client 
       
   314 
       
   315  @SYMTestActions		Initialization
       
   316  						Change to app mode with offset and 90 degrees rotation
       
   317  						Translate a rectangle corresponding to the original app mode
       
   318  						Compare the expected rectangle with the translated rectangle
       
   319  
       
   320  @SYMTestExpectedResults  The translated rectangle should take into account the offset and rotation
       
   321 							and be equal to the expected rectangle
       
   322 */
       
   323 void CWSGceCsc::GRAPHICS_WSERV_CSC_103L()
       
   324 	{
       
   325 	TRect screen(iScreenDevice->SizeInPixels());
       
   326 	RWindow testWindow(iSession);
       
   327 	
       
   328 	iTestName.Format(_L("GRAPHICS_WSERV_CSC_103L"));
       
   329 	INFO_PRINTF2(_L("%S"),&iTestName);
       
   330 	
       
   331 	iDisplayMode = iScreenDevice->DisplayMode();
       
   332 	
       
   333 	ConstructOpaqueWindowLC(testWindow, 
       
   334 			                iWhite, 
       
   335 		                    0, 
       
   336                             TPoint(0, 0),
       
   337                             screen.Size());
       
   338 	iSession.Flush();
       
   339 	Pause(1000);
       
   340 
       
   341 	// Get the screen modes
       
   342 	RArray<TInt> modeList;
       
   343 	TInt err = iScreenDevice->GetScreenSizeModeList(&modeList);
       
   344 	ASSERT_TRUE(err > 1);  //2 modes expected
       
   345 	ASSERT_TRUE(modeList.Count() > 1); //2 modes expected
       
   346 	
       
   347 	// The initial extent and the expected translated extent
       
   348 	TRect initial(TPoint(10,10), TSize(20,30));
       
   349 	TRect extent(initial);
       
   350 	TRect expected(TPoint(15,15), TSize(20,30));
       
   351 	
       
   352 	// Change app mode to 5 pixels offset
       
   353 	iScreenDevice->SetAppScreenMode(modeList[1]);
       
   354 	iScreenDevice->SetScreenMode(modeList[1]);
       
   355 	iSession.Flush();
       
   356 	Pause(100);
       
   357 
       
   358 	TPoint origin = iScreenDevice->GetCurrentScreenModeScaledOrigin();
       
   359 	if(origin != TPoint(0,0))
       
   360 		{
       
   361 		// Calculate the new extent
       
   362 	    MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
   363 	    ASSERT_NOT_NULL(csc);
       
   364 		csc->TranslateExtent(initial, extent);	
       
   365 		ASSERT_TRUE(extent == expected); 
       
   366 		}
       
   367 	else
       
   368 		{
       
   369 		INFO_PRINTF1(_L("Non zero offset not supported"));
       
   370 		}
       
   371     // Change app mode
       
   372     iScreenDevice->SetAppScreenMode(modeList[0]);
       
   373     iScreenDevice->SetScreenMode(modeList[0]);
       
   374     iSession.Flush();
       
   375     Pause(100);
       
   376 
       
   377     modeList.Close();
       
   378 	CleanupStack::PopAndDestroy(&testWindow);
       
   379 	iSession.Flush();
       
   380 	Pause(1000);
       
   381 	}
       
   382 
       
   383 /**
       
   384  @SYMTestCaseID			GRAPHICS_WSERV_CSC_104L
       
   385  
       
   386  @SYMTestCaseDesc		Compare the screen composition using bitmaps with different display modes
       
   387  						
       
   388  @SYMPREQ				CSC
       
   389  
       
   390  @SYMTestStatus			Implemented
       
   391  
       
   392  @SYMTestPriority		1
       
   393  
       
   394  @SYMTestPurpose		To check that bitmaps with different display modes  
       
   395 
       
   396  @SYMTestActions		Initialization.
       
   397  						Draw a pattern on the screen
       
   398  						Retrieve to a bitmap the UI content using the legacy API
       
   399  						Blank the screen.
       
   400  						Display the retrieved content to a surface
       
   401  						Retrieve the composited content to a 2nd bitmap
       
   402  						Compare the UI content with the composited content
       
   403  
       
   404  @SYMTestExpectedResults  The bitmaps format should not match and should return KErrArgument 
       
   405 */
       
   406 void CWSGceCsc::GRAPHICS_WSERV_CSC_104L()
       
   407 	{
       
   408 	TRect screen(iScreenDevice->SizeInPixels());
       
   409 	RWindow testWindow(iSession);
       
   410 	RWindow surfacedTestWindow(iSession);
       
   411 	TSurfaceId surfaceID;
       
   412 
       
   413     MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
   414     ASSERT_NOT_NULL(csc);
       
   415 	
       
   416 	TSize compositionScreenSize;
       
   417 	User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize));
       
   418 	
       
   419 	iTestName.Format(_L("GRAPHICS_WSERV_CSC_102"));
       
   420 	INFO_PRINTF2(_L("%S"),&iTestName);
       
   421 	
       
   422 	iDisplayMode = iScreenDevice->DisplayMode();
       
   423 
       
   424 	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
       
   425 			                                        KSurfaceFormat, 
       
   426 			                                        compositionScreenSize.iWidth * KBytesPerPixel));
       
   427 	ASSERT_EQUALS(err,KErrNone);
       
   428 	
       
   429 	ConstructOpaqueWindowLC(testWindow, 
       
   430 			                iWhite, 
       
   431 		                    0, 
       
   432                             TPoint(0, 0),
       
   433                             compositionScreenSize);
       
   434 
       
   435 	iSession.Flush();
       
   436 	Pause(100);
       
   437 	
       
   438 	CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
       
   439 	CleanupStack::PushL(bmp1);
       
   440 	User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
       
   441 	
       
   442 	// Invalid bitmap display mode
       
   443 	CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
       
   444 	CleanupStack::PushL(bmp2);
       
   445 	User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor256));
       
   446 	
       
   447 	iSession.Flush();
       
   448 	Pause(500);
       
   449 
       
   450 	// Draw a pattern using WServ
       
   451 	SetBackgroundColorWindow(testWindow, iWhite);
       
   452 
       
   453 	TSize rectSize(100, 100);
       
   454 	testWindow.Invalidate();
       
   455 	testWindow.BeginRedraw();
       
   456 	iGc->Activate(testWindow);
       
   457 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   458 	iGc->SetBrushColor(KRgbDarkRed);
       
   459 	iGc->DrawRect(TRect(TPoint(35, 5), rectSize));
       
   460 	iGc->SetBrushColor(KRgbBlack);
       
   461 	iGc->DrawRect(TRect(TPoint(55, 15), rectSize));
       
   462 	iGc->SetBrushColor(KRgbDarkBlue);
       
   463 	iGc->DrawRect(TRect(TPoint(75, 35), rectSize));
       
   464 	iGc->SetBrushColor(KRgbYellow);
       
   465 	iGc->DrawRect(TRect(TPoint(95, 55), rectSize));
       
   466 	iGc->Deactivate();
       
   467 	testWindow.EndRedraw();
       
   468 	iSession.Flush();
       
   469 	Pause(500);
       
   470 	
       
   471 	iScreenDevice->CopyScreenToBitmap(bmp1);
       
   472 	iSession.Flush();
       
   473     Pause(100);
       
   474     
       
   475 	ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
       
   476 			                        iRed,
       
   477 		                            0,
       
   478 		                            TPoint(0, 0),
       
   479 		                            compositionScreenSize,
       
   480 		                            surfaceID);
       
   481 	
       
   482 	TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
       
   483 	ASSERT_EQUALS(err,KErrNone);
       
   484 	iSession.Flush();
       
   485     Pause(500);
       
   486     
       
   487 	TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
       
   488 	ASSERT_EQUALS(err,KErrNone);
       
   489 	iSession.Flush();
       
   490     Pause(500);
       
   491 
       
   492     // negative test, it should fail wit KErrArgument
       
   493 	TInt ret = csc->ComposeScreen(*bmp2);
       
   494 	ASSERT_EQUALS(ret, KErrArgument);
       
   495 	
       
   496 	iUtility->DestroyAll();
       
   497 	CleanupStack::PopAndDestroy(&surfacedTestWindow);
       
   498 	CleanupStack::PopAndDestroy(bmp2);
       
   499 	CleanupStack::PopAndDestroy(bmp1);
       
   500 	CleanupStack::PopAndDestroy(&testWindow);
       
   501 	iSession.Flush();
       
   502 	Pause(1000);
       
   503 	}
       
   504 
       
   505 /**
       
   506  @SYMTestCaseID         GRAPHICS_WSERV_CSC_105L
       
   507  @SYMTestCaseDesc       Correct bitmap size returned when in small screen mode
       
   508  @SYMDEF                DEF139191                   
       
   509  @SYMPREQ               CSC
       
   510  @SYMTestStatus         Implemented
       
   511  @SYMTestPriority       1
       
   512  @SYMTestPurpose        Checking GetCompositedSize is correct on gce & acceptable behaviour in non gce mode
       
   513  @SYMTestActions        For every available screen mode
       
   514                         Get size from GetCompositedSize
       
   515                         Draw some coloured rectangles on screen
       
   516                         If gce, do a full screen surface, and paste the coloured rectangles into the surface
       
   517                         ComposeScreen - bitmap 1 should be the same as bitmap 2
       
   518                         Note - non GCE mode - GetCompositedSize returns unrotated appmode size, so only
       
   519                             compares the intersection of that with actual screen size
       
   520                         Note - gce mode - GetCompositedSize returns actual rotated screen size, so 
       
   521                             does a complete screen comparison
       
   522  @SYMTestExpectedResults  All asserts should complete. Comparison should succeed!
       
   523 */
       
   524 void CWSGceCsc::GRAPHICS_WSERV_CSC_105L()
       
   525     {
       
   526     iTestName.Format(_L("GRAPHICS_WSERV_CSC_105"));
       
   527     INFO_PRINTF2(_L("%S"),&iTestName);
       
   528     TInt err;
       
   529     //get list of modes
       
   530     RArray<TInt> screenModes;
       
   531     err = iScreenDevice->GetScreenSizeModeList(&screenModes);
       
   532     ASSERT_TRUE (err > 0);
       
   533     //get first mode info
       
   534     TPixelsAndRotation firstModeInfo;
       
   535     iScreenDevice->GetScreenModeSizeAndRotation(screenModes[0],firstModeInfo);
       
   536 
       
   537     //make sure csc is available
       
   538     MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
   539     ASSERT_NOT_NULL(csc);
       
   540 
       
   541     TBool differentSizes = EFalse;
       
   542     TSizeMode currentModeInfo;
       
   543     TSize compositionScreenSize;
       
   544     //for every screen mode
       
   545     for (TInt ii = 0; ii < screenModes.Count(); ++ii && !differentSizes)
       
   546         {
       
   547         //set mode
       
   548         iScreenDevice->SetAppScreenMode(screenModes[ii]);
       
   549         iScreenDevice->SetScreenMode(screenModes[ii]);
       
   550         iSession.Flush();
       
   551         Pause(100);
       
   552         //get mode info
       
   553         currentModeInfo = iScreenDevice->GetCurrentScreenModeAttributes();
       
   554         if (currentModeInfo.iScreenSize.iWidth != firstModeInfo.iPixelSize.iWidth ||
       
   555                 currentModeInfo.iScreenSize.iHeight != firstModeInfo.iPixelSize.iHeight ||
       
   556                 currentModeInfo.iRotation != firstModeInfo.iRotation)
       
   557             {   //note that we have modes of different sizes / rotations
       
   558             differentSizes = ETrue;
       
   559             }
       
   560 
       
   561         RWindow testWindow(iSession);
       
   562         RWindow surfacedTestWindow(iSession);
       
   563         TSurfaceId surfaceID;
       
   564 
       
   565         err = csc->GetCompositedSize(compositionScreenSize);
       
   566         ASSERT_EQUALS (err,KErrNone);
       
   567         iDisplayMode = iScreenDevice->DisplayMode();
       
   568         
       
   569         if (GCEIsSupported())
       
   570             {   //create a surface
       
   571             TRAP(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, 
       
   572                                                        KSurfaceFormat, 
       
   573                                                        compositionScreenSize.iWidth * KBytesPerPixel));
       
   574             ASSERT_EQUALS(err,KErrNone);
       
   575             }
       
   576         
       
   577         //create a basic window
       
   578         ConstructOpaqueWindowLC(testWindow, 
       
   579                 iWhite, 
       
   580                 0, 
       
   581                 -currentModeInfo.iOrigin,
       
   582                 compositionScreenSize);  //negative origin to ensure it fills screen, not app mode area
       
   583         iSession.Flush();
       
   584         Pause(100);
       
   585         
       
   586         //bitmap 1 to compare against
       
   587         CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
       
   588         CleanupStack::PushL(bmp1);
       
   589         User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU));
       
   590         //bitmap 2 to pass into csc
       
   591         CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
       
   592         CleanupStack::PushL(bmp2);
       
   593         User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU));
       
   594         
       
   595         //draw coloured rectangles in the test window
       
   596         SetBackgroundColorWindow(testWindow, iWhite);
       
   597         DrawBasicPattern (testWindow);
       
   598         
       
   599         //copy screen to bitmap 1
       
   600         err = iScreenDevice->CopyScreenToBitmap(bmp1);
       
   601         ASSERT_EQUALS (err,KErrNone);
       
   602         iSession.Flush();
       
   603         Pause(100);
       
   604         
       
   605         if (GCEIsSupported())
       
   606             {   //place a window with a surface into the screen
       
   607             ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, 
       
   608                     iRed,
       
   609                     0,
       
   610                     -currentModeInfo.iOrigin,
       
   611                     compositionScreenSize,
       
   612                     surfaceID);  //negative origin to ensure it fills screen,not app mode area
       
   613 
       
   614             //make surface boring cyan
       
   615             TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan));
       
   616             ASSERT_EQUALS(err,KErrNone);
       
   617             iSession.Flush();
       
   618             Pause(300);
       
   619             
       
   620             //paste bitmap 1 contents into the surface
       
   621             TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1));
       
   622             ASSERT_EQUALS(err,KErrNone);
       
   623             iSession.Flush();
       
   624             Pause(300);
       
   625             }
       
   626         
       
   627         //use csc to get a copy of the screen
       
   628         err = csc->ComposeScreen(*bmp2);
       
   629         ASSERT_EQUALS (err, KErrNone);
       
   630         
       
   631         //should match the original bitmap copy of the screen
       
   632         ASSERT_TRUE(Compare(*bmp1, *bmp2));    
       
   633         
       
   634         if (GCEIsSupported())
       
   635             {
       
   636             iUtility->DestroyAll();
       
   637             CleanupStack::PopAndDestroy(&surfacedTestWindow);
       
   638             }
       
   639         else
       
   640             {
       
   641             surfacedTestWindow.Close();
       
   642             }
       
   643         CleanupStack::PopAndDestroy(bmp2);
       
   644         CleanupStack::PopAndDestroy(bmp1);
       
   645         CleanupStack::PopAndDestroy(&testWindow);
       
   646         iSession.Flush();
       
   647         Pause(300);
       
   648         }
       
   649     if (!differentSizes)
       
   650         {
       
   651         INFO_PRINTF1(_L("Didn't find screen modes of different sizes - test inconclusive"));
       
   652         }
       
   653     iScreenDevice->SetAppScreenMode(screenModes[0]);
       
   654     iScreenDevice->SetScreenMode(screenModes[0]);
       
   655     screenModes.Close();
       
   656     }