sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Test Direct Screen Access on a screen that supports transparency
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "tdirecta2.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
const TInt KMainTestOrdinalPriority=65535;
|
sl@0
|
21 |
const TInt KOntopOfAllOthersTestOrdinalPriority=65537;
|
sl@0
|
22 |
|
sl@0
|
23 |
CTDirect2::CTDirect2(CTestStep* aStep):
|
sl@0
|
24 |
CTWsGraphicsBase(aStep)
|
sl@0
|
25 |
{
|
sl@0
|
26 |
}
|
sl@0
|
27 |
|
sl@0
|
28 |
CTDirect2::~CTDirect2()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
delete iDsa;
|
sl@0
|
31 |
delete iUnderWindow;
|
sl@0
|
32 |
delete iOverWindow;
|
sl@0
|
33 |
delete iScreenDevice;
|
sl@0
|
34 |
delete iWindowGroup;
|
sl@0
|
35 |
delete iTimer;
|
sl@0
|
36 |
|
sl@0
|
37 |
// put focus back to current screen as this test changed the focus screen to primary screen
|
sl@0
|
38 |
TheClient->iWs.SetFocusScreen(iTest->iScreenNumber);
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
void CTDirect2::ConstructL()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
// the following line makes sure that a console object hidden outside of
|
sl@0
|
44 |
// screens range doesn't affect test results being on top of tested objects
|
sl@0
|
45 |
TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
TInt CTDirect2::Timeout(TAny* aDirect2)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
static_cast<CTDirect2*>(aDirect2)->HandleTimeout();
|
sl@0
|
51 |
return KErrNone;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
void CTDirect2::HandleTimeout()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
// Send window group to back to avoid possibility of it
|
sl@0
|
57 |
// interfering with other parts of this test
|
sl@0
|
58 |
iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
|
sl@0
|
59 |
|
sl@0
|
60 |
iTimer->Cancel(); // Don't call back again
|
sl@0
|
61 |
TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period
|
sl@0
|
62 |
iTestCaseComplete = ETrue; // Move to next test case
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
// Send window group to back to avoid possibility of it
|
sl@0
|
73 |
// interfering with other tests
|
sl@0
|
74 |
iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
|
sl@0
|
75 |
|
sl@0
|
76 |
iTestCaseComplete = ETrue; // Move to next test case
|
sl@0
|
77 |
|
sl@0
|
78 |
// Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
// Starts DSA on a topmost window, then puts a translucent window ontop of it
|
sl@0
|
82 |
// to make sure wserv sends a DSA Abort even though the translucent window
|
sl@0
|
83 |
// hasn't changed the visible area of the DSA window
|
sl@0
|
84 |
void CTDirect2::StartTranslucentWindowOverDsaL()
|
sl@0
|
85 |
{
|
sl@0
|
86 |
// Use a new window group so we can put windows ontop of all others
|
sl@0
|
87 |
iWindowGroup = new(ELeave) CTWindowGroup(TheClient);
|
sl@0
|
88 |
iWindowGroup->ConstructL();
|
sl@0
|
89 |
|
sl@0
|
90 |
// Create new blank window
|
sl@0
|
91 |
iUnderWindow = new(ELeave) CTBlankWindow();
|
sl@0
|
92 |
iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc);
|
sl@0
|
93 |
iUnderWindow->SetColor(TRgb(0,192,0));
|
sl@0
|
94 |
|
sl@0
|
95 |
// Make window group visible ontop of all others
|
sl@0
|
96 |
User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority));
|
sl@0
|
97 |
TheClient->Flush();
|
sl@0
|
98 |
|
sl@0
|
99 |
// Call Finish() to wait until under window has been rendered.
|
sl@0
|
100 |
// Once window has been rendered, we can be sure window server has
|
sl@0
|
101 |
// calculated the "top visible" region of the window.
|
sl@0
|
102 |
TheClient->iWs.Finish();
|
sl@0
|
103 |
|
sl@0
|
104 |
// Start DSA on under window
|
sl@0
|
105 |
iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs);
|
sl@0
|
106 |
User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber));
|
sl@0
|
107 |
iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this);
|
sl@0
|
108 |
iDsa->StartL();
|
sl@0
|
109 |
|
sl@0
|
110 |
// Put translucent window ontop so as to reduce the top visible area, but leave the
|
sl@0
|
111 |
// visible area unchanged (as the translucent window doesn't change the visible area
|
sl@0
|
112 |
// of the window underneath it).
|
sl@0
|
113 |
iOverWindow = new(ELeave) CTTitledWindow();
|
sl@0
|
114 |
_LIT(KTranslucentWindowTitle, "Translucent window");
|
sl@0
|
115 |
iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue);
|
sl@0
|
116 |
TWindowTitle windowTitle(KTranslucentWindowTitle);
|
sl@0
|
117 |
iOverWindow->SetTitle(windowTitle);
|
sl@0
|
118 |
iOverWindow->SetColor(TRgb(192, 0, 0, 128));
|
sl@0
|
119 |
TheClient->Flush();
|
sl@0
|
120 |
|
sl@0
|
121 |
// Start a timer, if the timeout triggers, fail the test, as we should get
|
sl@0
|
122 |
// an abort DSA from wserv within the timeout
|
sl@0
|
123 |
iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
|
sl@0
|
124 |
const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort
|
sl@0
|
125 |
iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this));
|
sl@0
|
126 |
|
sl@0
|
127 |
// Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow
|
sl@0
|
128 |
// to be called
|
sl@0
|
129 |
}
|
sl@0
|
130 |
|
sl@0
|
131 |
void CTDirect2::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
134 |
switch(aCurTestCase)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
@SYMTestCaseID GRAPHICS-WSERV-0176
|
sl@0
|
138 |
|
sl@0
|
139 |
@SYMDEF PDEF116863
|
sl@0
|
140 |
|
sl@0
|
141 |
@SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA
|
sl@0
|
142 |
|
sl@0
|
143 |
@SYMTestPriority High
|
sl@0
|
144 |
|
sl@0
|
145 |
@SYMTestStatus Implemented
|
sl@0
|
146 |
|
sl@0
|
147 |
@SYMTestActions Start DSA on a blank window.
|
sl@0
|
148 |
Then place a translucent window so that it partially overlaps the DSA window.
|
sl@0
|
149 |
|
sl@0
|
150 |
@SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window.
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
case 1:
|
sl@0
|
153 |
((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176"));
|
sl@0
|
154 |
if (!iOnceOnly)
|
sl@0
|
155 |
{
|
sl@0
|
156 |
_LIT(DSA1,"Translucent window overlaping DSA window");
|
sl@0
|
157 |
INFO_PRINTF1(DSA1);
|
sl@0
|
158 |
StartTranslucentWindowOverDsaL(); // call this only once
|
sl@0
|
159 |
iOnceOnly = ETrue;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
if (!iTestCaseComplete)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
// Keep calling this test case until iTestCaseComplete is true
|
sl@0
|
164 |
ResetCounter(aCurTestCase-1);
|
sl@0
|
165 |
}
|
sl@0
|
166 |
else
|
sl@0
|
167 |
{
|
sl@0
|
168 |
iOnceOnly = EFalse;
|
sl@0
|
169 |
// Move to next test case in sequence
|
sl@0
|
170 |
iTestCaseComplete = EFalse;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
|
sl@0
|
174 |
default:
|
sl@0
|
175 |
INFO_PRINTF1(_L("Test complete\n"));
|
sl@0
|
176 |
((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
177 |
((CTDirect2Step*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
178 |
TestComplete();
|
sl@0
|
179 |
break;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
((CTDirect2Step*)iStep)->RecordTestResultL();
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
__WS_CONSTRUCT_STEP__(Direct2)
|
sl@0
|
185 |
|