|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Test Direct Screen Access on a screen that supports transparency |
|
15 // |
|
16 // |
|
17 |
|
18 #include "tdirecta2.h" |
|
19 |
|
20 const TInt KMainTestOrdinalPriority=65535; |
|
21 const TInt KOntopOfAllOthersTestOrdinalPriority=65537; |
|
22 |
|
23 CTDirect2::CTDirect2(CTestStep* aStep): |
|
24 CTWsGraphicsBase(aStep) |
|
25 { |
|
26 } |
|
27 |
|
28 CTDirect2::~CTDirect2() |
|
29 { |
|
30 delete iDsa; |
|
31 delete iUnderWindow; |
|
32 delete iOverWindow; |
|
33 delete iScreenDevice; |
|
34 delete iWindowGroup; |
|
35 delete iTimer; |
|
36 |
|
37 // put focus back to current screen as this test changed the focus screen to primary screen |
|
38 TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); |
|
39 } |
|
40 |
|
41 void CTDirect2::ConstructL() |
|
42 { |
|
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); |
|
46 } |
|
47 |
|
48 TInt CTDirect2::Timeout(TAny* aDirect2) |
|
49 { |
|
50 static_cast<CTDirect2*>(aDirect2)->HandleTimeout(); |
|
51 return KErrNone; |
|
52 } |
|
53 |
|
54 void CTDirect2::HandleTimeout() |
|
55 { |
|
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); |
|
59 |
|
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 |
|
63 } |
|
64 |
|
65 void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) |
|
66 { |
|
67 iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore |
|
68 } |
|
69 |
|
70 void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) |
|
71 { |
|
72 // Send window group to back to avoid possibility of it |
|
73 // interfering with other tests |
|
74 iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); |
|
75 |
|
76 iTestCaseComplete = ETrue; // Move to next test case |
|
77 |
|
78 // Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv |
|
79 } |
|
80 |
|
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() |
|
85 { |
|
86 // Use a new window group so we can put windows ontop of all others |
|
87 iWindowGroup = new(ELeave) CTWindowGroup(TheClient); |
|
88 iWindowGroup->ConstructL(); |
|
89 |
|
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)); |
|
94 |
|
95 // Make window group visible ontop of all others |
|
96 User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority)); |
|
97 TheClient->Flush(); |
|
98 |
|
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(); |
|
103 |
|
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); |
|
108 iDsa->StartL(); |
|
109 |
|
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)); |
|
119 TheClient->Flush(); |
|
120 |
|
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)); |
|
126 |
|
127 // Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow |
|
128 // to be called |
|
129 } |
|
130 |
|
131 void CTDirect2::RunTestCaseL(TInt aCurTestCase) |
|
132 { |
|
133 ((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
134 switch(aCurTestCase) |
|
135 { |
|
136 /** |
|
137 @SYMTestCaseID GRAPHICS-WSERV-0176 |
|
138 |
|
139 @SYMDEF PDEF116863 |
|
140 |
|
141 @SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA |
|
142 |
|
143 @SYMTestPriority High |
|
144 |
|
145 @SYMTestStatus Implemented |
|
146 |
|
147 @SYMTestActions Start DSA on a blank window. |
|
148 Then place a translucent window so that it partially overlaps the DSA window. |
|
149 |
|
150 @SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window. |
|
151 */ |
|
152 case 1: |
|
153 ((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176")); |
|
154 if (!iOnceOnly) |
|
155 { |
|
156 _LIT(DSA1,"Translucent window overlaping DSA window"); |
|
157 INFO_PRINTF1(DSA1); |
|
158 StartTranslucentWindowOverDsaL(); // call this only once |
|
159 iOnceOnly = ETrue; |
|
160 } |
|
161 if (!iTestCaseComplete) |
|
162 { |
|
163 // Keep calling this test case until iTestCaseComplete is true |
|
164 ResetCounter(aCurTestCase-1); |
|
165 } |
|
166 else |
|
167 { |
|
168 iOnceOnly = EFalse; |
|
169 // Move to next test case in sequence |
|
170 iTestCaseComplete = EFalse; |
|
171 } |
|
172 break; |
|
173 |
|
174 default: |
|
175 INFO_PRINTF1(_L("Test complete\n")); |
|
176 ((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
177 ((CTDirect2Step*)iStep)->CloseTMSGraphicsStep(); |
|
178 TestComplete(); |
|
179 break; |
|
180 } |
|
181 ((CTDirect2Step*)iStep)->RecordTestResultL(); |
|
182 } |
|
183 |
|
184 __WS_CONSTRUCT_STEP__(Direct2) |
|
185 |