sl@0: // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // sl@0: // Permission is hereby granted, free of charge, to any person obtaining a sl@0: // copy of this software and/or associated documentation files (the sl@0: // "Materials"), to deal in the Materials without restriction, including sl@0: // without limitation the rights to use, copy, modify, merge, publish, sl@0: // distribute, sublicense, and/or sell copies of the Materials, and to sl@0: // permit persons to whom the Materials are furnished to do so, subject to sl@0: // the following conditions: sl@0: // sl@0: // The above copyright notice and this permission notice shall be included sl@0: // in all copies or substantial portions of the Materials. sl@0: // sl@0: // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, sl@0: // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF sl@0: // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. sl@0: // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, sl@0: // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE sl@0: // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. sl@0: // sl@0: // Description: sl@0: // Implementation of test class for OpenWF-C RI display driver interface sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "tscreeninterface.h" sl@0: sl@0: #define KCompositorVersion 0x01023456 sl@0: #define KRgbRed TRgb(0x0000ff) sl@0: #define KRgbGreen TRgb(0x00ff00) sl@0: #define KRgbYellow TRgb(0x00ffff) sl@0: #define KRgbBlue TRgb(0xff0000) sl@0: sl@0: const TInt KDefaultScreenNumber = 0; sl@0: const TTimeIntervalMicroSeconds32 KDelay = 1000000; //delay in microseconds sl@0: const TTimeIntervalMicroSeconds32 KMinimalDelay = 1000; //delay in microseconds sl@0: sl@0: _LIT(KImageSectionName, "ImageInfo"); sl@0: _LIT(KContiguousFlag, "ContiguousFlag"); sl@0: _LIT(KNonFastpathablePixelFormat, "NonFastpathablePixelFormat"); sl@0: _LIT(KFastpathablePixelFormat, "FastpathablePixelFormat"); sl@0: sl@0: /* sl@0: * CTestScreenInterface implementation sl@0: */ sl@0: sl@0: CTestScreenInterface::CTestScreenInterface() sl@0: :iContiguous(EFlagNotListed), sl@0: iFastpathablePixelFormat(EUidPixelFormatARGB_8888_PRE), sl@0: iNonFastpathablePixelFormat(EUidPixelFormatRGB_565), sl@0: iMappable(ETrue), sl@0: iMaxBuffers(2), sl@0: iMinBuffers(1), sl@0: iCacheAttrib(ECacheNotlisted) sl@0: { sl@0: // No implementation required sl@0: } sl@0: sl@0: CTestScreenInterface::~CTestScreenInterface() sl@0: { sl@0: TearDown(); sl@0: } sl@0: sl@0: void CTestScreenInterface::SetupL() sl@0: { sl@0: iUtility = CStreamUtility::NewL(); sl@0: iRed.SetInternal(0xFFFF0000); sl@0: iGreen.SetInternal(0xFF00FF00); sl@0: iBlue.SetInternal(0xFF0000FF); sl@0: ReadIniData(); sl@0: User::After(KDelay); // consider reading delay from ini file sl@0: } sl@0: sl@0: /** sl@0: * test Suite furniture sl@0: **/ sl@0: void CTestScreenInterface::TearDownL() sl@0: { sl@0: // Nothing leaves in this function, sl@0: // but TearDownL() is needed for the CTestFixture (TEF) interface sl@0: TearDown(); sl@0: } sl@0: sl@0: void CTestScreenInterface::TearDown() sl@0: { sl@0: if(iUtility) sl@0: { sl@0: delete iUtility; sl@0: iUtility = NULL; sl@0: } sl@0: } sl@0: sl@0: // Create a suite of all the tests sl@0: CTestSuite* CTestScreenInterface::CreateSuiteL(const TDesC& aName) sl@0: { sl@0: SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion); sl@0: SUB_SUITE_OPT(CTestScreenInterface,NULL); sl@0: sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0100L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0101L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0102L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0103L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0104L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0105L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0106L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0107L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0108L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0109L); sl@0: sl@0: END_SUITE; sl@0: sl@0: } sl@0: sl@0: /// This handles any non-member uses of the extended ASSERT_XXX macros sl@0: void TefUnitFailLeaveL() sl@0: { sl@0: User::Leave(KErrTEFUnitFail); sl@0: } sl@0: sl@0: void CTestScreenInterface::ReadIniData() sl@0: { sl@0: TBool contiguousFlag; sl@0: TBool returnValue = iConfig.GetBool(KImageSectionName, KContiguousFlag, contiguousFlag); sl@0: if (returnValue) sl@0: { sl@0: if(contiguousFlag) sl@0: { sl@0: iContiguous = EContiguous; sl@0: } sl@0: else sl@0: { sl@0: iContiguous = ENonContiguous; sl@0: } sl@0: } sl@0: sl@0: TInt fastpathablePixelFormat; sl@0: returnValue = iConfig.GetHex(KImageSectionName, KFastpathablePixelFormat, fastpathablePixelFormat); sl@0: if(returnValue) sl@0: { sl@0: iFastpathablePixelFormat = static_cast(fastpathablePixelFormat); sl@0: } sl@0: sl@0: TInt nonFastpathablePixelFormat; sl@0: returnValue = iConfig.GetHex(KImageSectionName, KNonFastpathablePixelFormat, nonFastpathablePixelFormat); sl@0: if(returnValue) sl@0: { sl@0: iNonFastpathablePixelFormat = static_cast(nonFastpathablePixelFormat); sl@0: } sl@0: } sl@0: sl@0: TInt CTestScreenInterface::BaseTestContiguousFlag(TBool aContiguous) sl@0: { sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, aContiguous, 1); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, _L("SetTopLayerSurface() returned %i"),err ); sl@0: RDebug::Printf("SetTopLayerSurface() returned %i",err); sl@0: sl@0: if (err==KErrNone) sl@0: { //Must successfully SetTopLayerSurface before calling UpdateDisplay. sl@0: screenContext->UpdateDisplay(); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0100 sl@0: @SYMTestCaseDesc Create a screen size stream and display on screen sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a screen size stream based on the display attributes with contigous and non-contiguous flags sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: @SYMTestExpectedResults sl@0: If contiguous flag is set in the ini file, and the stream is created using the flag, sl@0: the stream should be properly displayed on screen. The stream created using the opposit flag from ini value should fail. sl@0: If contiguous flag is not set in the ini file, sl@0: the stream should be properly displayed on screen for contiguous and non-contiguous flag. sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0100L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()")); sl@0: LOG((" *** CTestScreenInterface test 0100L")); sl@0: sl@0: if(iContiguous != EFlagNotListed) sl@0: { sl@0: sl@0: // We expect the opposit flag to the one from the ini file to fail sl@0: if(iContiguous == EContiguous) sl@0: { sl@0: ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(ENonContiguous)); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(EContiguous)); sl@0: } sl@0: // The contiguous flag from the ini file should pass sl@0: ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(iContiguous)); sl@0: // The last run here should be the "good" run so that it can do a Display() call. sl@0: } sl@0: else sl@0: { sl@0: // Contiguous or Non-contiguous flags should both pass if nothing set in the ini file sl@0: ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(EContiguous)); sl@0: ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(ENonContiguous)); sl@0: } sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L() done")); sl@0: LOG((" *** CTestScreenInterface test 0100L done")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0101 sl@0: @SYMTestCaseDesc Create a stream, display on screen, then rotate the screen involving scaling sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority Medium sl@0: @SYMTestPurpose Verify screen rotation works sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a screen size stream sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: Rotate the screen 90 degrees, 180 degrees, 270 degrees sl@0: Update the screen respectively sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: The stream should be properly displayed on screen sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0101L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()")); sl@0: LOG((" *** CTestScreenInterface test 0101L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: if (attributes.iSupportedRotations > 1) sl@0: { sl@0: INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations); sl@0: TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation0, sl@0: sizeof(screenRotation0)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: INFO_PRINTF1(_L("Rotate screen 90 degree")); sl@0: // Rotate screen 90 degree and test sl@0: TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation1, sl@0: sizeof(screenRotation1)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: if (attributes.iSupportedRotations > 2) sl@0: { sl@0: INFO_PRINTF1(_L("Rotate screen 180 degree")); sl@0: // Rotate screen 180 degree and test sl@0: TUint32 screenRotation2 = COpenWFC_RI_Display::EScreenRotate180; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation2, sl@0: sizeof(screenRotation2)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: sl@0: if (attributes.iSupportedRotations > 3) sl@0: { sl@0: INFO_PRINTF1(_L("Rotate screen 270 degree")); sl@0: // Rotate screen 270 degree and test sl@0: TUint32 screenRotation3 = COpenWFC_RI_Display::EScreenRotate270; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation3, sl@0: sizeof(screenRotation3)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: sl@0: // Set screen back to rotation 0 sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation0, sl@0: sizeof(screenRotation0)); sl@0: screenContext->CommitAttribute(); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped.")); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0102 sl@0: @SYMTestCaseDesc Create a stream, display on screen, then rotate the screen, not involving scaling sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority Medium sl@0: @SYMTestPurpose Verify screen rotation works sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a stream of the size (screenHeight, screenWidth) sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: Rotate the screen 90 degrees sl@0: Update the screen sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: The stream should be properly displayed on screen sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0102L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()")); sl@0: LOG((" *** CTestScreenInterface test 0102L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: if (attributes.iSupportedRotations > 1) sl@0: { sl@0: INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations); sl@0: TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation0, sl@0: sizeof(screenRotation0)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalHeight,attributes.iNormalWidth), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: INFO_PRINTF1(_L("Rotate screen 90 degree")); sl@0: // Rotate screen 90 degree and test sl@0: TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation1, sl@0: sizeof(screenRotation1)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped.")); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0103 sl@0: @SYMTestCaseDesc Create a stream, fill the stream several times and display on screen sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check displaying stream repeatedly sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a screen size stream sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: Repeat filling the stream, associate with toplayer and update several times sl@0: Destory the screen context sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: Each time, the stream should be properly displayed on screen sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0103L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()")); sl@0: LOG((" *** CTestScreenInterface test 0103L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbYellow); sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: User::After(KDelay); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: User::After(KDelay); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: User::After(KDelay); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbYellow); sl@0: err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: User::After(KDelay); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: User::After(KDelay); sl@0: sl@0: // Set a non-topmost layer sl@0: err = screenContext->SetLayerSurface(1, ns); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0104 sl@0: @SYMTestCaseDesc Display all display attributes sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check display attributes sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Get all display attribtues sl@0: Destory the screen context sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: Display attributes should be correct sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0104L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()")); sl@0: LOG((" *** CTestScreenInterface test 0104L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: INFO_PRINTF1(_L("Printing attribute values: ")); sl@0: INFO_PRINTF2(_L("EScreenAttributeSupportedRotation: %i "), attributes.iSupportedRotations); sl@0: INFO_PRINTF2(_L("EScreenAttributeCurrentRotation: 0x%x "), attributes.iCurrentRotation); sl@0: INFO_PRINTF2(_L("EScreenAttributeDefaultRotation: 0x%x "), attributes.iDefaultRotation); sl@0: INFO_PRINTF2(_L("EScreenAttributeBytesPerPixel: %i "), attributes.iBytesPerPixel); sl@0: INFO_PRINTF2(_L("EScreenAttributeFlippedHeight: %i "), attributes.iFlippedHeight); sl@0: INFO_PRINTF2(_L("EScreenAttributeFlippedWidth: %i "), attributes.iFlippedWidth); sl@0: INFO_PRINTF2(_L("EScreenAttributeFlippedStride: %i "), attributes.iFlippedStride); sl@0: INFO_PRINTF2(_L("EScreenAttributeNormalHeight: %i "), attributes.iNormalHeight); sl@0: INFO_PRINTF2(_L("EScreenAttributeNormalWidth: %i "), attributes.iNormalWidth); sl@0: INFO_PRINTF2(_L("EScreenAttributeNormalStride: %i "), attributes.iNormalStride); sl@0: INFO_PRINTF2(_L("EScreenAttributePixelFormat: 0x%x "), attributes.iPixelFormat); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0105 sl@0: @SYMTestCaseDesc Create a screen size stream of non-fastpathable pixel format and display on screen sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test - Negative Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a screen size stream based on the display attributes with a non-fastpathable pixelformat sl@0: Fill the stream sl@0: Associate the stream with the topmost display layer sl@0: @SYMTestExpectedResults sl@0: Test should pass. sl@0: SetTopLayerSurface should return KErrNotSupported. sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0105L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()")); sl@0: LOG((" *** CTestScreenInterface test 0105L")); sl@0: sl@0: if (!iNonFastpathablePixelFormat) sl@0: { sl@0: INFO_PRINTF1(_L("No non-fastpathable format specified - negative test cannot be run.")); sl@0: User::Leave(KErrTEFUnitInconclusive); sl@0: } sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iNonFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: sl@0: ASSERT_TRUE(KErrNotSupported == screenContext->SetTopLayerSurface(ns)); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0106 sl@0: @SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check stream display repeatedly sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a stream sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: Destory the screen context sl@0: Repeat the above actions for a number of times in a for loop sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: Each time, the stream should be properly displayed on screen sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0106L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()")); sl@0: LOG((" *** CTestScreenInterface test 0106L")); sl@0: sl@0: SymbianStreamType ns = NULL; sl@0: const TInt loopMaxNum = 10; sl@0: sl@0: for (TInt i = 0; i < loopMaxNum; ++i) sl@0: { sl@0: //INFO_PRINTF2(_L("Create screen context and stream loop: %i"), i); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: if(ns == NULL) sl@0: { sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: } sl@0: sl@0: if(i%3 == 0) sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: } sl@0: else if (i%3 == 1) sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: } sl@0: else sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbBlue); sl@0: } sl@0: sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: sl@0: User::After(KDelay); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0107 sl@0: @SYMTestCaseDesc Simple Non Trivial Attributes sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check that simple non-trivial attributes are accepted by SetTopLayerSurface. sl@0: Note this test does not pass in "real" attributes, so the result is predictable. sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Create a fastpathable stream sl@0: Fill the stream sl@0: Associate the stream with the topmost display layer sl@0: and NULL Non Trivial Atrributes sl@0: Update the screen sl@0: Associate the stream with the topmost display layer sl@0: and empty Non Trivial Atrributes sl@0: Update the screen sl@0: Associate the stream with the topmost display layer sl@0: and wrong Non Trivial Atrributes sl@0: This should fail sl@0: Destory the screen context sl@0: @SYMTestExpectedResults sl@0: SetTopLayerSurface should not fail, except for wrong attribute. sl@0: SetTopLayerSurface should not crash or panic. sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0107L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()")); sl@0: LOG((" *** CTestScreenInterface test 0107L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 1); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: sl@0: TInt err = screenContext->SetTopLayerSurface(ns,NULL); sl@0: ASSERT_FALSE(err); sl@0: screenContext->UpdateDisplay(); sl@0: sl@0: TInt emptyList=0; sl@0: err = screenContext->SetTopLayerSurface(ns,&emptyList); sl@0: ASSERT_FALSE(err); sl@0: screenContext->UpdateDisplay(); sl@0: sl@0: TInt wrongList=-1; sl@0: err = screenContext->SetTopLayerSurface(ns,&wrongList); sl@0: ASSERT_TRUE(err); sl@0: sl@0: //Calling UpdateDisplay should fall-back to the previous setting of top layer surface sl@0: screenContext->UpdateDisplay(); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0108 sl@0: @SYMTestCaseDesc Test getting and setting attributes sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check getting and setting attibutes with good and bad values sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Get and set attributes with good and bad values sl@0: Destory the screen context sl@0: @SYMTestExpectedResults sl@0: GetAttribute should always succeed with all valid TScreenAttribute values sl@0: and appropriate attribute size sl@0: SetAttribute should succeed for modifying the current rotation sl@0: Invalid valued for getting and setting attributes should return correct error code sl@0: **/ sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0108L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()")); sl@0: LOG((" *** CTestScreenInterface test 0108L")); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: TInt err; sl@0: sl@0: for(TUint ii = COpenWFC_RI_Display::EScreenAttributeInvalid; ii <= COpenWFC_RI_Display::EScreenAttributeScreenGeometry; ++ii) sl@0: { sl@0: if(ii == COpenWFC_RI_Display::EScreenAttributeScreenGeometry) sl@0: { sl@0: err = screenContext->GetAttribute(ii, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: } sl@0: else sl@0: { sl@0: err = screenContext->GetAttribute(ii, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenAttribute)); sl@0: } sl@0: sl@0: if(ii == COpenWFC_RI_Display::EScreenAttributeInvalid) sl@0: { sl@0: ASSERT_TRUE(err == KErrNotSupported); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: } sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, &screenRotation, sl@0: sizeof(screenRotation)); sl@0: // The only parameter that can be modified is the current rotation sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeSupportedRotation, &screenRotation, sl@0: sizeof(screenRotation)); sl@0: ASSERT_TRUE(err == KErrNotSupported); sl@0: sl@0: // Set attribute to NULL sl@0: err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, NULL, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: sl@0: // Set attribute size to be 0 sl@0: err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, &attributes, 0); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: sl@0: // Set attribute == NULL sl@0: err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, NULL, sl@0: sizeof(COpenWFC_RI_Display::TScreenAttribute)); sl@0: ASSERT_TRUE(err != KErrNone); sl@0: sl@0: // Set attribute with wrong size sl@0: err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenAttribute)); sl@0: ASSERT_TRUE(err != KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0109 sl@0: @SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times sl@0: @SYMREQ sl@0: @SYMPREQ REQ 417-54885 sl@0: @SYMTestType Unit Test sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Check stream display repeatedly sl@0: @SYMTestActions sl@0: Create a screen context sl@0: Set display attributes sl@0: Repeat the below actions for a number of times in a for loop sl@0: Create a stream sl@0: Fill the stream sl@0: Associates the stream with the topmost display layer sl@0: Update the screen sl@0: Finally sl@0: Destory the screen context sl@0: sl@0: @SYMTestExpectedResults sl@0: Methods should complete without error. sl@0: Each time, the stream should be properly displayed on screen sl@0: The streams should be destroyed in a timely manner after they stop being displayed sl@0: **/ sl@0: sl@0: void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0109L() sl@0: { sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()")); sl@0: LOG((" *** CTestScreenInterface test 0106L")); sl@0: _LIT(KDirectPost, "DirectPost"); sl@0: TBool directPost; //If DirectPost is not defined then the exact order of buffer releasing cannot be asserted. sl@0: TBool definedDirectPost = iConfig.GetBool(KImageSectionName, KDirectPost, directPost); sl@0: TInt offset; sl@0: TInt error; sl@0: TSurfaceId surface; sl@0: SymbianStreamType ns = NULL; sl@0: TSurfaceId prevsurface = TSurfaceId::CreateNullId(); sl@0: sl@0: COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber); sl@0: CleanupStack::PushL(screenContext); sl@0: sl@0: for (TInt i = 0; i < 10; ++i) sl@0: { sl@0: //INFO_PRINTF2(_L("Create stream loop: %i"), i); sl@0: sl@0: TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0; sl@0: screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, sl@0: &screenRotation, sl@0: sizeof(screenRotation)); sl@0: screenContext->CommitAttribute(); sl@0: sl@0: COpenWFC_RI_Display::TScreenGeometryAttribute attributes; sl@0: screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, sl@0: sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute)); sl@0: sl@0: surface = TSurfaceId::CreateNullId(); sl@0: ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), sl@0: iFastpathablePixelFormat, attributes.iNormalStride, sl@0: surface, iContiguous, 2); sl@0: ASSERT_FALSE((*ns).IsNull()); sl@0: sl@0: if(i%3 == 0) sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbRed); sl@0: } sl@0: else if (i%3 == 1) sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbGreen); sl@0: } sl@0: else sl@0: { sl@0: iUtility->FillStreamL(ns, KRgbBlue); sl@0: } sl@0: sl@0: sl@0: if (!prevsurface.IsNull()) sl@0: { sl@0: error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset); sl@0: ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1); sl@0: } sl@0: TInt err = screenContext->SetTopLayerSurface(ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: //GetBufferOffset is a safe way to check if the surface is still alive sl@0: if (!prevsurface.IsNull()) sl@0: { sl@0: error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset); sl@0: ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1); sl@0: } sl@0: sl@0: err = screenContext->UpdateDisplay(); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: User::After(KMinimalDelay); sl@0: sl@0: error=iUtility->Manager().GetBufferOffset(surface,0,offset); sl@0: ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1); sl@0: sl@0: if (!prevsurface.IsNull()) sl@0: { sl@0: error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset); sl@0: ASSERT_TRUE(error); //previous surface should definitely be deleted by now sl@0: } sl@0: iUtility->DestroyStream(ns); sl@0: error=iUtility->Manager().GetBufferOffset(surface,0,offset); sl@0: ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1); sl@0: prevsurface=surface; sl@0: sl@0: User::After(KDelay); sl@0: } sl@0: CleanupStack::PopAndDestroy(screenContext); sl@0: sl@0: if (!prevsurface.IsNull()) sl@0: { sl@0: error=iUtility->Manager().GetBufferOffset(surface,0,offset); sl@0: ASSERT_TRUE(error); //previous surface should definitely be deleted by now sl@0: } sl@0: } sl@0: