First public contribution.
1 // Copyright (c) 2008-2009 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.
14 // Test Direct Screen Access on a screen that supports transparency
18 #include "tdirecta2.h"
20 const TInt KMainTestOrdinalPriority=65535;
21 const TInt KOntopOfAllOthersTestOrdinalPriority=65537;
23 CTDirect2::CTDirect2(CTestStep* aStep):
24 CTWsGraphicsBase(aStep)
28 CTDirect2::~CTDirect2()
37 // put focus back to current screen as this test changed the focus screen to primary screen
38 TheClient->iWs.SetFocusScreen(iTest->iScreenNumber);
41 void CTDirect2::ConstructL()
43 // the following line makes sure that a console object hidden outside of
44 // screens range doesn't affect test results being on top of tested objects
45 TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority);
48 TInt CTDirect2::Timeout(TAny* aDirect2)
50 static_cast<CTDirect2*>(aDirect2)->HandleTimeout();
54 void CTDirect2::HandleTimeout()
56 // Send window group to back to avoid possibility of it
57 // interfering with other parts of this test
58 iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
60 iTimer->Cancel(); // Don't call back again
61 TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period
62 iTestCaseComplete = ETrue; // Move to next test case
65 void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
67 iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore
70 void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
72 // Send window group to back to avoid possibility of it
73 // interfering with other tests
74 iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
76 iTestCaseComplete = ETrue; // Move to next test case
78 // Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv
81 // Starts DSA on a topmost window, then puts a translucent window ontop of it
82 // to make sure wserv sends a DSA Abort even though the translucent window
83 // hasn't changed the visible area of the DSA window
84 void CTDirect2::StartTranslucentWindowOverDsaL()
86 // Use a new window group so we can put windows ontop of all others
87 iWindowGroup = new(ELeave) CTWindowGroup(TheClient);
88 iWindowGroup->ConstructL();
90 // Create new blank window
91 iUnderWindow = new(ELeave) CTBlankWindow();
92 iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc);
93 iUnderWindow->SetColor(TRgb(0,192,0));
95 // Make window group visible ontop of all others
96 User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority));
99 // Call Finish() to wait until under window has been rendered.
100 // Once window has been rendered, we can be sure window server has
101 // calculated the "top visible" region of the window.
102 TheClient->iWs.Finish();
104 // Start DSA on under window
105 iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs);
106 User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber));
107 iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this);
110 // Put translucent window ontop so as to reduce the top visible area, but leave the
111 // visible area unchanged (as the translucent window doesn't change the visible area
112 // of the window underneath it).
113 iOverWindow = new(ELeave) CTTitledWindow();
114 _LIT(KTranslucentWindowTitle, "Translucent window");
115 iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue);
116 TWindowTitle windowTitle(KTranslucentWindowTitle);
117 iOverWindow->SetTitle(windowTitle);
118 iOverWindow->SetColor(TRgb(192, 0, 0, 128));
121 // Start a timer, if the timeout triggers, fail the test, as we should get
122 // an abort DSA from wserv within the timeout
123 iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
124 const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort
125 iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this));
127 // Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow
131 void CTDirect2::RunTestCaseL(TInt aCurTestCase)
133 ((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
137 @SYMTestCaseID GRAPHICS-WSERV-0176
141 @SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA
143 @SYMTestPriority High
145 @SYMTestStatus Implemented
147 @SYMTestActions Start DSA on a blank window.
148 Then place a translucent window so that it partially overlaps the DSA window.
150 @SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window.
153 ((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176"));
156 _LIT(DSA1,"Translucent window overlaping DSA window");
158 StartTranslucentWindowOverDsaL(); // call this only once
161 if (!iTestCaseComplete)
163 // Keep calling this test case until iTestCaseComplete is true
164 ResetCounter(aCurTestCase-1);
169 // Move to next test case in sequence
170 iTestCaseComplete = EFalse;
175 INFO_PRINTF1(_L("Test complete\n"));
176 ((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
177 ((CTDirect2Step*)iStep)->CloseTMSGraphicsStep();
181 ((CTDirect2Step*)iStep)->RecordTestResultL();
184 __WS_CONSTRUCT_STEP__(Direct2)