os/graphics/graphicscomposition/openwfcompositionengine/test/tscreeninterface/tscreeninterface.cpp
Update contrib.
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and/or associated documentation files (the
5 // "Materials"), to deal in the Materials without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Materials, and to
8 // permit persons to whom the Materials are furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Materials.
14 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
23 // Implementation of test class for OpenWF-C RI display driver interface
26 #include <WF/openwfc_ri_display.h>
27 #include <WF/openwfc_ri_display_update.h>
28 #include <test/extendtef.h>
29 #include <test/tefunit.h>
31 #include "tscreeninterface.h"
33 #define KCompositorVersion 0x01023456
34 #define KRgbRed TRgb(0x0000ff)
35 #define KRgbGreen TRgb(0x00ff00)
36 #define KRgbYellow TRgb(0x00ffff)
37 #define KRgbBlue TRgb(0xff0000)
39 const TInt KDefaultScreenNumber = 0;
40 const TTimeIntervalMicroSeconds32 KDelay = 1000000; //delay in microseconds
41 const TTimeIntervalMicroSeconds32 KMinimalDelay = 1000; //delay in microseconds
43 _LIT(KImageSectionName, "ImageInfo");
44 _LIT(KContiguousFlag, "ContiguousFlag");
45 _LIT(KNonFastpathablePixelFormat, "NonFastpathablePixelFormat");
46 _LIT(KFastpathablePixelFormat, "FastpathablePixelFormat");
49 * CTestScreenInterface implementation
52 CTestScreenInterface::CTestScreenInterface()
53 :iContiguous(EFlagNotListed),
54 iFastpathablePixelFormat(EUidPixelFormatARGB_8888_PRE),
55 iNonFastpathablePixelFormat(EUidPixelFormatRGB_565),
59 iCacheAttrib(ECacheNotlisted)
61 // No implementation required
64 CTestScreenInterface::~CTestScreenInterface()
69 void CTestScreenInterface::SetupL()
71 iUtility = CStreamUtility::NewL();
72 iRed.SetInternal(0xFFFF0000);
73 iGreen.SetInternal(0xFF00FF00);
74 iBlue.SetInternal(0xFF0000FF);
76 User::After(KDelay); // consider reading delay from ini file
80 * test Suite furniture
82 void CTestScreenInterface::TearDownL()
84 // Nothing leaves in this function,
85 // but TearDownL() is needed for the CTestFixture (TEF) interface
89 void CTestScreenInterface::TearDown()
98 // Create a suite of all the tests
99 CTestSuite* CTestScreenInterface::CreateSuiteL(const TDesC& aName)
101 SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion);
102 SUB_SUITE_OPT(CTestScreenInterface,NULL);
104 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0100L);
105 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0101L);
106 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0102L);
107 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0103L);
108 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0104L);
109 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0105L);
110 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0106L);
111 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0107L);
112 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0108L);
113 ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0109L);
119 /// This handles any non-member uses of the extended ASSERT_XXX macros
120 void TefUnitFailLeaveL()
122 User::Leave(KErrTEFUnitFail);
125 void CTestScreenInterface::ReadIniData()
127 TBool contiguousFlag;
128 TBool returnValue = iConfig.GetBool(KImageSectionName, KContiguousFlag, contiguousFlag);
133 iContiguous = EContiguous;
137 iContiguous = ENonContiguous;
141 TInt fastpathablePixelFormat;
142 returnValue = iConfig.GetHex(KImageSectionName, KFastpathablePixelFormat, fastpathablePixelFormat);
145 iFastpathablePixelFormat = static_cast<TUidPixelFormat>(fastpathablePixelFormat);
148 TInt nonFastpathablePixelFormat;
149 returnValue = iConfig.GetHex(KImageSectionName, KNonFastpathablePixelFormat, nonFastpathablePixelFormat);
152 iNonFastpathablePixelFormat = static_cast<TUidPixelFormat>(nonFastpathablePixelFormat);
156 TInt CTestScreenInterface::BaseTestContiguousFlag(TBool aContiguous)
158 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
159 CleanupStack::PushL(screenContext);
161 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
162 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
164 sizeof(screenRotation));
165 screenContext->CommitAttribute();
167 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
168 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
169 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
171 TSurfaceId surface = TSurfaceId::CreateNullId();
172 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
173 iFastpathablePixelFormat, attributes.iNormalStride,
174 surface, aContiguous, 1);
175 ASSERT_FALSE((*ns).IsNull());
177 iUtility->FillStreamL(ns, KRgbGreen);
179 TInt err = screenContext->SetTopLayerSurface(ns);
180 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, _L("SetTopLayerSurface() returned %i"),err );
181 RDebug::Printf("SetTopLayerSurface() returned %i",err);
184 { //Must successfully SetTopLayerSurface before calling UpdateDisplay.
185 screenContext->UpdateDisplay();
188 CleanupStack::PopAndDestroy(screenContext);
194 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0100
195 @SYMTestCaseDesc Create a screen size stream and display on screen
197 @SYMPREQ REQ 417-54885
198 @SYMTestType Unit Test
199 @SYMTestPriority High
200 @SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen
202 Create a screen context
203 Set display attributes
204 Create a screen size stream based on the display attributes with contigous and non-contiguous flags
206 Associates the stream with the topmost display layer
208 @SYMTestExpectedResults
209 If contiguous flag is set in the ini file, and the stream is created using the flag,
210 the stream should be properly displayed on screen. The stream created using the opposit flag from ini value should fail.
211 If contiguous flag is not set in the ini file,
212 the stream should be properly displayed on screen for contiguous and non-contiguous flag.
214 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()
216 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()"));
217 LOG((" *** CTestScreenInterface test 0100L"));
219 if(iContiguous != EFlagNotListed)
222 // We expect the opposit flag to the one from the ini file to fail
223 if(iContiguous == EContiguous)
225 ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(ENonContiguous));
229 ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(EContiguous));
231 // The contiguous flag from the ini file should pass
232 ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(iContiguous));
233 // The last run here should be the "good" run so that it can do a Display() call.
237 // Contiguous or Non-contiguous flags should both pass if nothing set in the ini file
238 ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(EContiguous));
239 ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(ENonContiguous));
241 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L() done"));
242 LOG((" *** CTestScreenInterface test 0100L done"));
246 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0101
247 @SYMTestCaseDesc Create a stream, display on screen, then rotate the screen involving scaling
249 @SYMPREQ REQ 417-54885
250 @SYMTestType Unit Test
251 @SYMTestPriority Medium
252 @SYMTestPurpose Verify screen rotation works
254 Create a screen context
255 Set display attributes
256 Create a screen size stream
258 Associates the stream with the topmost display layer
260 Rotate the screen 90 degrees, 180 degrees, 270 degrees
261 Update the screen respectively
262 @SYMTestExpectedResults
263 Methods should complete without error.
264 The stream should be properly displayed on screen
266 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()
268 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()"));
269 LOG((" *** CTestScreenInterface test 0101L"));
271 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
272 CleanupStack::PushL(screenContext);
274 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
275 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
276 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
278 if (attributes.iSupportedRotations > 1)
280 INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
281 TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
282 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
284 sizeof(screenRotation0));
285 screenContext->CommitAttribute();
287 TSurfaceId surface = TSurfaceId::CreateNullId();
288 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
289 iFastpathablePixelFormat, attributes.iNormalStride,
290 surface, iContiguous, 1);
292 ASSERT_FALSE((*ns).IsNull());
293 iUtility->FillStreamL(ns, KRgbRed);
295 TInt err = screenContext->SetTopLayerSurface(ns);
296 ASSERT_TRUE(err == KErrNone);
298 err = screenContext->UpdateDisplay();
299 ASSERT_TRUE(err == KErrNone);
301 INFO_PRINTF1(_L("Rotate screen 90 degree"));
302 // Rotate screen 90 degree and test
303 TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
304 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
306 sizeof(screenRotation1));
307 screenContext->CommitAttribute();
309 err = screenContext->UpdateDisplay();
310 ASSERT_TRUE(err == KErrNone);
312 if (attributes.iSupportedRotations > 2)
314 INFO_PRINTF1(_L("Rotate screen 180 degree"));
315 // Rotate screen 180 degree and test
316 TUint32 screenRotation2 = COpenWFC_RI_Display::EScreenRotate180;
317 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
319 sizeof(screenRotation2));
320 screenContext->CommitAttribute();
322 err = screenContext->UpdateDisplay();
323 ASSERT_TRUE(err == KErrNone);
326 if (attributes.iSupportedRotations > 3)
328 INFO_PRINTF1(_L("Rotate screen 270 degree"));
329 // Rotate screen 270 degree and test
330 TUint32 screenRotation3 = COpenWFC_RI_Display::EScreenRotate270;
331 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
333 sizeof(screenRotation3));
334 screenContext->CommitAttribute();
336 err = screenContext->UpdateDisplay();
337 ASSERT_TRUE(err == KErrNone);
340 // Set screen back to rotation 0
341 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
343 sizeof(screenRotation0));
344 screenContext->CommitAttribute();
345 err = screenContext->UpdateDisplay();
346 ASSERT_TRUE(err == KErrNone);
350 INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
353 CleanupStack::PopAndDestroy(screenContext);
357 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0102
358 @SYMTestCaseDesc Create a stream, display on screen, then rotate the screen, not involving scaling
360 @SYMPREQ REQ 417-54885
361 @SYMTestType Unit Test
362 @SYMTestPriority Medium
363 @SYMTestPurpose Verify screen rotation works
365 Create a screen context
366 Set display attributes
367 Create a stream of the size (screenHeight, screenWidth)
369 Associates the stream with the topmost display layer
371 Rotate the screen 90 degrees
373 @SYMTestExpectedResults
374 Methods should complete without error.
375 The stream should be properly displayed on screen
377 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()
379 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()"));
380 LOG((" *** CTestScreenInterface test 0102L"));
382 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
383 CleanupStack::PushL(screenContext);
385 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
386 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
387 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
389 if (attributes.iSupportedRotations > 1)
391 INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
392 TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
393 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
395 sizeof(screenRotation0));
396 screenContext->CommitAttribute();
398 TSurfaceId surface = TSurfaceId::CreateNullId();
399 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalHeight,attributes.iNormalWidth),
400 iFastpathablePixelFormat, attributes.iNormalStride,
401 surface, iContiguous, 1);
403 ASSERT_FALSE((*ns).IsNull());
404 iUtility->FillStreamL(ns, KRgbRed);
406 TInt err = screenContext->SetTopLayerSurface(ns);
407 ASSERT_TRUE(err == KErrNone);
409 err = screenContext->UpdateDisplay();
410 ASSERT_TRUE(err == KErrNone);
412 INFO_PRINTF1(_L("Rotate screen 90 degree"));
413 // Rotate screen 90 degree and test
414 TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
415 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
417 sizeof(screenRotation1));
418 screenContext->CommitAttribute();
420 err = screenContext->UpdateDisplay();
421 ASSERT_TRUE(err == KErrNone);
425 INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
428 CleanupStack::PopAndDestroy(screenContext);
432 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0103
433 @SYMTestCaseDesc Create a stream, fill the stream several times and display on screen
435 @SYMPREQ REQ 417-54885
436 @SYMTestType Unit Test
437 @SYMTestPriority High
438 @SYMTestPurpose Check displaying stream repeatedly
440 Create a screen context
441 Set display attributes
442 Create a screen size stream
444 Associates the stream with the topmost display layer
446 Repeat filling the stream, associate with toplayer and update several times
447 Destory the screen context
448 @SYMTestExpectedResults
449 Methods should complete without error.
450 Each time, the stream should be properly displayed on screen
452 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()
454 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()"));
455 LOG((" *** CTestScreenInterface test 0103L"));
457 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
458 CleanupStack::PushL(screenContext);
460 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
461 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
463 sizeof(screenRotation));
464 screenContext->CommitAttribute();
466 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
467 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
468 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
470 TSurfaceId surface = TSurfaceId::CreateNullId();
471 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
472 iFastpathablePixelFormat, attributes.iNormalStride,
473 surface, iContiguous, 1);
474 ASSERT_FALSE((*ns).IsNull());
476 iUtility->FillStreamL(ns, KRgbYellow);
477 TInt err = screenContext->SetTopLayerSurface(ns);
478 ASSERT_TRUE(err == KErrNone);
479 err = screenContext->UpdateDisplay();
480 ASSERT_TRUE(err == KErrNone);
483 iUtility->FillStreamL(ns, KRgbRed);
484 err = screenContext->SetTopLayerSurface(ns);
485 ASSERT_TRUE(err == KErrNone);
486 err = screenContext->UpdateDisplay();
487 ASSERT_TRUE(err == KErrNone);
490 iUtility->FillStreamL(ns, KRgbGreen);
491 err = screenContext->SetTopLayerSurface(ns);
492 ASSERT_TRUE(err == KErrNone);
493 err = screenContext->UpdateDisplay();
494 ASSERT_TRUE(err == KErrNone);
497 iUtility->FillStreamL(ns, KRgbYellow);
498 err = screenContext->SetTopLayerSurface(ns);
499 ASSERT_TRUE(err == KErrNone);
500 err = screenContext->UpdateDisplay();
501 ASSERT_TRUE(err == KErrNone);
504 iUtility->FillStreamL(ns, KRgbRed);
505 err = screenContext->SetTopLayerSurface(ns);
506 ASSERT_TRUE(err == KErrNone);
507 err = screenContext->UpdateDisplay();
508 ASSERT_TRUE(err == KErrNone);
511 // Set a non-topmost layer
512 err = screenContext->SetLayerSurface(1, ns);
513 ASSERT_TRUE(err == KErrArgument);
515 CleanupStack::PopAndDestroy(screenContext);
519 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0104
520 @SYMTestCaseDesc Display all display attributes
522 @SYMPREQ REQ 417-54885
523 @SYMTestType Unit Test
524 @SYMTestPriority High
525 @SYMTestPurpose Check display attributes
527 Create a screen context
528 Set display attributes
529 Get all display attribtues
530 Destory the screen context
531 @SYMTestExpectedResults
532 Methods should complete without error.
533 Display attributes should be correct
535 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()
537 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()"));
538 LOG((" *** CTestScreenInterface test 0104L"));
540 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
541 CleanupStack::PushL(screenContext);
543 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
544 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
545 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
547 INFO_PRINTF1(_L("Printing attribute values: "));
548 INFO_PRINTF2(_L("EScreenAttributeSupportedRotation: %i "), attributes.iSupportedRotations);
549 INFO_PRINTF2(_L("EScreenAttributeCurrentRotation: 0x%x "), attributes.iCurrentRotation);
550 INFO_PRINTF2(_L("EScreenAttributeDefaultRotation: 0x%x "), attributes.iDefaultRotation);
551 INFO_PRINTF2(_L("EScreenAttributeBytesPerPixel: %i "), attributes.iBytesPerPixel);
552 INFO_PRINTF2(_L("EScreenAttributeFlippedHeight: %i "), attributes.iFlippedHeight);
553 INFO_PRINTF2(_L("EScreenAttributeFlippedWidth: %i "), attributes.iFlippedWidth);
554 INFO_PRINTF2(_L("EScreenAttributeFlippedStride: %i "), attributes.iFlippedStride);
555 INFO_PRINTF2(_L("EScreenAttributeNormalHeight: %i "), attributes.iNormalHeight);
556 INFO_PRINTF2(_L("EScreenAttributeNormalWidth: %i "), attributes.iNormalWidth);
557 INFO_PRINTF2(_L("EScreenAttributeNormalStride: %i "), attributes.iNormalStride);
558 INFO_PRINTF2(_L("EScreenAttributePixelFormat: 0x%x "), attributes.iPixelFormat);
560 CleanupStack::PopAndDestroy(screenContext);
564 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0105
565 @SYMTestCaseDesc Create a screen size stream of non-fastpathable pixel format and display on screen
567 @SYMPREQ REQ 417-54885
568 @SYMTestType Unit Test - Negative Test
569 @SYMTestPriority High
570 @SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen
572 Create a screen context
573 Set display attributes
574 Create a screen size stream based on the display attributes with a non-fastpathable pixelformat
576 Associate the stream with the topmost display layer
577 @SYMTestExpectedResults
579 SetTopLayerSurface should return KErrNotSupported.
581 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()
583 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()"));
584 LOG((" *** CTestScreenInterface test 0105L"));
586 if (!iNonFastpathablePixelFormat)
588 INFO_PRINTF1(_L("No non-fastpathable format specified - negative test cannot be run."));
589 User::Leave(KErrTEFUnitInconclusive);
591 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
592 CleanupStack::PushL(screenContext);
594 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
595 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
597 sizeof(screenRotation));
598 screenContext->CommitAttribute();
600 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
601 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
602 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
604 TSurfaceId surface = TSurfaceId::CreateNullId();
605 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
606 iNonFastpathablePixelFormat, attributes.iNormalStride,
607 surface, iContiguous, 1);
608 ASSERT_FALSE((*ns).IsNull());
610 iUtility->FillStreamL(ns, KRgbGreen);
612 ASSERT_TRUE(KErrNotSupported == screenContext->SetTopLayerSurface(ns));
614 CleanupStack::PopAndDestroy(screenContext);
618 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0106
619 @SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times
621 @SYMPREQ REQ 417-54885
622 @SYMTestType Unit Test
623 @SYMTestPriority High
624 @SYMTestPurpose Check stream display repeatedly
626 Create a screen context
627 Set display attributes
630 Associates the stream with the topmost display layer
632 Destory the screen context
633 Repeat the above actions for a number of times in a for loop
634 @SYMTestExpectedResults
635 Methods should complete without error.
636 Each time, the stream should be properly displayed on screen
638 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()
640 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()"));
641 LOG((" *** CTestScreenInterface test 0106L"));
643 SymbianStreamType ns = NULL;
644 const TInt loopMaxNum = 10;
646 for (TInt i = 0; i < loopMaxNum; ++i)
648 //INFO_PRINTF2(_L("Create screen context and stream loop: %i"), i);
650 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
651 CleanupStack::PushL(screenContext);
653 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
654 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
656 sizeof(screenRotation));
657 screenContext->CommitAttribute();
659 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
660 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
661 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
665 TSurfaceId surface = TSurfaceId::CreateNullId();
666 ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
667 iFastpathablePixelFormat, attributes.iNormalStride,
668 surface, iContiguous, 1);
669 ASSERT_FALSE((*ns).IsNull());
674 iUtility->FillStreamL(ns, KRgbRed);
678 iUtility->FillStreamL(ns, KRgbGreen);
682 iUtility->FillStreamL(ns, KRgbBlue);
685 TInt err = screenContext->SetTopLayerSurface(ns);
686 ASSERT_TRUE(err == KErrNone);
688 err = screenContext->UpdateDisplay();
689 ASSERT_TRUE(err == KErrNone);
691 CleanupStack::PopAndDestroy(screenContext);
698 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0107
699 @SYMTestCaseDesc Simple Non Trivial Attributes
701 @SYMPREQ REQ 417-54885
702 @SYMTestType Unit Test
703 @SYMTestPriority High
704 @SYMTestPurpose Check that simple non-trivial attributes are accepted by SetTopLayerSurface.
705 Note this test does not pass in "real" attributes, so the result is predictable.
707 Create a screen context
708 Set display attributes
709 Create a fastpathable stream
711 Associate the stream with the topmost display layer
712 and NULL Non Trivial Atrributes
714 Associate the stream with the topmost display layer
715 and empty Non Trivial Atrributes
717 Associate the stream with the topmost display layer
718 and wrong Non Trivial Atrributes
720 Destory the screen context
721 @SYMTestExpectedResults
722 SetTopLayerSurface should not fail, except for wrong attribute.
723 SetTopLayerSurface should not crash or panic.
725 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()
727 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()"));
728 LOG((" *** CTestScreenInterface test 0107L"));
730 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
731 CleanupStack::PushL(screenContext);
733 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
734 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
736 sizeof(screenRotation));
737 screenContext->CommitAttribute();
739 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
740 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
741 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
743 TSurfaceId surface = TSurfaceId::CreateNullId();
744 SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
745 iFastpathablePixelFormat, attributes.iNormalStride,
746 surface, iContiguous, 1);
747 ASSERT_FALSE((*ns).IsNull());
749 iUtility->FillStreamL(ns, KRgbGreen);
751 TInt err = screenContext->SetTopLayerSurface(ns,NULL);
753 screenContext->UpdateDisplay();
756 err = screenContext->SetTopLayerSurface(ns,&emptyList);
758 screenContext->UpdateDisplay();
761 err = screenContext->SetTopLayerSurface(ns,&wrongList);
764 //Calling UpdateDisplay should fall-back to the previous setting of top layer surface
765 screenContext->UpdateDisplay();
767 CleanupStack::PopAndDestroy(screenContext);
771 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0108
772 @SYMTestCaseDesc Test getting and setting attributes
774 @SYMPREQ REQ 417-54885
775 @SYMTestType Unit Test
776 @SYMTestPriority High
777 @SYMTestPurpose Check getting and setting attibutes with good and bad values
779 Create a screen context
780 Get and set attributes with good and bad values
781 Destory the screen context
782 @SYMTestExpectedResults
783 GetAttribute should always succeed with all valid TScreenAttribute values
784 and appropriate attribute size
785 SetAttribute should succeed for modifying the current rotation
786 Invalid valued for getting and setting attributes should return correct error code
788 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()
790 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()"));
791 LOG((" *** CTestScreenInterface test 0108L"));
793 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
794 CleanupStack::PushL(screenContext);
796 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
799 for(TUint ii = COpenWFC_RI_Display::EScreenAttributeInvalid; ii <= COpenWFC_RI_Display::EScreenAttributeScreenGeometry; ++ii)
801 if(ii == COpenWFC_RI_Display::EScreenAttributeScreenGeometry)
803 err = screenContext->GetAttribute(ii, &attributes,
804 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
808 err = screenContext->GetAttribute(ii, &attributes,
809 sizeof(COpenWFC_RI_Display::TScreenAttribute));
812 if(ii == COpenWFC_RI_Display::EScreenAttributeInvalid)
814 ASSERT_TRUE(err == KErrNotSupported);
818 ASSERT_TRUE(err == KErrNone);
822 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
823 err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, &screenRotation,
824 sizeof(screenRotation));
825 // The only parameter that can be modified is the current rotation
826 ASSERT_TRUE(err == KErrNone);
828 err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeSupportedRotation, &screenRotation,
829 sizeof(screenRotation));
830 ASSERT_TRUE(err == KErrNotSupported);
832 // Set attribute to NULL
833 err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, NULL,
834 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
835 ASSERT_TRUE(err == KErrArgument);
837 // Set attribute size to be 0
838 err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, &attributes, 0);
839 ASSERT_TRUE(err == KErrArgument);
841 // Set attribute == NULL
842 err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, NULL,
843 sizeof(COpenWFC_RI_Display::TScreenAttribute));
844 ASSERT_TRUE(err != KErrNone);
846 // Set attribute with wrong size
847 err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
848 sizeof(COpenWFC_RI_Display::TScreenAttribute));
849 ASSERT_TRUE(err != KErrNone);
851 CleanupStack::PopAndDestroy(screenContext);
855 @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0109
856 @SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times
858 @SYMPREQ REQ 417-54885
859 @SYMTestType Unit Test
860 @SYMTestPriority High
861 @SYMTestPurpose Check stream display repeatedly
863 Create a screen context
864 Set display attributes
865 Repeat the below actions for a number of times in a for loop
868 Associates the stream with the topmost display layer
871 Destory the screen context
873 @SYMTestExpectedResults
874 Methods should complete without error.
875 Each time, the stream should be properly displayed on screen
876 The streams should be destroyed in a timely manner after they stop being displayed
879 void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()
881 INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()"));
882 LOG((" *** CTestScreenInterface test 0106L"));
883 _LIT(KDirectPost, "DirectPost");
884 TBool directPost; //If DirectPost is not defined then the exact order of buffer releasing cannot be asserted.
885 TBool definedDirectPost = iConfig.GetBool(KImageSectionName, KDirectPost, directPost);
889 SymbianStreamType ns = NULL;
890 TSurfaceId prevsurface = TSurfaceId::CreateNullId();
892 COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
893 CleanupStack::PushL(screenContext);
895 for (TInt i = 0; i < 10; ++i)
897 //INFO_PRINTF2(_L("Create stream loop: %i"), i);
899 TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
900 screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
902 sizeof(screenRotation));
903 screenContext->CommitAttribute();
905 COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
906 screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
907 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
909 surface = TSurfaceId::CreateNullId();
910 ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
911 iFastpathablePixelFormat, attributes.iNormalStride,
912 surface, iContiguous, 2);
913 ASSERT_FALSE((*ns).IsNull());
917 iUtility->FillStreamL(ns, KRgbRed);
921 iUtility->FillStreamL(ns, KRgbGreen);
925 iUtility->FillStreamL(ns, KRgbBlue);
929 if (!prevsurface.IsNull())
931 error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
932 ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
934 TInt err = screenContext->SetTopLayerSurface(ns);
935 ASSERT_TRUE(err == KErrNone);
936 //GetBufferOffset is a safe way to check if the surface is still alive
937 if (!prevsurface.IsNull())
939 error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
940 ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
943 err = screenContext->UpdateDisplay();
944 ASSERT_TRUE(err == KErrNone);
946 User::After(KMinimalDelay);
948 error=iUtility->Manager().GetBufferOffset(surface,0,offset);
949 ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
951 if (!prevsurface.IsNull())
953 error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
954 ASSERT_TRUE(error); //previous surface should definitely be deleted by now
956 iUtility->DestroyStream(ns);
957 error=iUtility->Manager().GetBufferOffset(surface,0,offset);
958 ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
963 CleanupStack::PopAndDestroy(screenContext);
965 if (!prevsurface.IsNull())
967 error=iUtility->Manager().GetBufferOffset(surface,0,offset);
968 ASSERT_TRUE(error); //previous surface should definitely be deleted by now