sl@0
|
1 |
// Copyright (c) 2010 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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent - Internal Nokia test code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <w32std.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <wspublishandsubscribedata.h>
|
sl@0
|
25 |
#include "trenderorientation.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
const TInt KPublishTimeout = 1000000; // 1 second in microseconds
|
sl@0
|
28 |
const TInt KNumIterations = 20;
|
sl@0
|
29 |
|
sl@0
|
30 |
// Values for the device orientation that we receive via P&S from the Theme Server
|
sl@0
|
31 |
// Must match those in renderorientationtracker.h, and, obviously, those used by the real theme server
|
sl@0
|
32 |
const TUid KThemeOrientationCategory = {0x20022E82}; // == KHbPsHardwareCoarseOrientationCategoryUid
|
sl@0
|
33 |
const TUint KThemeOrientationKey = 0x4F726965; // == KHbPsHardwareCoarseOrientationKey
|
sl@0
|
34 |
|
sl@0
|
35 |
void CTWindowSet::ConstructL()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
User::LeaveIfError(iWs.Connect());
|
sl@0
|
38 |
iWs.SetAutoFlush(ETrue);
|
sl@0
|
39 |
|
sl@0
|
40 |
iWindowGroup = RWindowGroup(iWs);
|
sl@0
|
41 |
User::LeaveIfError(iWindowGroup.Construct(reinterpret_cast<TUint32>(&iWindowGroup)));
|
sl@0
|
42 |
|
sl@0
|
43 |
iChildWindow = RWindow(iWs);
|
sl@0
|
44 |
User::LeaveIfError(iChildWindow.Construct(iWindowGroup, reinterpret_cast<TUint32>(&iChildWindow)));
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
CTWindowSet::~CTWindowSet()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
Destroy();
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
void CTWindowSet::Destroy()
|
sl@0
|
53 |
{
|
sl@0
|
54 |
iChildWindow.Close();
|
sl@0
|
55 |
iWindowGroup.Close();
|
sl@0
|
56 |
iWs.Close();
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
CTRenderOrientation::CTRenderOrientation()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
// check that these two enums are aligned
|
sl@0
|
62 |
__ASSERT_COMPILE(EDisplayOrientationAuto == ENumWindowSets);
|
sl@0
|
63 |
|
sl@0
|
64 |
SetTestStepName(KTRenderOrientation);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
CTRenderOrientation::~CTRenderOrientation()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
Gets the Render Orientation as published by window server
|
sl@0
|
73 |
|
sl@0
|
74 |
@return TRenderOrienation that was last publised by window server.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
TRenderOrientation CTRenderOrientation::GetRenderOrientationL()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
return GetOrientationL(iWsRenderOrientationProperty);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
Gets the Theme Orientation as published by theme server
|
sl@0
|
83 |
|
sl@0
|
84 |
@return TRenderOrienation that was last publised by theme server.
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
TRenderOrientation CTRenderOrientation::GetThemeOrientationL()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
return GetOrientationL(iThemeOrientationProperty);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
/**
|
sl@0
|
92 |
Gets the orientation as published to the given RProperty
|
sl@0
|
93 |
|
sl@0
|
94 |
@return TRenderOrienation that was last publised to the given RProperty
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
TRenderOrientation CTRenderOrientation::GetOrientationL(RProperty& aProperty)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
TInt orientation=EDisplayOrientationNormal;
|
sl@0
|
99 |
User::LeaveIfError(aProperty.Get(orientation));
|
sl@0
|
100 |
|
sl@0
|
101 |
TESTL(orientation >= EDisplayOrientationNormal);
|
sl@0
|
102 |
TESTL(orientation < EDisplayOrientationAuto);
|
sl@0
|
103 |
|
sl@0
|
104 |
return static_cast<TRenderOrientation>(orientation);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
/**
|
sl@0
|
108 |
Tests each usable TRenderOrientation KNumIterations times for the given test phase / use case.
|
sl@0
|
109 |
|
sl@0
|
110 |
@param aStepName - the test step ID to use
|
sl@0
|
111 |
@param aTestPhase - the internal test phase
|
sl@0
|
112 |
*/
|
sl@0
|
113 |
void CTRenderOrientation::TestOrientationChangeL(const TDesC& aStepName, TTestPhase aTestPhase)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
SetTestStepID(aStepName);
|
sl@0
|
116 |
|
sl@0
|
117 |
// more preamble to toggle between timing the wserv render orienation property
|
sl@0
|
118 |
// and the theme server orientation property
|
sl@0
|
119 |
RProperty *orientationProperty = NULL;
|
sl@0
|
120 |
switch(aTestPhase)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
case EThemeOrientationChangeOnly:
|
sl@0
|
123 |
{
|
sl@0
|
124 |
// render orientation ignores theme orientation
|
sl@0
|
125 |
iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(EDisplayOrientationNormal);
|
sl@0
|
126 |
// we want to subscribe and wait for the theme orientation published by the theme server
|
sl@0
|
127 |
orientationProperty = &iThemeOrientationProperty;
|
sl@0
|
128 |
break;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
case EThemeOrientationChange:
|
sl@0
|
131 |
{
|
sl@0
|
132 |
TESTL(EDisplayOrientationNormal == GetThemeOrientationL());
|
sl@0
|
133 |
iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(EDisplayOrientationAuto);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
// deliberate drop-through
|
sl@0
|
136 |
default:
|
sl@0
|
137 |
// we want to subscribe and wait for the render orientation published by WServ
|
sl@0
|
138 |
orientationProperty = &iWsRenderOrientationProperty;
|
sl@0
|
139 |
break;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
TInt renderOrientation = GetRenderOrientationL();
|
sl@0
|
143 |
|
sl@0
|
144 |
// For consistancy, check that we are starting from the same orientation
|
sl@0
|
145 |
TESTL(EDisplayOrientationNormal == renderOrientation);
|
sl@0
|
146 |
|
sl@0
|
147 |
// Set-up the timer
|
sl@0
|
148 |
iProfiler->InitResults();
|
sl@0
|
149 |
iTimingsTaken = 0;
|
sl@0
|
150 |
|
sl@0
|
151 |
// repeat numerous times to get a decent average
|
sl@0
|
152 |
for(TInt iterations=0; iterations < KNumIterations; ++iterations)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
renderOrientation = GetRenderOrientationL();
|
sl@0
|
155 |
// For consistancy, check that we are starting from the same orientation
|
sl@0
|
156 |
TESTL(EDisplayOrientationNormal == renderOrientation);
|
sl@0
|
157 |
|
sl@0
|
158 |
// loop through the orientations, ending up changing back to normal
|
sl@0
|
159 |
for(++renderOrientation; renderOrientation <= EDisplayOrientationAuto; ++renderOrientation)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
// % can be slow, do it outside of the timing
|
sl@0
|
162 |
TRenderOrientation testOrientation = static_cast<TRenderOrientation>(renderOrientation%EDisplayOrientationAuto);
|
sl@0
|
163 |
|
sl@0
|
164 |
orientationProperty->Subscribe(iOrientationStatus);
|
sl@0
|
165 |
|
sl@0
|
166 |
// start the timeout timer
|
sl@0
|
167 |
iTimeoutTimer.After(iTimeoutStatus, KPublishTimeout);
|
sl@0
|
168 |
// start the results timer
|
sl@0
|
169 |
iProfiler->StartTimer();
|
sl@0
|
170 |
|
sl@0
|
171 |
switch(aTestPhase)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
case EIndicatedOrientationChange:
|
sl@0
|
174 |
// Do the indicated orientation Change
|
sl@0
|
175 |
iWindowSet[EFirstWindowSet].Session().IndicateAppOrientation(testOrientation);
|
sl@0
|
176 |
break;
|
sl@0
|
177 |
|
sl@0
|
178 |
case EWindowOrdinalChange:
|
sl@0
|
179 |
// move the relevant window group to the front
|
sl@0
|
180 |
// N.B. this will go wrong if the number of orientations and windows are not equal
|
sl@0
|
181 |
iWindowSet[testOrientation].WindowGroup().SetOrdinalPosition(0);
|
sl@0
|
182 |
break;
|
sl@0
|
183 |
|
sl@0
|
184 |
case EThemeOrientationChange:
|
sl@0
|
185 |
// Needs the focus window to be in auto mode
|
sl@0
|
186 |
// deliberate drop through
|
sl@0
|
187 |
case EThemeOrientationChangeOnly:
|
sl@0
|
188 |
iThemeOrientationProperty.Set(testOrientation);
|
sl@0
|
189 |
break;
|
sl@0
|
190 |
|
sl@0
|
191 |
default:
|
sl@0
|
192 |
TESTL(EFalse);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
// Wait for the update to have been published ( or time out while waiting )
|
sl@0
|
196 |
User::WaitForRequest(iOrientationStatus, iTimeoutStatus);
|
sl@0
|
197 |
|
sl@0
|
198 |
iProfiler->MarkResultSetL();
|
sl@0
|
199 |
++iTimingsTaken;
|
sl@0
|
200 |
|
sl@0
|
201 |
if(KErrNone != iOrientationStatus.Int())
|
sl@0
|
202 |
{
|
sl@0
|
203 |
// timed out
|
sl@0
|
204 |
iWsRenderOrientationProperty.Cancel();
|
sl@0
|
205 |
TESTL(EFalse);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else
|
sl@0
|
208 |
{
|
sl@0
|
209 |
// Check that it is actually the expected orientation
|
sl@0
|
210 |
if(EThemeOrientationChangeOnly == aTestPhase)
|
sl@0
|
211 |
TESTL(GetThemeOrientationL() == testOrientation);
|
sl@0
|
212 |
else
|
sl@0
|
213 |
TESTL(GetRenderOrientationL() == testOrientation);
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
if(KRequestPending == iTimeoutStatus.Int())
|
sl@0
|
217 |
{
|
sl@0
|
218 |
// as expected, so cancel the timeout timer
|
sl@0
|
219 |
iTimeoutTimer.Cancel();
|
sl@0
|
220 |
}
|
sl@0
|
221 |
else
|
sl@0
|
222 |
{
|
sl@0
|
223 |
// timed out
|
sl@0
|
224 |
TESTL(EFalse);
|
sl@0
|
225 |
}
|
sl@0
|
226 |
}
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
// wrap it up
|
sl@0
|
230 |
iProfiler->ResultsAnalysis(KTRenderOrientation,KErrNotFound,ENone,ENone,iTimingsTaken);
|
sl@0
|
231 |
}
|
sl@0
|
232 |
|
sl@0
|
233 |
TVerdict CTRenderOrientation::doTestStepL()
|
sl@0
|
234 |
{
|
sl@0
|
235 |
INFO_PRINTF1(_L("Testing: Indicated Orientation Change"));
|
sl@0
|
236 |
TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0201"), EIndicatedOrientationChange);
|
sl@0
|
237 |
|
sl@0
|
238 |
INFO_PRINTF1(_L("Testing: Window Ordinal Position Change"));
|
sl@0
|
239 |
TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0202"), EWindowOrdinalChange);
|
sl@0
|
240 |
|
sl@0
|
241 |
INFO_PRINTF1(_L("Testing: Theme Orientation Change"));
|
sl@0
|
242 |
TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0203"), EThemeOrientationChange);
|
sl@0
|
243 |
|
sl@0
|
244 |
INFO_PRINTF1(_L("Testing: Theme Orientation Change Only"));
|
sl@0
|
245 |
TestOrientationChangeL(_L("GRAPHICS-UI-BENCH-0204"), EThemeOrientationChangeOnly);
|
sl@0
|
246 |
|
sl@0
|
247 |
return TestStepResult();
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
_LIT(KThemeServerPropertyDefine, "twsthemeserverpropertydefine.exe");
|
sl@0
|
251 |
_LIT(KThemeServerPropertyDefineCmdDefine, "define");
|
sl@0
|
252 |
_LIT(KThemeServerPropertyDefineCmdDelete, "delete");
|
sl@0
|
253 |
|
sl@0
|
254 |
/**
|
sl@0
|
255 |
Uses a test executable to define or delete a test version of the theme server rotation RProperty
|
sl@0
|
256 |
*/
|
sl@0
|
257 |
void CTRenderOrientation::ThemeServerProperty(const TDesC& aCmd)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
/* This Process called with the argument KThemeServerPropertyDefineCmdDefine defines the
|
sl@0
|
260 |
theme server RProperty, or with KThemeServerPropertyDefineCmdDelete, deletes
|
sl@0
|
261 |
the theme server RProperty.
|
sl@0
|
262 |
This is because an RProperty with this catagory UID can only be defined and deleted
|
sl@0
|
263 |
from within a process with the same UID3 as the RProperty catogory you are trying to
|
sl@0
|
264 |
define/delete */
|
sl@0
|
265 |
RProcess themeServerPropertyDefine;
|
sl@0
|
266 |
TInt err = themeServerPropertyDefine.Create(KThemeServerPropertyDefine, aCmd);
|
sl@0
|
267 |
if (KErrNone != err)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
_LIT(KLog, "themeServerPropertyDefine.Create() failed with error: %d");
|
sl@0
|
270 |
INFO_PRINTF2(KLog, err);
|
sl@0
|
271 |
TEST(EFalse);
|
sl@0
|
272 |
}
|
sl@0
|
273 |
|
sl@0
|
274 |
// wait for themeServerPropertyDefine process to terminate
|
sl@0
|
275 |
TRequestStatus themeServerPropertyDefineLogonStatus;
|
sl@0
|
276 |
themeServerPropertyDefine.Logon(themeServerPropertyDefineLogonStatus);
|
sl@0
|
277 |
themeServerPropertyDefine.Resume();
|
sl@0
|
278 |
User::WaitForRequest(themeServerPropertyDefineLogonStatus);
|
sl@0
|
279 |
if (themeServerPropertyDefineLogonStatus != KErrNone)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
_LIT(KLog, "themeServerPropertyDefine.Logon() failed with error: %d");
|
sl@0
|
282 |
INFO_PRINTF2(KLog, themeServerPropertyDefineLogonStatus);
|
sl@0
|
283 |
TEST(EFalse);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
themeServerPropertyDefine.Close();
|
sl@0
|
286 |
}
|
sl@0
|
287 |
|
sl@0
|
288 |
/*
|
sl@0
|
289 |
Initialise for the testing
|
sl@0
|
290 |
*/
|
sl@0
|
291 |
TVerdict CTRenderOrientation::doTestStepPreambleL()
|
sl@0
|
292 |
{
|
sl@0
|
293 |
// Create in reverse order so that windowSet 0 is at the front/foreground
|
sl@0
|
294 |
for(TInt windowSet = ENumWindowSets - 1; windowSet >= 0 ; --windowSet)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
iWindowSet[windowSet].ConstructL();
|
sl@0
|
297 |
TRenderOrientation orientation = static_cast<TRenderOrientation>(windowSet%EDisplayOrientationAuto);
|
sl@0
|
298 |
iWindowSet[windowSet].Session().IndicateAppOrientation(orientation);
|
sl@0
|
299 |
iWindowSet[windowSet].WindowGroup().SetOrdinalPosition(0);
|
sl@0
|
300 |
}
|
sl@0
|
301 |
|
sl@0
|
302 |
User::LeaveIfError(iWsRenderOrientationProperty.Attach(KRenderOrientationCategory, KRenderOrientationKey));
|
sl@0
|
303 |
|
sl@0
|
304 |
ThemeServerProperty(KThemeServerPropertyDefineCmdDefine);
|
sl@0
|
305 |
User::LeaveIfError(iThemeOrientationProperty.Attach(KThemeOrientationCategory, KThemeOrientationKey));
|
sl@0
|
306 |
|
sl@0
|
307 |
User::LeaveIfError(iTimeoutTimer.CreateLocal());
|
sl@0
|
308 |
|
sl@0
|
309 |
return CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
/*
|
sl@0
|
313 |
Tidy up after the testing
|
sl@0
|
314 |
*/
|
sl@0
|
315 |
TVerdict CTRenderOrientation::doTestStepPostambleL()
|
sl@0
|
316 |
{
|
sl@0
|
317 |
iTimeoutTimer.Close();
|
sl@0
|
318 |
|
sl@0
|
319 |
iThemeOrientationProperty.Close();
|
sl@0
|
320 |
ThemeServerProperty(KThemeServerPropertyDefineCmdDelete);
|
sl@0
|
321 |
iWsRenderOrientationProperty.Close();
|
sl@0
|
322 |
|
sl@0
|
323 |
for(TInt windowThing = 0; windowThing < ENumWindowSets; ++windowThing)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
iWindowSet[windowThing].Destroy();
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
return CTe_graphicsperformanceSuiteStepBase::doTestStepPostambleL();
|
sl@0
|
329 |
}
|