|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tscrollingperf.h" |
|
23 |
|
24 const TInt KIterationsToTest = 16384; |
|
25 |
|
26 CScrollingPerf::~CScrollingPerf() |
|
27 { |
|
28 delete iWGc; |
|
29 delete iWsScreenDevice; |
|
30 delete iBitmap32bit; |
|
31 iWs.Close(); |
|
32 } |
|
33 |
|
34 CScrollingPerf::CScrollingPerf() |
|
35 { |
|
36 SetTestStepName(KScrollingPerfName); |
|
37 } |
|
38 |
|
39 /** |
|
40 Override of base class virtual |
|
41 |
|
42 @return - TVerdict code |
|
43 */ |
|
44 TVerdict CScrollingPerf::doTestStepPreambleL() |
|
45 { |
|
46 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); |
|
47 User::LeaveIfError(iWs.Connect()); |
|
48 iWsScreenDevice = new(ELeave) CWsScreenDevice(iWs); |
|
49 User::LeaveIfError(iWsScreenDevice->Construct(0)); |
|
50 User::LeaveIfError(iWsScreenDevice->CreateContext(iWGc)); |
|
51 return TestStepResult(); |
|
52 } |
|
53 |
|
54 /** |
|
55 Override of base class pure virtual |
|
56 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
57 not leave. That being the case, the current test result value will be EPass. |
|
58 |
|
59 @return - TVerdict code |
|
60 */ |
|
61 TVerdict CScrollingPerf::doTestStepL() |
|
62 { |
|
63 SetTestStepID(_L("GRAPHICS-UI-BENCH-0019")); |
|
64 MoveClippedChildWindowL(); |
|
65 RecordTestResultL(); |
|
66 SetTestStepID(_L("GRAPHICS-UI-BENCH-0018")); |
|
67 ScrollRWindowL(); |
|
68 RecordTestResultL(); |
|
69 |
|
70 SetTestStepResult(EPass); |
|
71 return TestStepResult(); |
|
72 } |
|
73 |
|
74 /** |
|
75 @SYMTestCaseID |
|
76 GRAPHICS-UI-BENCH-0018 |
|
77 |
|
78 @SYMTestCaseDesc |
|
79 Tests how long it takes to scroll using the RWindow::Scroll API. |
|
80 |
|
81 @SYMTestActions |
|
82 Compare the results over time, and before and after changes to WSERV code. |
|
83 |
|
84 @SYMTestExpectedResults |
|
85 Test should pass and display total test time and time per Scroll() action |
|
86 */ |
|
87 void CScrollingPerf::ScrollRWindowL() |
|
88 { |
|
89 const TRect cropTo(0,0,200,200); |
|
90 |
|
91 RWindowGroup topWind(iWs); |
|
92 CleanupClosePushL(topWind); |
|
93 User::LeaveIfError(topWind.Construct(1)); // cli hnd 1 |
|
94 User::LeaveIfError(topWind.SetName(_L("ScrollRWindowL"))); |
|
95 |
|
96 RWindow wind(iWs); |
|
97 CleanupClosePushL(wind); |
|
98 User::LeaveIfError(wind.Construct(topWind, 2)); // cli hnd 2 |
|
99 wind.SetExtent(cropTo.iTl, cropTo.Size()); |
|
100 wind.Activate(); |
|
101 |
|
102 const TInt scrollByX = 0; |
|
103 const TInt scrollByY = 2; |
|
104 const TRect invalidated(0, 0, 200, 2); |
|
105 |
|
106 iWGc->Activate(wind); |
|
107 iWGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
108 |
|
109 iProfiler->InitResults(); |
|
110 for(TInt count=0; count<KIterationsToTest; ++count) |
|
111 { |
|
112 wind.Scroll(TPoint(scrollByX, scrollByY)); |
|
113 wind.BeginRedraw(); |
|
114 |
|
115 // do some bitshiftin' for fancy smooth colour bands |
|
116 // - otherwise there's little to see |
|
117 TInt step = (count >> 2); |
|
118 TInt r = (step & 0xf); |
|
119 TInt g = (step & 0xf0) >> 4; |
|
120 TInt b = (step & 0xf00) >> 8; |
|
121 if (step & 0x10) r = 15-r; |
|
122 if (step & 0x100) g = 15-g; |
|
123 r <<= 4; |
|
124 g <<= 4; |
|
125 b <<= 4; |
|
126 |
|
127 iWGc->SetPenColor(TRgb(r, g, b)); |
|
128 iWGc->DrawRect(invalidated); |
|
129 wind.EndRedraw(); |
|
130 iProfiler->MarkResultSetL(); |
|
131 } |
|
132 |
|
133 iProfiler->ResultsAnalysis(_L("RWindowScrolling"), 0, 0, 0, KIterationsToTest); |
|
134 iWGc->Deactivate(); |
|
135 CleanupStack::PopAndDestroy(2, &topWind); |
|
136 } |
|
137 |
|
138 /** |
|
139 @SYMTestCaseID |
|
140 GRAPHICS-UI-BENCH-0019 |
|
141 |
|
142 @SYMTestCaseDesc |
|
143 Tests how long it takes to move a child window against its parent window. |
|
144 |
|
145 @SYMTestActions |
|
146 Compare the results over time, and before and after changes to WSERV code. |
|
147 |
|
148 @SYMTestExpectedResults |
|
149 Test should pass and display total test time and time per SetPosition() action |
|
150 */ |
|
151 void CScrollingPerf::MoveClippedChildWindowL() |
|
152 { |
|
153 INFO_PRINTF1(_L("CScrollingPerf::MoveClippedChildWindowL")); |
|
154 |
|
155 const TRect parentExtent(32,32,160,160); |
|
156 TRect parentFill(0, 0, parentExtent.Width(), parentExtent.Height()); |
|
157 parentFill.Shrink(16, 16); |
|
158 const TRect childExtent(0,0,256,256); |
|
159 TRect childFill(0, 0, childExtent.Width(), childExtent.Height()); |
|
160 childFill.Shrink(16, 16); |
|
161 |
|
162 RWindowGroup topWind(iWs); |
|
163 CleanupClosePushL(topWind); |
|
164 topWind.Construct(1); // cli hnd 1 |
|
165 User::LeaveIfError(topWind.SetName(_L("MoveClippedChildWindowL"))); |
|
166 |
|
167 RWindow parentWind(iWs); |
|
168 CleanupClosePushL(parentWind); |
|
169 User::LeaveIfError(parentWind.Construct(topWind, 2)); // cli hnd 2 |
|
170 parentWind.SetExtent(parentExtent.iTl, parentExtent.Size()); |
|
171 parentWind.SetBackgroundColor(TRgb(0, 0, 0)); |
|
172 parentWind.Activate(); |
|
173 |
|
174 RWindow childWind(iWs); |
|
175 CleanupClosePushL(childWind); |
|
176 User::LeaveIfError(childWind.Construct(parentWind, 3)); // cli hnd 3 |
|
177 childWind.SetExtent(childExtent.iTl, childExtent.Size()); |
|
178 childWind.SetBackgroundColor(TRgb(128, 128, 128)); |
|
179 childWind.Activate(); |
|
180 |
|
181 parentWind.BeginRedraw(); |
|
182 iWGc->Activate(parentWind); |
|
183 iWGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
184 iWGc->SetBrushColor(TRgb(255, 0, 0)); |
|
185 iWGc->DrawRect(parentFill); |
|
186 iWGc->Deactivate(); |
|
187 parentWind.EndRedraw(); |
|
188 |
|
189 childWind.BeginRedraw(); |
|
190 iWGc->Activate(childWind); |
|
191 iWGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
192 iWGc->SetBrushColor(TRgb(0, 255, 0)); |
|
193 iWGc->DrawRect(childFill); |
|
194 iWGc->Deactivate(); |
|
195 childWind.EndRedraw(); |
|
196 |
|
197 TInt step=0; TInt x=0; TInt y=0; |
|
198 TInt inc, dir = 0; |
|
199 |
|
200 iProfiler->InitResults(); |
|
201 for(TInt count=0; count<KIterationsToTest; ++count) |
|
202 { |
|
203 step = (count >> 2); |
|
204 inc = (step & 0xff); |
|
205 dir = (step & 0x300) >> 8; |
|
206 switch (dir) |
|
207 { |
|
208 case 0: |
|
209 x = inc; |
|
210 y = 0; |
|
211 break; |
|
212 case 1: |
|
213 x = 255; |
|
214 y = inc; |
|
215 break; |
|
216 case 2: |
|
217 x = 255-inc; |
|
218 y = 255; |
|
219 break; |
|
220 case 3: |
|
221 x = 0; |
|
222 y = 255-inc; |
|
223 break; |
|
224 } |
|
225 TPoint chPos(x-192, y-192); |
|
226 childWind.SetPosition(chPos); |
|
227 iProfiler->MarkResultSetL(); |
|
228 } |
|
229 |
|
230 iProfiler->ResultsAnalysis(_L("ScrollMovingChild"), 0, 0, 0, KIterationsToTest); |
|
231 CleanupStack::PopAndDestroy(3, &topWind); |
|
232 } |