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