|
1 // Copyright (c) 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 |
|
23 #include "tpan.h" |
|
24 #include "te_gesturegenerator.h" |
|
25 #include "twindow.h" |
|
26 |
|
27 |
|
28 _LIT(KSemaphore, "SemTPanSync"); // Name of the global semaphore |
|
29 |
|
30 const TInt KGestureGenerationLimit = 50; |
|
31 |
|
32 // Test bitmap file location |
|
33 _LIT(KBigBitmap,"z:\\resource\\apps\\uibench_s60_big.mbm"); |
|
34 _LIT(KTestStep0001,"GRAPHICS-UI-BENCH-S60-0001"); |
|
35 |
|
36 CTPan::CTPan() |
|
37 { |
|
38 SetTestStepName(KTPan); |
|
39 } |
|
40 |
|
41 TVerdict CTPan::doTestStepPreambleL() |
|
42 { |
|
43 // The semaphore has to be created before, otherwise the control can't open it. |
|
44 TESTNOERRORL(iSemaphore.CreateGlobal(KSemaphore, 0)); |
|
45 return CTe_ConeStepBase::doTestStepPreambleL(); |
|
46 } |
|
47 |
|
48 TVerdict CTPan::doTestStepPostambleL() |
|
49 { |
|
50 iSemaphore.Close(); |
|
51 return CTe_ConeStepBase::doTestStepPostambleL(); |
|
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. |
|
58 |
|
59 @return - TVerdict code |
|
60 */ |
|
61 TVerdict CTPan::doTestStepL() |
|
62 { |
|
63 SetTestStepID(KTestStep0001); |
|
64 PanBitmapL(); |
|
65 //RecordTestResultL(); // not possible because of heap panic |
|
66 return TestStepResult(); |
|
67 } |
|
68 |
|
69 /** |
|
70 @SYMTestCaseID |
|
71 GRAPHICS-UI-BENCH-S60-0001 |
|
72 |
|
73 @SYMTestCaseDesc |
|
74 Tests how long it takes to pan a bitmap in reaction to pointer events. |
|
75 |
|
76 @SYMTestActions |
|
77 Create the bitmap and generate the pointer events. Depending on the location of the |
|
78 pointer the bitmap is drawn to the screen. |
|
79 |
|
80 @SYMTestExpectedResults |
|
81 Test should pass and display the average framerate for the whole test. |
|
82 */ |
|
83 void CTPan::PanBitmapL() |
|
84 { |
|
85 iProfiler->InitResults(); |
|
86 |
|
87 // Simulate some horizontal drag pointer events |
|
88 GestureGenerator::SimulateFlickGestureL(iSemaphore, TPoint(0, 0), |
|
89 TPoint(KGestureGenerationLimit, 0)); |
|
90 // Simulate some vertical drag pointer events |
|
91 GestureGenerator::SimulateFlickGestureL(iSemaphore, TPoint(KGestureGenerationLimit, 0), |
|
92 TPoint(KGestureGenerationLimit, KGestureGenerationLimit)); |
|
93 |
|
94 iProfiler->MarkResultSetL(); |
|
95 TSize screenSize = CTWindow::GetDisplaySizeInPixels(); |
|
96 iProfiler->ResultsAnalysisFrameRate(KTestStep0001, 0, 0, 0, |
|
97 iAppUi->PanControl()->Iterations(), screenSize.iWidth * screenSize.iHeight); |
|
98 } |
|
99 |
|
100 void CTPan::InitUIL(CCoeEnv* aCoeEnv) |
|
101 { |
|
102 iAppUi = new(ELeave) CPanAppUi(); |
|
103 // iAppUi needs to be put on the cleanupstack until CCoeEnv takes ownership of iAppUi |
|
104 CleanupStack::PushL(iAppUi); |
|
105 iAppUi->ConstructL(TRect(CTWindow::GetDisplaySizeInPixels())); |
|
106 CleanupStack::Pop(iAppUi); |
|
107 aCoeEnv->SetAppUi(iAppUi); |
|
108 } |
|
109 |
|
110 //============================================================================= |
|
111 |
|
112 CPanAppUi::CPanAppUi() |
|
113 { |
|
114 // empty |
|
115 } |
|
116 |
|
117 CPanAppUi::~CPanAppUi() |
|
118 { |
|
119 RemoveFromStack(iPanControl); |
|
120 delete iPanControl; |
|
121 } |
|
122 |
|
123 void CPanAppUi::ConstructL(const TRect& aRect) |
|
124 { |
|
125 BaseConstructL(ENoAppResourceFile); |
|
126 iPanControl = CPanControl::NewL(aRect); |
|
127 AddToStackL(iPanControl); |
|
128 } |
|
129 |
|
130 CPanControl* CPanAppUi::PanControl() |
|
131 { |
|
132 return iPanControl; |
|
133 } |
|
134 |
|
135 //============================================================================= |
|
136 |
|
137 CPanControl* CPanControl::NewL(const TRect& aRect, const CCoeControl* aParent) |
|
138 { |
|
139 CPanControl* self = CPanControl::NewLC(aRect, aParent); |
|
140 CleanupStack::Pop(self); |
|
141 return self; |
|
142 } |
|
143 |
|
144 CPanControl* CPanControl::NewLC(const TRect& aRect, const CCoeControl* aParent) |
|
145 { |
|
146 CPanControl* self = new(ELeave) CPanControl(); |
|
147 CleanupStack::PushL(self); |
|
148 self->ConstructL(aRect, aParent); |
|
149 return self; |
|
150 } |
|
151 |
|
152 CPanControl::CPanControl() : iWsSession(CCoeEnv::Static()->WsSession()) |
|
153 { |
|
154 // empty |
|
155 } |
|
156 |
|
157 CPanControl::~CPanControl() |
|
158 { |
|
159 delete iSourceBitmap; |
|
160 iSemaphore.Close(); |
|
161 } |
|
162 |
|
163 void CPanControl::ConstructL(const TRect& aRect, const CCoeControl* aParent) |
|
164 { |
|
165 User::LeaveIfError(iSemaphore.OpenGlobal(KSemaphore)); |
|
166 iSourceBitmap = new(ELeave) CFbsBitmap; |
|
167 User::LeaveIfError(iSourceBitmap->Load(KBigBitmap, 0)); |
|
168 |
|
169 // No owner, so create an own window |
|
170 if(!aParent) |
|
171 { |
|
172 CreateWindowL(); |
|
173 DrawableWindow()->PointerFilter(EPointerFilterDrag, 0); |
|
174 SetRect(aRect); |
|
175 ActivateL(); |
|
176 } |
|
177 else |
|
178 { |
|
179 // use parent window as compound control |
|
180 SetContainerWindowL(*aParent); |
|
181 SetRect(aRect); |
|
182 } |
|
183 } |
|
184 |
|
185 void CPanControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
186 { |
|
187 if((aPointerEvent.iType == TPointerEvent::EDrag) || (aPointerEvent.iType == TPointerEvent::EButton1Down)) |
|
188 { |
|
189 iCurrentPointerPos = aPointerEvent.iPosition; |
|
190 } |
|
191 DrawNow(); // Draws the entire control |
|
192 iWsSession.Finish(); // Wait until WServ has finished drawing |
|
193 iIterations++; // Update frame counter |
|
194 iSemaphore.Signal(); // Signal test that control was drawn |
|
195 } |
|
196 |
|
197 void CPanControl::Draw(const TRect& aRect) const |
|
198 { |
|
199 CWindowGc& gc = SystemGc(); |
|
200 TRect sourceRect = Rect(); |
|
201 sourceRect.Move(iCurrentPointerPos); |
|
202 gc.DrawBitmap(aRect, iSourceBitmap, sourceRect); |
|
203 } |
|
204 |
|
205 TInt CPanControl::Iterations() |
|
206 { |
|
207 return iIterations; |
|
208 } |
|
209 |
|
210 CFbsBitmap* CPanControl::Bitmap() |
|
211 { |
|
212 return iSourceBitmap; |
|
213 } |