Update contrib.
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include "egltest_surfacescaling.h"
23 #include <test/tefunit.h> // for ASSERT macros
24 #include <test/egltestcommonutils.h>
25 #include "egltestcommoninisettings.h"
27 //We are restricted by the screen comparison utility that requires images to be EColor16MU
28 const TDisplayMode KTestSourceDisplayMode = EColor16MU;
30 CEglTest_SurfaceScalingBase::~CEglTest_SurfaceScalingBase()
33 delete iImageComparison;
39 TVerdict CEglTest_SurfaceScalingBase::doTestStepPreambleL()
41 TVerdict verdict = CEglTestStep::doTestStepPreambleL();
43 INFO_PRINTF1(_L("doTestStepPreambleL() - Initialise surface scaling test settings..."));
44 if(!CheckForExtensionL(KEGL_NOK_surface_scaling))
46 ERR_PRINTF1(_L("KEGL_NOK_surface_scaling not supported!"));
47 User::Leave(KErrNotSupported);
49 //retrieve the pointers to the EGL surface scaling extension functions
50 iPfnEglQuerySurfaceScalingCapabilityNOK = reinterpret_cast <TFPtrEglQuerySurfaceScalingCapabilityNok> (eglGetProcAddress("eglQuerySurfaceScalingCapabilityNOK"));
51 iPfnEglSetSurfaceScalingNOK = reinterpret_cast <TFPtrEglSetSurfaceScalingNok> (eglGetProcAddress("eglSetSurfaceScalingNOK"));
52 if(!iPfnEglQuerySurfaceScalingCapabilityNOK)
54 ERR_PRINTF1(_L(" Cannot retrieve address of the \"eglQuerySurfaceScalingCapabilityNOK\" function"));
55 User::Leave(KErrNotSupported);
57 if(!iPfnEglSetSurfaceScalingNOK)
59 ERR_PRINTF1(_L(" Cannot retrieve address of the \"eglSetSurfaceScalingNOK\" function"));
60 User::Leave(KErrNotSupported);
63 //retrieve surface scaling ini settings
64 CIniData* iniData = CIniData::NewL(KConfigFileName);
65 CleanupStack::PushL(iniData);
67 _LIT(KSectionSurfaceScaling, "SurfaceScaling");
68 _LIT(KKeyAllScalable, "AllScalable");
71 if(!iniData->FindVar(KSectionSurfaceScaling,KKeyAllScalable,scalable))
73 ERR_PRINTF3(_L(" Cannot retrieve section:%S key:%S"), &KSectionSurfaceScaling, &KKeyAllScalable);
74 User::Leave(KErrNotSupported);
76 iAllScalable = (scalable.FindF( _L("true"))==KErrNotFound)? EFalse : ETrue;
77 INFO_PRINTF1(_L(" ************************************************************************"));
78 INFO_PRINTF1(_L(" **** The test will be run in following configuration: "));
79 INFO_PRINTF2(_L(" **** All window surfaces scalable: %S"), &scalable);
80 INFO_PRINTF1(_L(" ************************************************************************"));
81 CleanupStack::PopAndDestroy(iniData);
83 //Initiate a window server session and create a window group
84 OpenWsSessionL(KDefaultWindowGroupId);
86 //Create a Screen Device
87 const TInt screen0 = 0;
88 iScreenDevice = new(ELeave) CWsScreenDevice(iWsSession);
89 User::LeaveIfError(iScreenDevice->Construct(screen0));
91 // get full screen size
92 TPixelsAndRotation sizeAndRotation;
93 iScreenDevice->GetDefaultScreenSizeAndRotation(sizeAndRotation);
94 iScreenSize = sizeAndRotation.iPixelSize;
96 //Create the image comparison tool from the screen device as required by most tests
97 iImageComparison = CTGraphicsScreenComparison::NewL(*iScreenDevice);
102 TVerdict CEglTest_SurfaceScalingBase::doTestStepPostambleL()
104 INFO_PRINTF1(_L("doTestStepPostambleL() - Cleaning up"));
106 // cleanup egltest framework stuff
109 // cleanup member variables
110 delete iImageComparison;
111 iImageComparison = NULL;
112 delete iScreenDevice;
113 iScreenDevice = NULL;
115 // close window and wserver session
119 return CEglTestStep::doTestStepPostambleL();
122 void CEglTest_SurfaceScalingBase::CreateAndActivateWindowL(const TSize& aWindowSize)
124 ConstructWindowL(iWindow, aWindowSize);
127 void CEglTest_SurfaceScalingBase::CloseWindow()
132 //check if border color matches with expected values
133 void CEglTest_SurfaceScalingBase::CheckBorderColorL(EGLint aExpectedRedChannelColor, EGLint aExpectedBlueChannelColor, EGLint aExpectedGreenChannelColor)
135 EGLint value = 0xffff; //set color channel to some arbitrary number
136 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &value));
137 ASSERT_EQUALS(value, aExpectedRedChannelColor);
139 value = 0xffff; //set color channel to some arbitrary number
140 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &value));
141 ASSERT_EQUALS(value, aExpectedGreenChannelColor);
143 value = 0xffff; //set color channel to some arbitrary number
144 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &value));
145 ASSERT_EQUALS(value, aExpectedBlueChannelColor);
148 //check if scaling attributes match with expected values
149 void CEglTest_SurfaceScalingBase::CheckScalingAttributesL(EGLint aExpectedSurfaceWidth, EGLint aExpectedSurfaceHeight, EGLint aExpectedExtentWidth, EGLint aExpectedExtentHeight, EGLint aExpectedOffsetX, EGLint aExpectedOffsetY)
151 EGLint value = 0xffff; //set initial value to some arbitrary number
152 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &value));
153 ASSERT_EQUALS(value, aExpectedSurfaceWidth);
155 value = 0xffff; //set initial value to some arbitrary number
156 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &value));
157 ASSERT_EQUALS(value, aExpectedSurfaceHeight);
159 value = 0xffff; //set initial value to some arbitrary number
160 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &value));
161 ASSERT_EQUALS(value, aExpectedExtentWidth);
163 value = 0xffff; //set initial value to some arbitrary number
164 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &value));
165 ASSERT_EQUALS(value, aExpectedExtentHeight);
167 value = 0xffff; //set initial value to some arbitrary number
168 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &value));
169 ASSERT_EQUALS(value, aExpectedOffsetX);
171 value = 0xffff; //set initial value to some arbitrary number
172 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &value));
173 ASSERT_EQUALS(value, aExpectedOffsetY);
177 Simple create bitmap function to initialise a rectangular bitmap in four simple colours plus borders
178 ---------------------------
180 ¦ ----------------- ¦
184 ¦ e ¦--------¦--------¦ i ¦
188 ¦ ----------------- ¦
190 ---------------------------
192 CFbsBitmap* CEglTest_SurfaceScalingBase::CreateBitmapLC(const TSize& aSize, TInt aBorderTop, TInt aBorderBottom, TInt aBorderLeft, TInt aBorderRight, const TRgb& aBorderColor)
194 // create the bitmap to the requested size (DisplayMode set to default value)
195 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
196 CleanupStack::PushL(bitmap);
197 User::LeaveIfError(bitmap->Create(aSize,KTestSourceDisplayMode));
198 TEST(bitmap->SizeInPixels().iHeight == aSize.iHeight);
199 TEST(bitmap->SizeInPixels().iWidth == aSize.iWidth);
201 //Create a device and context for the purpose of generating the bitmap which will be the
202 //master reference used in the test
203 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
204 CleanupStack::PushL(bitmapDevice);
205 CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
206 CleanupStack::PushL(bitmapGc);
207 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
208 bitmapGc->Activate(bitmapDevice);
210 // First off, set the whole bitmap to the border colour
211 bitmapGc->SetBrushColor(aBorderColor);
212 bitmapGc->SetPenColor(aBorderColor);
213 bitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
214 bitmapGc->DrawRect(aSize);
216 // Set each individual quadrant to a different arbitrary colour
217 const TInt height = aSize.iHeight;
218 const TInt width = aSize.iWidth;
219 const TInt quadrantHeight = (height - aBorderTop - aBorderBottom) / 2;
220 const TInt quadrantWidth = (width - aBorderLeft - aBorderRight) / 2;
222 // quadrant 1 - Colour KRgbMagenta
223 TRect rect = TRect(TPoint(aBorderLeft, aBorderTop), TSize(quadrantWidth, quadrantHeight));
224 bitmapGc->SetBrushColor(KRgbMagenta);
225 bitmapGc->SetPenColor(KRgbMagenta);
226 bitmapGc->DrawRect(rect);
228 // quadrant 2 - Colour KRgbCyan
229 rect = TRect(TPoint(aBorderLeft+quadrantWidth, aBorderTop), TSize(quadrantWidth, quadrantHeight));
230 bitmapGc->SetBrushColor(KRgbCyan);
231 bitmapGc->SetPenColor(KRgbCyan);
232 bitmapGc->DrawRect(rect);
234 // quadrant 3 - Colour KRgbYellow
235 rect = TRect(TPoint(aBorderLeft, aBorderTop+quadrantHeight), TSize(quadrantWidth, quadrantHeight));
236 bitmapGc->SetBrushColor(KRgbYellow);
237 bitmapGc->SetPenColor(KRgbYellow);
238 bitmapGc->DrawRect(rect);
240 // quadrant 4 - Colour KRgbDarkGreen
241 rect = TRect(TPoint(aBorderLeft+quadrantWidth, aBorderTop+quadrantHeight), TSize(quadrantWidth, quadrantHeight));
242 bitmapGc->SetBrushColor(KRgbDarkGreen);
243 bitmapGc->SetPenColor(KRgbDarkGreen);
244 bitmapGc->DrawRect(rect);
247 CleanupStack::PopAndDestroy(2, bitmapDevice);
251 void CEglTest_SurfaceScalingBase::WritePixelsToSurfaceL(const CFbsBitmap& aBitmap)
253 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin
254 const TSize bitmapSize = aBitmap.SizeInPixels();
255 TUint8* address = reinterpret_cast<TUint8*>(aBitmap.DataAddress());
256 const TInt stride = aBitmap.DataStride();
257 address += (bitmapSize.iHeight - 1) * stride;
259 // copy pixel data to the drawing surface
260 vgWritePixels(address, -stride, KDefaultSurfaceFormat,0,0, bitmapSize.iWidth, bitmapSize.iHeight);
261 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
263 // force all outstanding requests on the current context to complete
269 @SYMTestCaseID GRAPHICS-EGL-0651
278 Choose a suitable extent to test that specified border colours are correct.
281 For a number of different situations, do the following:
282 1. Create a window of known size
283 2. Create a fixed size surface, filled in with a predefined bitmap
284 3. Draw the surface onto the window for a set extent and border colour
285 4. Compare window content and border against a reference bitmap containing expected values.
287 @SYMTestExpectedResults
288 The window content matches the independently created reference bitmap in each situation
290 TVerdict CEglTest_SurfaceScaling_Positive::doTestStepL()
292 SetTestStepID(_L("GRAPHICS-EGL-0651"));
293 SetTestStepName(_L("GRAPHICS-EGL-0651"));
294 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Positive::doTestStepL started...."));
296 // Create display object
298 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
299 iEglSess->InitializeL();
301 // NOTE: Borders depend on what you set as extent, offset, window and surface
302 // Care should be taken when choosing size values, better to use even numbers
303 // (CreateBitmap splits rectangle in four, so we don't want a pixel mismatch there)
304 for (TInt index=1; index<=17; index++)
306 // Set some default values which are used in most cases
307 iWindowWidth = iWindowHeight = 200;
308 iBorderColor = TRgb(0,0,0);
309 iBorderTop = iBorderBottom = iBorderLeft = iBorderRight = 0;
314 // surface scaled to same window size with no border
315 iSurfaceWidth = 100; iSurfaceHeight = 50;
316 iExtentWidth = 200; iExtentHeight = 200;
317 iOffsetX = 0; iOffsetY = 0;
320 // surface scaled to half the window size with border top
321 iSurfaceWidth = 100; iSurfaceHeight = 50;
322 iExtentWidth = 200; iExtentHeight = 100;
323 iOffsetX = 0; iOffsetY = 100;
324 iBorderColor = TRgb(0,0,0); // arbitrary border colour
328 // surface scaled to half the window size with border bottom
329 iSurfaceWidth = 100; iSurfaceHeight = 50;
330 iExtentWidth = 200; iExtentHeight = 100;
331 iOffsetX = 0; iOffsetY = 0;
332 iBorderColor = TRgb(128,0,255); // arbitrary border colour
336 // surface scaled to half the window size with border top and bottom
337 iSurfaceWidth = 100; iSurfaceHeight = 50;
338 iExtentWidth = 200; iExtentHeight = 100;
339 iOffsetX = 0; iOffsetY = 50;
340 iBorderColor = TRgb(128,0,0); // arbitrary border colour
341 iBorderTop = 50; iBorderBottom = 50;
344 // surface scaled to half the window size with border left
345 iSurfaceWidth = 100; iSurfaceHeight = 50;
346 iExtentWidth = 100; iExtentHeight = 200;
347 iOffsetX = 100; iOffsetY = 0;
348 iBorderColor = TRgb(96,96,96); // arbitrary border colour
352 // surface scaled to half the window size with border right
353 iSurfaceWidth = 100; iSurfaceHeight = 50;
354 iExtentWidth = 100; iExtentHeight = 200;
355 iOffsetX = 0; iOffsetY = 0;
356 iBorderColor = TRgb(192,192,192); // arbitrary border colour
360 // surface scaled to half the window size with border left and right
361 iSurfaceWidth = 100; iSurfaceHeight = 50;
362 iExtentWidth = 100; iExtentHeight = 200;
363 iOffsetX = 50; iOffsetY = 0;
364 iBorderColor = TRgb(0,0,0); // arbitrary border colour
365 iBorderLeft = 50; iBorderRight = 50;
368 // surface scaled in different proportions in width and height, with borders
369 iSurfaceWidth = 100; iSurfaceHeight = 50;
370 iExtentWidth = 190; iExtentHeight = 10;
371 iOffsetX = 5; iOffsetY = 95;
372 iBorderColor = TRgb(240,240,240); // arbitrary border colour
373 iBorderTop = 95; iBorderBottom = 95; iBorderLeft = 5; iBorderRight = 5;
376 // surface scaled to double the window height size, surface cropped with no borders
377 iSurfaceWidth = 100; iSurfaceHeight = 50;
378 iExtentWidth = 400; iExtentHeight = 200;
379 iOffsetX = 0; iOffsetY = 0;
382 // surface scaled to double the window width and height size, surface cropped with no borders
383 iSurfaceWidth = 100; iSurfaceHeight = 50;
384 iExtentWidth = 400; iExtentHeight = 400;
385 iOffsetX = 0; iOffsetY = 0;
388 // surface scaled to double the window width and height size, surface cropped with borders top and left
389 iSurfaceWidth = 100; iSurfaceHeight = 50;
390 iExtentWidth = 400; iExtentHeight = 400;
391 iOffsetX = 100; iOffsetY = 100;
392 iBorderColor = TRgb(255,128,255); // arbitrary border colour
393 iBorderTop = 100; iBorderLeft = 100;
396 // QnHD to full screen size
397 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
398 iSurfaceWidth = 320; iSurfaceHeight = 180;
399 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
400 iOffsetX = 0; iOffsetY = 0;
403 // QVGA to full screen size
404 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
405 iSurfaceWidth = 320; iSurfaceHeight = 240;
406 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
407 iOffsetX = 0; iOffsetY = 0;
410 // HVGA to full screen size
411 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
412 iSurfaceWidth = 480; iSurfaceHeight = 320;
413 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
414 iOffsetX = 0; iOffsetY = 0;
417 // 480x270 to full screen size
418 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
419 iSurfaceWidth = 480; iSurfaceHeight = 270;
420 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
421 iOffsetX = 0; iOffsetY = 0;
424 // VGA to full screen size
425 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
426 iSurfaceWidth = 640; iSurfaceHeight = 480;
427 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
428 iOffsetX = 0; iOffsetY = 0;
431 // WVGA to full screen size
432 iWindowWidth = iScreenSize.iWidth; iWindowHeight = iScreenSize.iHeight;
433 iSurfaceWidth = 768; iSurfaceHeight = 480;
434 iExtentWidth = iWindowWidth; iExtentHeight = iWindowHeight;
435 iOffsetX = 0; iOffsetY = 0;
438 ERR_PRINTF2(_L("Inconsistency in test code, case does not exist: %d."), index);
439 User::Leave(KErrNotSupported);
443 // perform the testing
444 doTestPartialStepL();
450 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Positive::doTestStepL completed!"));
452 CloseTMSGraphicsStep();
453 return TestStepResult();
456 TVerdict CEglTest_SurfaceScaling_Positive::doTestPartialStepL()
458 INFO_PRINTF5(_L("doTestPartialStepL started with (%d,%d) fixed surface scaled to (%d,%d) extent...."), iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight);
460 // Establish the connection to the window server and create
461 // a WindowGroup and a Window object
462 CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
465 EGLConfig matchingConfigs[1];
466 EGLint numConfigs = 0;
468 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
469 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
471 EGLint attrib_list[] = {
472 EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
473 EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
474 EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
475 EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
476 EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
477 EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
478 EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
479 EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
480 EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
483 // Create the window surface and the egl context and make them current
484 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
486 // Create the test bitmap that will be used in the scaled surface
487 // NOTE: This bitmap generally does not have borders,
488 CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
490 // Copy test bitmap to drawing surface
491 WritePixelsToSurfaceL(*testBitmap);
493 //call eglSwapBuffers
494 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
495 //Wait for the draw operation to complete
498 // Create the reference bitmap that should be expected after the scaling
499 // NOTE: This bitmap may have borders
500 // Size could exceed that of the window, so check both extent and window
501 const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
502 const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
503 CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
505 // compare window contents with expected bitmap
506 TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
507 TEST(comparison==KErrNone);
508 INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
511 CleanupStack::PopAndDestroy(2, testBitmap); // refBitmap, testBitmap
512 iEglSess->CleanupSurfaceAndContextL();
515 INFO_PRINTF1(_L("....doTestPartialStepL completed!"));
516 return TestStepResult();
520 @SYMTestCaseID GRAPHICS-EGL-0661
529 Resize native window to verify target extent remains fixed.
532 1. Create a window of known size
533 2. Create a fixed size surface, filled in with a predefined bitmap
534 3. Draw the surface onto the window for a set extent and border colour
535 4. Repeat step 3 but increasing native window size by (1,1) pixels.
536 5. Compare window content and border against a reference bitmap containing expected values.
538 @SYMTestExpectedResults
539 The window content matches the independently created reference bitmap in each situation
541 TVerdict CEglTest_SurfaceScaling_WindowResize::doTestStepL()
543 SetTestStepID(_L("GRAPHICS-EGL-0661"));
544 SetTestStepName(_L("GRAPHICS-EGL-0661"));
545 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_WindowResize::doTestStepL started...."));
547 // set the initial value of a square window
548 const TInt KWindowSize = 100;
550 // surface with size and extent that matches the window size and no offset
551 iWindowWidth = iWindowHeight = KWindowSize;
552 iSurfaceWidth = iSurfaceHeight = KWindowSize;
553 iExtentWidth = iExtentHeight = KWindowSize;
554 iOffsetX = 0; iOffsetY = 0;
555 iBorderColor = TRgb(0x99,0xcc,0xff); // set some arbitrary colour
556 iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
558 // Establish the connection to the window server and create
559 // a WindowGroup and a Window object
560 CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
562 // Create display object
564 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
565 iEglSess->InitializeL();
568 EGLConfig matchingConfigs[1];
569 EGLint numConfigs = 0;
571 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
572 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
574 EGLint attrib_list[] = {
575 EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
576 EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
577 EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
578 EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
579 EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
580 EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
581 EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
582 EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
583 EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
586 // Create the window surface and the egl context and make them current
587 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
589 // Create the test bitmap that will be used in the scaled surface
590 // NOTE: This bitmap generally does not have borders,
591 CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
593 // Copy test bitmap to drawing surface
594 WritePixelsToSurfaceL(*testBitmap);
596 // Start doing iterations by increasing native window size.
597 INFO_PRINTF1(_L("Start increasing native window size by (1,1)..."));
600 while(iWindowWidth<=(KWindowSize*2) && iWindowHeight<=(KWindowSize*2))
602 // Note that borders will appear while window size is bigger than extent
603 // - iSurfaceWidth/iSurfaceHeight - unmodified
604 // - iExtentWidth/iExtentHeight - unmodified
605 // - iOffsetX/iOffsetY - unmodified
606 // Set up expected values for the border
607 iBorderTop = 0; iBorderLeft = 0;
608 iBorderBottom = iExtentHeight<iWindowHeight ? iWindowHeight-iExtentHeight : 0;
609 iBorderRight = iExtentWidth<iWindowWidth ? iWindowWidth-iExtentWidth : 0;
611 // resize window to new given size
612 iWindow.Invalidate();
613 iWindow.BeginRedraw();
614 iWindow.SetSize(TSize(iWindowWidth, iWindowHeight));
617 // re-populate buffers with the unmodified fixed size surface content
618 WritePixelsToSurfaceL(*testBitmap);
620 // perform the testing
621 doTestPartialStepL();
627 CleanupStack::PopAndDestroy(testBitmap);
628 iEglSess->CleanupSurfaceAndContextL();
632 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_WindowResize::doTestStepL completed!"));
634 CloseTMSGraphicsStep();
635 return TestStepResult();
638 TVerdict CEglTest_SurfaceScaling_WindowResize::doTestPartialStepL()
640 INFO_PRINTF3(_L("doTestPartialStepL started for native window size of (%d, %d)...."), iWindowWidth, iWindowHeight);
642 // resize may be effective only after swapbuffers
643 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
644 ASSERT_EGL_TRUE(eglWaitClient());
646 //check all expected values
647 CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY);
648 CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green());
650 // Create the reference bitmap that should be expected after the window resize
651 // NOTE: This bitmap may have borders
652 // Size could exceed that of the window, so check both extent and window
653 const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
654 const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
655 CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
657 // compare window contents with expected bitmap
658 TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
659 TEST(comparison==KErrNone);
660 INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
663 CleanupStack::PopAndDestroy(refBitmap);
665 return TestStepResult();
669 @SYMTestCaseID GRAPHICS-EGL-0668
678 Create a fixed size surface and vary the extent position for a range of values.
681 1. Create a window of known size
682 2. Create a fixed size surface, filled in with a predefined bitmap
683 3. Draw the surface onto the window for a set extent and border colour
684 4. Repeat step 3 but increasing target extent offset by (1,1) pixels.
685 5. Compare window content and border against a reference bitmap containing expected values.
687 @SYMTestExpectedResults
688 The window content matches the independently created reference bitmap in each situation
690 TVerdict CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL()
692 SetTestStepID(_L("GRAPHICS-EGL-0668"));
693 SetTestStepName(_L("GRAPHICS-EGL-0668"));
694 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL started...."));
696 // surface with size and extent that matches the window size and no offset
697 iWindowWidth = iWindowHeight = 100;
698 iSurfaceWidth = iExtentWidth = iWindowWidth;
699 iSurfaceHeight = iExtentHeight = iWindowHeight;
700 iOffsetX = 0; iOffsetY = 0;
701 iBorderColor = TRgb(0x11,0x22,0x33); // set some arbitrary colour
702 iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
704 // Establish the connection to the window server and create
705 // a WindowGroup and a Window object
706 CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
708 // Create display object
710 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
711 iEglSess->InitializeL();
714 EGLConfig matchingConfigs[1];
715 EGLint numConfigs = 0;
717 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
718 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
720 EGLint attrib_list[] = {
721 EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
722 EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
723 EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
724 EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
725 EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
726 EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
727 EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
728 EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
729 EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
732 // Create the window surface and the egl context and make them current
733 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
735 // Create the test bitmap that will be used in the scaled surface
736 // NOTE: This bitmap generally does not have borders,
737 CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
739 // Copy test bitmap to drawing surface
740 WritePixelsToSurfaceL(*testBitmap);
742 // This test is a bit different. Since the extent remains the same, and we only change
743 // the offset, we create an oversized reference bitmap and compare the screen with a
744 // region contained within the reference bitmap
745 // Size is three times the extent so that it has extent size borders all around
746 const TInt refWidth = 3*iExtentWidth;
747 const TInt refHeight = 3*iExtentHeight;
748 iBorderTop=iBorderBottom=iBorderLeft=iBorderRight=iExtentWidth;
749 CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
751 // Start doing iterations by increasing target extent offset
752 INFO_PRINTF1(_L("Start increasing target extent offset size by (1,1)..."));
753 for (iOffsetX=-iExtentWidth,iOffsetY=-iExtentHeight; iOffsetX<=iExtentWidth&&iOffsetY<=iExtentHeight; ++iOffsetX,++iOffsetY)
755 // Note that borders will appear other than when offset is (0,0)
756 // - iSurfaceWidth/iSurfaceHeight - unmodified
757 // - iExtentWidth/iExtentHeight - unmodified
759 // set new offset values
760 ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
762 // re-populate buffers with the unmodified fixed size surface content
763 WritePixelsToSurfaceL(*testBitmap);
765 // perform the testing
766 doTestPartialStepL(*refBitmap);
770 CleanupStack::PopAndDestroy(2, testBitmap); //testBitmap, refBitmap
771 iEglSess->CleanupSurfaceAndContextL();
775 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_ExtentPositionChange::doTestStepL completed!"));
777 CloseTMSGraphicsStep();
778 return TestStepResult();
781 TVerdict CEglTest_SurfaceScaling_ExtentPositionChange::doTestPartialStepL(const CFbsBitmap& aRefBitmap)
783 INFO_PRINTF3(_L("doTestPartialStepL started for offset of (%d, %d)...."), iOffsetX, iOffsetY);
785 // offset change may be effective only after swapbuffers
786 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
787 ASSERT_EGL_TRUE(eglWaitClient());
788 // Finish() to ensure all native window operations related to the surface complete before image comparision.
791 //check all expected values
792 CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY);
793 CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green());
795 // Prepare the offset of the reference bitmap to know what sub-region should be compared
796 const TInt refWidth = 3*iExtentWidth;
797 const TInt refHeight = 3*iExtentHeight;
798 TPoint bitmapOffset(refWidth-iExtentWidth-iRefBitmapOffset, refHeight-iExtentHeight-iRefBitmapOffset);
799 iRefBitmapOffset++; // increase offset for next iteration
801 // Comparision takes into account specific region within the reference bitmap
802 TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), bitmapOffset, aRefBitmap, TestStepName());
803 TEST(comparison==KErrNone);
804 INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
806 return TestStepResult();
810 @SYMTestCaseID GRAPHICS-EGL-0669
819 Create a fixed size surface and vary the extent size for a range of values
822 1. Create a window of known size
823 2. Create a fixed size surface, filled in with a predefined bitmap
824 3. Draw the surface onto the window for a set extent and border colour
825 4. Repeat step 3 but increasing target extent size by (2,2) pixels.
826 5. Compare window content and border against a reference bitmap containing expected values.
828 @SYMTestExpectedResults
829 The window content matches the independently created reference bitmap in each situation
831 TVerdict CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL()
833 SetTestStepID(_L("GRAPHICS-EGL-0669"));
834 SetTestStepName(_L("GRAPHICS-EGL-0669"));
835 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL started...."));
837 // set the initial value of a square window
838 const TInt KWindowSize = 100;
840 // surface with size and extent that matches the window size and no offset
841 iWindowWidth = iWindowHeight = KWindowSize;
842 iSurfaceWidth = iSurfaceHeight = KWindowSize;
843 iExtentWidth = iExtentHeight = KWindowSize;
844 iOffsetX = 0; iOffsetY = 0;
845 iBorderColor = TRgb(0x80,0x40,0xF0); // set some arbitrary colour
846 iBorderTop = 0; iBorderBottom = 0; iBorderLeft = 0; iBorderRight = 0;
848 // Establish the connection to the window server and create
849 // a WindowGroup and a Window object
850 CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
852 // Create display object
854 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
855 iEglSess->InitializeL();
858 EGLConfig matchingConfigs[1];
859 EGLint numConfigs = 0;
861 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
862 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
864 EGLint attrib_list[] = {
865 EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
866 EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
867 EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
868 EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
869 EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
870 EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
871 EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
872 EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
873 EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
876 // Create the window surface and the egl context and make them current
877 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
879 // Create the test bitmap that will be used in the scaled surface
880 // NOTE: This bitmap generally does not have borders,
881 CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
883 // Copy test bitmap to drawing surface
884 WritePixelsToSurfaceL(*testBitmap);
886 // Start doing iterations by increasing target extent size
887 // We do increments of (2,2) because the reference bitmap is simetrically split into 4 areas, so size
888 // of this reference bitmap should be an even number of pixels
889 INFO_PRINTF1(_L("Start increasing target extent size by (2,2)..."));
892 while(iExtentWidth <= (KWindowSize*2) && iExtentHeight <= (KWindowSize*2))
894 // Note that borders will appear while extent is smaller than window
895 // - iSurfaceWidth/iSurfaceHeight - unmodified
896 // - iOffsetX/iOffsetY - unmodified
897 // Set up expected values for the border
898 iBorderTop = 0; iBorderLeft = 0;
899 iBorderBottom = iExtentHeight<iWindowHeight ? iWindowHeight-iExtentHeight : 0;
900 iBorderRight = iExtentWidth<iWindowWidth ? iWindowWidth-iExtentWidth : 0;
902 // set new target extent values
903 ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
905 // re-populate buffers with the unmodified fixed size surface content
906 WritePixelsToSurfaceL(*testBitmap);
908 // perform the testing
909 doTestPartialStepL();
915 CleanupStack::PopAndDestroy(testBitmap);
916 iEglSess->CleanupSurfaceAndContextL();
920 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_ExtentSizeChange::doTestStepL completed!"));
922 CloseTMSGraphicsStep();
923 return TestStepResult();
926 TVerdict CEglTest_SurfaceScaling_ExtentSizeChange::doTestPartialStepL()
928 INFO_PRINTF3(_L("doTestPartialStepL started for extent size of (%d, %d)...."), iExtentWidth, iExtentHeight);
930 // extent change may be effective only after swapbuffers
931 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
932 ASSERT_EGL_TRUE(eglWaitClient());
933 // Finish() to ensure all native window operations related to the surface complete before image comparision.
936 //check all expected values
937 CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY);
938 CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green());
940 // Create the reference bitmap that should be expected after the window resize
941 // NOTE: This bitmap may have borders
942 // Size could exceed that of the window, so check both extent and window
943 const TInt refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
944 const TInt refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
945 CFbsBitmap* refBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
947 // compare window contents with expected bitmap
948 TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *refBitmap, TestStepName());
949 TEST(comparison==KErrNone);
950 INFO_PRINTF3(_L("CompareScreenImageL returns %d (expected is %d)"), comparison, KErrNone);
953 CleanupStack::PopAndDestroy(refBitmap);
955 return TestStepResult();
959 @SYMTestCaseID GRAPHICS-EGL-0670
968 Check that updating surface scaling attributes is visible only after calling eglSwapBuffers
971 1. Create a window of known size
972 2. Create a fixed size surface, filled in with a predefined bitmap
973 3. Draw the surface onto the window for a set extent and border colour
974 4. Repeat step 3 but increasing target extent size and changing border colours
975 5. Compare window content and border against a reference bitmap containing expected values
976 5a. Before calling eglSwapBuffers
977 5b. After callnig eglSwapBuffers
979 @SYMTestExpectedResults
980 5a. The window content matches the independently created reference with old values
981 5b. The window content matches the independently created reference with new values
983 TVerdict CEglTest_SurfaceScaling_SwapBuffers::doTestStepL()
985 SetTestStepID(_L("GRAPHICS-EGL-0670"));
986 SetTestStepName(_L("GRAPHICS-EGL-0670"));
987 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_SwapBuffers::doTestStepL started...."));
989 // set the initial value of a square window
990 const TInt KWindowSize = 200;
992 // surface with size that matches the window size and no offset and extent a quarter
993 // of that originally positioned in the middle (so borders should be seen)
994 iWindowWidth = iWindowHeight = KWindowSize;
995 iSurfaceWidth = iSurfaceHeight = KWindowSize;
996 iExtentWidth = iExtentHeight = KWindowSize/4;
997 iOffsetX = (iWindowWidth-iExtentWidth)/2; iOffsetY = (iWindowHeight-iExtentHeight)/2; // to center the surface at the middle of the window
998 iBorderColor = TRgb(0xFF,0xFF,0x00); // set some arbitrary colour with blue channel to 0x00
999 iBorderTop = iBorderBottom = iExtentHeight<iWindowHeight ? (iWindowHeight-iExtentHeight)/2 : 0;
1000 iBorderLeft = iBorderRight = iExtentWidth<iWindowWidth ? (iWindowWidth-iExtentWidth)/2 : 0;
1002 // Establish the connection to the window server and create
1003 // a WindowGroup and a Window object
1004 CreateAndActivateWindowL(TSize(iWindowWidth, iWindowHeight));
1006 // Create display object
1008 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
1009 iEglSess->InitializeL();
1011 // Choose EGL config
1012 EGLConfig matchingConfigs[1];
1013 EGLint numConfigs = 0;
1015 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
1016 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
1018 EGLint attrib_list[] = {
1019 EGL_FIXED_WIDTH_NOK, iSurfaceWidth,
1020 EGL_FIXED_HEIGHT_NOK, iSurfaceHeight,
1021 EGL_TARGET_EXTENT_OFFSET_X_NOK, iOffsetX,
1022 EGL_TARGET_EXTENT_OFFSET_Y_NOK, iOffsetY,
1023 EGL_TARGET_EXTENT_WIDTH_NOK, iExtentWidth,
1024 EGL_TARGET_EXTENT_HEIGHT_NOK, iExtentHeight,
1025 EGL_BORDER_COLOR_RED_NOK, iBorderColor.Red(),
1026 EGL_BORDER_COLOR_GREEN_NOK, iBorderColor.Green(),
1027 EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue(),
1030 // Create the window surface and the egl context and make them current
1031 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
1033 // Create the test bitmap that will be used in the scaled surface
1034 // NOTE: This bitmap generally does not have borders,
1035 CFbsBitmap* testBitmap = CreateBitmapLC(TSize(iSurfaceWidth, iSurfaceHeight),0,0,0,0,TRgb(0,0,0));
1037 // Copy test bitmap to drawing surface
1038 WritePixelsToSurfaceL(*testBitmap);
1040 // we need to update the window content for the first frame comparison inside the loop further down
1041 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
1042 ASSERT_EGL_TRUE(eglWaitClient());
1044 // Start doing iterations changing border colours and increasing target extent size
1045 // We do increments of (2,2) because the reference bitmap is simetrically split into 4 areas, so size
1046 // of this reference bitmap should be an even number of pixels
1047 INFO_PRINTF1(_L("Start changing border colours and increasing target extent size by (2,2)..."));
1050 // re-populate buffers with the unmodified fixed size surface content
1051 WritePixelsToSurfaceL(*testBitmap);
1053 // perform the testing
1054 doTestPartialStepL();
1056 // break the loop when necessary
1057 if (iBorderColor.Blue()>=255)
1062 CleanupStack::PopAndDestroy(testBitmap);
1063 iEglSess->CleanupSurfaceAndContextL();
1067 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_SwapBuffers::doTestStepL completed!"));
1068 RecordTestResultL();
1069 CloseTMSGraphicsStep();
1070 return TestStepResult();
1073 TVerdict CEglTest_SurfaceScaling_SwapBuffers::doTestPartialStepL()
1075 INFO_PRINTF4(_L("doTestPartialStepL started for border colour (%d,%d,%d)...."), iBorderColor.Red(), iBorderColor.Green(), iBorderColor.Blue());
1077 // Note that borders will appear while extent is smaller than window
1078 // - iSurfaceWidth/iSurfaceHeight - unmodified
1079 // - iExtentWidth/iExtentHeight - modified
1080 // - iOffsetX/iOffsetY - modified
1082 // Set up new value for border blue channel, storing old ones
1083 TRgb oldBorderColor(iBorderColor);
1084 TInt newColorBlue = oldBorderColor.Blue() + 5;
1085 TESTL(newColorBlue>=0 && newColorBlue<=255);
1086 iBorderColor.SetBlue(newColorBlue);
1088 // Set up new values for extent/offset, storing old ones
1089 TInt oldExtentWidth = iExtentWidth;
1090 TInt oldExtentHeight = iExtentHeight;
1093 iOffsetX = (iWindowWidth-iExtentWidth)/2;
1094 iOffsetY = (iWindowHeight-iExtentHeight)/2;
1096 // Set up expected values for the border, storing old ones
1097 TInt oldBorderTop = iBorderTop;
1098 TInt oldBorderBottom = iBorderBottom;
1099 TInt oldBorderLeft = iBorderLeft;
1100 TInt oldBorderRight = iBorderRight;
1101 iBorderTop = iBorderBottom = iExtentHeight<iWindowHeight ? (iWindowHeight-iExtentHeight)/2 : 0;
1102 iBorderLeft = iBorderRight = iExtentWidth<iWindowWidth ? (iWindowWidth-iExtentWidth)/2 : 0;
1104 // set new extent/offset values
1105 ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), iOffsetX, iOffsetY, iExtentWidth, iExtentHeight));
1106 // set new border colour values
1107 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, iBorderColor.Blue()));
1109 // Check that values have been updated as expected
1110 CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY);
1111 CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green());
1113 // Check that the screen has NOT BEEN UPDATED just yet
1115 // Create the reference bitmap that should be expected before the extent/border changes
1116 TInt refWidth = oldExtentWidth>iWindowWidth ? oldExtentWidth : iWindowWidth;
1117 TInt refHeight = oldExtentHeight>iWindowHeight ? oldExtentHeight : iWindowHeight;
1118 CFbsBitmap* oldRefBitmap = CreateBitmapLC(TSize(refWidth, refHeight), oldBorderTop, oldBorderBottom, oldBorderLeft, oldBorderRight, oldBorderColor);
1120 // compare screen with old reference bitmap
1121 TInt comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *oldRefBitmap, TestStepName());
1122 TEST(comparison==KErrNone);
1123 INFO_PRINTF3(_L("CompareScreenImageL before eglSwapBuffers returns %d (expected is %d)"), comparison, KErrNone);
1125 // extent/offset changes MUST be effective only after swapbuffers
1126 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSess->Surface()));
1127 ASSERT_EGL_TRUE(eglWaitClient());
1128 // Finish() to ensure all native window operations related to the surface complete before image comparision.
1129 iWsSession.Finish();
1131 //check values still are as expected
1132 CheckScalingAttributesL(iSurfaceWidth, iSurfaceHeight, iExtentWidth, iExtentHeight, iOffsetX, iOffsetY);
1133 CheckBorderColorL(iBorderColor.Red(), iBorderColor.Blue(), iBorderColor.Green());
1135 // Create the reference bitmap that should be expected after the extent/border changes
1136 refWidth = iExtentWidth>iWindowWidth ? iExtentWidth : iWindowWidth;
1137 refHeight = iExtentHeight>iWindowHeight ? iExtentHeight : iWindowHeight;
1138 CFbsBitmap* newRefBitmap = CreateBitmapLC(TSize(refWidth, refHeight), iBorderTop, iBorderBottom, iBorderLeft, iBorderRight, iBorderColor);
1140 // compare screen with new reference bitmap
1141 comparison = iImageComparison->CompareScreenImageL(TSize(iWindowWidth, iWindowHeight), TPoint(0,0), TPoint(0,0), *newRefBitmap, TestStepName());
1142 TEST(comparison==KErrNone);
1143 INFO_PRINTF3(_L("CompareScreenImageL after eglSwapBuffers returns %d (expected is %d)"), comparison, KErrNone);
1146 CleanupStack::PopAndDestroy(2, oldRefBitmap); // oldRefBitmap, newRefBitmap
1148 return TestStepResult();
1152 @SYMTestCaseID GRAPHICS-EGL-0652
1161 Check that all configs that support surface scaling also support window surfaces.
1164 1. Query number of configs
1165 2. Iterate through all configs and check if surface scaling is supported
1166 3. If surface scaling is supported, chech that it supports window surfaces and
1167 attempt to create a fixed size window surface
1168 4. If surface scaling is not supported, check eglGetConfigAttrib return value and
1169 attempt to create a fixed size window surface
1171 @SYMTestExpectedResults
1172 3. All configs that support surface scaling support window surfaces and window surface creation succeeds.
1173 4. If surface scaling is not supported, eglGetConfigAttrib sets value to EGL_FALSE and window surface creation fails.
1175 TVerdict CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL()
1177 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL"));
1178 SetTestStepName(_L("GRAPHICS-EGL-0652"));
1179 SetTestStepID(_L("GRAPHICS-EGL-0652"));
1181 // Establish the connection to the window server and create
1182 // a WindowGroup and a Window object
1183 CreateAndActivateWindowL(TSize(100, 100));
1185 // Create display object
1187 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
1188 iEglSess->InitializeL();
1190 EGLConfig matchingConfigs[KMaxEglConfigs];
1191 EGLint numConfigs = 0;
1193 EGLint attrib_list[] = {
1194 EGL_FIXED_WIDTH_NOK, 50,
1195 EGL_FIXED_HEIGHT_NOK, 50,
1196 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1197 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1198 EGL_TARGET_EXTENT_WIDTH_NOK, 100,
1199 EGL_TARGET_EXTENT_HEIGHT_NOK, 100,
1202 // Query total number of configs
1203 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
1204 TESTL(numConfigs >= 1 && numConfigs <= KMaxEglConfigs);
1205 INFO_PRINTF2(_L("Found %d configs in total"), numConfigs);
1208 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
1210 // Check that if surface scaling is supported in the config, then window surfaces are supported too
1211 for(TInt i=0; i<numConfigs; i++)
1213 // query scaling support
1214 EGLint scalingSupport = -32; // arbitraty value which is neither EGL_TRUE nor EGL_FALSE
1215 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_SCALING_NOK, &scalingSupport));
1217 // query window surface support
1218 EGLint surfaceType=-1;
1219 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_TYPE, &surfaceType));
1221 // check that if surface scaling is supported, it also supports window surfaces
1222 if (scalingSupport==EGL_TRUE)
1224 INFO_PRINTF2(_L("Config %d supports surface scaling. Checking window surface support..."), i);
1225 TEST((surfaceType&EGL_WINDOW_BIT) == EGL_WINDOW_BIT);
1229 // check value was updated accordingly
1230 INFO_PRINTF2(_L("Config %d does NOT support surface scaling."), i);
1231 TEST(scalingSupport==EGL_FALSE);
1234 // check if config supports window surface, fixed window surface creation follows scaling support
1235 if ((surfaceType&EGL_WINDOW_BIT) == EGL_WINDOW_BIT)
1237 EGLSurface windowSurface = eglCreateWindowSurface(iDisplay, matchingConfigs[i], &iWindow, attrib_list);
1238 if (scalingSupport==EGL_TRUE)
1240 INFO_PRINTF1(_L("Checking window surface creation succeeds..."));
1241 TEST_EGL_ERROR(windowSurface =! EGL_NO_SURFACE, EGL_SUCCESS);
1245 INFO_PRINTF1(_L("Checking window surface creation fails..."));
1246 TEST_EGL_ERROR(windowSurface == EGL_NO_SURFACE, EGL_BAD_MATCH);
1255 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_WindowSurface_Check::doTestStepL completed!"));
1256 RecordTestResultL();
1257 CloseTMSGraphicsStep();
1258 return TestStepResult();
1262 @SYMTestCaseID GRAPHICS-EGL-0653
1271 Negative test. This test is to check the return value and error code of eglCreateWindowSurface
1272 when creating a fixed size window surface with invalid combination of Surface Scaling attributes
1273 and illegal values for each attribute.
1276 1. Create a fixed size Window Surface with invalid combination of Surface Scaling attributes.
1277 - Only specify 5 out of 6 of the following attributes, when specified, should be valid.
1278 EGL_EXTENT_WIDTH_NOK, EGL_EXTENT_HEIGHT_NOK, EGL_TARGET_EXTENT_WIDTH_NOK,
1279 EGL_TARGET_EXTENT_HEIGHT_NOK, EGL_TARGET_EXTENT_OFFSET_X_NOK, EGL_TARGET_EXTENT_OFFSET_Y_NOK
1280 2. Create a fixed size Window Surface with illegal values for each attribute.
1281 [attribute] [illegal value]
1282 EGL_FIXED_WIDTH_NOK less than or equal to zero
1283 EGL_FIXED_HEIGHT_NOK less than or equal to zero
1284 EGL_TARGET_EXTENT_WIDTH_NOK less than or equal to zero
1285 EGL_TARGET_EXTENT_HEIGHT_NOK less than or equal to zero
1287 @SYMTestExpectedResults
1288 1. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
1289 2. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
1291 TVerdict CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL()
1293 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL"));
1294 SetTestStepName(_L("GRAPHICS-EGL-0653"));
1295 SetTestStepID(_L("GRAPHICS-EGL-0653"));
1297 // Establish the connection to the window server and create
1298 // a WindowGroup and a Window object
1299 CreateAndActivateWindowL(TSize(100, 100));
1301 // Create display object
1303 CreateEglSessionL();
1304 iEglSess->InitializeL();
1306 // Choose EGL config
1307 EGLConfig matchingConfigs[1];
1308 EGLint numConfigs = 0;
1310 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
1311 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
1313 // Make the fixed size surface half width and height of the window
1314 TInt surfaceWidth = iWindow.Size().iWidth / 2;
1315 TInt surfaceHeight = iWindow.Size().iHeight / 2;
1317 TInt invalidCombinationAttrNum = 6;
1318 EGLint invalid_combination_attrib_list[][11] = {
1320 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1321 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1322 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1323 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1324 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1327 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1328 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1329 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1330 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1331 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1334 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1335 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1336 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1337 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1338 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1341 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1342 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1343 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1344 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1345 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1348 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1349 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1350 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1351 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1352 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1355 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1356 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1357 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1358 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1359 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1363 TInt illegalValAttrNum = 14;
1364 EGLint illegal_value_attrib_list[][19] = {
1366 EGL_FIXED_WIDTH_NOK, -1,
1367 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1368 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1369 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1370 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1371 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1372 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1373 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1374 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1377 EGL_FIXED_WIDTH_NOK, 0,
1378 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1379 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1380 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1381 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1382 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1383 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1384 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1385 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1388 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1389 EGL_FIXED_HEIGHT_NOK, -1,
1390 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1391 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1392 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1393 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1394 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1395 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1396 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1399 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1400 EGL_FIXED_HEIGHT_NOK, 0,
1401 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1402 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1403 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1404 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1405 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1406 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1407 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1410 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1411 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1412 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1413 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1414 EGL_TARGET_EXTENT_WIDTH_NOK, -1,
1415 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1416 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1417 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1418 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1421 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1422 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1423 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1424 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1425 EGL_TARGET_EXTENT_WIDTH_NOK, 0,
1426 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1427 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1428 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1429 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1432 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1433 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1434 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1435 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1436 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1437 EGL_TARGET_EXTENT_HEIGHT_NOK, -1,
1438 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1439 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1440 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1443 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1444 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1445 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1446 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1447 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1448 EGL_TARGET_EXTENT_HEIGHT_NOK, 0,
1449 EGL_BORDER_COLOR_RED_NOK, 0xfc,
1450 EGL_BORDER_COLOR_GREEN_NOK, 0xfd,
1451 EGL_BORDER_COLOR_BLUE_NOK, 0xfe,
1454 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1455 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1456 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1457 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1458 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1459 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1460 EGL_BORDER_COLOR_RED_NOK, -1,
1461 EGL_BORDER_COLOR_GREEN_NOK, 0,
1462 EGL_BORDER_COLOR_BLUE_NOK, 0,
1465 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1466 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1467 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1468 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1469 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1470 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1471 EGL_BORDER_COLOR_RED_NOK, 0,
1472 EGL_BORDER_COLOR_GREEN_NOK, -1,
1473 EGL_BORDER_COLOR_BLUE_NOK, 0,
1476 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1477 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1478 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1479 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1480 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1481 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1482 EGL_BORDER_COLOR_RED_NOK, 0,
1483 EGL_BORDER_COLOR_GREEN_NOK, 0,
1484 EGL_BORDER_COLOR_BLUE_NOK, -1,
1487 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1488 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1489 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1490 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1491 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1492 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1493 EGL_BORDER_COLOR_RED_NOK, 256,
1494 EGL_BORDER_COLOR_GREEN_NOK, 0,
1495 EGL_BORDER_COLOR_BLUE_NOK, 0,
1498 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1499 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1500 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1501 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1502 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1503 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1504 EGL_BORDER_COLOR_RED_NOK, 0,
1505 EGL_BORDER_COLOR_GREEN_NOK, 256,
1506 EGL_BORDER_COLOR_BLUE_NOK, 0,
1509 EGL_FIXED_WIDTH_NOK, surfaceWidth,
1510 EGL_FIXED_HEIGHT_NOK, surfaceHeight,
1511 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1512 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1513 EGL_TARGET_EXTENT_WIDTH_NOK, iWindow.Size().iWidth,
1514 EGL_TARGET_EXTENT_HEIGHT_NOK, iWindow.Size().iHeight,
1515 EGL_BORDER_COLOR_RED_NOK, 0,
1516 EGL_BORDER_COLOR_GREEN_NOK, 0,
1517 EGL_BORDER_COLOR_BLUE_NOK, 256,
1521 INFO_PRINTF1(_L("Calling eglCreateWindowSurface with invalid combination of Surface Scaling attributes... - only five out of six compulsary attributes specified"));
1522 for(TInt i = 0;i < invalidCombinationAttrNum;i++)
1524 EGLSurface surface = eglCreateWindowSurface(iDisplay, matchingConfigs[0], &iWindow, invalid_combination_attrib_list[i]);
1525 TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
1528 INFO_PRINTF1(_L("Calling eglCreateWindowSurface with illegal values for each attribute..."));
1529 for(TInt i = 0;i < illegalValAttrNum;i++)
1531 EGLSurface surface = eglCreateWindowSurface(iDisplay, matchingConfigs[0], &iWindow, illegal_value_attrib_list[i]);
1532 TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
1539 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Negative_CreateWindowSurface::doTestStepL completed!"));
1540 RecordTestResultL();
1541 CloseTMSGraphicsStep();
1542 return TestStepResult();
1546 @SYMTestCaseID GRAPHICS-EGL-0654
1555 Negative test. This test is to check the return value and error code when creating
1556 a fixed size non window surface.
1559 1. Attempt to create a pixmap with scaling attributes specified
1560 2. Attempt to create a pbuffer surface with scaling attributes specified
1561 3. Attempt to create a window surface with scaling attributes specified but
1562 config doesn't support surface scaling
1564 @SYMTestExpectedResults
1565 1. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
1566 2. EGL_NO_SURFACE is returned with error set to EGL_BAD_ATTRIBUTE
1567 3. EGL_NO_SURFACE is returned with error set to EGL_BAD_MATCH
1569 TVerdict CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL()
1571 INFO_PRINTF1(_L("CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL"));
1572 SetTestStepName(_L("GRAPHICS-EGL-0654"));
1573 SetTestStepID(_L("GRAPHICS-EGL-0654"));
1575 // Establish the connection to the window server and create
1576 // a WindowGroup and a Window object
1577 CreateAndActivateWindowL(TSize(100, 100));
1580 User::LeaveIfError(RFbsSession::Connect());
1581 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
1582 CleanupStack::PushL(bitmap);
1583 User::LeaveIfError(bitmap->Create(TSize(20, 20), EColor16MU));
1585 // Create display object
1587 CreateEglSessionL();
1588 iEglSess->InitializeL();
1591 EGLSurface surface = EGL_NO_SURFACE;
1592 EGLint numConfigs = 0;
1594 // Use OpenVG to draw
1595 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
1597 const EGLint KFixedSize_surface_attrib_list[] = {
1598 EGL_FIXED_WIDTH_NOK, 100,
1599 EGL_FIXED_HEIGHT_NOK, 100,
1600 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1601 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1602 EGL_TARGET_EXTENT_WIDTH_NOK, 150,
1603 EGL_TARGET_EXTENT_HEIGHT_NOK, 150,
1606 // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
1607 TInt index = iAllScalable ? 1 : 0;
1608 for(; index < 3; index++)
1613 INFO_PRINTF1(_L("Calling eglCreateWindowSurface with surface scaling attribute specified in a config that does not support scaling..."));
1614 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], &config, 1, &numConfigs));
1615 TEST(numConfigs==1);
1616 surface = eglCreateWindowSurface(iDisplay, config, &iWindow, KFixedSize_surface_attrib_list);
1617 TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_MATCH);
1620 INFO_PRINTF1(_L("Calling eglCreatePixmapSurface with surface scaling attribute specified..."));
1621 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], &config, 1, &numConfigs));
1622 TEST(numConfigs==1);
1623 surface = eglCreatePixmapSurface(iDisplay, config, (NativePixmapType)bitmap, KFixedSize_surface_attrib_list);
1624 TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
1627 INFO_PRINTF1(_L("Calling eglCreatePbufferSurface with surface scaling attribute specified..."));
1628 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor64K], &config, 1, &numConfigs));
1629 TEST(numConfigs==1);
1630 surface = eglCreatePbufferSurface(iDisplay, config, KFixedSize_surface_attrib_list);
1631 TEST_EGL_ERROR(surface == EGL_NO_SURFACE, EGL_BAD_ATTRIBUTE);
1637 CleanupStack::PopAndDestroy(bitmap);
1640 RFbsSession::Disconnect();
1642 INFO_PRINTF1(_L("....CEglTest_SurfaceScaling_Negative_FixedSize_NonWindowSurface::doTestStepL completed!"));
1643 RecordTestResultL();
1644 CloseTMSGraphicsStep();
1645 return TestStepResult();
1649 @SYMTestCaseID GRAPHICS-EGL-0655
1658 Exercising border color set by default.
1661 1. Create a fixed size EGL Window Surface without border color specified.
1662 2. Create a fixed size EGL Window Surface with border color specified for one channel.
1663 3. Create a fixed size EGL Window Surface with border color specified for two channels.
1665 @SYMTestExpectedResults
1666 Retrieved border color matches to the value it has been set at surface creation,
1667 if during the surface creation border color has not been specified it is set to black (0x0).
1669 TVerdict CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL()
1671 SetTestStepName(_L("GRAPHICS-EGL-0655"));
1672 SetTestStepID(_L("GRAPHICS-EGL-0655"));
1673 INFO_PRINTF1(_L("CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL"));
1675 // Establish the connection to the window server and create
1676 // a WindowGroup and a Window object
1677 CreateAndActivateWindowL(TSize(100,100));
1678 const TInt KWindowWidth = iWindow.Size().iWidth;
1679 const TInt KWindowHeight = iWindow.Size().iHeight;
1681 // Create display object
1683 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
1684 iEglSess->InitializeL();
1686 // Choose EGL config
1687 EGLConfig matchingConfigs[1];
1688 EGLint numConfigs = 0;
1690 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
1691 TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
1693 // Make the fixed size surface half width and height of the window
1694 const TInt KSurfaceWidth = KWindowWidth/2;
1695 const TInt KSurfaceHeight = KWindowHeight/2;
1697 EGLint attrib_list1[] = {
1698 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
1699 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
1700 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1701 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1702 EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
1703 EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
1706 EGLint attrib_list2[] = {
1707 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
1708 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
1709 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1710 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1711 EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
1712 EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
1713 EGL_BORDER_COLOR_RED_NOK, 0xf0,
1716 EGLint attrib_list3[] = {
1717 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
1718 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
1719 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1720 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1721 EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
1722 EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
1723 EGL_BORDER_COLOR_BLUE_NOK, 0xf8,
1724 EGL_BORDER_COLOR_GREEN_NOK, 0xfc,
1727 for(TInt index = 0; index < 3; index++)
1729 EGLint* attrib_list = NULL;
1730 EGLint expectedRedChannelColor = 0;
1731 EGLint expectedGreenChannelColor = 0;
1732 EGLint expectedBlueChannelColor = 0;
1737 attrib_list = attrib_list1;
1740 expectedRedChannelColor = 0xf0;
1741 attrib_list = attrib_list2;
1744 expectedBlueChannelColor = 0xf8;
1745 expectedGreenChannelColor = 0xfc;
1746 attrib_list = attrib_list3;
1749 // Create the window surface and the egl context and make them current
1750 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
1752 // Check expected border colours
1753 CheckBorderColorL(expectedRedChannelColor, expectedBlueChannelColor, expectedGreenChannelColor);
1756 iEglSess->CleanupSurfaceAndContextL();
1762 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingDefaultBorderColor::doTestStepL completed!"));
1763 RecordTestResultL();
1764 CloseTMSGraphicsStep();
1765 return TestStepResult();
1770 @SYMTestCaseID GRAPHICS-EGL-0656
1779 Modifying an existing fixed size surface border color.
1782 1. Create a fixed size EGL Window Surface with border color specified.
1783 2. Modify border color with the new values.
1785 @SYMTestExpectedResults
1786 New color will take place only after setting new values.
1789 TVerdict CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL()
1791 SetTestStepName(_L("GRAPHICS-EGL-0656"));
1792 SetTestStepID(_L("GRAPHICS-EGL-0656"));
1793 INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL"));
1795 // Establish the connection to the window server and create
1796 // a WindowGroup and a Window object
1797 CreateAndActivateWindowL(TSize(100,100));
1799 // Create display object
1801 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
1802 iEglSess->InitializeL();
1804 // Choose EGL config
1805 EGLConfig matchingConfigs[1];
1806 EGLint numConfigs = 0;
1808 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
1809 TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
1811 // Make the fixed size surface half width and height of the window
1812 const TInt KWindowWidth = iWindow.Size().iWidth;
1813 const TInt KWindowHeight = iWindow.Size().iHeight;
1814 const TInt KSurfaceWidth = KWindowWidth/2;
1815 const TInt KSurfaceHeight = KWindowHeight/2;
1816 const TInt KExtentWidth = KSurfaceWidth;
1817 const TInt KExtentHeight = KSurfaceHeight;
1818 const EGLint KRedChannelColor = 0x20;
1819 const EGLint KGreenChannelColor = 0x40;
1820 const EGLint KBlueChannelColor = 0x60;
1822 EGLint attrib_list[] = {
1823 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
1824 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
1825 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
1826 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
1827 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
1828 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
1829 EGL_BORDER_COLOR_RED_NOK, KRedChannelColor,
1830 EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor,
1831 EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor,
1834 // Create the window surface and the egl context and make them current
1835 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
1837 CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
1839 //modify existing attributes
1840 const EGLint KOffsetColor = 100;
1841 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor + KOffsetColor));
1842 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor + KOffsetColor));
1843 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor + KOffsetColor));
1845 //check that border color has been modified now
1846 CheckBorderColorL(KRedChannelColor+KOffsetColor, KBlueChannelColor+KOffsetColor, KGreenChannelColor+KOffsetColor);
1849 iEglSess->CleanupSurfaceAndContextL();
1853 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingBorderColor::doTestStepL completed!"));
1855 RecordTestResultL();
1856 CloseTMSGraphicsStep();
1857 return TestStepResult();
1861 @SYMTestCaseID GRAPHICS-EGL-0657
1870 Negative testing. Modifying an existing non-fixed size surface border color.
1873 1. Create a non-fixed size EGL Window Surface.
1874 2. Try to set border color after surface creation.
1875 3. Repeat steps 1-2 for pixmap and pbuffer surface
1877 @SYMTestExpectedResults
1878 Setting border color has no effect.
1880 TVerdict CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL()
1882 SetTestStepName(_L("GRAPHICS-EGL-0657"));
1883 SetTestStepID(_L("GRAPHICS-EGL-0657"));
1884 INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL"));
1886 // Establish the connection to the window server and create
1887 // a WindowGroup and a Window object
1888 CreateAndActivateWindowL(TSize(100,100));
1890 const TInt KWindowWidth = iWindow.Size().iWidth;
1891 const TInt KWindowHeight = iWindow.Size().iHeight;
1892 const TInt KSurfaceWidth = KWindowWidth;
1893 const TInt KSurfaceHeight = KWindowHeight;
1895 // Create display object
1897 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
1898 iEglSess->InitializeL();
1900 // Choose EGL config
1901 EGLConfig matchingConfigs[1];
1902 EGLint numConfigs = 0;
1904 // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
1905 TInt index = iAllScalable ? 1 : 0;
1906 for(; index < 3; index++)
1911 // Create the non-fixed size window surface and the egl context and make them current
1912 INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
1913 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
1914 TESTL(numConfigs == 1);
1915 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);
1918 // Create the pbuffer surface and the egl context and make them current
1919 INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
1920 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
1921 TESTL(numConfigs == 1);
1922 iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
1925 // Create the pixmap surface and the egl context and make them current
1926 INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
1927 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
1928 TESTL(numConfigs == 1);
1929 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
1933 // Set border color values to a non fixed size window (nothing should happen)
1934 const EGLint KRedChannelColor = 0x20;
1935 const EGLint KGreenChannelColor = 0x40;
1936 const EGLint KBlueChannelColor = 0x60;
1937 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor));
1938 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor));
1939 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor));
1941 // Check all attributes (this is a non-fixed size window)
1942 // Note that we cannot use CheckBorderColorL because values are not updated
1943 EGLint redChannelColor = -1;
1944 EGLint greenChannelColor = -2;
1945 EGLint blueChannelColor = -3;
1946 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &redChannelColor));
1947 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &blueChannelColor));
1948 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &greenChannelColor));
1949 TEST(redChannelColor == -1);
1950 TEST(greenChannelColor == -2);
1951 TEST(blueChannelColor == -3);
1953 // Set invalid border color values to a non fixed size window (nothing should happen)
1954 INFO_PRINTF1(_L("Attempt to set invalid border color values to a non fixed size window..."));
1955 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor+256));
1956 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor+256));
1957 ASSERT_EGL_TRUE(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor+256));
1959 // Check all attributes (this is a non-fixed size window)
1960 // Note that we cannot use CheckBorderColorL because values are not updated
1961 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &redChannelColor));
1962 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &blueChannelColor));
1963 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &greenChannelColor));
1964 TEST(redChannelColor == -1);
1965 TEST(greenChannelColor == -2);
1966 TEST(blueChannelColor == -3);
1968 // destroy surface and context
1969 iEglSess->CleanupSurfaceAndContextL();
1976 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingBorderColorNonFixed::doTestStepL completed!"));
1978 RecordTestResultL();
1979 CloseTMSGraphicsStep();
1980 return TestStepResult();
1984 @SYMTestCaseID GRAPHICS-EGL-0658
1993 Negative testing. Attempt to modify an existing fixed size surface border color with invalid values.
1996 1. Create a fixed size EGL Window Surface with border color specified.
1997 2. Try to modify border color with the negative values.
1998 3. Try to modify border color with the positive values greater than 255.
2000 @SYMTestExpectedResults
2001 Attempt to modify the border color with the new values will fail with error code EGL_BAD_ATTRIBUTE.
2003 TVerdict CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL()
2005 SetTestStepName(_L("GRAPHICS-EGL-0658"));
2006 SetTestStepID(_L("GRAPHICS-EGL-0658"));
2007 INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL"));
2009 // Establish the connection to the window server and create
2010 // a WindowGroup and a Window object
2011 CreateAndActivateWindowL(TSize(100,100));
2012 const TInt KWindowWidth = iWindow.Size().iWidth;
2013 const TInt KWindowHeight = iWindow.Size().iHeight;
2015 // Create display object
2017 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2018 iEglSess->InitializeL();
2020 // Choose EGL config
2021 EGLConfig matchingConfigs[1];
2022 EGLint numConfigs = 0;
2024 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
2025 TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
2027 // Make the fixed size surface half width and height of the window
2028 const TInt KSurfaceWidth = KWindowWidth/2;
2029 const TInt KSurfaceHeight = KWindowHeight/2;
2030 const EGLint KRedChannelColor = 0x20;
2031 const EGLint KGreenChannelColor = 0x40;
2032 const EGLint KBlueChannelColor = 0x60;
2034 EGLint attrib_list[] = {
2035 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
2036 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
2037 EGL_TARGET_EXTENT_OFFSET_X_NOK, 0,
2038 EGL_TARGET_EXTENT_OFFSET_Y_NOK, 0,
2039 EGL_TARGET_EXTENT_WIDTH_NOK, KWindowWidth,
2040 EGL_TARGET_EXTENT_HEIGHT_NOK, KWindowHeight,
2041 EGL_BORDER_COLOR_RED_NOK, KRedChannelColor,
2042 EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor,
2043 EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor,
2047 // Create the window surface and the egl context and make them current
2048 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
2050 // check initial values match
2051 CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
2053 //modify existing attributes with negative value
2054 INFO_PRINTF1(_L("Attempt to set negative border color values..."));
2055 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, -KRedChannelColor) == EGL_FALSE);
2056 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2057 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, -KBlueChannelColor) == EGL_FALSE);
2058 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2059 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, -KGreenChannelColor) == EGL_FALSE);
2060 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2062 //check that border color has not been modified
2063 CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
2065 //modify existing attributes with very big positive value
2066 INFO_PRINTF1(_L("Attempt to set border color values that are too big..."));
2067 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, KRedChannelColor + 256) == EGL_FALSE);
2068 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2069 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, KBlueChannelColor + 256) == EGL_FALSE);
2070 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2071 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, KGreenChannelColor + 256) == EGL_FALSE);
2072 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2074 //check that border color has not been modified
2075 CheckBorderColorL(KRedChannelColor, KBlueChannelColor, KGreenChannelColor);
2078 iEglSess->CleanupSurfaceAndContextL();
2082 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingInvalidBorderColor::doTestStepL completed!"));
2083 RecordTestResultL();
2084 CloseTMSGraphicsStep();
2085 return TestStepResult();
2089 @SYMTestCaseID GRAPHICS-EGL-0659
2098 Negative testing. Attempt to modify an extent with eglSurfaceAttrib() after surface has been created.
2101 1. Create a fixed size EGL Window Surface.
2102 2. Try to modify a surface extent parameters with arbitrary values via eglSurfaceAttrib().
2104 @SYMTestExpectedResults
2105 Attempt to modify the extent will fail with error code EGL_BAD_ATTRIBUTE.
2107 TVerdict CEglTest_SurfaceScalingModifyingExtent::doTestStepL()
2109 SetTestStepName(_L("GRAPHICS-EGL-0659"));
2110 SetTestStepID(_L("GRAPHICS-EGL-0659"));
2111 INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingExtent::doTestStepL"));
2113 // Establish the connection to the window server and create
2114 // a WindowGroup and a Window object
2115 CreateAndActivateWindowL(TSize(100,100));
2117 // Create display object
2119 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2120 iEglSess->InitializeL();
2122 INFO_PRINTF1(_L("Attempt to modify surface extent for fixed size surfaces..."));
2123 // Choose EGL config
2124 EGLConfig matchingConfigs[1];
2125 EGLint numConfigs = 0;
2126 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
2127 TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
2129 const TInt KWindowWidth = iWindow.Size().iWidth;
2130 const TInt KWindowHeight = iWindow.Size().iHeight;
2131 const TInt KSurfaceWidth = KWindowWidth/2;
2132 const TInt KSurfaceHeight = KWindowHeight/2;
2133 const TInt KExtentWidth = KWindowWidth;
2134 const TInt KExtentHeight = KWindowHeight;
2135 const TInt KOffsetX = 10;
2136 const TInt KOffsetY = 20;
2138 EGLint attrib_list[] = {
2139 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
2140 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
2141 EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
2142 EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
2143 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
2144 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
2147 // Create the window surface and the egl context and make them current
2148 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
2150 // Invalid update - modify existing attributes with any value
2151 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, KSurfaceWidth/2) == EGL_FALSE);
2152 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2153 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, KSurfaceHeight/2) == EGL_FALSE);
2154 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2155 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth/2) == EGL_FALSE);
2156 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2157 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight/2) == EGL_FALSE);
2158 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2159 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX/2) == EGL_FALSE);
2160 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2161 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY/2) == EGL_FALSE);
2162 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2164 // check that attributes have not been modified
2165 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
2168 iEglSess->CleanupSurfaceAndContextL();
2172 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingExtent::doTestStepL completed!"));
2173 RecordTestResultL();
2174 CloseTMSGraphicsStep();
2175 return TestStepResult();
2179 @SYMTestCaseID GRAPHICS-EGL-0671
2188 Negative testing. Attempt to modify an extent with eglSurfaceAttrib() after surface has been created.
2191 1. Create a non fixed size EGL Window Surface.
2192 2. Try to modify a surface extent parameters with arbitrary values via eglSurfaceAttrib().
2193 3. Repeat steps 2-3 for pixmap and pbuffer surface
2195 @SYMTestExpectedResults
2196 Attempt to modify the extent will fail with error code EGL_BAD_ATTRIBUTE.
2198 TVerdict CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL()
2200 SetTestStepName(_L("GRAPHICS-EGL-0671"));
2201 SetTestStepID(_L("GRAPHICS-EGL-0671"));
2202 INFO_PRINTF1(_L("CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL"));
2204 // Establish the connection to the window server and create
2205 // a WindowGroup and a Window object
2206 CreateAndActivateWindowL(TSize(100,100));
2208 const TInt KWindowWidth = iWindow.Size().iWidth;
2209 const TInt KWindowHeight = iWindow.Size().iHeight;
2210 const TInt KSurfaceWidth = KWindowWidth;
2211 const TInt KSurfaceHeight = KWindowHeight;
2212 const TInt KExtentWidth = KWindowWidth;
2213 const TInt KExtentHeight = KWindowHeight;
2214 const TInt KOffsetX = 11;
2215 const TInt KOffsetY = 22;
2217 // Create display object
2219 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2220 iEglSess->InitializeL();
2222 // Choose EGL config
2223 EGLConfig matchingConfigs[1];
2224 EGLint numConfigs = 0;
2226 // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
2227 TInt index = iAllScalable ? 1 : 0;
2228 for(; index < 3; index++)
2233 // Create the non-fixed size window surface and the egl context and make them current
2234 INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
2235 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
2236 TESTL(numConfigs == 1);
2237 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);
2240 // Create the pbuffer surface and the egl context and make them current
2241 INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
2242 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2243 TESTL(numConfigs == 1);
2244 iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
2247 // Create the pixmap surface and the egl context and make them current
2248 INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
2249 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2250 TESTL(numConfigs == 1);
2251 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
2255 // Invalid update - modify existing attributes with any value
2256 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, KSurfaceWidth/2) == EGL_FALSE);
2257 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2258 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, KSurfaceHeight/2) == EGL_FALSE);
2259 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2260 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth/2) == EGL_FALSE);
2261 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2262 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight/2) == EGL_FALSE);
2263 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2264 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX/2) == EGL_FALSE);
2265 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2266 TEST(eglSurfaceAttrib(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY/2) == EGL_FALSE);
2267 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2269 // destroy surface and context
2270 iEglSess->CleanupSurfaceAndContextL();
2277 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingModifyingExtentNonFixed::doTestStepL completed!"));
2278 RecordTestResultL();
2279 CloseTMSGraphicsStep();
2280 return TestStepResult();
2284 @SYMTestCaseID GRAPHICS-EGL-0660
2293 Query surface attrubutes related to scaling.
2296 1. Create a non-fixed size EGL Window Surface.
2297 2. Query surface attributes.
2299 @SYMTestExpectedResults
2300 2. Query surface attributes succeeds and all atributes matches to the expected values.
2302 TVerdict CEglTest_SurfaceScalingQuerySurface::doTestStepL()
2304 SetTestStepName(_L("GRAPHICS-EGL-0660"));
2305 SetTestStepID(_L("GRAPHICS-EGL-0660"));
2306 INFO_PRINTF1(_L("CEglTest_SurfaceScalingQuerySurface::doTestStepL"));
2308 // Establish the connection to the window server and create
2309 // a WindowGroup and a Window object
2310 CreateAndActivateWindowL(TSize(100,100));
2312 // Create display object
2314 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2315 iEglSess->InitializeL();
2317 // Choose EGL config
2318 EGLConfig matchingConfigs[1];
2319 EGLint numConfigs = 0;
2320 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
2321 TESTL (numConfigs == 1); // Abort the test if the EGL config is not supported
2323 const TInt KWindowWidth = iWindow.Size().iWidth;
2324 const TInt KWindowHeight = iWindow.Size().iHeight;
2325 const TInt KSurfaceWidth = KWindowWidth/2;
2326 const TInt KSurfaceHeight = KWindowHeight/2;
2327 const TInt KExtentWidth = KWindowWidth;
2328 const TInt KExtentHeight = KWindowHeight;
2329 const EGLint KXOffset = 10;
2330 const EGLint KYOffset = 20;
2331 const EGLint KBorderColorRed = 0xa0;
2332 const EGLint KBorderColorBlue = 0xf0;
2333 const EGLint KBorderColorGreen = 0xfc;
2335 EGLint attrib_list[] = {
2336 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
2337 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
2338 EGL_TARGET_EXTENT_OFFSET_X_NOK, KXOffset,
2339 EGL_TARGET_EXTENT_OFFSET_Y_NOK, KYOffset,
2340 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
2341 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
2342 EGL_BORDER_COLOR_BLUE_NOK, KBorderColorBlue,
2343 EGL_BORDER_COLOR_GREEN_NOK, KBorderColorGreen,
2344 EGL_BORDER_COLOR_RED_NOK, KBorderColorRed,
2347 // Create the window surface and the egl context and make them current
2348 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
2350 INFO_PRINTF1(_L("Query surface attributes and border colour back and check expected values..."));
2351 CheckBorderColorL(KBorderColorRed, KBorderColorBlue, KBorderColorGreen);
2352 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KXOffset, KYOffset);
2354 INFO_PRINTF1(_L("Check EGL_FIXED_WIDTH_NOK and EGL_FIXED_HEIGHT_NOK cannot be queried..."));
2355 EGLint surfaceFixedWidth = -1;
2356 EGLint surfaceFixedHeight = -2;
2357 TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, &surfaceFixedWidth));
2358 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2359 TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, &surfaceFixedHeight));
2360 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2361 TEST(surfaceFixedWidth == -1);
2362 TEST(surfaceFixedHeight == -2);
2365 iEglSess->CleanupSurfaceAndContextL();
2369 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingQuerySurface::doTestStepL completed!"));
2370 RecordTestResultL();
2371 CloseTMSGraphicsStep();
2372 return TestStepResult();
2376 @SYMTestCaseID GRAPHICS-EGL-0662
2385 Negative testing. Query surface attributes which are not supported by this API.
2388 1. Create a non-fixed size EGL window surface.
2389 2. Query surface attributes.
2390 3. Repeat step 2 for EGL window surface, pixmap and pbuffer surface
2392 @SYMTestExpectedResults
2393 Query surface attributes will fail with error code EGL_BAD_ATTRIBUTE.
2395 TVerdict CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL()
2397 SetTestStepName(_L("GRAPHICS-EGL-0662"));
2398 SetTestStepID(_L("GRAPHICS-EGL-0662"));
2399 INFO_PRINTF1(_L("CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL"));
2401 // Establish the connection to the window server and create
2402 // a WindowGroup and a Window object
2403 CreateAndActivateWindowL(TSize(100,100));
2405 const TInt KWindowWidth = iWindow.Size().iWidth;
2406 const TInt KWindowHeight = iWindow.Size().iHeight;
2407 const TInt KSurfaceWidth = KWindowWidth;
2408 const TInt KSurfaceHeight = KWindowHeight;
2410 // Create display object
2412 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2413 iEglSess->InitializeL();
2415 // Choose EGL config
2416 EGLConfig matchingConfigs[1];
2417 EGLint numConfigs = 0;
2419 // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
2420 TInt index = iAllScalable ? 1 : 0;
2421 for(; index < 3; index++)
2426 // Create the non-fixed size window surface and the egl context and make them current
2427 INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
2428 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
2429 TESTL(numConfigs == 1);
2430 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);
2433 // Create the pbuffer surface and the egl context and make them current
2434 INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
2435 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2436 TESTL(numConfigs == 1);
2437 iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
2440 // Create the pixmap surface and the egl context and make them current
2441 INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
2442 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2443 TESTL(numConfigs == 1);
2444 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
2448 INFO_PRINTF1(_L("Check EGL_FIXED_WIDTH_NOK and EGL_FIXED_HEIGHT_NOK cannot be queried..."));
2449 EGLint surfaceFixedWidth = -1;
2450 EGLint surfaceFixedHeight = -2;
2451 TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_WIDTH_NOK, &surfaceFixedWidth));
2452 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2453 TEST(EGL_FALSE == eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_FIXED_HEIGHT_NOK, &surfaceFixedHeight));
2454 ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
2455 TEST(surfaceFixedWidth == -1);
2456 TEST(surfaceFixedHeight == -2);
2458 INFO_PRINTF1(_L("Check surface size is as we would expect..."));
2459 EGLint surfaceWidth = 0;
2460 EGLint surfaceHeight = 0;
2461 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
2462 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
2463 TEST(surfaceWidth == KWindowWidth); // non-fixed size surface
2464 TEST(surfaceHeight == KWindowHeight); // non-fixed size surface
2466 INFO_PRINTF1(_L("Check scaling attributes cannot be queried..."));
2467 EGLint extentOffsetX = -1;
2468 EGLint extentOffsetY = -2;
2469 EGLint extentWidth = -3;
2470 EGLint extentHeight = -4;
2471 EGLint borderColorBlue = -5;
2472 EGLint borderColorRed = -6;
2473 EGLint borderColorGreen = -7;
2474 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &extentOffsetX));
2475 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &extentOffsetY));
2476 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
2477 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
2478 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_BLUE_NOK, &borderColorBlue));
2479 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_GREEN_NOK, &borderColorGreen));
2480 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_BORDER_COLOR_RED_NOK, &borderColorRed));
2481 TEST(extentOffsetX == -1);
2482 TEST(extentOffsetY == -2);
2483 TEST(extentWidth == -3);
2484 TEST(extentHeight == -4);
2485 TEST(borderColorBlue == -5);
2486 TEST(borderColorRed == -6);
2487 TEST(borderColorGreen == -7);
2489 // destroy surface and context
2490 iEglSess->CleanupSurfaceAndContextL();
2497 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingQuerySurfaceNonFixed::doTestStepL completed!"));
2498 RecordTestResultL();
2499 CloseTMSGraphicsStep();
2500 return TestStepResult();
2504 @SYMTestCaseID GRAPHICS-EGL-0663
2513 Negative testing. Query surface scaling capability with invalid parameters.
2516 1. Query surface scaling capability for the different configs.
2517 2. Query surface scaling capability with invalid display.
2518 3. Query surface scaling capability with negative surface width.
2519 4. Query surface scaling capability with negative surface height.
2520 5. Query surface scaling capability with negative target width.
2521 6. Query surface scaling capability with negative target height.
2522 7. Query surface scaling capability with zero surface width.
2523 8. Query surface scaling capability with zero surface height.
2524 9. Query surface scaling capability with zero target width.
2525 10. Query surface scaling capability with zero target height.
2527 @SYMTestExpectedResults
2528 1. Query surface capability will fail with error code EGL_BAD_MATCH if config doesn't support scaling and succeed otherwise.
2529 2. Query surface capability will fail with error code EGL_BAD_DISPLAY.
2530 3. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2531 4. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2532 5. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2533 6. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2534 7. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2535 8. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2536 9. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2537 10. Query surface capability will fail with error code EGL_BAD_PARAMETER.
2539 TVerdict CEglTest_SurfaceScalingCapability::doTestStepL()
2541 SetTestStepName(_L("GRAPHICS-EGL-0663"));
2542 SetTestStepID(_L("GRAPHICS-EGL-0663"));
2543 INFO_PRINTF1(_L("CEglTest_SurfaceScalingCapability::doTestStepL"));
2545 // Create display object
2547 CreateEglSessionL();
2548 iEglSess->InitializeL();
2550 // Choose EGL config
2551 EGLConfig matchingConfigs[KMaxEglConfigs];
2552 EGLint numConfigs = 0;
2554 CreateAndActivateWindowL(TSize(100,100));
2556 const TInt KWindowWidth = iWindow.Size().iWidth;
2557 const TInt KWindowHeight = iWindow.Size().iHeight;
2558 const TInt KSurfaceWidth = KWindowWidth/2;
2559 const TInt KSurfaceHeight = KWindowHeight/2;
2560 const EGLDisplay KInvalidDisplay = iDisplay - 100;
2561 EGLint capability = -1; //arbitrary number beyond the existing range
2562 EGLConfig config = -1;
2564 INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
2565 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
2566 for(TInt index = 0; index < numConfigs; index++)
2568 EGLint value = EGL_FALSE;
2569 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[index], EGL_SURFACE_SCALING_NOK, &value));
2570 if(value == EGL_FALSE)
2572 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[index], KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2573 TEST(capability == -1); //make sure that value has not been modified
2574 ASSERT_EGL_ERROR(EGL_BAD_MATCH);
2579 {//memorize the first config that supports scaling
2580 config = matchingConfigs[index];
2582 ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[index], KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability));
2583 TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
2588 TEST(config != -1); // make sure that at least one config supports scaling
2591 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(KInvalidDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2592 TEST(capability == -1); //make sure that value has not been modified
2593 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
2596 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, -KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2597 TEST(capability == -1); //make sure that value has not been modified
2598 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2599 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, -KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2600 TEST(capability == -1); //make sure that value has not been modified
2601 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2603 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, -KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2604 TEST(capability == -1); //make sure that value has not been modified
2605 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2606 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, -KWindowHeight, &capability) == EGL_FALSE);
2607 TEST(capability == -1); //make sure that value has not been modified
2608 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2611 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, -0, KSurfaceHeight, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2612 TEST(capability == -1); //make sure that value has not been modified
2613 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2614 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, -0, KWindowHeight, &capability) == EGL_FALSE);
2615 TEST(capability == -1); //make sure that value has not been modified
2616 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2618 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, -0, KWindowWidth, KWindowHeight, &capability) == EGL_FALSE);
2619 TEST(capability == -1); //make sure that value has not been modified
2620 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2621 TEST(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, config, KSurfaceWidth, KSurfaceHeight, KWindowWidth, -0, &capability) == EGL_FALSE);
2622 TEST(capability == -1); //make sure that value has not been modified
2623 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
2629 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingCapability::doTestStepL completed!"));
2630 RecordTestResultL();
2631 CloseTMSGraphicsStep();
2632 return TestStepResult();
2636 @SYMTestCaseID GRAPHICS-EGL-0664
2645 Call eglSetSurfaceScalingNOK with fixed size surface and a target extent that can be set.
2648 Retrieve all available EGL configs and for those that support surface scaling
2649 1. Create a window surface with surface scaling attributes and make it current
2650 2. Query these attributes and check they correspond with what is expected
2651 3. Query if surface supports scaling to a different extent
2652 4. Set the new extent and new offset to the surface
2653 5. Query these attributes
2655 @SYMTestExpectedResults
2656 5. Surface scaling attributes have been updated
2658 TVerdict CEglTest_SurfaceScalingSet::doTestStepL()
2660 SetTestStepName(_L("GRAPHICS-EGL-0664"));
2661 SetTestStepID(_L("GRAPHICS-EGL-0664"));
2662 INFO_PRINTF1(_L("CEglTest_SurfaceScalingSet::doTestStepL"));
2664 // Establish the connection to the window server and create
2665 // a WindowGroup and a Window object
2666 CreateAndActivateWindowL(TSize(100, 100));
2668 const TInt KWindowWidth = iWindow.Size().iWidth;
2669 const TInt KWindowHeight = iWindow.Size().iHeight;
2670 const TInt KSurfaceWidth = KWindowWidth/2;
2671 const TInt KSurfaceHeight = KWindowHeight/2;
2672 const TInt KExtentWidth = KWindowWidth;
2673 const TInt KExtentHeight = KWindowHeight;
2674 const EGLint KOffsetX = 3;
2675 const EGLint KOffsetY = 7;
2677 EGLint attrib_list[] = {
2678 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
2679 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
2680 EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
2681 EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
2682 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
2683 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
2686 // Create display object
2688 CreateEglSessionL();
2689 iEglSess->InitializeL();
2691 // Choose EGL config
2692 EGLConfig matchingConfigs[KMaxEglConfigs];
2693 EGLint numConfigs = 0;
2695 // Query total number of configs
2696 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
2697 TESTL(numConfigs >= 1 && numConfigs <= KMaxEglConfigs);
2698 INFO_PRINTF2(_L("Found %d configs"), numConfigs);
2701 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, matchingConfigs, KMaxEglConfigs, &numConfigs));
2703 // Check if surface scaling is supported in the config, if so, create surface
2704 for(TInt i=0; i<numConfigs; i++)
2706 EGLint value = -32; // arbitraty value which is neither EGL_TRUE nor EGL_FALSE
2707 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_SURFACE_SCALING_NOK, &value));
2708 if (value==EGL_TRUE)
2710 INFO_PRINTF2(_L("Config %d supports surface scaling. Create a window surface..."), i);
2712 // Create the window surface and the egl context and make them current
2713 EGLint renderableType = 0;
2714 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, matchingConfigs[i], EGL_RENDERABLE_TYPE, &renderableType));
2715 if (renderableType&EGL_OPENVG_BIT)
2717 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[i], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
2719 else if (renderableType&EGL_OPENGL_ES_BIT)
2721 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[i], iWindow, EFalse, EGL_OPENGL_ES_API, 1, attrib_list);
2725 WARN_PRINTF2(_L("Config %d does not support either OPENVG or OPENGL_ES. Skip!"), i);
2729 // Check values are as expected
2730 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
2732 // modify target extent atttributes
2733 // 1 - first check that this new extent is supported, should do as we're reducing it
2734 EGLint capability = -1; //arbitrary number beyond the existing range
2735 EGLint newExtentWidth = KExtentWidth / 2;
2736 EGLint newExtentHeight = KExtentHeight / 2;
2737 EGLint newOffsetX = KOffsetX * 2;
2738 EGLint newOffsetY = KOffsetY * 2;
2739 ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[i], KSurfaceWidth, KSurfaceHeight, newExtentWidth, newExtentHeight, &capability));
2740 TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
2741 // 2 - set new extent
2742 ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight));
2744 // Check attributes have changed
2745 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, newExtentWidth, newExtentHeight, newOffsetX, newOffsetY);
2748 iEglSess->CleanupSurfaceAndContextL();
2756 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSet::doTestStepL completed!"));
2757 RecordTestResultL();
2758 CloseTMSGraphicsStep();
2759 return TestStepResult();
2763 @SYMTestCaseID GRAPHICS-EGL-0665
2772 Negative testing. Call eglSetSurfaceScalingNOK with invalid parameters
2775 1. Set surface scaling with invalid display.
2776 2. Set surface scaling with negative target width.
2777 3. Set surface scaling with negative target height.
2778 3. Set surface scaling with zero target width.
2779 3. Set surface scaling with zero target height.
2780 @SYMTestExpectedResults
2781 1. Set surface scaling will fail with error code EGL_BAD_DISPLAY.
2782 2. Set surface scaling will fail with error code EGL_BAD_PARAMETER.
2783 3. Set surface scaling will fail with error code EGL_BAD_PARAMETER.
2784 4. Set surface scaling will fail with error code EGL_BAD_PARAMETER.
2785 5. Set surface scaling will fail with error code EGL_BAD_PARAMETER.
2787 TVerdict CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL()
2789 SetTestStepName(_L("GRAPHICS-EGL-0665"));
2790 SetTestStepID(_L("GRAPHICS-EGL-0665"));
2791 INFO_PRINTF1(_L("CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL"));
2793 // Establish the connection to the window server and create
2794 // a WindowGroup and a Window object
2795 CreateAndActivateWindowL(TSize(100, 100));
2797 // Create display object
2799 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2800 iEglSess->InitializeL();
2802 // Choose EGL config
2803 EGLConfig matchingConfigs[1];
2804 EGLint numConfigs = 0;
2805 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
2806 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
2808 const TInt KWindowWidth = iWindow.Size().iWidth;
2809 const TInt KWindowHeight = iWindow.Size().iHeight;
2810 const TInt KSurfaceWidth = KWindowWidth/2;
2811 const TInt KSurfaceHeight = KWindowHeight/2;
2812 const TInt KExtentWidth = KWindowWidth;
2813 const TInt KExtentHeight = KWindowHeight;
2814 const EGLint KOffsetX = 11;
2815 const EGLint KOffsetY = 13;
2816 EGLint attrib_list[] = {
2817 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
2818 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
2819 EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
2820 EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
2821 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
2822 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
2825 // Create the window surface and the egl context and make them current
2826 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
2828 // Check all attributes
2829 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, KOffsetX, KOffsetY);
2831 for(TInt index = 0; index < 5; index++)
2833 // new attribute values
2834 EGLDisplay newDisplay = iDisplay;
2835 EGLint newExtentWidth = KExtentWidth;
2836 EGLint newExtentHeight = KExtentHeight;
2837 EGLint newOffsetX = KOffsetX;
2838 EGLint newOffsetY = KOffsetY;
2839 // expected error value
2840 EGLint error = EGL_BAD_PARAMETER;
2845 // Invalid display - valid extent
2846 newDisplay = newDisplay - 100;
2847 error = EGL_BAD_DISPLAY;
2850 // Valid display - Negative extent width
2851 newExtentWidth = -newExtentHeight;
2854 // Valid display - Negative extent height
2855 newExtentHeight = -newExtentHeight;
2858 // Valid display - zero extent width
2862 // Valid display - zero extent height
2863 newExtentHeight = 0;
2867 TEST(EGL_FALSE == iPfnEglSetSurfaceScalingNOK(newDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight));
2868 ASSERT_EGL_ERROR(error);
2870 // attributes haven't changed
2871 CheckScalingAttributesL(KSurfaceWidth, KSurfaceHeight, KWindowWidth, KWindowHeight, KOffsetX, KOffsetY);
2878 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSetInvalidAttributes::doTestStepL completed!"));
2879 RecordTestResultL();
2880 CloseTMSGraphicsStep();
2881 return TestStepResult();
2885 @SYMTestCaseID GRAPHICS-EGL-0666
2894 Negative testing. Query scaling attributes in non-fixed size surfaces
2897 1. Create a window surface from a non-fixed size surface
2898 2. Set surface scaling with valid target extent.
2899 3. Query scaling attributes
2900 4. Repeat step 2-3 for EGL window surface, pixmap and pbuffer surface
2902 @SYMTestExpectedResults
2903 2. Set surface scaling will fail with error code EGL_BAD_MATCH.
2904 3. Query scaling attributes does not fail, but values not updated
2906 TVerdict CEglTest_SurfaceScalingSetNonFixed::doTestStepL()
2908 SetTestStepName(_L("GRAPHICS-EGL-0666"));
2909 SetTestStepID(_L("GRAPHICS-EGL-0666"));
2910 INFO_PRINTF1(_L("CEglTest_SurfaceScalingSetNonFixed::doTestStepL"));
2912 // Establish the connection to the window server and create
2913 // a WindowGroup and a Window object
2914 CreateAndActivateWindowL(TSize(100, 100));
2916 const TInt KWindowWidth = iWindow.Size().iWidth;
2917 const TInt KWindowHeight = iWindow.Size().iHeight;
2918 const TInt KSurfaceWidth = KWindowWidth;
2919 const TInt KSurfaceHeight = KWindowHeight;
2921 // Create display object
2923 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
2924 iEglSess->InitializeL();
2926 // Choose EGL config - Make sure it DOES NOT support surface scaling
2927 EGLConfig matchingConfigs[1];
2928 EGLint numConfigs = 0;
2930 // If all window surfaces in EGL are scalable, first case must be skipped. Others still valid
2931 TInt index = iAllScalable ? 1 : 0;
2932 for(; index < 3; index++)
2937 // Create the non-fixed size window surface and the egl context and make them current
2938 INFO_PRINTF1(_L("Create the non-fixed size window surface and the egl context and make them current..."));
2939 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribs_NoScaling], matchingConfigs, 1, &numConfigs));
2940 TESTL(numConfigs == 1);
2941 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow);
2944 // Create the pbuffer surface and the egl context and make them current
2945 INFO_PRINTF1(_L("Create the pbuffer surface and the egl context and make them current..."));
2946 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPBufferAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2947 TESTL(numConfigs == 1);
2948 iEglSess->CreatePbufferSurfaceAndMakeCurrentL(matchingConfigs[0], TSize(KSurfaceWidth, KSurfaceHeight));
2951 // Create the pixmap surface and the egl context and make them current
2952 INFO_PRINTF1(_L("Create the pixmap surface and the egl context and make them current..."));
2953 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[EPixmapAttribsColor16MU], matchingConfigs, 1, &numConfigs));
2954 TESTL(numConfigs == 1);
2955 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(TSize(KSurfaceWidth, KSurfaceHeight), EColor16MU);
2959 // Check all attributes (this is a non-fixed size surface) -
2960 // Note that we cannot use CheckScalingAttributesL because values are not updated
2961 EGLint surfaceWidth = 0;
2962 EGLint surfaceHeight = 0;
2963 EGLint extentWidth = -1;
2964 EGLint extentHeight = -2;
2965 EGLint offsetX = -3;
2966 EGLint offsetY = -4;
2967 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
2968 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
2969 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
2970 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
2971 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &offsetX));
2972 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &offsetY));
2973 TEST((surfaceWidth == KWindowWidth) && (surfaceHeight == KWindowHeight));
2974 // following values should not be modified (non fixed size window)
2975 TEST((extentWidth == -1) && (extentHeight == -2));
2976 TEST((offsetX == -3) && (offsetY == -4));
2978 // new attribute values
2979 EGLint newExtentWidth = extentWidth / 2;
2980 EGLint newExtentHeight = extentHeight / 2;
2981 EGLint newOffsetX = offsetX * 2;
2982 EGLint newOffsetY = offsetY * 2;
2984 // Valid parameters - But non fixed size surface
2985 TEST(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), newOffsetX, newOffsetY, newExtentWidth, newExtentHeight) == EGL_FALSE);
2986 ASSERT_EGL_ERROR(EGL_BAD_MATCH);
2988 // attributes haven't changed
2989 // Note that we cannot use CheckScalingAttributesL because values are not updated
2990 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_WIDTH, &surfaceWidth));
2991 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_HEIGHT, &surfaceHeight));
2992 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_WIDTH_NOK, &extentWidth));
2993 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_HEIGHT_NOK, &extentHeight));
2994 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_X_NOK, &offsetX));
2995 ASSERT_EGL_TRUE(eglQuerySurface(iDisplay, iEglSess->Surface(), EGL_TARGET_EXTENT_OFFSET_Y_NOK, &offsetY));
2996 TEST((surfaceWidth == KWindowWidth) && (surfaceHeight == KWindowHeight));
2997 TEST((extentWidth == -1) && (extentHeight == -2));
2998 TEST((offsetX == -3) && (offsetY == -4));
3000 // destroy surface and context
3001 iEglSess->CleanupSurfaceAndContextL();
3008 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingSetNonFixed::doTestStepL completed!"));
3009 RecordTestResultL();
3010 CloseTMSGraphicsStep();
3011 return TestStepResult();
3015 @SYMTestCaseID GRAPHICS-EGL-0667
3024 Negative testing. Calling extensions without initialising EGL
3027 Without initialising EGL
3028 1. Call query surface scaling capability
3029 2. Call set surface scaling
3031 @SYMTestExpectedResults
3032 1. Query scaling capability will fail with error code EGL_NOT_INITIALIZED.
3033 2. Set surface scaling will fail with error code EGL_NOT_INITIALIZED.
3035 TVerdict CEglTest_SurfaceScalingNotInitialized::doTestStepL()
3037 SetTestStepName(_L("GRAPHICS-EGL-0667"));
3038 SetTestStepID(_L("GRAPHICS-EGL-0667"));
3039 INFO_PRINTF1(_L("CEglTest_SurfaceScalingNotInitialized::doTestStepL"));
3041 // a WindowGroup and a Window object
3042 CreateAndActivateWindowL(TSize(100, 100));
3044 // Create display object
3046 CreateEglSessionL(); // initialise EGL Session so we can make use of its helper objects
3047 iEglSess->InitializeL();
3049 // Choose EGL config
3050 EGLConfig matchingConfigs[1];
3051 EGLint numConfigs = 0;
3052 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KScalingConfigAttribs[EWindowAttribsColor16MU_Scaling], matchingConfigs, 1, &numConfigs));
3053 TESTL(numConfigs == 1); // Abort the test if the EGL config is not supported
3055 const TInt KWindowWidth = iWindow.Size().iWidth;
3056 const TInt KWindowHeight = iWindow.Size().iHeight;
3057 const TInt KSurfaceWidth = KWindowWidth/2;
3058 const TInt KSurfaceHeight = KWindowHeight/2;
3059 const TInt KExtentWidth = KWindowWidth;
3060 const TInt KExtentHeight = KWindowHeight;
3061 const EGLint KOffsetX = 11;
3062 const EGLint KOffsetY = 13;
3063 EGLint attrib_list[] = {
3064 EGL_FIXED_WIDTH_NOK, KSurfaceWidth,
3065 EGL_FIXED_HEIGHT_NOK, KSurfaceHeight,
3066 EGL_TARGET_EXTENT_OFFSET_X_NOK, KOffsetX,
3067 EGL_TARGET_EXTENT_OFFSET_Y_NOK, KOffsetY,
3068 EGL_TARGET_EXTENT_WIDTH_NOK, KExtentWidth,
3069 EGL_TARGET_EXTENT_HEIGHT_NOK, KExtentHeight,
3072 // Create the window surface and the egl context and make them current
3073 iEglSess->CreateWindowSurfaceAndMakeCurrentL(matchingConfigs[0], iWindow, EFalse, EGL_OPENVG_API, 1, attrib_list);
3075 // First set new offset attributes (fairly simple, so should be supported)
3076 INFO_PRINTF1(_L("Set new offset attributes - should succeed..."));
3077 EGLint capability = -1; //arbitrary number beyond the existing range
3078 ASSERT_EGL_TRUE(iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[0], KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, &capability));
3079 TEST((capability == EGL_SUPPORTED_NOK) || (capability == EGL_SLOW_NOK));
3080 ASSERT_EGL_TRUE(iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), KOffsetX+1, KOffsetY+1, KExtentWidth, KExtentHeight));
3082 // Terminate display and try again
3083 INFO_PRINTF1(_L("Terminate display and try again, should fail now..."));
3084 eglTerminate(iDisplay);
3086 capability = -1; //arbitrary number beyond the existing range
3087 TEST(EGL_FALSE == iPfnEglQuerySurfaceScalingCapabilityNOK(iDisplay, matchingConfigs[0], KSurfaceWidth, KSurfaceHeight, KExtentWidth, KExtentHeight, &capability));
3088 TEST(capability == -1); //make sure that value has not been modified
3089 ASSERT_EGL_ERROR(EGL_NOT_INITIALIZED);
3091 TEST(EGL_FALSE == iPfnEglSetSurfaceScalingNOK(iDisplay, iEglSess->Surface(), KOffsetX, KOffsetY, KExtentWidth, KExtentHeight));
3092 ASSERT_EGL_ERROR(EGL_NOT_INITIALIZED);
3098 INFO_PRINTF1(_L("....CEglTest_SurfaceScalingNotInitialized::doTestStepL completed!"));
3099 RecordTestResultL();
3100 CloseTMSGraphicsStep();
3101 return TestStepResult();