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