os/graphics/egl/egltest/src/egltest_surfacescaling.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19 */
    20 
    21 #include "egltest_surfacescaling.h"
    22 
    23 #include <test/tefunit.h> // for ASSERT macros
    24 #include <test/egltestcommonutils.h>
    25 #include "egltestcommoninisettings.h"
    26 
    27 //We are restricted by the screen comparison utility that requires images to be EColor16MU
    28 const TDisplayMode KTestSourceDisplayMode = EColor16MU;
    29 
    30 CEglTest_SurfaceScalingBase::~CEglTest_SurfaceScalingBase()
    31     {
    32 	CleanAll();
    33 	delete iImageComparison;
    34 	delete iScreenDevice;
    35     CloseWindow();
    36     CloseWsSession();
    37     }
    38 
    39 TVerdict CEglTest_SurfaceScalingBase::doTestStepPreambleL()
    40     {
    41     TVerdict verdict = CEglTestStep::doTestStepPreambleL();
    42 
    43     INFO_PRINTF1(_L("doTestStepPreambleL() - Initialise surface scaling test settings..."));
    44     if(!CheckForExtensionL(KEGL_NOK_surface_scaling))
    45         {
    46 		ERR_PRINTF1(_L("KEGL_NOK_surface_scaling not supported!"));
    47         User::Leave(KErrNotSupported);
    48         }
    49     //retrieve the pointers to the EGL surface scaling extension functions 
    50     iPfnEglQuerySurfaceScalingCapabilityNOK = reinterpret_cast <TFPtrEglQuerySurfaceScalingCapabilityNok> (eglGetProcAddress("eglQuerySurfaceScalingCapabilityNOK"));
    51     iPfnEglSetSurfaceScalingNOK = reinterpret_cast <TFPtrEglSetSurfaceScalingNok> (eglGetProcAddress("eglSetSurfaceScalingNOK"));
    52 	if(!iPfnEglQuerySurfaceScalingCapabilityNOK)
    53 		{
    54 		ERR_PRINTF1(_L("   Cannot retrieve address of the \"eglQuerySurfaceScalingCapabilityNOK\" function"));
    55         User::Leave(KErrNotSupported);
    56 		}
    57 	if(!iPfnEglSetSurfaceScalingNOK)
    58 		{
    59 		ERR_PRINTF1(_L("   Cannot retrieve address of the \"eglSetSurfaceScalingNOK\" function"));
    60         User::Leave(KErrNotSupported);
    61 		}
    62 
    63     //retrieve surface scaling ini settings
    64 	CIniData* iniData = CIniData::NewL(KConfigFileName);
    65     CleanupStack::PushL(iniData);
    66     
    67     _LIT(KSectionSurfaceScaling, "SurfaceScaling");
    68     _LIT(KKeyAllScalable, "AllScalable"); 
    69     
    70     TPtrC scalable;
    71 	if(!iniData->FindVar(KSectionSurfaceScaling,KKeyAllScalable,scalable))
    72         {
    73 		ERR_PRINTF3(_L("   Cannot retrieve section:%S key:%S"), &KSectionSurfaceScaling, &KKeyAllScalable);
    74 		User::Leave(KErrNotSupported);
    75         }
    76 	iAllScalable = (scalable.FindF( _L("true"))==KErrNotFound)? EFalse : ETrue;
    77 	INFO_PRINTF1(_L("  ************************************************************************"));
    78 	INFO_PRINTF1(_L("  ****   The test will be run in following configuration: "));
    79 	INFO_PRINTF2(_L("  ****   All window surfaces scalable: %S"), &scalable);
    80 	INFO_PRINTF1(_L("  ************************************************************************"));
    81 	CleanupStack::PopAndDestroy(iniData);
    82 
    83     //Initiate a window server session and create a window group
    84     OpenWsSessionL(KDefaultWindowGroupId);
    85 
    86     //Create a Screen Device
    87     const TInt screen0 = 0;
    88     iScreenDevice = new(ELeave) CWsScreenDevice(iWsSession);
    89     User::LeaveIfError(iScreenDevice->Construct(screen0));
    90     
    91     // get full screen size
    92     TPixelsAndRotation sizeAndRotation;
    93     iScreenDevice->GetDefaultScreenSizeAndRotation(sizeAndRotation);
    94     iScreenSize = sizeAndRotation.iPixelSize;
    95     		
    96 	//Create the image comparison tool from the screen device as required by most tests 		
    97     iImageComparison = CTGraphicsScreenComparison::NewL(*iScreenDevice);
    98 
    99     return verdict;
   100     }
   101 
   102 TVerdict CEglTest_SurfaceScalingBase::doTestStepPostambleL()
   103     {
   104 	INFO_PRINTF1(_L("doTestStepPostambleL() - Cleaning up"));
   105 	
   106 	// cleanup egltest framework stuff
   107 	CleanAll();
   108 
   109 	// cleanup member variables
   110 	delete iImageComparison;
   111 	iImageComparison = NULL;
   112 	delete iScreenDevice;
   113 	iScreenDevice = NULL;
   114 	
   115 	// close window and wserver session
   116     CloseWindow();
   117     CloseWsSession();
   118 
   119     return CEglTestStep::doTestStepPostambleL();
   120     }
   121 
   122 void CEglTest_SurfaceScalingBase::CreateAndActivateWindowL(const TSize& aWindowSize)
   123     {
   124     ConstructWindowL(iWindow, aWindowSize);
   125     }
   126 
   127 void CEglTest_SurfaceScalingBase::CloseWindow()
   128     {
   129 	iWindow.Close();
   130     }
   131 
   132 //check if border color matches with expected values
   133 void CEglTest_SurfaceScalingBase::CheckBorderColorL(EGLint aExpectedRedChannelColor, EGLint aExpectedBlueChannelColor, EGLint aExpectedGreenChannelColor)
   134     {
   135     EGLint value = 0xffff; //set color channel to some arbitrary number 
   136     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &value));
   137     ASSERT_EQUALS(value, aExpectedRedChannelColor);
   138 
   139     value = 0xffff; //set color channel to some arbitrary number
   140     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &value));
   141     ASSERT_EQUALS(value, aExpectedGreenChannelColor);
   142 
   143     value = 0xffff; //set color channel to some arbitrary number
   144     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &value));
   145     ASSERT_EQUALS(value, aExpectedBlueChannelColor);
   146     }
   147 
   148 //check if scaling attributes match with expected values
   149 void CEglTest_SurfaceScalingBase::CheckScalingAttributesL(EGLint aExpectedSurfaceWidth, EGLint aExpectedSurfaceHeight, EGLint aExpectedExtentWidth, EGLint aExpectedExtentHeight, EGLint aExpectedOffsetX, EGLint aExpectedOffsetY)
   150     {
   151     EGLint value = 0xffff; //set initial value to some arbitrary number 
   152     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &value));
   153     ASSERT_EQUALS(value, aExpectedSurfaceWidth);
   154     
   155     value = 0xffff; //set initial value to some arbitrary number 
   156     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &value));
   157     ASSERT_EQUALS(value, aExpectedSurfaceHeight);
   158     
   159     value = 0xffff; //set initial value to some arbitrary number 
   160     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &value));
   161     ASSERT_EQUALS(value, aExpectedExtentWidth);
   162 
   163     value = 0xffff; //set initial value to some arbitrary number 
   164     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &value));
   165     ASSERT_EQUALS(value, aExpectedExtentHeight);
   166    
   167     value = 0xffff; //set initial value to some arbitrary number 
   168     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &value));
   169     ASSERT_EQUALS(value, aExpectedOffsetX);
   170    
   171     value = 0xffff; //set initial value to some arbitrary number 
   172     ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &value));
   173     ASSERT_EQUALS(value, aExpectedOffsetY);
   174     }
   175 
   176 /*
   177  Simple create bitmap function to initialise a rectangular bitmap in four simple colours plus borders
   178      ---------------------------
   179              borderTop         
   180          -----------------     
   181      b.                  b. 
   182             1      2        
   183      L                   R  
   184      e  ---------------- i  
   185      f                   g  
   186      t      3      4     h  
   187                          t  
   188          -----------------     
   189            borderBottom        
   190      --------------------------- 
   191 */
   192 CFbsBitmap* CEglTest_SurfaceScalingBase::CreateBitmapLC(const TSize& aSize, TInt aBorderTop, TInt aBorderBottom, TInt aBorderLeft, TInt aBorderRight, const TRgb& aBorderColor)
   193     {
   194     // create the bitmap to the requested size (DisplayMode set to default value)
   195     CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
   196     CleanupStack::PushL(bitmap);
   197     User::LeaveIfError(bitmap->Create(aSize,KTestSourceDisplayMode));
   198     TEST(bitmap->SizeInPixels().iHeight == aSize.iHeight);
   199     TEST(bitmap->SizeInPixels().iWidth == aSize.iWidth);
   200 
   201     //Create a device and context for the purpose of generating the bitmap which will be the
   202     //master reference used in the test
   203     CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
   204     CleanupStack::PushL(bitmapDevice);
   205     CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
   206     CleanupStack::PushL(bitmapGc);
   207     bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   208     bitmapGc->Activate(bitmapDevice);
   209 
   210     // First off, set the whole bitmap to the border colour
   211     bitmapGc->SetBrushColor(aBorderColor);
   212     bitmapGc->SetPenColor(aBorderColor);
   213     bitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   214     bitmapGc->DrawRect(aSize);
   215     
   216     // Set each individual quadrant to a different arbitrary colour
   217     const TInt height = aSize.iHeight;
   218     const TInt width  = aSize.iWidth;
   219     const TInt quadrantHeight = (height - aBorderTop - aBorderBottom) / 2;
   220     const TInt quadrantWidth = (width - aBorderLeft - aBorderRight) / 2;
   221 
   222     // quadrant 1 - Colour KRgbMagenta
   223     TRect rect = TRect(TPoint(aBorderLeft, aBorderTop), TSize(quadrantWidth, quadrantHeight));
   224     bitmapGc->SetBrushColor(KRgbMagenta);
   225     bitmapGc->SetPenColor(KRgbMagenta);
   226     bitmapGc->DrawRect(rect);
   227 
   228     // quadrant 2 - Colour KRgbCyan
   229     rect = TRect(TPoint(aBorderLeft+quadrantWidth, aBorderTop), TSize(quadrantWidth, quadrantHeight));
   230     bitmapGc->SetBrushColor(KRgbCyan);
   231     bitmapGc->SetPenColor(KRgbCyan);
   232     bitmapGc->DrawRect(rect);
   233 
   234     // quadrant 3 - Colour KRgbYellow
   235     rect = TRect(TPoint(aBorderLeft, aBorderTop+quadrantHeight), TSize(quadrantWidth, quadrantHeight));
   236     bitmapGc->SetBrushColor(KRgbYellow);
   237     bitmapGc->SetPenColor(KRgbYellow);
   238     bitmapGc->DrawRect(rect);
   239 
   240     // quadrant 4 - Colour KRgbDarkGreen
   241     rect = TRect(TPoint(aBorderLeft+quadrantWidth, aBorderTop+quadrantHeight), TSize(quadrantWidth, quadrantHeight));
   242     bitmapGc->SetBrushColor(KRgbDarkGreen);
   243     bitmapGc->SetPenColor(KRgbDarkGreen);
   244     bitmapGc->DrawRect(rect);
   245 
   246     //clean-up
   247     CleanupStack::PopAndDestroy(2, bitmapDevice);
   248     return bitmap;
   249     }
   250 
   251 void CEglTest_SurfaceScalingBase::WritePixelsToSurfaceL(const CFbsBitmap& aBitmap)
   252 	{
   253     // Mind the fact that CFbsBitmap and VGImages use different coordinates origin
   254     const TSize bitmapSize = aBitmap.SizeInPixels();
   255     TUint8* address = reinterpret_cast<TUint8*>(aBitmap.DataAddress());
   256     const TInt stride = aBitmap.DataStride();
   257     address += (bitmapSize.iHeight - 1) * stride;
   258     
   259     // copy pixel data to the drawing surface
   260     vgWritePixels(address, -stride, KDefaultSurfaceFormat,0,0, bitmapSize.iWidth, bitmapSize.iHeight);
   261     ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   262     
   263     // force all outstanding requests on the current context to complete
   264     vgFinish();
   265     iWsSession.Finish();
   266 	}
   267 
   268 /**
   269 @SYMTestCaseID GRAPHICS-EGL-0651
   270 
   271 @SYMTestPriority 1
   272 
   273 @SYMPREQ 2676
   274 
   275 @SYMREQ 417-56592
   276 
   277 @SYMTestCaseDesc
   278 Choose a suitable extent to test that specified border colours are correct.
   279 
   280 @SYMTestActions
   281 For a number of different situations, do the following:
   282 1. Create a window of known size
   283 2. Create a fixed size surface, filled in with a predefined bitmap
   284 3. Draw the surface onto the window for a set extent and border colour
   285 4. Compare window content and border against a reference bitmap containing expected values. 
   286 
   287 @SYMTestExpectedResults
   288 The window content matches the independently created reference bitmap in each situation
   289 */
   290 TVerdict CEglTest_SurfaceScaling_Positive::doTestStepL()
   291     {
   292     SetTestStepID(_L("GRAPHICS-EGL-0651"));
   293     SetTestStepName(_L("GRAPHICS-EGL-0651"));
   294     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Positive::doTestStepL started...."));
   295 
   296     // Create display object
   297     GetDisplayL();
   298     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
   299     iEglSess->InitializeL();
   300     
   301     //  NOTE: Borders depend on what you set as extent, offset, window and surface
   302     //        Care should be taken when choosing size values, better to use even numbers
   303 	//		  (CreateBitmap splits rectangle in four, so we don't want a pixel mismatch there) 
   304     for (TInt index=1; index<=17; index++)
   305     	{
   306 		// Set some default values which are used in most cases
   307 		iWindowWidth = iWindowHeight = 200;
   308 		iBorderColor = TRgb(0,0,0);
   309 	    iBorderTop = iBorderBottom = iBorderLeft = iBorderRight = 0;
   310 
   311 	    switch(index)
   312         {
   313 		case 1:
   314 			// surface scaled to same window size with no border
   315 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   316 		    iExtentWidth = 200; iExtentHeight = 200;
   317 		    iOffsetX = 0; iOffsetY = 0;
   318 			break;
   319 		case 2:
   320 			// surface scaled to half the window size with border top 
   321 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   322 		    iExtentWidth = 200; iExtentHeight = 100;
   323 		    iOffsetX = 0; iOffsetY = 100;
   324 		    iBorderColor = TRgb(0,0,0);         // arbitrary border colour
   325 		    iBorderTop = 100;
   326 			break;
   327 		case 3:
   328 			// surface scaled to half the window size with border bottom
   329 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   330 		    iExtentWidth = 200; iExtentHeight = 100;
   331 		    iOffsetX = 0; iOffsetY = 0;
   332 		    iBorderColor = TRgb(128,0,255);     // arbitrary border colour
   333 		    iBorderBottom = 100;
   334 			break;
   335 		case 4:
   336 			// surface scaled to half the window size with border top and bottom
   337 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   338 		    iExtentWidth = 200; iExtentHeight = 100;
   339 		    iOffsetX = 0; iOffsetY = 50;
   340 		    iBorderColor = TRgb(128,0,0);         // arbitrary border colour
   341 		    iBorderTop = 50; iBorderBottom = 50;
   342 			break;
   343 		case 5:
   344 			// surface scaled to half the window size with border left
   345 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   346 		    iExtentWidth = 100; iExtentHeight = 200;
   347 		    iOffsetX = 100; iOffsetY = 0;
   348 		    iBorderColor = TRgb(96,96,96);         // arbitrary border colour
   349 		    iBorderLeft = 100;
   350 			break;
   351 		case 6:
   352 			// surface scaled to half the window size with border right
   353 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   354 		    iExtentWidth = 100; iExtentHeight = 200;
   355 		    iOffsetX = 0; iOffsetY = 0;
   356 		    iBorderColor = TRgb(192,192,192);       // arbitrary border colour
   357 		    iBorderRight = 100;
   358 			break;
   359 		case 7:
   360 			// surface scaled to half the window size with border left and right
   361 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   362 		    iExtentWidth = 100; iExtentHeight = 200;
   363 		    iOffsetX = 50; iOffsetY = 0;
   364 		    iBorderColor = TRgb(0,0,0);				// arbitrary border colour
   365 		    iBorderLeft = 50; iBorderRight = 50;
   366 			break;
   367 		case 8:
   368 			// surface scaled in different proportions in width and height, with borders 
   369 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   370 		    iExtentWidth = 190; iExtentHeight = 10;
   371 		    iOffsetX = 5; iOffsetY = 95;
   372 		    iBorderColor = TRgb(240,240,240);       // arbitrary border colour
   373 		    iBorderTop = 95; iBorderBottom = 95; iBorderLeft = 5; iBorderRight = 5;
   374 			break;
   375 		case 9:
   376 			// surface scaled to double the window height size, surface cropped with no borders
   377 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   378 		    iExtentWidth = 400; iExtentHeight = 200;
   379 		    iOffsetX = 0; iOffsetY = 0;
   380 			break;
   381 		case 10:
   382 			// surface scaled to double the window width and height size, surface cropped with no borders
   383 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   384 		    iExtentWidth = 400; iExtentHeight = 400;
   385 		    iOffsetX = 0; iOffsetY = 0;
   386 			break;
   387 		case 11:
   388 			// surface scaled to double the window width and height size, surface cropped with borders top and left
   389 		    iSurfaceWidth = 100; iSurfaceHeight = 50;
   390 		    iExtentWidth = 400; iExtentHeight = 400;
   391 		    iOffsetX = 100; iOffsetY = 100;
   392 		    iBorderColor = TRgb(255,128,255);      // arbitrary border colour
   393 		    iBorderTop = 100; iBorderLeft = 100;
   394 			break;
   395 		case 12:
   396 			// QnHD to full screen size
   397 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   398 		    iSurfaceWidth = 320; iSurfaceHeight = 180;
   399 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   400 		    iOffsetX = 0; iOffsetY = 0;
   401 			break;
   402 		case 13:
   403 			// QVGA to full screen size
   404 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   405 		    iSurfaceWidth = 320; iSurfaceHeight = 240;
   406 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   407 		    iOffsetX = 0; iOffsetY = 0;
   408 			break;
   409 		case 14:
   410 			// HVGA to full screen size
   411 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   412 		    iSurfaceWidth = 480; iSurfaceHeight = 320;
   413 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   414 		    iOffsetX = 0; iOffsetY = 0;
   415 			break;
   416 		case 15:
   417 			// 480x270 to full screen size
   418 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   419 		    iSurfaceWidth = 480; iSurfaceHeight = 270;
   420 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   421 		    iOffsetX = 0; iOffsetY = 0;
   422 			break;
   423 		case 16:
   424 			// VGA to full screen size
   425 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   426 		    iSurfaceWidth = 640; iSurfaceHeight = 480;
   427 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   428 		    iOffsetX = 0; iOffsetY = 0;
   429 			break;
   430 		case 17:
   431 			// WVGA to full screen size
   432 			iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
   433 		    iSurfaceWidth = 768; iSurfaceHeight = 480;
   434 		    iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
   435 		    iOffsetX = 0; iOffsetY = 0;
   436 			break;
   437 		default:
   438 		    ERR_PRINTF2(_L("Inconsistency in test code, case does not exist: %d."), index);
   439 		    User::Leave(KErrNotSupported);
   440 		    break;
   441         }
   442 
   443 		// perform the testing
   444 	    doTestPartialStepL();
   445     	}
   446 
   447     // clean-up
   448     CleanAll();
   449 
   450     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Positive::doTestStepL completed!"));
   451     RecordTestResultL();
   452     CloseTMSGraphicsStep();
   453     return TestStepResult();
   454     }
   455 
   456 TVerdict CEglTest_SurfaceScaling_Positive::doTestPartialStepL()
   457     {
   458     INFO_PRINTF5(_L("doTestPartialStepL started with (%d,%d) fixed surface scaled to (%d,%d) extent...."), iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight);
   459 
   460     // Establish the connection to the window server and create
   461     // a WindowGroup and a Window object
   462     CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
   463 
   464     // Choose EGL config
   465     EGLConfig matchingConfigs[1];
   466     EGLint numConfigs = 0;
   467 
   468     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
   469     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
   470 
   471     EGLint attrib_list[] = {
   472               EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
   473               EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
   474               EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
   475               EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
   476               EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
   477               EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
   478               EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
   479               EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
   480               EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
   481               EGL_NONE};
   482     
   483     // Create the window surface and the egl context and make them current
   484     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
   485 
   486     // Create the test bitmap that will be used in the scaled surface 
   487     //  NOTE: This bitmap generally does not have borders, 
   488     CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
   489     
   490     // Copy test bitmap to drawing surface
   491     WritePixelsToSurfaceL(*testBitmap);
   492 
   493     //call eglSwapBuffers
   494     ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
   495     //Wait for the draw operation to complete
   496     eglWaitClient();
   497 
   498     // Create the reference bitmap that should be expected after the scaling 
   499     //  NOTE: This bitmap may have borders
   500     //        Size could exceed that of the window, so check both extent and window
   501     const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
   502     const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
   503     CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
   504 
   505     // compare window contents with expected bitmap
   506     TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
   507     TEST(comparison==KErrNone);
   508     INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
   509 
   510     /// Cleanup
   511     CleanupStack::PopAndDestroy(2, testBitmap); // refBitmap, testBitmap
   512     iEglSess->CleanupSurfaceAndContextL();
   513     CloseWindow();
   514     
   515     INFO_PRINTF1(_L("....doTestPartialStepL completed!"));
   516     return TestStepResult();
   517     }
   518 
   519 /**
   520 @SYMTestCaseID GRAPHICS-EGL-0661
   521 
   522 @SYMTestPriority 1
   523 
   524 @SYMPREQ 2676
   525 
   526 @SYMREQ 417-56592
   527 
   528 @SYMTestCaseDesc
   529 Resize native window to verify target extent remains fixed.
   530 
   531 @SYMTestActions
   532 1. Create a window of known size
   533 2. Create a fixed size surface, filled in with a predefined bitmap
   534 3. Draw the surface onto the window for a set extent and border colour
   535 4. Repeat step 3 but increasing native window size by (1,1) pixels.
   536 5. Compare window content and border against a reference bitmap containing expected values. 
   537 
   538 @SYMTestExpectedResults
   539 The window content matches the independently created reference bitmap in each situation
   540 */
   541 TVerdict CEglTest_SurfaceScaling_WindowResize::doTestStepL()
   542     {
   543     SetTestStepID(_L("GRAPHICS-EGL-0661"));
   544     SetTestStepName(_L("GRAPHICS-EGL-0661"));
   545     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_WindowResize::doTestStepL started...."));
   546 
   547     // set the initial value of a square window
   548     const TInt KWindowSize = 100;
   549     
   550     // surface with size and extent that matches the window size and no offset
   551     iWindowWidth = iWindowHeight = KWindowSize;
   552     iSurfaceWidth = iSurfaceHeight = KWindowSize;
   553     iExtentWidth = iExtentHeight = KWindowSize;
   554     iOffsetX = 0; iOffsetY = 0;
   555     iBorderColor = TRgb(0x99,0xcc,0xff);	// set some arbitrary colour
   556     iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
   557 
   558     // Establish the connection to the window server and create
   559     // a WindowGroup and a Window object
   560     CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
   561 
   562     // Create display object
   563     GetDisplayL();
   564     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
   565     iEglSess->InitializeL();
   566 
   567     // Choose EGL config
   568     EGLConfig matchingConfigs[1];
   569     EGLint numConfigs = 0;
   570 
   571     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
   572     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
   573 
   574     EGLint attrib_list[] = {
   575               EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
   576               EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
   577               EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
   578               EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
   579               EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
   580               EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
   581               EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
   582               EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
   583               EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
   584               EGL_NONE};
   585     
   586     // Create the window surface and the egl context and make them current
   587     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
   588     
   589     // Create the test bitmap that will be used in the scaled surface 
   590     //  NOTE: This bitmap generally does not have borders, 
   591     CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
   592     
   593     // Copy test bitmap to drawing surface
   594     WritePixelsToSurfaceL(*testBitmap);
   595 
   596     // Start doing iterations by increasing native window size.
   597     INFO_PRINTF1(_L("Start increasing native window size by (1,1)..."));
   598     iWindowWidth=1;
   599     iWindowHeight=1;
   600     while(iWindowWidth<=(KWindowSize*2) && iWindowHeight<=(KWindowSize*2))
   601     	{
   602 		// Note that borders will appear while window size is bigger than extent
   603 		//  - iSurfaceWidth/iSurfaceHeight - unmodified
   604 		//  - iExtentWidth/iExtentHeight - unmodified
   605 		//  - iOffsetX/iOffsetY - unmodified 
   606 		// Set up expected values for the border
   607 		iBorderTop = 0; iBorderLeft = 0; 
   608 		iBorderBottom = iExtentHeight<iWindowHeight ? iWindowHeight-iExtentHeight : 0; 
   609 		iBorderRight = iExtentWidth<iWindowWidth ? iWindowWidth-iExtentWidth : 0; 
   610 
   611 		// resize window to new given size
   612 	    iWindow.Invalidate();
   613 		iWindow.BeginRedraw();
   614 		iWindow.SetSize(TSize(iWindowWidth, iWindowHeight));
   615 		iWindow.EndRedraw();
   616 
   617 		// re-populate buffers with the unmodified fixed size surface content
   618 	    WritePixelsToSurfaceL(*testBitmap);
   619 		
   620 		// perform the testing
   621 		doTestPartialStepL();
   622 		++iWindowWidth;
   623 		++iWindowHeight;
   624     	}
   625 
   626     /// Cleanup
   627     CleanupStack::PopAndDestroy(testBitmap);
   628     iEglSess->CleanupSurfaceAndContextL();
   629     CleanAll();
   630     CloseWindow();
   631     
   632     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_WindowResize::doTestStepL completed!"));
   633     RecordTestResultL();
   634     CloseTMSGraphicsStep();
   635     return TestStepResult();
   636     }
   637 
   638 TVerdict CEglTest_SurfaceScaling_WindowResize::doTestPartialStepL()
   639     {
   640     INFO_PRINTF3(_L("doTestPartialStepL started for native window size of (%d, %d)...."), iWindowWidth, iWindowHeight);
   641 
   642 	// resize may be effective only after swapbuffers 
   643 	ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
   644 	ASSERT_EGL_TRUE(eglWaitClient());
   645 	
   646 	//check all expected values
   647     CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY); 
   648     CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green()); 
   649 
   650     // Create the reference bitmap that should be expected after the window resize 
   651     //  NOTE: This bitmap may have borders
   652     //        Size could exceed that of the window, so check both extent and window
   653     const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
   654     const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
   655     CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
   656     
   657     // compare window contents with expected bitmap
   658     TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
   659     TEST(comparison==KErrNone);
   660     INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
   661 
   662     /// Cleanup
   663     CleanupStack::PopAndDestroy(refBitmap);
   664 
   665     return TestStepResult();
   666     }
   667 
   668 /**
   669 @SYMTestCaseID GRAPHICS-EGL-0668
   670 
   671 @SYMTestPriority 1
   672 
   673 @SYMPREQ 2676
   674 
   675 @SYMREQ 417-56592
   676 
   677 @SYMTestCaseDesc
   678 Create a fixed size surface and vary the extent position for a range of values.
   679 
   680 @SYMTestActions
   681 1. Create a window of known size
   682 2. Create a fixed size surface, filled in with a predefined bitmap
   683 3. Draw the surface onto the window for a set extent and border colour
   684 4. Repeat step 3 but increasing target extent offset by (1,1) pixels.
   685 5. Compare window content and border against a reference bitmap containing expected values. 
   686 
   687 @SYMTestExpectedResults
   688 The window content matches the independently created reference bitmap in each situation
   689 */
   690 TVerdict CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL()
   691     {
   692     SetTestStepID(_L("GRAPHICS-EGL-0668"));
   693     SetTestStepName(_L("GRAPHICS-EGL-0668"));
   694     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL started...."));
   695 
   696     // surface with size and extent that matches the window size and no offset
   697     iWindowWidth = iWindowHeight = 100;
   698     iSurfaceWidth = iExtentWidth = iWindowWidth;
   699     iSurfaceHeight = iExtentHeight = iWindowHeight;
   700     iOffsetX = 0; iOffsetY = 0;
   701     iBorderColor = TRgb(0x11,0x22,0x33);	// set some arbitrary colour
   702     iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
   703 
   704     // Establish the connection to the window server and create
   705     // a WindowGroup and a Window object
   706     CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
   707 
   708     // Create display object
   709     GetDisplayL();
   710     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
   711     iEglSess->InitializeL();
   712 
   713     // Choose EGL config
   714     EGLConfig matchingConfigs[1];
   715     EGLint numConfigs = 0;
   716 
   717     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
   718     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
   719 
   720     EGLint attrib_list[] = {
   721               EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
   722               EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
   723               EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
   724               EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
   725               EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
   726               EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
   727               EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
   728               EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
   729               EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
   730               EGL_NONE};
   731     
   732     // Create the window surface and the egl context and make them current
   733     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
   734     
   735     // Create the test bitmap that will be used in the scaled surface 
   736     //  NOTE: This bitmap generally does not have borders, 
   737     CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
   738     
   739     // Copy test bitmap to drawing surface
   740     WritePixelsToSurfaceL(*testBitmap);
   741 
   742 	// This test is a bit different. Since the extent remains the same, and we only change
   743     //  the offset, we create an oversized reference bitmap and compare the screen with a
   744     //  region contained within the reference bitmap 
   745     // Size is three times the extent so that it has extent size borders all around
   746     const TInt refWidth = 3*iExtentWidth;
   747     const TInt refHeight = 3*iExtentHeight;
   748     iBorderTop=iBorderBottom=iBorderLeft=iBorderRight=iExtentWidth;	
   749     CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
   750 
   751     // Start doing iterations by increasing target extent offset
   752     INFO_PRINTF1(_L("Start increasing target extent offset size by (1,1)..."));
   753     for (iOffsetX=-iExtentWidth,iOffsetY=-iExtentHeight; iOffsetX<=iExtentWidth&&iOffsetY<=iExtentHeight; ++iOffsetX,++iOffsetY)
   754     	{
   755 		// Note that borders will appear other than when offset is (0,0)
   756 		//  - iSurfaceWidth/iSurfaceHeight - unmodified
   757 		//  - iExtentWidth/iExtentHeight - unmodified
   758 	
   759 	    // set new offset values
   760 	    ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
   761 
   762 		// re-populate buffers with the unmodified fixed size surface content
   763 	    WritePixelsToSurfaceL(*testBitmap);
   764 
   765 		// perform the testing
   766 		doTestPartialStepL(*refBitmap);
   767     	}
   768     
   769     /// Cleanup
   770     CleanupStack::PopAndDestroy(2, testBitmap); //testBitmap, refBitmap
   771     iEglSess->CleanupSurfaceAndContextL();
   772     CleanAll();
   773     CloseWindow();
   774     
   775     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL completed!"));
   776     RecordTestResultL();
   777     CloseTMSGraphicsStep();
   778     return TestStepResult();
   779     }
   780 
   781 TVerdict CEglTest_SurfaceScaling_ExtentPositionChange::doTestPartialStepL(const CFbsBitmap& aRefBitmap)
   782     {
   783     INFO_PRINTF3(_L("doTestPartialStepL started for offset of (%d, %d)...."), iOffsetX, iOffsetY);
   784 
   785     // offset change may be effective only after swapbuffers 
   786 	ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
   787 	ASSERT_EGL_TRUE(eglWaitClient());
   788 	// Finish() to ensure all native window operations related to the surface complete before image comparision.
   789 	iWsSession.Finish();
   790 	
   791 	//check all expected values
   792     CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY); 
   793     CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green()); 
   794 
   795     // Prepare the offset of the reference bitmap to know what sub-region should be compared
   796     const TInt refWidth = 3*iExtentWidth;
   797     const TInt refHeight = 3*iExtentHeight;
   798     TPoint bitmapOffset(refWidth-iExtentWidth-iRefBitmapOffset, refHeight-iExtentHeight-iRefBitmapOffset);
   799     iRefBitmapOffset++;		// increase offset for next iteration
   800     
   801     // Comparision takes into account specific region within the reference bitmap
   802     TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), bitmapOffset, aRefBitmap, TestStepName());
   803     TEST(comparison==KErrNone);
   804     INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
   805 
   806     return TestStepResult();
   807     }
   808 
   809 /**
   810 @SYMTestCaseID GRAPHICS-EGL-0669
   811 
   812 @SYMTestPriority 1
   813 
   814 @SYMPREQ 2676
   815 
   816 @SYMREQ 417-56592
   817 
   818 @SYMTestCaseDesc
   819 Create a fixed size surface and vary the extent size for a range of values
   820 
   821 @SYMTestActions
   822 1. Create a window of known size
   823 2. Create a fixed size surface, filled in with a predefined bitmap
   824 3. Draw the surface onto the window for a set extent and border colour
   825 4. Repeat step 3 but increasing target extent size by (2,2) pixels.
   826 5. Compare window content and border against a reference bitmap containing expected values. 
   827 
   828 @SYMTestExpectedResults
   829 The window content matches the independently created reference bitmap in each situation
   830 */
   831 TVerdict CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL()
   832     {
   833     SetTestStepID(_L("GRAPHICS-EGL-0669"));
   834     SetTestStepName(_L("GRAPHICS-EGL-0669"));
   835     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL started...."));
   836 
   837     // set the initial value of a square window
   838     const TInt KWindowSize = 100;
   839     
   840     // surface with size and extent that matches the window size and no offset
   841     iWindowWidth = iWindowHeight = KWindowSize;
   842     iSurfaceWidth = iSurfaceHeight = KWindowSize;
   843     iExtentWidth = iExtentHeight = KWindowSize; 	
   844     iOffsetX = 0; iOffsetY = 0;
   845     iBorderColor = TRgb(0x80,0x40,0xF0);	// set some arbitrary colour
   846     iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
   847 
   848     // Establish the connection to the window server and create
   849     // a WindowGroup and a Window object
   850     CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
   851 
   852     // Create display object
   853     GetDisplayL();
   854     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
   855     iEglSess->InitializeL();
   856 
   857     // Choose EGL config
   858     EGLConfig matchingConfigs[1];
   859     EGLint numConfigs = 0;
   860 
   861     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
   862     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
   863 
   864     EGLint attrib_list[] = {
   865               EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
   866               EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
   867               EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
   868               EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
   869               EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
   870               EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
   871               EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
   872               EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
   873               EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
   874               EGL_NONE};
   875     
   876     // Create the window surface and the egl context and make them current
   877     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
   878     
   879     // Create the test bitmap that will be used in the scaled surface 
   880     //  NOTE: This bitmap generally does not have borders, 
   881     CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
   882     
   883     // Copy test bitmap to drawing surface
   884     WritePixelsToSurfaceL(*testBitmap);
   885 
   886     // Start doing iterations by increasing target extent size 
   887     //  We do increments of (2,2) because the reference bitmap is simetrically split into 4 areas, so size
   888     //  of this reference bitmap should be an even number of pixels
   889     INFO_PRINTF1(_L("Start increasing target extent size by (2,2)..."));
   890     iExtentWidth=2;
   891     iExtentHeight=2;
   892 	while(iExtentWidth <= (KWindowSize*2) && iExtentHeight <= (KWindowSize*2))
   893     	{
   894 		// Note that borders will appear while extent is smaller than window
   895 		//  - iSurfaceWidth/iSurfaceHeight - unmodified
   896 		//  - iOffsetX/iOffsetY - unmodified 
   897 		// Set up expected values for the border
   898 		iBorderTop = 0; iBorderLeft = 0; 
   899 		iBorderBottom = iExtentHeight<iWindowHeight ? iWindowHeight-iExtentHeight : 0; 
   900 		iBorderRight = iExtentWidth<iWindowWidth ? iWindowWidth-iExtentWidth : 0; 
   901 
   902 	    // set new target extent values
   903 	    ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
   904 
   905 		// re-populate buffers with the unmodified fixed size surface content
   906 	    WritePixelsToSurfaceL(*testBitmap);
   907 		
   908 		// perform the testing
   909 		doTestPartialStepL();
   910 		iExtentWidth+=2;
   911 		iExtentHeight+=2;
   912 		}
   913 
   914     /// Cleanup
   915     CleanupStack::PopAndDestroy(testBitmap);
   916     iEglSess->CleanupSurfaceAndContextL();
   917     CleanAll();
   918     CloseWindow();
   919     
   920     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL completed!"));
   921     RecordTestResultL();
   922     CloseTMSGraphicsStep();
   923     return TestStepResult();
   924     }
   925 
   926 TVerdict CEglTest_SurfaceScaling_ExtentSizeChange::doTestPartialStepL()
   927     {
   928     INFO_PRINTF3(_L("doTestPartialStepL started for extent size of (%d, %d)...."), iExtentWidth, iExtentHeight);
   929 
   930     // extent change may be effective only after swapbuffers 
   931 	ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
   932 	ASSERT_EGL_TRUE(eglWaitClient());
   933 	// Finish() to ensure all native window operations related to the surface complete before image comparision.
   934 	iWsSession.Finish();
   935 	
   936 	//check all expected values
   937     CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY); 
   938     CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green()); 
   939 
   940     // Create the reference bitmap that should be expected after the window resize 
   941     //  NOTE: This bitmap may have borders
   942     //        Size could exceed that of the window, so check both extent and window
   943     const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
   944     const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
   945     CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
   946     
   947     // compare window contents with expected bitmap
   948     TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
   949     TEST(comparison==KErrNone);
   950     INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
   951 
   952     /// Cleanup
   953     CleanupStack::PopAndDestroy(refBitmap);
   954 
   955     return TestStepResult();
   956     }
   957 
   958 /**
   959 @SYMTestCaseID GRAPHICS-EGL-0670
   960 
   961 @SYMTestPriority 1
   962 
   963 @SYMPREQ 2676
   964 
   965 @SYMREQ 417-56592
   966 
   967 @SYMTestCaseDesc
   968 Check that updating surface scaling attributes is visible only after calling eglSwapBuffers
   969 
   970 @SYMTestActions
   971 1. Create a window of known size
   972 2. Create a fixed size surface, filled in with a predefined bitmap
   973 3. Draw the surface onto the window for a set extent and border colour
   974 4. Repeat step 3 but increasing target extent size and changing border colours
   975 5. Compare window content and border against a reference bitmap containing expected values
   976   5a. Before calling eglSwapBuffers
   977   5b. After callnig eglSwapBuffers  
   978 
   979 @SYMTestExpectedResults
   980 5a. The window content matches the independently created reference with old values
   981 5b. The window content matches the independently created reference with new values
   982 */
   983 TVerdict CEglTest_SurfaceScaling_SwapBuffers::doTestStepL()
   984     {
   985     SetTestStepID(_L("GRAPHICS-EGL-0670"));
   986     SetTestStepName(_L("GRAPHICS-EGL-0670"));
   987     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_SwapBuffers::doTestStepL started...."));
   988 
   989     // set the initial value of a square window
   990     const TInt KWindowSize = 200;
   991     
   992     // surface with size that matches the window size and no offset and extent a quarter 
   993     // of that originally positioned in the middle (so borders should be seen)
   994     iWindowWidth = iWindowHeight = KWindowSize;
   995     iSurfaceWidth = iSurfaceHeight = KWindowSize;
   996     iExtentWidth = iExtentHeight = KWindowSize/4; 	
   997     iOffsetX = (iWindowWidth-iExtentWidth)/2; iOffsetY = (iWindowHeight-iExtentHeight)/2;	// to center the surface at the middle of the window
   998     iBorderColor = TRgb(0xFF,0xFF,0x00);	// set some arbitrary colour with blue channel to 0x00
   999 	iBorderTop = iBorderBottom = iExtentHeight<iWindowHeight ? (iWindowHeight-iExtentHeight)/2 : 0; 
  1000 	iBorderLeft = iBorderRight = iExtentWidth<iWindowWidth ? (iWindowWidth-iExtentWidth)/2 : 0; 
  1001 
  1002     // Establish the connection to the window server and create
  1003     // a WindowGroup and a Window object
  1004     CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
  1005 
  1006     // Create display object
  1007     GetDisplayL();
  1008     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  1009     iEglSess->InitializeL();
  1010 
  1011     // Choose EGL config
  1012     EGLConfig matchingConfigs[1];
  1013     EGLint numConfigs = 0;
  1014 
  1015     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  1016     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
  1017 
  1018     EGLint attrib_list[] = {
  1019               EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
  1020               EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
  1021               EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
  1022               EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
  1023               EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
  1024               EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
  1025               EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
  1026               EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
  1027               EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
  1028               EGL_NONE};
  1029     
  1030     // Create the window surface and the egl context and make them current
  1031     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  1032     
  1033     // Create the test bitmap that will be used in the scaled surface 
  1034     //  NOTE: This bitmap generally does not have borders, 
  1035     CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
  1036     
  1037     // Copy test bitmap to drawing surface
  1038     WritePixelsToSurfaceL(*testBitmap);
  1039 
  1040     // we need to update the window content for the first frame comparison inside the loop further down 
  1041 	ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
  1042 	ASSERT_EGL_TRUE(eglWaitClient());
  1043 
  1044 	// Start doing iterations changing border colours and increasing target extent size 
  1045     //  We do increments of (2,2) because the reference bitmap is simetrically split into 4 areas, so size
  1046     //  of this reference bitmap should be an even number of pixels
  1047     INFO_PRINTF1(_L("Start changing border colours and increasing target extent size by (2,2)..."));
  1048     for (;;)
  1049     	{
  1050 		// re-populate buffers with the unmodified fixed size surface content
  1051 		WritePixelsToSurfaceL(*testBitmap);
  1052 
  1053 		// perform the testing
  1054 		doTestPartialStepL();
  1055 		
  1056 		// break the loop when necessary
  1057 		if (iBorderColor.Blue()>=255)
  1058 			break;
  1059 		}
  1060 
  1061     /// Cleanup
  1062     CleanupStack::PopAndDestroy(testBitmap);
  1063     iEglSess->CleanupSurfaceAndContextL();
  1064     CleanAll();
  1065     CloseWindow();
  1066     
  1067     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_SwapBuffers::doTestStepL completed!"));
  1068     RecordTestResultL();
  1069     CloseTMSGraphicsStep();
  1070     return TestStepResult();
  1071     }
  1072 
  1073 TVerdict CEglTest_SurfaceScaling_SwapBuffers::doTestPartialStepL()
  1074     {
  1075     INFO_PRINTF4(_L("doTestPartialStepL started for border colour (%d,%d,%d)...."), iBorderColor.Red(), iBorderColor.Green(), iBorderColor.Blue());
  1076 
  1077 	// Note that borders will appear while extent is smaller than window
  1078 	//  - iSurfaceWidth/iSurfaceHeight - unmodified
  1079 	//  - iExtentWidth/iExtentHeight - modified 
  1080 	//  - iOffsetX/iOffsetY - modified
  1081 	
  1082     // Set up new value for border blue channel, storing old ones
  1083 	TRgb oldBorderColor(iBorderColor);
  1084 	TInt newColorBlue = oldBorderColor.Blue() + 5;
  1085 	TESTL(newColorBlue>=0 && newColorBlue<=255);
  1086 	iBorderColor.SetBlue(newColorBlue);
  1087 	
  1088     // Set up new values for extent/offset, storing old ones
  1089 	TInt oldExtentWidth = iExtentWidth;
  1090 	TInt oldExtentHeight = iExtentHeight;
  1091 	iExtentWidth+=2;
  1092 	iExtentHeight+=2;
  1093 	iOffsetX = (iWindowWidth-iExtentWidth)/2; 
  1094 	iOffsetY = (iWindowHeight-iExtentHeight)/2;
  1095 	
  1096 	// Set up expected values for the border, storing old ones
  1097 	TInt oldBorderTop = iBorderTop;
  1098 	TInt oldBorderBottom = iBorderBottom;
  1099 	TInt oldBorderLeft = iBorderLeft;
  1100 	TInt oldBorderRight = iBorderRight;
  1101 	iBorderTop = iBorderBottom = iExtentHeight<iWindowHeight ? (iWindowHeight-iExtentHeight)/2 : 0; 
  1102 	iBorderLeft = iBorderRight = iExtentWidth<iWindowWidth ? (iWindowWidth-iExtentWidth)/2 : 0; 
  1103 
  1104     // set new extent/offset values
  1105     ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
  1106     // set new border colour values
  1107     ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue()));
  1108     
  1109     // Check that values have been updated as expected
  1110     CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY); 
  1111     CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green()); 
  1112 
  1113     // Check that the screen has NOT BEEN UPDATED just yet
  1114 
  1115     // Create the reference bitmap that should be expected before the extent/border changes 
  1116     TInt refWidth = oldExtentWidth>iWindowWidth ? oldExtentWidth : iWindowWidth;
  1117     TInt refHeight = oldExtentHeight>iWindowHeight ? oldExtentHeight : iWindowHeight;
  1118     CFbsBitmap* oldRefBitmap = CreateBitmapLC(TSize(refWidth, refHeight), oldBorderTop, oldBorderBottom, oldBorderLeft, oldBorderRight, oldBorderColor);
  1119 
  1120     // compare screen with old reference bitmap
  1121     TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *oldRefBitmap, TestStepName());
  1122     TEST(comparison==KErrNone);
  1123     INFO_PRINTF3(_L("CompareScreenImageL before eglSwapBuffers returns %d (expected is %d)"), comparison, KErrNone);
  1124 
  1125     // extent/offset changes MUST be effective only after swapbuffers 
  1126 	ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
  1127 	ASSERT_EGL_TRUE(eglWaitClient());
  1128 	// Finish() to ensure all native window operations related to the surface complete before image comparision.
  1129 	iWsSession.Finish();
  1130 	
  1131 	//check values still are as expected
  1132     CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY); 
  1133     CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green()); 
  1134 
  1135     // Create the reference bitmap that should be expected after the extent/border changes 
  1136     refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
  1137     refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
  1138     CFbsBitmap* newRefBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
  1139 
  1140     // compare screen with new reference bitmap
  1141     comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *newRefBitmap, TestStepName());
  1142     TEST(comparison==KErrNone);
  1143     INFO_PRINTF3(_L("CompareScreenImageL after eglSwapBuffers returns %d (expected is %d)"), comparison, KErrNone);
  1144 
  1145     /// Cleanup
  1146     CleanupStack::PopAndDestroy(2, oldRefBitmap); // oldRefBitmap, newRefBitmap
  1147 
  1148     return TestStepResult();
  1149     }
  1150 
  1151 /**
  1152 @SYMTestCaseID GRAPHICS-EGL-0652
  1153 
  1154 @SYMTestPriority 1
  1155 
  1156 @SYMPREQ 2676
  1157 
  1158 @SYMREQ 417-56592
  1159 
  1160 @SYMTestCaseDesc
  1161 Check that all configs that support surface scaling also support window surfaces.
  1162 
  1163 @SYMTestActions
  1164 1. Query number of configs
  1165 2. Iterate through all configs and check if surface scaling is supported
  1166 3. If surface scaling is supported, chech that it supports window surfaces and 
  1167 	attempt to create a fixed size window surface
  1168 4. If surface scaling is not supported, check eglGetConfigAttrib return value and 
  1169 	attempt to create a fixed size window surface
  1170 
  1171 @SYMTestExpectedResults
  1172 3. All configs that support surface scaling support window surfaces and window surface creation succeeds.
  1173 4. If surface scaling is not supported, eglGetConfigAttrib sets value to EGL_FALSE and window surface creation fails.
  1174 */
  1175 TVerdict CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL()
  1176     {
  1177     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL"));
  1178     SetTestStepName(_L("GRAPHICS-EGL-0652"));
  1179     SetTestStepID(_L("GRAPHICS-EGL-0652"));
  1180 
  1181     // Establish the connection to the window server and create
  1182     // a WindowGroup and a Window object
  1183     CreateAndActivateWindowL(TSize(100, 100));
  1184 
  1185     // Create display object
  1186     GetDisplayL();
  1187     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  1188     iEglSess->InitializeL();
  1189 
  1190     EGLConfig matchingConfigs[KMaxEglConfigs];
  1191     EGLint numConfigs = 0;
  1192 
  1193     EGLint attrib_list[] = {
  1194 					EGL_FIXED_WIDTH_NOK, 50,
  1195 					EGL_FIXED_HEIGHT_NOK, 50,
  1196 					EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1197 					EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1198 					EGL_TARGET_EXTENT_WIDTH_NOK, 100,
  1199 					EGL_TARGET_EXTENT_HEIGHT_NOK, 100,
  1200 					EGL_NONE};
  1201 
  1202     // Query total number of configs
  1203     ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
  1204     TESTL(numConfigs >= 1 && numConfigs <= KMaxEglConfigs);
  1205     INFO_PRINTF2(_L("Found %d configs in total"), numConfigs);
  1206 
  1207     // Get all configs
  1208     ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
  1209 
  1210     // Check that if surface scaling is supported in the config, then window surfaces are supported too
  1211     for(TInt i=0; i<numConfigs; i++)
  1212         {
  1213 		// query scaling support
  1214 		EGLint scalingSupport = -32; // arbitraty value which is neither EGL_TRUE nor EGL_FALSE
  1215 		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_SCALING_NOK, &scalingSupport));
  1216 		
  1217 		// query window surface support
  1218 		EGLint surfaceType=-1;
  1219 		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_TYPE, &surfaceType));
  1220 		
  1221 		// check that if surface scaling is supported, it also supports window surfaces
  1222 		if (scalingSupport==EGL_TRUE)
  1223 			{
  1224 			INFO_PRINTF2(_L("Config %d supports surface scaling. Checking window surface support..."), i);
  1225 			TEST((surfaceType&EGL_WINDOW_BIT) == EGL_WINDOW_BIT);
  1226 			}
  1227 		else
  1228 			{
  1229 			// check value was updated accordingly
  1230 			INFO_PRINTF2(_L("Config %d does NOT support surface scaling."), i);
  1231 			TEST(scalingSupport==EGL_FALSE);
  1232 			}
  1233 
  1234 		// check if config supports window surface, fixed window surface creation follows scaling support 
  1235 		if ((surfaceType&EGL_WINDOW_BIT) == EGL_WINDOW_BIT)
  1236 			{
  1237 			EGLSurface windowSurface = eglCreateWindowSurface(iDisplay, matchingConfigs[i], &iWindow, attrib_list);
  1238 			if (scalingSupport==EGL_TRUE)
  1239 				{
  1240 				INFO_PRINTF1(_L("Checking window surface creation succeeds..."));
  1241 				TEST_EGL_ERROR(windowSurface =! EGL_NO_SURFACE, EGL_SUCCESS);
  1242 				}
  1243 			else
  1244 				{
  1245 				INFO_PRINTF1(_L("Checking window surface creation fails..."));
  1246 				TEST_EGL_ERROR(windowSurface == EGL_NO_SURFACE, EGL_BAD_MATCH);
  1247 				}
  1248 			}
  1249         }
  1250 
  1251     // clean-up
  1252     CleanAll();
  1253     CloseWindow();
  1254     
  1255     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL completed!"));
  1256     RecordTestResultL();
  1257     CloseTMSGraphicsStep();
  1258     return TestStepResult();
  1259     }
  1260 
  1261 /**
  1262 @SYMTestCaseID GRAPHICS-EGL-0653
  1263 
  1264 @SYMTestPriority 1
  1265 
  1266 @SYMPREQ 2676
  1267 
  1268 @SYMREQ 417-56592
  1269 
  1270 @SYMTestCaseDesc
  1271 Negative test. This test is to check the return value and error code of eglCreateWindowSurface 
  1272 when creating a fixed size window surface with invalid combination of Surface Scaling attributes 
  1273 and illegal values for each attribute.
  1274 
  1275 @SYMTestActions
  1276 1. Create a fixed size Window Surface with invalid combination of Surface Scaling attributes.
  1277     - Only specify 5 out of 6 of the following attributes, when specified, should be valid.
  1278     EGL_EXTENT_WIDTH_NOK, EGL_EXTENT_HEIGHT_NOK, EGL_TARGET_EXTENT_WIDTH_NOK, 
  1279     EGL_TARGET_EXTENT_HEIGHT_NOK, EGL_TARGET_EXTENT_OFFSET_X_NOK, EGL_TARGET_EXTENT_OFFSET_Y_NOK
  1280 2. Create a fixed size Window Surface with illegal values for each attribute.
  1281     [attribute]                         [illegal value]
  1282     EGL_FIXED_WIDTH_NOK                 less than or equal to zero
  1283     EGL_FIXED_HEIGHT_NOK                less than or equal to zero
  1284     EGL_TARGET_EXTENT_WIDTH_NOK         less than or equal to zero
  1285     EGL_TARGET_EXTENT_HEIGHT_NOK        less than or equal to zero
  1286 
  1287 @SYMTestExpectedResults
  1288 1. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
  1289 2. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
  1290 */
  1291 TVerdict CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL()
  1292     {
  1293     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL"));
  1294     SetTestStepName(_L("GRAPHICS-EGL-0653"));
  1295     SetTestStepID(_L("GRAPHICS-EGL-0653"));
  1296 
  1297     // Establish the connection to the window server and create
  1298     // a WindowGroup and a Window object
  1299     CreateAndActivateWindowL(TSize(100, 100));
  1300 
  1301     // Create display object
  1302     GetDisplayL();
  1303     CreateEglSessionL();
  1304     iEglSess->InitializeL();
  1305     
  1306     // Choose EGL config
  1307     EGLConfig matchingConfigs[1];
  1308     EGLint numConfigs = 0;
  1309     
  1310     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  1311     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
  1312     
  1313     // Make the fixed size surface half width and height of the window
  1314     TInt surfaceWidth = iWindow.Size().iWidth / 2;
  1315     TInt surfaceHeight = iWindow.Size().iHeight / 2;
  1316     
  1317     TInt invalidCombinationAttrNum = 6;
  1318     EGLint invalid_combination_attrib_list[][11] = {
  1319             {
  1320                 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1321                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1322                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1323                 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1324                 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1325                 EGL_NONE},
  1326             {
  1327                 EGL_FIXED_WIDTH_NOK, surfaceWidth,
  1328                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1329                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1330                 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1331                 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1332                 EGL_NONE},
  1333             {
  1334                 EGL_FIXED_WIDTH_NOK, surfaceWidth,
  1335                 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1336                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1337                 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1338                 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1339                 EGL_NONE},
  1340             {
  1341                 EGL_FIXED_WIDTH_NOK, surfaceWidth,
  1342                 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1343                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1344                 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1345                 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1346                 EGL_NONE},
  1347             {
  1348                 EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1349                 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1350                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1351                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1352                 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1353                 EGL_NONE},
  1354             {
  1355                 EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1356                 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1357                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1358                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1359                 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1360                 EGL_NONE}
  1361             };
  1362     
  1363     TInt illegalValAttrNum = 14;
  1364     EGLint illegal_value_attrib_list[][19] = {
  1365                 {
  1366                     EGL_FIXED_WIDTH_NOK, -1,
  1367                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1368                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1369                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1370                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1371                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1372                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1373                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1374                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1375                     EGL_NONE},
  1376                 {
  1377                     EGL_FIXED_WIDTH_NOK, 0,
  1378                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1379                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1380                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1381                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1382                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1383                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1384                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1385                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1386                     EGL_NONE},
  1387                 {
  1388                     EGL_FIXED_WIDTH_NOK, surfaceWidth,
  1389                     EGL_FIXED_HEIGHT_NOK, -1,
  1390                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1391                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1392                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1393                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1394                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1395                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1396                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1397                     EGL_NONE},
  1398                 {
  1399                     EGL_FIXED_WIDTH_NOK, surfaceWidth,
  1400                     EGL_FIXED_HEIGHT_NOK, 0,
  1401                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1402                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1403                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1404                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1405                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1406                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1407                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1408                     EGL_NONE},
  1409                 {
  1410                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1411                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1412                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1413                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1414                     EGL_TARGET_EXTENT_WIDTH_NOK, -1,
  1415                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1416                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1417                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1418                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1419                     EGL_NONE},
  1420                 {
  1421                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1422                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1423                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1424                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1425                     EGL_TARGET_EXTENT_WIDTH_NOK, 0,
  1426                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1427                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1428                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1429                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1430                     EGL_NONE},
  1431                 {
  1432                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1433                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1434                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1435                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1436                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1437                     EGL_TARGET_EXTENT_HEIGHT_NOK, -1,
  1438                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1439                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1440                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1441                     EGL_NONE},
  1442                 {
  1443                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1444                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1445                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1446                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1447                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1448                     EGL_TARGET_EXTENT_HEIGHT_NOK, 0,
  1449                     EGL_BORDER_COLOR_RED_NOK, 0xfc,
  1450                     EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
  1451                     EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
  1452                     EGL_NONE},
  1453                 {
  1454                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1455                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1456                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1457                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1458                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1459                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1460                     EGL_BORDER_COLOR_RED_NOK, -1,
  1461                     EGL_BORDER_COLOR_GREEN_NOK, 0,
  1462                     EGL_BORDER_COLOR_BLUE_NOK, 0,
  1463                     EGL_NONE},
  1464                 {
  1465                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1466                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1467                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1468                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1469                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1470                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1471                     EGL_BORDER_COLOR_RED_NOK, 0,
  1472                     EGL_BORDER_COLOR_GREEN_NOK, -1,
  1473                     EGL_BORDER_COLOR_BLUE_NOK, 0,
  1474                     EGL_NONE},
  1475                 {
  1476                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1477                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1478                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1479                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1480                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1481                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1482                     EGL_BORDER_COLOR_RED_NOK, 0,
  1483                     EGL_BORDER_COLOR_GREEN_NOK, 0,
  1484                     EGL_BORDER_COLOR_BLUE_NOK, -1,
  1485                     EGL_NONE},
  1486                 {
  1487                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1488                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1489                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1490                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1491                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1492                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1493                     EGL_BORDER_COLOR_RED_NOK, 256,
  1494                     EGL_BORDER_COLOR_GREEN_NOK, 0,
  1495                     EGL_BORDER_COLOR_BLUE_NOK, 0,
  1496                     EGL_NONE},
  1497                 {
  1498                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1499                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1500                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1501                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1502                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1503                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1504                     EGL_BORDER_COLOR_RED_NOK, 0,
  1505                     EGL_BORDER_COLOR_GREEN_NOK, 256,
  1506                     EGL_BORDER_COLOR_BLUE_NOK, 0,
  1507                     EGL_NONE},
  1508                 {
  1509                     EGL_FIXED_WIDTH_NOK, surfaceWidth,  
  1510                     EGL_FIXED_HEIGHT_NOK, surfaceHeight,
  1511                     EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1512                     EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1513                     EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
  1514                     EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
  1515                     EGL_BORDER_COLOR_RED_NOK, 0,
  1516                     EGL_BORDER_COLOR_GREEN_NOK, 0,
  1517                     EGL_BORDER_COLOR_BLUE_NOK, 256,
  1518                     EGL_NONE}
  1519                 };
  1520 
  1521     INFO_PRINTF1(_L("Calling eglCreateWindowSurface with invalid combination of Surface Scaling attributes... - only five out of six compulsary attributes specified"));
  1522     for(TInt i = 0;i < invalidCombinationAttrNum;i++)
  1523         {
  1524         EGLSurface surface = eglCreateWindowSurface(iDisplay, matchingConfigs[0], &iWindow, invalid_combination_attrib_list[i]);    
  1525         TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
  1526         }
  1527     
  1528     INFO_PRINTF1(_L("Calling eglCreateWindowSurface with illegal values for each attribute..."));
  1529     for(TInt i = 0;i < illegalValAttrNum;i++)
  1530         {
  1531         EGLSurface surface = eglCreateWindowSurface(iDisplay, matchingConfigs[0], &iWindow, illegal_value_attrib_list[i]);    
  1532         TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
  1533         }
  1534 
  1535     // clean-up
  1536     CloseWindow();
  1537     CleanAll();
  1538 
  1539     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL completed!"));
  1540     RecordTestResultL();
  1541     CloseTMSGraphicsStep();
  1542     return TestStepResult();
  1543     }
  1544 
  1545 /**
  1546 @SYMTestCaseID GRAPHICS-EGL-0654
  1547 
  1548 @SYMTestPriority 1
  1549 
  1550 @SYMPREQ 2676
  1551 
  1552 @SYMREQ 417-56592
  1553 
  1554 @SYMTestCaseDesc
  1555 Negative test. This test is to check the return value and error code when creating
  1556 a fixed size non window surface.
  1557 
  1558 @SYMTestActions
  1559 1. Attempt to create a pixmap with scaling attributes specified
  1560 2. Attempt to create a pbuffer surface with scaling attributes specified
  1561 3. Attempt to create a window surface with scaling attributes specified but 
  1562    config doesn't support surface scaling
  1563 
  1564 @SYMTestExpectedResults
  1565 1. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
  1566 2. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
  1567 3. EGL_NO_SURFACE is returned with error set to EGL_BAD_MATCH
  1568 */
  1569 TVerdict CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL()
  1570     {
  1571     INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL"));
  1572     SetTestStepName(_L("GRAPHICS-EGL-0654"));
  1573     SetTestStepID(_L("GRAPHICS-EGL-0654"));
  1574 
  1575     // Establish the connection to the window server and create
  1576     // a WindowGroup and a Window object
  1577     CreateAndActivateWindowL(TSize(100, 100));
  1578 
  1579     // Create bitmap
  1580     User::LeaveIfError(RFbsSession::Connect());
  1581     CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
  1582     CleanupStack::PushL(bitmap);
  1583     User::LeaveIfError(bitmap->Create(TSize(20, 20), EColor16MU));
  1584     
  1585     // Create display object
  1586     GetDisplayL();
  1587     CreateEglSessionL();
  1588     iEglSess->InitializeL();
  1589     
  1590     EGLConfig config;
  1591     EGLSurface surface = EGL_NO_SURFACE;
  1592     EGLint numConfigs = 0;
  1593     
  1594     // Use OpenVG to draw
  1595     ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
  1596     
  1597     const EGLint KFixedSize_surface_attrib_list[] = {
  1598                 EGL_FIXED_WIDTH_NOK, 100,
  1599                 EGL_FIXED_HEIGHT_NOK, 100,
  1600                 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1601                 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1602                 EGL_TARGET_EXTENT_WIDTH_NOK, 150,
  1603                 EGL_TARGET_EXTENT_HEIGHT_NOK, 150,
  1604                 EGL_NONE};
  1605            
  1606     // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
  1607     TInt index = iAllScalable ? 1 : 0;
  1608     for(; index < 3; index++)
  1609         {
  1610         switch(index)
  1611             {
  1612 		case 0:
  1613 			INFO_PRINTF1(_L("Calling eglCreateWindowSurface with surface scaling attribute specified in a config that does not support scaling..."));
  1614 			ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], &config, 1, &numConfigs));
  1615 			TEST(numConfigs==1);
  1616 			surface = eglCreateWindowSurface(iDisplay, config, &iWindow, KFixedSize_surface_attrib_list);    
  1617 			TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_MATCH);
  1618 			break;
  1619         case 1:
  1620 			INFO_PRINTF1(_L("Calling eglCreatePixmapSurface with surface scaling attribute specified..."));
  1621 		    ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], &config, 1, &numConfigs));
  1622 		    TEST(numConfigs==1);
  1623 			surface = eglCreatePixmapSurface(iDisplay, config, (NativePixmapType)bitmap, KFixedSize_surface_attrib_list);
  1624 			TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
  1625             break;
  1626         case 2:
  1627             INFO_PRINTF1(_L("Calling eglCreatePbufferSurface with surface scaling attribute specified..."));
  1628             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor64K], &config, 1, &numConfigs));
  1629             TEST(numConfigs==1);
  1630             surface = eglCreatePbufferSurface(iDisplay, config, KFixedSize_surface_attrib_list);    
  1631             TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
  1632             break;
  1633 			}
  1634         }
  1635    
  1636     // cleanup
  1637     CleanupStack::PopAndDestroy(bitmap);
  1638     CloseWindow();
  1639     CleanAll();
  1640     RFbsSession::Disconnect();
  1641 
  1642     INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL completed!"));
  1643     RecordTestResultL();
  1644     CloseTMSGraphicsStep();
  1645     return TestStepResult();
  1646     }
  1647 
  1648 /**
  1649 @SYMTestCaseID GRAPHICS-EGL-0655
  1650 
  1651 @SYMTestPriority 1
  1652 
  1653 @SYMPREQ 2676
  1654 
  1655 @SYMREQ 417-56592
  1656 
  1657 @SYMTestCaseDesc
  1658 Exercising border color set by default.
  1659 
  1660 @SYMTestActions
  1661 1. Create a fixed size EGL Window Surface without border color specified.
  1662 2. Create a fixed size EGL Window Surface with border color specified for one channel.
  1663 3. Create a fixed size EGL Window Surface with border color specified for two channels.
  1664  
  1665 @SYMTestExpectedResults
  1666 Retrieved border color matches to the value it has been set at surface creation, 
  1667 if during the surface creation border color has not been specified it is set to black (0x0).   
  1668 */
  1669 TVerdict CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL()
  1670     {
  1671     SetTestStepName(_L("GRAPHICS-EGL-0655"));
  1672     SetTestStepID(_L("GRAPHICS-EGL-0655"));
  1673     INFO_PRINTF1(_L("CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL"));
  1674 
  1675     // Establish the connection to the window server and create
  1676     // a WindowGroup and a Window object
  1677     CreateAndActivateWindowL(TSize(100,100));
  1678     const TInt KWindowWidth = iWindow.Size().iWidth;
  1679     const TInt KWindowHeight = iWindow.Size().iHeight;
  1680     
  1681     // Create display object
  1682     GetDisplayL();
  1683     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  1684     iEglSess->InitializeL();
  1685     
  1686     // Choose EGL config
  1687     EGLConfig matchingConfigs[1];
  1688     EGLint numConfigs = 0;
  1689     
  1690     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  1691     TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
  1692     
  1693     // Make the fixed size surface half width and height of the window
  1694     const TInt KSurfaceWidth = KWindowWidth/2;
  1695     const TInt KSurfaceHeight = KWindowHeight/2;
  1696     
  1697     EGLint attrib_list1[] = {
  1698               EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  1699               EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  1700               EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1701               EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1702               EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
  1703               EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
  1704               EGL_NONE};
  1705 
  1706     EGLint attrib_list2[] = {
  1707               EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  1708               EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  1709               EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1710               EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1711               EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
  1712               EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
  1713               EGL_BORDER_COLOR_RED_NOK, 0xf0,
  1714               EGL_NONE};
  1715 
  1716     EGLint attrib_list3[] = {
  1717               EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  1718               EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  1719               EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1720               EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1721               EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
  1722               EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
  1723               EGL_BORDER_COLOR_BLUE_NOK, 0xf8,
  1724               EGL_BORDER_COLOR_GREEN_NOK, 0xfc,
  1725               EGL_NONE};
  1726     
  1727     for(TInt index = 0; index < 3; index++)
  1728         {
  1729         EGLint* attrib_list = NULL;
  1730         EGLint expectedRedChannelColor = 0; 
  1731         EGLint expectedGreenChannelColor = 0; 
  1732         EGLint expectedBlueChannelColor = 0; 
  1733 
  1734         switch(index)
  1735             {
  1736         case 0:
  1737             attrib_list = attrib_list1;
  1738             break;
  1739         case 1:
  1740             expectedRedChannelColor = 0xf0;
  1741             attrib_list = attrib_list2;
  1742             break;
  1743         case 2:
  1744             expectedBlueChannelColor = 0xf8;
  1745             expectedGreenChannelColor = 0xfc;
  1746             attrib_list = attrib_list3;
  1747             break;
  1748             }
  1749         // Create the window surface and the egl context and make them current
  1750         iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  1751         
  1752         // Check expected border colours 
  1753         CheckBorderColorL(expectedRedChannelColor, expectedBlueChannelColor, expectedGreenChannelColor);
  1754     
  1755         // Cleanup
  1756         iEglSess->CleanupSurfaceAndContextL();
  1757         }
  1758     
  1759     CleanAll();
  1760     CloseWindow();
  1761     
  1762     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL completed!"));
  1763     RecordTestResultL();
  1764     CloseTMSGraphicsStep();
  1765     return TestStepResult();
  1766     }
  1767 
  1768 
  1769 /**
  1770 @SYMTestCaseID GRAPHICS-EGL-0656
  1771 
  1772 @SYMTestPriority 1
  1773 
  1774 @SYMPREQ 2676
  1775 
  1776 @SYMREQ 417-56592
  1777 
  1778 @SYMTestCaseDesc
  1779 Modifying an existing fixed size surface border color. 
  1780 
  1781 @SYMTestActions
  1782 1. Create a fixed size EGL Window Surface with border color specified.
  1783 2. Modify border color with the new values.
  1784  
  1785 @SYMTestExpectedResults
  1786 New color will take place only after setting new values.   
  1787 */
  1788 
  1789 TVerdict CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL()
  1790     {
  1791 	SetTestStepName(_L("GRAPHICS-EGL-0656"));
  1792 	SetTestStepID(_L("GRAPHICS-EGL-0656"));
  1793 	INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL"));
  1794 
  1795     // Establish the connection to the window server and create
  1796     // a WindowGroup and a Window object
  1797     CreateAndActivateWindowL(TSize(100,100));
  1798 
  1799     // Create display object
  1800     GetDisplayL();
  1801     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  1802     iEglSess->InitializeL();
  1803 
  1804     // Choose EGL config
  1805     EGLConfig matchingConfigs[1];
  1806     EGLint numConfigs = 0;
  1807     
  1808     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  1809     TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
  1810     
  1811     // Make the fixed size surface half width and height of the window
  1812     const TInt KWindowWidth = iWindow.Size().iWidth;
  1813     const TInt KWindowHeight = iWindow.Size().iHeight;
  1814     const TInt KSurfaceWidth = KWindowWidth/2;
  1815     const TInt KSurfaceHeight = KWindowHeight/2;
  1816     const TInt KExtentWidth = KSurfaceWidth;
  1817     const TInt KExtentHeight = KSurfaceHeight;
  1818     const EGLint KRedChannelColor = 0x20; 
  1819     const EGLint KGreenChannelColor = 0x40; 
  1820     const EGLint KBlueChannelColor = 0x60; 
  1821 
  1822     EGLint attrib_list[] = {
  1823               EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  1824               EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  1825               EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  1826               EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  1827               EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  1828               EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  1829               EGL_BORDER_COLOR_RED_NOK, KRedChannelColor,
  1830               EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor,
  1831               EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor,
  1832               EGL_NONE};
  1833 
  1834     // Create the window surface and the egl context and make them current
  1835     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  1836 
  1837     CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
  1838     
  1839     //modify existing attributes
  1840     const EGLint KOffsetColor = 100; 
  1841     ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor + KOffsetColor));
  1842     ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor + KOffsetColor));
  1843     ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor + KOffsetColor));
  1844 
  1845     //check that border color has been modified now
  1846     CheckBorderColorL(KRedChannelColor+KOffsetColor, KBlueChannelColor+KOffsetColor, KGreenChannelColor+KOffsetColor);
  1847     
  1848     // Cleanup
  1849     iEglSess->CleanupSurfaceAndContextL();
  1850     CleanAll();
  1851     CloseWindow();
  1852     
  1853 	INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL completed!"));
  1854 
  1855     RecordTestResultL();
  1856     CloseTMSGraphicsStep();
  1857     return TestStepResult();
  1858     }
  1859 
  1860 /**
  1861 @SYMTestCaseID 	GRAPHICS-EGL-0657
  1862 
  1863 @SYMTestPriority 1
  1864 
  1865 @SYMPREQ 2676
  1866 
  1867 @SYMREQ 417-56592
  1868 
  1869 @SYMTestCaseDesc
  1870 Negative testing. Modifying an existing non-fixed size surface border color. 
  1871 
  1872 @SYMTestActions
  1873 1. Create a non-fixed size EGL Window Surface.
  1874 2. Try to set border color after surface creation.
  1875 3. Repeat steps 1-2 for pixmap and pbuffer surface
  1876 
  1877 @SYMTestExpectedResults
  1878 Setting border color has no effect.   
  1879 */
  1880 TVerdict CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL()
  1881     {
  1882 	SetTestStepName(_L("GRAPHICS-EGL-0657"));
  1883 	SetTestStepID(_L("GRAPHICS-EGL-0657"));
  1884 	INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL"));
  1885 
  1886     // Establish the connection to the window server and create
  1887     // a WindowGroup and a Window object
  1888     CreateAndActivateWindowL(TSize(100,100));
  1889 
  1890     const TInt KWindowWidth = iWindow.Size().iWidth;
  1891     const TInt KWindowHeight = iWindow.Size().iHeight;
  1892     const TInt KSurfaceWidth = KWindowWidth;
  1893     const TInt KSurfaceHeight = KWindowHeight;
  1894 
  1895     // Create display object
  1896     GetDisplayL();
  1897     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  1898     iEglSess->InitializeL();
  1899 
  1900     // Choose EGL config
  1901     EGLConfig matchingConfigs[1];
  1902     EGLint numConfigs = 0;
  1903     
  1904     // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
  1905     TInt index = iAllScalable ? 1 : 0;
  1906     for(; index < 3; index++)
  1907         {
  1908         switch(index)
  1909             {
  1910         case 0:
  1911             // Create the non-fixed size window surface and the egl context and make them current
  1912             INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
  1913             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
  1914             TESTL(numConfigs == 1);
  1915             iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);    
  1916             break;
  1917         case 1:
  1918             // Create the pbuffer surface and the egl context and make them current
  1919             INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
  1920             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  1921             TESTL(numConfigs == 1);
  1922             iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
  1923             break;
  1924         case 2:
  1925             // Create the pixmap surface and the egl context and make them current
  1926             INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
  1927             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  1928             TESTL(numConfigs == 1);
  1929             iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
  1930             break;
  1931             }
  1932 
  1933 		// Set border color values to a non fixed size window (nothing should happen)
  1934 		const EGLint KRedChannelColor = 0x20; 
  1935 		const EGLint KGreenChannelColor = 0x40; 
  1936 		const EGLint KBlueChannelColor = 0x60; 
  1937 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor));
  1938 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor));
  1939 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor));
  1940 
  1941 		// Check all attributes (this is a non-fixed size window) 
  1942 		// Note that we cannot use CheckBorderColorL because values are not updated
  1943 		EGLint redChannelColor = -1; 
  1944 		EGLint greenChannelColor = -2; 
  1945 		EGLint blueChannelColor = -3; 
  1946 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &redChannelColor));
  1947 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &blueChannelColor));
  1948 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &greenChannelColor));
  1949 		TEST(redChannelColor == -1);
  1950 		TEST(greenChannelColor == -2);
  1951 		TEST(blueChannelColor == -3);
  1952 
  1953 		// Set invalid border color values to a non fixed size window (nothing should happen)
  1954 		INFO_PRINTF1(_L("Attempt to set invalid border color values to a non fixed size window..."));
  1955 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor+256));
  1956 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor+256));
  1957 		ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor+256));
  1958 		
  1959 		// Check all attributes (this is a non-fixed size window) 
  1960 		// Note that we cannot use CheckBorderColorL because values are not updated
  1961 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &redChannelColor));
  1962 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &blueChannelColor));
  1963 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &greenChannelColor));
  1964 		TEST(redChannelColor == -1);
  1965 		TEST(greenChannelColor == -2);
  1966 		TEST(blueChannelColor == -3);
  1967     
  1968 	   	// destroy surface and context
  1969 	    iEglSess->CleanupSurfaceAndContextL();
  1970         }
  1971     
  1972     // Cleanup
  1973     CleanAll();
  1974     CloseWindow();
  1975     
  1976 	INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL completed!"));
  1977 
  1978     RecordTestResultL();
  1979     CloseTMSGraphicsStep();
  1980     return TestStepResult();
  1981     }
  1982 
  1983 /**
  1984 @SYMTestCaseID GRAPHICS-EGL-0658
  1985 
  1986 @SYMTestPriority 1
  1987 
  1988 @SYMPREQ 2676
  1989 
  1990 @SYMREQ 417-56592
  1991 
  1992 @SYMTestCaseDesc
  1993 Negative testing. Attempt to modify an existing fixed size surface border color with invalid values. 
  1994 
  1995 @SYMTestActions
  1996 1. Create a fixed size EGL Window Surface with border color specified.
  1997 2. Try to modify border color with the negative values.
  1998 3. Try to modify border color with the positive values greater than 255.
  1999  
  2000 @SYMTestExpectedResults
  2001 Attempt to modify the border color with the new values will fail with error code EGL_BAD_ATTRIBUTE.   
  2002 */
  2003 TVerdict CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL()
  2004     {
  2005     SetTestStepName(_L("GRAPHICS-EGL-0658"));
  2006     SetTestStepID(_L("GRAPHICS-EGL-0658"));
  2007     INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL"));
  2008 
  2009     // Establish the connection to the window server and create
  2010     // a WindowGroup and a Window object
  2011     CreateAndActivateWindowL(TSize(100,100));
  2012     const TInt KWindowWidth = iWindow.Size().iWidth;
  2013     const TInt KWindowHeight = iWindow.Size().iHeight;
  2014 
  2015     // Create display object
  2016     GetDisplayL();
  2017     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2018     iEglSess->InitializeL();
  2019 
  2020     // Choose EGL config
  2021     EGLConfig matchingConfigs[1];
  2022     EGLint numConfigs = 0;
  2023     
  2024     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  2025     TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
  2026     
  2027     // Make the fixed size surface half width and height of the window
  2028     const TInt KSurfaceWidth = KWindowWidth/2;
  2029     const TInt KSurfaceHeight = KWindowHeight/2;
  2030     const EGLint KRedChannelColor = 0x20; 
  2031     const EGLint KGreenChannelColor = 0x40; 
  2032     const EGLint KBlueChannelColor = 0x60; 
  2033 
  2034     EGLint attrib_list[] = {
  2035               EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  2036               EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  2037               EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
  2038               EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
  2039               EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
  2040               EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
  2041               EGL_BORDER_COLOR_RED_NOK, KRedChannelColor,
  2042               EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor,
  2043               EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor,
  2044               EGL_NONE};
  2045 
  2046 
  2047     // Create the window surface and the egl context and make them current
  2048     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  2049 
  2050     // check initial values match
  2051     CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
  2052     
  2053     //modify existing attributes with negative value
  2054 	INFO_PRINTF1(_L("Attempt to set negative border color values..."));
  2055     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, -KRedChannelColor) == EGL_FALSE);
  2056     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2057     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, -KBlueChannelColor) == EGL_FALSE);
  2058     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2059     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, -KGreenChannelColor) == EGL_FALSE);
  2060     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2061 
  2062     //check that border color has not been modified
  2063     CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
  2064     
  2065     //modify existing attributes with very big positive value
  2066 	INFO_PRINTF1(_L("Attempt to set border color values that are too big..."));
  2067     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor + 256) == EGL_FALSE);
  2068     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2069     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor + 256) == EGL_FALSE);
  2070     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2071     TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor + 256) == EGL_FALSE);
  2072     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2073 
  2074     //check that border color has not been modified
  2075     CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
  2076 
  2077     /// Cleanup
  2078     iEglSess->CleanupSurfaceAndContextL();
  2079     CleanAll();
  2080     CloseWindow();
  2081     
  2082     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL completed!"));
  2083     RecordTestResultL();
  2084     CloseTMSGraphicsStep();
  2085     return TestStepResult();
  2086     }
  2087 
  2088 /**
  2089 @SYMTestCaseID GRAPHICS-EGL-0659
  2090 
  2091 @SYMTestPriority 1
  2092 
  2093 @SYMPREQ 2676
  2094 
  2095 @SYMREQ 417-56592
  2096 
  2097 @SYMTestCaseDesc
  2098 Negative testing. Attempt to modify an extent with eglSurfaceAttrib() after surface has been created. 
  2099 
  2100 @SYMTestActions
  2101 1. Create a fixed size EGL Window Surface.
  2102 2. Try to modify a surface extent parameters with arbitrary values via eglSurfaceAttrib().
  2103 
  2104 @SYMTestExpectedResults
  2105 Attempt to modify the extent will fail with error code EGL_BAD_ATTRIBUTE.   
  2106 */
  2107 TVerdict CEglTest_SurfaceScalingModifyingExtent::doTestStepL()
  2108     {
  2109     SetTestStepName(_L("GRAPHICS-EGL-0659"));
  2110     SetTestStepID(_L("GRAPHICS-EGL-0659"));
  2111     INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingExtent::doTestStepL"));
  2112 
  2113      // Establish the connection to the window server and create
  2114     // a WindowGroup and a Window object
  2115     CreateAndActivateWindowL(TSize(100,100));
  2116 
  2117     // Create display object
  2118     GetDisplayL();
  2119     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2120     iEglSess->InitializeL();
  2121 
  2122     INFO_PRINTF1(_L("Attempt to modify surface extent for fixed size surfaces..."));
  2123     // Choose EGL config
  2124     EGLConfig matchingConfigs[1];
  2125     EGLint numConfigs = 0;
  2126     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  2127 	TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
  2128 
  2129     const TInt KWindowWidth = iWindow.Size().iWidth;
  2130     const TInt KWindowHeight = iWindow.Size().iHeight;
  2131     const TInt KSurfaceWidth = KWindowWidth/2;
  2132 	const TInt KSurfaceHeight = KWindowHeight/2;
  2133 	const TInt KExtentWidth = KWindowWidth;
  2134 	const TInt KExtentHeight = KWindowHeight;
  2135     const TInt KOffsetX = 10;
  2136 	const TInt KOffsetY = 20;
  2137             
  2138     EGLint attrib_list[] = {
  2139                   EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  2140                   EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  2141                   EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
  2142                   EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
  2143                   EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  2144                   EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  2145                   EGL_NONE};
  2146     
  2147 	// Create the window surface and the egl context and make them current
  2148 	iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  2149 
  2150 	// Invalid update - modify existing attributes with any value
  2151 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, KSurfaceWidth/2) == EGL_FALSE);
  2152 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2153 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, KSurfaceHeight/2) == EGL_FALSE);
  2154 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2155 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth/2) == EGL_FALSE);
  2156 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2157 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight/2) == EGL_FALSE);
  2158 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2159 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX/2) == EGL_FALSE);
  2160 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2161 	TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY/2) == EGL_FALSE);
  2162 	ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2163 
  2164     // check that attributes have not been modified
  2165     CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
  2166 
  2167 	/// Cleanup
  2168     iEglSess->CleanupSurfaceAndContextL();
  2169     CleanAll();
  2170     CloseWindow();
  2171 
  2172     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingExtent::doTestStepL completed!"));
  2173     RecordTestResultL();
  2174     CloseTMSGraphicsStep();
  2175     return TestStepResult();
  2176     }
  2177 
  2178 /**
  2179 @SYMTestCaseID GRAPHICS-EGL-0671
  2180 
  2181 @SYMTestPriority 1
  2182 
  2183 @SYMPREQ 2676
  2184 
  2185 @SYMREQ 417-56592
  2186 
  2187 @SYMTestCaseDesc
  2188 Negative testing. Attempt to modify an extent with eglSurfaceAttrib() after surface has been created. 
  2189 
  2190 @SYMTestActions
  2191 1. Create a non fixed size EGL Window Surface.
  2192 2. Try to modify a surface extent parameters with arbitrary values via eglSurfaceAttrib().
  2193 3. Repeat steps 2-3 for pixmap and pbuffer surface
  2194 
  2195 @SYMTestExpectedResults
  2196 Attempt to modify the extent will fail with error code EGL_BAD_ATTRIBUTE.   
  2197 */
  2198 TVerdict CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL()
  2199     {
  2200     SetTestStepName(_L("GRAPHICS-EGL-0671"));
  2201     SetTestStepID(_L("GRAPHICS-EGL-0671"));
  2202     INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL"));
  2203 
  2204     // Establish the connection to the window server and create
  2205     // a WindowGroup and a Window object
  2206     CreateAndActivateWindowL(TSize(100,100));
  2207 
  2208     const TInt KWindowWidth = iWindow.Size().iWidth;
  2209     const TInt KWindowHeight = iWindow.Size().iHeight;
  2210     const TInt KSurfaceWidth = KWindowWidth;
  2211     const TInt KSurfaceHeight = KWindowHeight;
  2212 	const TInt KExtentWidth = KWindowWidth;
  2213 	const TInt KExtentHeight = KWindowHeight;
  2214     const TInt KOffsetX = 11;
  2215 	const TInt KOffsetY = 22;
  2216 
  2217     // Create display object
  2218     GetDisplayL();
  2219     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2220     iEglSess->InitializeL();
  2221      
  2222     // Choose EGL config
  2223     EGLConfig matchingConfigs[1];
  2224     EGLint numConfigs = 0;
  2225     
  2226     // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
  2227     TInt index = iAllScalable ? 1 : 0;
  2228     for(; index < 3; index++)
  2229         {
  2230         switch(index)
  2231             {
  2232         case 0:
  2233             // Create the non-fixed size window surface and the egl context and make them current
  2234             INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
  2235             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
  2236             TESTL(numConfigs == 1);
  2237             iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);    
  2238             break;
  2239         case 1:
  2240             // Create the pbuffer surface and the egl context and make them current
  2241             INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
  2242             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2243             TESTL(numConfigs == 1);
  2244             iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
  2245             break;
  2246         case 2:
  2247             // Create the pixmap surface and the egl context and make them current
  2248             INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
  2249             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2250             TESTL(numConfigs == 1);
  2251             iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
  2252             break;
  2253             }
  2254 
  2255 		// Invalid update - modify existing attributes with any value
  2256 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, KSurfaceWidth/2) == EGL_FALSE);
  2257 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2258 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, KSurfaceHeight/2) == EGL_FALSE);
  2259 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2260 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth/2) == EGL_FALSE);
  2261 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2262 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight/2) == EGL_FALSE);
  2263 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2264 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX/2) == EGL_FALSE);
  2265 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2266 		TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY/2) == EGL_FALSE);
  2267 		ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2268 
  2269 	   	// destroy surface and context
  2270 	    iEglSess->CleanupSurfaceAndContextL();
  2271         }
  2272     
  2273 	/// Cleanup
  2274     CleanAll();
  2275     CloseWindow();
  2276 
  2277     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL completed!"));
  2278     RecordTestResultL();
  2279     CloseTMSGraphicsStep();
  2280     return TestStepResult();
  2281     }
  2282 
  2283 /**
  2284 @SYMTestCaseID GRAPHICS-EGL-0660
  2285 
  2286 @SYMTestPriority 1
  2287 
  2288 @SYMPREQ 2676
  2289 
  2290 @SYMREQ 417-56592
  2291 
  2292 @SYMTestCaseDesc
  2293 Query surface attrubutes related to scaling. 
  2294 
  2295 @SYMTestActions
  2296 1. Create a non-fixed size EGL Window Surface.
  2297 2. Query surface attributes.
  2298 
  2299 @SYMTestExpectedResults
  2300 2. Query surface attributes succeeds and all atributes matches to the expected values.
  2301 */
  2302 TVerdict CEglTest_SurfaceScalingQuerySurface::doTestStepL()
  2303     {
  2304     SetTestStepName(_L("GRAPHICS-EGL-0660"));
  2305     SetTestStepID(_L("GRAPHICS-EGL-0660"));
  2306     INFO_PRINTF1(_L("CEglTest_SurfaceScalingQuerySurface::doTestStepL"));
  2307 
  2308     // Establish the connection to the window server and create
  2309     // a WindowGroup and a Window object
  2310     CreateAndActivateWindowL(TSize(100,100));
  2311 
  2312     // Create display object
  2313     GetDisplayL();
  2314     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2315     iEglSess->InitializeL();
  2316 
  2317     // Choose EGL config
  2318     EGLConfig matchingConfigs[1];
  2319     EGLint numConfigs = 0;
  2320     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  2321     TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
  2322 
  2323     const TInt KWindowWidth = iWindow.Size().iWidth;
  2324     const TInt KWindowHeight = iWindow.Size().iHeight;
  2325     const TInt KSurfaceWidth = KWindowWidth/2;
  2326     const TInt KSurfaceHeight = KWindowHeight/2;
  2327     const TInt KExtentWidth = KWindowWidth;
  2328     const TInt KExtentHeight = KWindowHeight;
  2329     const EGLint KXOffset = 10;
  2330     const EGLint KYOffset = 20;
  2331     const EGLint KBorderColorRed = 0xa0;
  2332     const EGLint KBorderColorBlue = 0xf0;
  2333     const EGLint KBorderColorGreen = 0xfc;
  2334 
  2335     EGLint attrib_list[] = {
  2336                   EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  2337                   EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  2338                   EGL_TARGET_EXTENT_OFFSET_X_NOK, KXOffset,
  2339                   EGL_TARGET_EXTENT_OFFSET_Y_NOK, KYOffset,
  2340                   EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  2341                   EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  2342                   EGL_BORDER_COLOR_BLUE_NOK, KBorderColorBlue,
  2343                   EGL_BORDER_COLOR_GREEN_NOK, KBorderColorGreen,
  2344                   EGL_BORDER_COLOR_RED_NOK, KBorderColorRed,
  2345                   EGL_NONE};
  2346 
  2347 	// Create the window surface and the egl context and make them current
  2348     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  2349 
  2350     INFO_PRINTF1(_L("Query surface attributes and border colour back and check expected values..."));
  2351     CheckBorderColorL(KBorderColorRed, KBorderColorBlue, KBorderColorGreen);
  2352     CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KXOffset, KYOffset);
  2353    
  2354     INFO_PRINTF1(_L("Check EGL_FIXED_WIDTH_NOK and EGL_FIXED_HEIGHT_NOK cannot be queried..."));
  2355     EGLint surfaceFixedWidth = -1;
  2356     EGLint surfaceFixedHeight = -2;
  2357     TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, &surfaceFixedWidth));
  2358     ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2359     TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, &surfaceFixedHeight));
  2360     ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2361 	TEST(surfaceFixedWidth == -1);
  2362 	TEST(surfaceFixedHeight == -2);
  2363     
  2364 	// clean-up
  2365 	iEglSess->CleanupSurfaceAndContextL();
  2366     CloseWindow();
  2367     CleanAll();
  2368     
  2369     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingQuerySurface::doTestStepL completed!"));
  2370     RecordTestResultL();
  2371     CloseTMSGraphicsStep();
  2372     return TestStepResult();
  2373     }
  2374     
  2375 /**
  2376 @SYMTestCaseID GRAPHICS-EGL-0662
  2377 
  2378 @SYMTestPriority 1
  2379 
  2380 @SYMPREQ 2676
  2381 
  2382 @SYMREQ 417-56592
  2383 
  2384 @SYMTestCaseDesc
  2385 Negative testing. Query surface attributes which are not supported by this API. 
  2386 
  2387 @SYMTestActions
  2388 1. Create a non-fixed size EGL window surface.
  2389 2. Query surface attributes.
  2390 3. Repeat step 2 for EGL window surface, pixmap and pbuffer surface
  2391 
  2392 @SYMTestExpectedResults
  2393 Query surface attributes will fail with error code EGL_BAD_ATTRIBUTE.   
  2394 */
  2395 TVerdict CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL()
  2396     {
  2397     SetTestStepName(_L("GRAPHICS-EGL-0662"));
  2398     SetTestStepID(_L("GRAPHICS-EGL-0662"));
  2399     INFO_PRINTF1(_L("CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL"));
  2400 
  2401     // Establish the connection to the window server and create
  2402     // a WindowGroup and a Window object
  2403     CreateAndActivateWindowL(TSize(100,100));
  2404 
  2405     const TInt KWindowWidth = iWindow.Size().iWidth;
  2406     const TInt KWindowHeight = iWindow.Size().iHeight;
  2407     const TInt KSurfaceWidth = KWindowWidth;
  2408     const TInt KSurfaceHeight = KWindowHeight;
  2409 
  2410     // Create display object
  2411     GetDisplayL();
  2412     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2413     iEglSess->InitializeL();
  2414      
  2415     // Choose EGL config
  2416     EGLConfig matchingConfigs[1];
  2417     EGLint numConfigs = 0;
  2418     
  2419     // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
  2420     TInt index = iAllScalable ? 1 : 0;
  2421     for(; index < 3; index++)
  2422         {
  2423         switch(index)
  2424             {
  2425         case 0:
  2426             // Create the non-fixed size window surface and the egl context and make them current
  2427             INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
  2428             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
  2429             TESTL(numConfigs == 1);
  2430             iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);    
  2431             break;
  2432         case 1:
  2433             // Create the pbuffer surface and the egl context and make them current
  2434             INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
  2435             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2436             TESTL(numConfigs == 1);
  2437             iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
  2438             break;
  2439         case 2:
  2440             // Create the pixmap surface and the egl context and make them current
  2441             INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
  2442             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2443             TESTL(numConfigs == 1);
  2444             iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
  2445             break;
  2446             }
  2447 
  2448         INFO_PRINTF1(_L("Check EGL_FIXED_WIDTH_NOK and EGL_FIXED_HEIGHT_NOK cannot be queried..."));
  2449         EGLint surfaceFixedWidth = -1;
  2450         EGLint surfaceFixedHeight = -2;
  2451         TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, &surfaceFixedWidth));
  2452         ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2453         TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, &surfaceFixedHeight));
  2454         ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
  2455         TEST(surfaceFixedWidth == -1);
  2456         TEST(surfaceFixedHeight == -2);
  2457     
  2458         INFO_PRINTF1(_L("Check surface size is as we would expect..."));
  2459         EGLint surfaceWidth = 0;
  2460     	EGLint surfaceHeight = 0;
  2461     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
  2462     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
  2463     	TEST(surfaceWidth == KWindowWidth);		// non-fixed size surface
  2464     	TEST(surfaceHeight == KWindowHeight);	// non-fixed size surface
  2465 
  2466     	INFO_PRINTF1(_L("Check scaling attributes cannot be queried..."));
  2467     	EGLint extentOffsetX = -1;
  2468     	EGLint extentOffsetY = -2;
  2469     	EGLint extentWidth = -3;
  2470     	EGLint extentHeight = -4;
  2471     	EGLint borderColorBlue = -5;
  2472     	EGLint borderColorRed = -6;
  2473     	EGLint borderColorGreen = -7;
  2474     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &extentOffsetX));
  2475     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &extentOffsetY));
  2476     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
  2477     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
  2478     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &borderColorBlue));
  2479     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &borderColorGreen));
  2480     	ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &borderColorRed));
  2481     	TEST(extentOffsetX == -1);
  2482     	TEST(extentOffsetY == -2);
  2483     	TEST(extentWidth == -3);
  2484     	TEST(extentHeight == -4);
  2485     	TEST(borderColorBlue == -5);
  2486     	TEST(borderColorRed == -6);
  2487     	TEST(borderColorGreen == -7);
  2488 
  2489     	// destroy surface and context
  2490         iEglSess->CleanupSurfaceAndContextL();
  2491         }
  2492 
  2493     // clean-up
  2494     CloseWindow();
  2495     CleanAll();
  2496 
  2497     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL completed!"));
  2498     RecordTestResultL();
  2499     CloseTMSGraphicsStep();
  2500     return TestStepResult();
  2501     }
  2502 
  2503 /**
  2504 @SYMTestCaseID GRAPHICS-EGL-0663
  2505 
  2506 @SYMTestPriority 1
  2507 
  2508 @SYMPREQ 2676
  2509 
  2510 @SYMREQ 417-56592
  2511 
  2512 @SYMTestCaseDesc
  2513 Negative testing. Query surface scaling capability with invalid parameters. 
  2514 
  2515 @SYMTestActions
  2516 1. Query surface scaling capability for the different configs.
  2517 2. Query surface scaling capability with invalid display.
  2518 3. Query surface scaling capability with negative surface width.
  2519 4. Query surface scaling capability with negative surface height.
  2520 5. Query surface scaling capability with negative target width.
  2521 6. Query surface scaling capability with negative target height.
  2522 7. Query surface scaling capability with zero surface width.
  2523 8. Query surface scaling capability with zero surface height.
  2524 9. Query surface scaling capability with zero target width.
  2525 10. Query surface scaling capability with zero target height.
  2526 
  2527 @SYMTestExpectedResults
  2528 1. Query surface capability will fail with error code EGL_BAD_MATCH if config doesn't support scaling and succeed otherwise.   
  2529 2. Query surface capability will fail with error code EGL_BAD_DISPLAY.   
  2530 3. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2531 4. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2532 5. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2533 6. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2534 7. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2535 8. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2536 9. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2537 10. Query surface capability will fail with error code EGL_BAD_PARAMETER.   
  2538 */
  2539 TVerdict CEglTest_SurfaceScalingCapability::doTestStepL()
  2540     {
  2541     SetTestStepName(_L("GRAPHICS-EGL-0663"));
  2542     SetTestStepID(_L("GRAPHICS-EGL-0663"));
  2543     INFO_PRINTF1(_L("CEglTest_SurfaceScalingCapability::doTestStepL"));
  2544 
  2545     // Create display object
  2546     GetDisplayL();
  2547     CreateEglSessionL();
  2548     iEglSess->InitializeL();
  2549 
  2550     // Choose EGL config
  2551     EGLConfig matchingConfigs[KMaxEglConfigs];
  2552     EGLint numConfigs = 0;
  2553     
  2554     CreateAndActivateWindowL(TSize(100,100));
  2555     
  2556     const TInt KWindowWidth = iWindow.Size().iWidth;
  2557     const TInt KWindowHeight = iWindow.Size().iHeight;
  2558     const TInt KSurfaceWidth = KWindowWidth/2;
  2559     const TInt KSurfaceHeight = KWindowHeight/2;
  2560     const EGLDisplay KInvalidDisplay = iDisplay - 100;
  2561     EGLint capability = -1; //arbitrary number beyond the existing range 
  2562     EGLConfig config = -1;
  2563     
  2564     INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
  2565     ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
  2566     for(TInt index = 0; index < numConfigs; index++)
  2567         {
  2568         EGLint value = EGL_FALSE;
  2569         ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[index], EGL_SURFACE_SCALING_NOK, &value));
  2570         if(value == EGL_FALSE)
  2571             {
  2572             TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[index], KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2573             TEST(capability == -1); //make sure that value has not been modified
  2574             ASSERT_EGL_ERROR(EGL_BAD_MATCH);
  2575             }
  2576         else  
  2577             {
  2578             if(config == -1) 
  2579                 {//memorize the first config that supports scaling
  2580                 config = matchingConfigs[index];
  2581                 }
  2582             ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[index], KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability));
  2583             TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
  2584             capability = -1; 
  2585             }
  2586         }
  2587     capability = -1; 
  2588     TEST(config != -1); // make sure that at least one config supports scaling 
  2589     
  2590     //invalid display
  2591     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(KInvalidDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2592     TEST(capability == -1); //make sure that value has not been modified
  2593     ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
  2594 
  2595     //negative width
  2596     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, -KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2597     TEST(capability == -1); //make sure that value has not been modified
  2598     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2599     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, -KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2600     TEST(capability == -1); //make sure that value has not been modified
  2601     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2602     //negative height
  2603     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, -KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2604     TEST(capability == -1); //make sure that value has not been modified
  2605     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2606     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, -KWindowHeight, &capability) == EGL_FALSE);
  2607     TEST(capability == -1); //make sure that value has not been modified
  2608     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2609     
  2610     //zero width
  2611     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, -0, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2612     TEST(capability == -1); //make sure that value has not been modified
  2613     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2614     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, -0, KWindowHeight, &capability) == EGL_FALSE);
  2615     TEST(capability == -1); //make sure that value has not been modified
  2616     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2617     //zero height
  2618     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, -0, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
  2619     TEST(capability == -1); //make sure that value has not been modified
  2620     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2621     TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, -0, &capability) == EGL_FALSE);
  2622     TEST(capability == -1); //make sure that value has not been modified
  2623     ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
  2624    
  2625     // Cleanup
  2626     CloseWindow();
  2627     CleanAll();
  2628     
  2629     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingCapability::doTestStepL completed!"));
  2630     RecordTestResultL();
  2631     CloseTMSGraphicsStep();
  2632     return TestStepResult();
  2633     }
  2634 
  2635 /**
  2636 @SYMTestCaseID GRAPHICS-EGL-0664
  2637 
  2638 @SYMTestPriority 1
  2639 
  2640 @SYMPREQ 2676
  2641 
  2642 @SYMREQ 417-56592
  2643 
  2644 @SYMTestCaseDesc
  2645 Call eglSetSurfaceScalingNOK with fixed size surface and a target extent that can be set. 
  2646 
  2647 @SYMTestActions
  2648 Retrieve all available EGL configs and for those that support surface scaling 
  2649 1. Create a window surface with surface scaling attributes and make it current
  2650 2. Query these attributes and check they correspond with what is expected
  2651 3. Query if surface supports scaling to a different extent
  2652 4. Set the new extent and new offset to the surface
  2653 5. Query these attributes
  2654 
  2655 @SYMTestExpectedResults
  2656 5. Surface scaling attributes have been updated    
  2657 */
  2658 TVerdict CEglTest_SurfaceScalingSet::doTestStepL()
  2659     {
  2660     SetTestStepName(_L("GRAPHICS-EGL-0664"));
  2661     SetTestStepID(_L("GRAPHICS-EGL-0664"));
  2662     INFO_PRINTF1(_L("CEglTest_SurfaceScalingSet::doTestStepL"));
  2663 
  2664     // Establish the connection to the window server and create
  2665     // a WindowGroup and a Window object
  2666     CreateAndActivateWindowL(TSize(100, 100));
  2667 
  2668     const TInt KWindowWidth = iWindow.Size().iWidth;
  2669     const TInt KWindowHeight = iWindow.Size().iHeight;
  2670     const TInt KSurfaceWidth = KWindowWidth/2;
  2671     const TInt KSurfaceHeight = KWindowHeight/2;
  2672     const TInt KExtentWidth = KWindowWidth;
  2673     const TInt KExtentHeight = KWindowHeight;
  2674     const EGLint KOffsetX = 3;
  2675     const EGLint KOffsetY = 7;
  2676 
  2677     EGLint attrib_list[] = {
  2678                   EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  2679                   EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  2680                   EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
  2681                   EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
  2682                   EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  2683                   EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  2684                   EGL_NONE};
  2685 
  2686     // Create display object
  2687     GetDisplayL();
  2688     CreateEglSessionL();
  2689     iEglSess->InitializeL();
  2690 
  2691     // Choose EGL config
  2692     EGLConfig matchingConfigs[KMaxEglConfigs];
  2693     EGLint numConfigs = 0;
  2694 
  2695     // Query total number of configs
  2696     ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
  2697     TESTL(numConfigs >= 1 && numConfigs <= KMaxEglConfigs);
  2698     INFO_PRINTF2(_L("Found %d configs"), numConfigs);
  2699 
  2700     // Get the configs
  2701     ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
  2702 
  2703     // Check if surface scaling is supported in the config, if so, create surface
  2704     for(TInt i=0; i<numConfigs; i++)
  2705         {
  2706 		EGLint value = -32; // arbitraty value which is neither EGL_TRUE nor EGL_FALSE
  2707 		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_SCALING_NOK, &value));
  2708 		if (value==EGL_TRUE)
  2709 			{
  2710 			INFO_PRINTF2(_L("Config %d supports surface scaling. Create a window surface..."), i);
  2711 
  2712 		    // Create the window surface and the egl context and make them current
  2713 			EGLint renderableType = 0;
  2714 			ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i],  EGL_RENDERABLE_TYPE, &renderableType));
  2715 			if (renderableType&EGL_OPENVG_BIT)
  2716 				{
  2717 				iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[i], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
  2718 				}
  2719 			else if (renderableType&EGL_OPENGL_ES_BIT)
  2720 				{
  2721 				iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[i], iWindow, EFalse, EGL_OPENGL_ES_API, 1, attrib_list);
  2722 				}
  2723 			else
  2724 				{
  2725 				WARN_PRINTF2(_L("Config %d does not support either OPENVG or OPENGL_ES. Skip!"), i);
  2726 				continue;
  2727 				}
  2728 
  2729 		    // Check values are as expected
  2730 	        CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
  2731 
  2732 	        // modify target extent atttributes
  2733 	        // 1 - first check that this new extent is supported, should do as we're reducing it
  2734 	        EGLint capability = -1; 	//arbitrary number beyond the existing range 
  2735 	        EGLint newExtentWidth = KExtentWidth / 2;
  2736 	    	EGLint newExtentHeight = KExtentHeight / 2;
  2737 	        EGLint newOffsetX = KOffsetX * 2;
  2738 	    	EGLint newOffsetY = KOffsetY * 2;
  2739 	        ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[i], KSurfaceWidth, KSurfaceHeight, newExtentWidth, newExtentHeight, &capability));
  2740             TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
  2741 			// 2 - set new extent
  2742 	        ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight));
  2743 
  2744 	        // Check attributes have changed
  2745 	        CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, newExtentWidth, newExtentHeight, newOffsetX, newOffsetY);
  2746 
  2747 			// Cleanup
  2748 	        iEglSess->CleanupSurfaceAndContextL();
  2749 			}
  2750         }
  2751     
  2752     // Cleanup
  2753     CloseWindow();
  2754     CleanAll();
  2755     
  2756     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSet::doTestStepL completed!"));
  2757     RecordTestResultL();
  2758     CloseTMSGraphicsStep();
  2759     return TestStepResult();
  2760 	}
  2761 
  2762 /**
  2763 @SYMTestCaseID GRAPHICS-EGL-0665
  2764 
  2765 @SYMTestPriority 1
  2766 
  2767 @SYMPREQ 2676
  2768 
  2769 @SYMREQ 417-56592
  2770 
  2771 @SYMTestCaseDesc
  2772 Negative testing. Call eglSetSurfaceScalingNOK with invalid parameters 
  2773 
  2774 @SYMTestActions
  2775 1. Set surface scaling with invalid display.
  2776 2. Set surface scaling with negative target width.
  2777 3. Set surface scaling with negative target height.
  2778 3. Set surface scaling with zero target width.
  2779 3. Set surface scaling with zero target height.
  2780 @SYMTestExpectedResults
  2781 1. Set surface scaling will fail with error code EGL_BAD_DISPLAY.   
  2782 2. Set surface scaling will fail with error code EGL_BAD_PARAMETER.   
  2783 3. Set surface scaling will fail with error code EGL_BAD_PARAMETER.   
  2784 4. Set surface scaling will fail with error code EGL_BAD_PARAMETER.   
  2785 5. Set surface scaling will fail with error code EGL_BAD_PARAMETER.   
  2786 */
  2787 TVerdict CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL()
  2788     {
  2789     SetTestStepName(_L("GRAPHICS-EGL-0665"));
  2790     SetTestStepID(_L("GRAPHICS-EGL-0665"));
  2791     INFO_PRINTF1(_L("CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL"));
  2792 
  2793     // Establish the connection to the window server and create
  2794     // a WindowGroup and a Window object
  2795     CreateAndActivateWindowL(TSize(100, 100));
  2796 
  2797     // Create display object
  2798     GetDisplayL();
  2799     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2800     iEglSess->InitializeL();
  2801 
  2802     // Choose EGL config
  2803     EGLConfig matchingConfigs[1];
  2804     EGLint numConfigs = 0;
  2805     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  2806     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
  2807 
  2808     const TInt KWindowWidth = iWindow.Size().iWidth;
  2809     const TInt KWindowHeight = iWindow.Size().iHeight;
  2810     const TInt KSurfaceWidth = KWindowWidth/2;
  2811     const TInt KSurfaceHeight = KWindowHeight/2;
  2812     const TInt KExtentWidth = KWindowWidth;
  2813     const TInt KExtentHeight = KWindowHeight;
  2814     const EGLint KOffsetX = 11;
  2815     const EGLint KOffsetY = 13;
  2816     EGLint attrib_list[] = {
  2817                   EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  2818                   EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  2819                   EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
  2820                   EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
  2821                   EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  2822                   EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  2823                   EGL_NONE};
  2824 
  2825     // Create the window surface and the egl context and make them current
  2826     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  2827 
  2828     // Check all attributes
  2829     CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
  2830 
  2831     for(TInt index = 0; index < 5; index++)
  2832         {
  2833 		// new attribute values
  2834 		EGLDisplay newDisplay = iDisplay;
  2835 		EGLint newExtentWidth = KExtentWidth;
  2836 		EGLint newExtentHeight = KExtentHeight;
  2837 		EGLint newOffsetX = KOffsetX;
  2838 		EGLint newOffsetY = KOffsetY;
  2839 		// expected error value
  2840 		EGLint error = EGL_BAD_PARAMETER;
  2841 		
  2842 		switch(index)
  2843             {
  2844         case 0:
  2845             // Invalid display - valid extent
  2846             newDisplay = newDisplay - 100;
  2847             error = EGL_BAD_DISPLAY;
  2848             break;
  2849         case 1:
  2850             // Valid display - Negative extent width
  2851         	newExtentWidth = -newExtentHeight;
  2852             break;
  2853         case 2:
  2854             // Valid display - Negative extent height
  2855         	newExtentHeight = -newExtentHeight;
  2856         	break;
  2857 		case 3:
  2858 			// Valid display - zero extent width
  2859 			newExtentWidth = 0;
  2860 			break;
  2861 		case 4:
  2862 			// Valid display - zero extent height
  2863 			newExtentHeight = 0;
  2864 			break;
  2865 			}
  2866 
  2867 		TEST(EGL_FALSE == iPfnEglSetSurfaceScalingNOK(newDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight));
  2868 		ASSERT_EGL_ERROR(error);
  2869 
  2870 		// attributes haven't changed
  2871 	    CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, KOffsetX, KOffsetY);
  2872         }
  2873     
  2874     // Cleanup
  2875     CleanAll();
  2876     CloseWindow();
  2877     
  2878     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL completed!"));
  2879     RecordTestResultL();
  2880     CloseTMSGraphicsStep();
  2881     return TestStepResult();
  2882     }
  2883 
  2884 /**
  2885 @SYMTestCaseID GRAPHICS-EGL-0666
  2886 
  2887 @SYMTestPriority 1
  2888 
  2889 @SYMPREQ 2676
  2890 
  2891 @SYMREQ 417-56592
  2892 
  2893 @SYMTestCaseDesc
  2894 Negative testing. Query scaling attributes in non-fixed size surfaces 
  2895 
  2896 @SYMTestActions
  2897 1. Create a window surface from a non-fixed size surface
  2898 2. Set surface scaling with valid target extent.
  2899 3. Query scaling attributes
  2900 4. Repeat step 2-3 for EGL window surface, pixmap and pbuffer surface
  2901 
  2902 @SYMTestExpectedResults
  2903 2. Set surface scaling will fail with error code EGL_BAD_MATCH.
  2904 3. Query scaling attributes does not fail, but values not updated
  2905 */
  2906 TVerdict CEglTest_SurfaceScalingSetNonFixed::doTestStepL()
  2907     {
  2908     SetTestStepName(_L("GRAPHICS-EGL-0666"));
  2909     SetTestStepID(_L("GRAPHICS-EGL-0666"));
  2910     INFO_PRINTF1(_L("CEglTest_SurfaceScalingSetNonFixed::doTestStepL"));
  2911 
  2912     // Establish the connection to the window server and create
  2913     // a WindowGroup and a Window object
  2914     CreateAndActivateWindowL(TSize(100, 100));
  2915 
  2916     const TInt KWindowWidth = iWindow.Size().iWidth;
  2917     const TInt KWindowHeight = iWindow.Size().iHeight;
  2918     const TInt KSurfaceWidth = KWindowWidth;
  2919     const TInt KSurfaceHeight = KWindowHeight;
  2920 
  2921     // Create display object
  2922     GetDisplayL();
  2923     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  2924     iEglSess->InitializeL();
  2925 
  2926     // Choose EGL config - Make sure it DOES NOT support surface scaling
  2927     EGLConfig matchingConfigs[1];
  2928     EGLint numConfigs = 0;
  2929     
  2930     // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
  2931     TInt index = iAllScalable ? 1 : 0;
  2932     for(; index < 3; index++)
  2933         {
  2934         switch(index)
  2935             {
  2936         case 0:
  2937             // Create the non-fixed size window surface and the egl context and make them current
  2938             INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
  2939             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
  2940             TESTL(numConfigs == 1);
  2941             iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);    
  2942             break;
  2943         case 1:
  2944             // Create the pbuffer surface and the egl context and make them current
  2945             INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
  2946             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2947             TESTL(numConfigs == 1);
  2948             iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
  2949             break;
  2950         case 2:
  2951             // Create the pixmap surface and the egl context and make them current
  2952             INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
  2953             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
  2954             TESTL(numConfigs == 1);
  2955             iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
  2956             break;
  2957             }
  2958 
  2959 		// Check all attributes (this is a non-fixed size surface)  - 
  2960 		// Note that we cannot use CheckScalingAttributesL because values are not updated
  2961 		EGLint surfaceWidth = 0;
  2962 		EGLint surfaceHeight = 0;
  2963 		EGLint extentWidth = -1;	
  2964 		EGLint extentHeight = -2;
  2965 		EGLint offsetX = -3;
  2966 		EGLint offsetY = -4;
  2967 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
  2968 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
  2969 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
  2970 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
  2971 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &offsetX));
  2972 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &offsetY));
  2973 		TEST((surfaceWidth == KWindowWidth) && (surfaceHeight == KWindowHeight));
  2974 		// following values should not be modified (non fixed size window)
  2975 		TEST((extentWidth == -1) && (extentHeight == -2));
  2976 		TEST((offsetX == -3) && (offsetY == -4));
  2977 	
  2978 		// new attribute values
  2979 		EGLint newExtentWidth = extentWidth / 2;
  2980 		EGLint newExtentHeight = extentHeight / 2;
  2981 		EGLint newOffsetX = offsetX * 2;
  2982 		EGLint newOffsetY = offsetY * 2;
  2983 	
  2984 		// Valid parameters - But non fixed size surface
  2985 		TEST(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight) == EGL_FALSE);
  2986 		ASSERT_EGL_ERROR(EGL_BAD_MATCH);
  2987 	
  2988 		// attributes haven't changed
  2989 		// Note that we cannot use CheckScalingAttributesL because values are not updated
  2990 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
  2991 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
  2992 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
  2993 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
  2994 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &offsetX));
  2995 		ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &offsetY));
  2996 		TEST((surfaceWidth == KWindowWidth) && (surfaceHeight == KWindowHeight));
  2997 		TEST((extentWidth == -1) && (extentHeight == -2));
  2998 		TEST((offsetX == -3) && (offsetY == -4));
  2999 	
  3000     	// destroy surface and context
  3001         iEglSess->CleanupSurfaceAndContextL();
  3002         }
  3003 
  3004     // Cleanup
  3005     CleanAll();
  3006     CloseWindow();
  3007     
  3008     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSetNonFixed::doTestStepL completed!"));
  3009     RecordTestResultL();
  3010     CloseTMSGraphicsStep();
  3011     return TestStepResult();
  3012     }
  3013 
  3014 /**
  3015 @SYMTestCaseID GRAPHICS-EGL-0667
  3016 
  3017 @SYMTestPriority 1
  3018 
  3019 @SYMPREQ 2676
  3020 
  3021 @SYMREQ 417-56592
  3022 
  3023 @SYMTestCaseDesc
  3024 Negative testing. Calling extensions without initialising EGL
  3025 
  3026 @SYMTestActions
  3027 Without initialising EGL
  3028 1. Call query surface scaling capability
  3029 2. Call set surface scaling
  3030 
  3031 @SYMTestExpectedResults
  3032 1. Query scaling capability will fail with error code EGL_NOT_INITIALIZED.
  3033 2. Set surface scaling will fail with error code EGL_NOT_INITIALIZED.
  3034 */
  3035 TVerdict CEglTest_SurfaceScalingNotInitialized::doTestStepL()
  3036     {
  3037     SetTestStepName(_L("GRAPHICS-EGL-0667"));
  3038     SetTestStepID(_L("GRAPHICS-EGL-0667"));
  3039     INFO_PRINTF1(_L("CEglTest_SurfaceScalingNotInitialized::doTestStepL"));
  3040 
  3041     // a WindowGroup and a Window object
  3042     CreateAndActivateWindowL(TSize(100, 100));
  3043 
  3044     // Create display object
  3045     GetDisplayL();
  3046     CreateEglSessionL();    // initialise EGL Session so we can make use of its helper objects
  3047     iEglSess->InitializeL();
  3048 
  3049     // Choose EGL config
  3050     EGLConfig matchingConfigs[1];
  3051     EGLint numConfigs = 0;
  3052     ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
  3053     TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
  3054 
  3055     const TInt KWindowWidth = iWindow.Size().iWidth;
  3056     const TInt KWindowHeight = iWindow.Size().iHeight;
  3057     const TInt KSurfaceWidth = KWindowWidth/2;
  3058     const TInt KSurfaceHeight = KWindowHeight/2;
  3059     const TInt KExtentWidth = KWindowWidth;
  3060     const TInt KExtentHeight = KWindowHeight;
  3061     const EGLint KOffsetX = 11;
  3062     const EGLint KOffsetY = 13;
  3063     EGLint attrib_list[] = {
  3064                   EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
  3065                   EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
  3066                   EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
  3067                   EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
  3068                   EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
  3069                   EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
  3070                   EGL_NONE};
  3071 
  3072     // Create the window surface and the egl context and make them current
  3073     iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);    
  3074 
  3075     // First set new offset attributes (fairly simple, so should be supported)
  3076     INFO_PRINTF1(_L("Set new offset attributes - should succeed..."));
  3077     EGLint capability = -1; 	//arbitrary number beyond the existing range 
  3078     ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[0], KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, &capability));
  3079     TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
  3080     ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), KOffsetX+1, KOffsetY+1, KExtentWidth, KExtentHeight));
  3081     
  3082     // Terminate display and try again
  3083     INFO_PRINTF1(_L("Terminate display and try again, should fail now..."));
  3084     eglTerminate(iDisplay);
  3085 
  3086     capability = -1; 	//arbitrary number beyond the existing range 
  3087     TEST(EGL_FALSE == iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[0], KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, &capability));
  3088     TEST(capability == -1); //make sure that value has not been modified
  3089     ASSERT_EGL_ERROR(EGL_NOT_INITIALIZED);
  3090     
  3091     TEST(EGL_FALSE == iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), KOffsetX, KOffsetY, KExtentWidth, KExtentHeight));
  3092     ASSERT_EGL_ERROR(EGL_NOT_INITIALIZED);
  3093     
  3094     // Cleanup
  3095     CleanAll();
  3096     CloseWindow();
  3097     
  3098     INFO_PRINTF1(_L("....CEglTest_SurfaceScalingNotInitialized::doTestStepL completed!"));
  3099     RecordTestResultL();
  3100     CloseTMSGraphicsStep();
  3101     return TestStepResult();
  3102     }
  3103