sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Test Direct Screen Access on a screen that supports transparency sl@0: // sl@0: // sl@0: sl@0: #include "tdirecta2.h" sl@0: sl@0: const TInt KMainTestOrdinalPriority=65535; sl@0: const TInt KOntopOfAllOthersTestOrdinalPriority=65537; sl@0: sl@0: CTDirect2::CTDirect2(CTestStep* aStep): sl@0: CTWsGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTDirect2::~CTDirect2() sl@0: { sl@0: delete iDsa; sl@0: delete iUnderWindow; sl@0: delete iOverWindow; sl@0: delete iScreenDevice; sl@0: delete iWindowGroup; sl@0: delete iTimer; sl@0: sl@0: // put focus back to current screen as this test changed the focus screen to primary screen sl@0: TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); sl@0: } sl@0: sl@0: void CTDirect2::ConstructL() sl@0: { sl@0: // the following line makes sure that a console object hidden outside of sl@0: // screens range doesn't affect test results being on top of tested objects sl@0: TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority); sl@0: } sl@0: sl@0: TInt CTDirect2::Timeout(TAny* aDirect2) sl@0: { sl@0: static_cast(aDirect2)->HandleTimeout(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CTDirect2::HandleTimeout() sl@0: { sl@0: // Send window group to back to avoid possibility of it sl@0: // interfering with other parts of this test sl@0: iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); sl@0: sl@0: iTimer->Cancel(); // Don't call back again sl@0: TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period sl@0: iTestCaseComplete = ETrue; // Move to next test case sl@0: } sl@0: sl@0: void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) sl@0: { sl@0: iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore sl@0: } sl@0: sl@0: void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) sl@0: { sl@0: // Send window group to back to avoid possibility of it sl@0: // interfering with other tests sl@0: iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); sl@0: sl@0: iTestCaseComplete = ETrue; // Move to next test case sl@0: sl@0: // Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv sl@0: } sl@0: sl@0: // Starts DSA on a topmost window, then puts a translucent window ontop of it sl@0: // to make sure wserv sends a DSA Abort even though the translucent window sl@0: // hasn't changed the visible area of the DSA window sl@0: void CTDirect2::StartTranslucentWindowOverDsaL() sl@0: { sl@0: // Use a new window group so we can put windows ontop of all others sl@0: iWindowGroup = new(ELeave) CTWindowGroup(TheClient); sl@0: iWindowGroup->ConstructL(); sl@0: sl@0: // Create new blank window sl@0: iUnderWindow = new(ELeave) CTBlankWindow(); sl@0: iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc); sl@0: iUnderWindow->SetColor(TRgb(0,192,0)); sl@0: sl@0: // Make window group visible ontop of all others sl@0: User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority)); sl@0: TheClient->Flush(); sl@0: sl@0: // Call Finish() to wait until under window has been rendered. sl@0: // Once window has been rendered, we can be sure window server has sl@0: // calculated the "top visible" region of the window. sl@0: TheClient->iWs.Finish(); sl@0: sl@0: // Start DSA on under window sl@0: iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs); sl@0: User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber)); sl@0: iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this); sl@0: iDsa->StartL(); sl@0: sl@0: // Put translucent window ontop so as to reduce the top visible area, but leave the sl@0: // visible area unchanged (as the translucent window doesn't change the visible area sl@0: // of the window underneath it). sl@0: iOverWindow = new(ELeave) CTTitledWindow(); sl@0: _LIT(KTranslucentWindowTitle, "Translucent window"); sl@0: iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue); sl@0: TWindowTitle windowTitle(KTranslucentWindowTitle); sl@0: iOverWindow->SetTitle(windowTitle); sl@0: iOverWindow->SetColor(TRgb(192, 0, 0, 128)); sl@0: TheClient->Flush(); sl@0: sl@0: // Start a timer, if the timeout triggers, fail the test, as we should get sl@0: // an abort DSA from wserv within the timeout sl@0: iTimer = CPeriodic::NewL(CActive::EPriorityStandard); sl@0: const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort sl@0: iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this)); sl@0: sl@0: // Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow sl@0: // to be called sl@0: } sl@0: sl@0: void CTDirect2::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0176 sl@0: sl@0: @SYMDEF PDEF116863 sl@0: sl@0: @SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Start DSA on a blank window. sl@0: Then place a translucent window so that it partially overlaps the DSA window. sl@0: sl@0: @SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window. sl@0: */ sl@0: case 1: sl@0: ((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176")); sl@0: if (!iOnceOnly) sl@0: { sl@0: _LIT(DSA1,"Translucent window overlaping DSA window"); sl@0: INFO_PRINTF1(DSA1); sl@0: StartTranslucentWindowOverDsaL(); // call this only once sl@0: iOnceOnly = ETrue; sl@0: } sl@0: if (!iTestCaseComplete) sl@0: { sl@0: // Keep calling this test case until iTestCaseComplete is true sl@0: ResetCounter(aCurTestCase-1); sl@0: } sl@0: else sl@0: { sl@0: iOnceOnly = EFalse; sl@0: // Move to next test case in sequence sl@0: iTestCaseComplete = EFalse; sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: INFO_PRINTF1(_L("Test complete\n")); sl@0: ((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTDirect2Step*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTDirect2Step*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(Direct2) sl@0: