|
1 // Copyright (c) 2008-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 #include <coemain.h> |
|
18 #include <coecntrl.h> |
|
19 #include <coeaui.h> |
|
20 |
|
21 #include "tmultiptrtestcontrol.h" |
|
22 #include "tconemultiptrtestappui.h" |
|
23 #include "tconemultiptrconst.h" |
|
24 #include "tconemultiptrcompoundstep.h" |
|
25 |
|
26 |
|
27 /** |
|
28 CCoeControl derived class. Acts as both event handler for events comming from wserv and an |
|
29 event buffer for storing of events. |
|
30 |
|
31 @param aWindowOwning defaulted to EFalse |
|
32 */ |
|
33 void CMultiPtrTestControlBase::ConstructL() |
|
34 { |
|
35 iEventBuffer.SetLengthL(EEventBufferSize); |
|
36 } |
|
37 |
|
38 |
|
39 CMultiPtrTestControlBase::~CMultiPtrTestControlBase() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 TInt CMultiPtrTestControlBase::EventsLeft() |
|
45 { |
|
46 return iEventBuffer.Count(); |
|
47 } |
|
48 |
|
49 |
|
50 void CMultiPtrTestControlBase::AddExpectedEvent( TAdvancedPointerEvent& aEvent) |
|
51 { |
|
52 iEventBuffer.Add( &aEvent ); |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 Handles events from wserv and does the testing by comparing those with the events from |
|
58 event buffer. If any test fails, it calls the Failed function of CConeMultiPtrTestAppUi |
|
59 which stops the activescheduler. Once all the evnts in buffer are tested it calls |
|
60 NextSetOfEvents function to continue with other sub test case. |
|
61 */ |
|
62 void CMultiPtrTestControlBase::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
63 { |
|
64 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
65 |
|
66 if( iPassive ) |
|
67 { |
|
68 return; |
|
69 } |
|
70 |
|
71 const TAdvancedPointerEvent* advancedPointerEvent = aPointerEvent.AdvancedPointerEvent(); |
|
72 |
|
73 TAdvancedPointerEvent expectedPtrEvent; |
|
74 |
|
75 if( 0 == iEventBuffer.Remove(&expectedPtrEvent) ) |
|
76 { |
|
77 NotifyControlL( EMultiPtrTestFailed ); |
|
78 return; |
|
79 } |
|
80 |
|
81 TRAPD( err, CheckEventL(expectedPtrEvent, *advancedPointerEvent) ); |
|
82 |
|
83 if( ETestFailed == err ) |
|
84 { |
|
85 NotifyControlL( EMultiPtrTestFailed ); |
|
86 } |
|
87 else if( iEventBuffer.Count() == 0 ) |
|
88 { |
|
89 NotifyControlL( EmultiPtrNext ); |
|
90 } |
|
91 |
|
92 } |
|
93 |
|
94 |
|
95 /** |
|
96 Compare the parameters of the received event with those of the anticipated event. |
|
97 */ |
|
98 void CMultiPtrTestControlBase::CheckEventL(const TAdvancedPointerEvent& aExpectedEvent, const TAdvancedPointerEvent& aActualEvent) |
|
99 { |
|
100 RDebug::Print( _L("ExPtr %d AcPtr %d"), aExpectedEvent.PointerNumber(), aActualEvent.PointerNumber() ); |
|
101 RDebug::Print( _L("ExType %d AcType %d"),aExpectedEvent.iType, aActualEvent.iType ); |
|
102 RDebug::Print( _L("ExProx %d AcProx %d"), aExpectedEvent.ProximityAndPressure(), aActualEvent.ProximityAndPressure() ); |
|
103 RDebug::Print( _L("ExPos X %d Y %d"), aExpectedEvent.iPosition.iX, aExpectedEvent.iPosition.iY ); |
|
104 RDebug::Print( _L("AcPos X %d Y %d"), aActualEvent.iPosition.iX, aActualEvent.iPosition.iY ); |
|
105 RDebug::Print( _L("ExMod 0x%X AcMod 0x%X"), aExpectedEvent.iModifiers, aActualEvent.iModifiers ); |
|
106 |
|
107 TInt err = ETestPassed; |
|
108 |
|
109 if( aExpectedEvent.PointerNumber() != aActualEvent.PointerNumber() ) |
|
110 { |
|
111 RDebug::Print( _L("*** Pointer numbers differ") ); |
|
112 err = ETestFailed; |
|
113 } |
|
114 |
|
115 if ( aExpectedEvent.iPosition != aActualEvent.iPosition ) |
|
116 { |
|
117 RDebug::Print( _L("*** Position data differs") ); |
|
118 err = ETestFailed; |
|
119 } |
|
120 |
|
121 if ( aExpectedEvent.iParentPosition == aActualEvent.iParentPosition ) |
|
122 { |
|
123 RDebug::Print( _L("*** ParentPosition data differs") ); |
|
124 err = ETestFailed; |
|
125 } |
|
126 |
|
127 if( aExpectedEvent.iType != aActualEvent.iType ) |
|
128 { |
|
129 RDebug::Print( _L("*** Type data differs") ); |
|
130 err = ETestFailed; |
|
131 } |
|
132 |
|
133 // Disregard other modifiers, as build machines often have numlock, scroll-lock etc on. |
|
134 if( !(aActualEvent.iModifiers & EModifierAdvancedPointerEvent) ) |
|
135 { |
|
136 RDebug::Print( _L("*** Key modifier flags differ") ); |
|
137 err = ETestFailed; |
|
138 } |
|
139 |
|
140 if( aExpectedEvent.ProximityAndPressure() != aActualEvent.ProximityAndPressure() ) |
|
141 { |
|
142 RDebug::Print( _L("*** Proximity/pressure data differs") ); |
|
143 err = ETestFailed; |
|
144 } |
|
145 |
|
146 |
|
147 if( ETestPassed != err ) |
|
148 { |
|
149 RDebug::Print( _L("") ); |
|
150 User::Leave( err ); |
|
151 } |
|
152 |
|
153 RDebug::Print( _L("") ); |
|
154 } |
|
155 |
|
156 |
|
157 TBool CMultiPtrTestControlBase::Captures() |
|
158 { |
|
159 return CapturesPointer(); |
|
160 } |
|
161 |
|
162 |
|
163 void CMultiPtrTestControlBase::SetDrags() |
|
164 { |
|
165 Window().PointerFilter( (EPointerFilterMove | EPointerFilterDrag), 0 ); |
|
166 } |
|
167 |
|
168 |
|
169 void CMultiPtrTestControlBase::SetGrabs() |
|
170 { |
|
171 Window().SetPointerGrab( ETrue ); |
|
172 } |
|
173 |
|
174 |
|
175 void CMultiPtrTestControlBase::SetPassive( TBool aPassive ) |
|
176 { |
|
177 iPassive = aPassive; |
|
178 } |
|
179 |
|
180 |
|
181 // |
|
182 /** |
|
183 A derived simple control |
|
184 for use with CConeMultiPtrTestAppUi |
|
185 */ |
|
186 |
|
187 /** |
|
188 PV in CMultiPtrTestControlBase |
|
189 */ |
|
190 void CMultiPtrTestControl::NotifyControlL( TInt aNotify ) |
|
191 { |
|
192 switch( aNotify ) |
|
193 { |
|
194 case EMultiPtrTestFailed: |
|
195 iAppUi->Failed(); |
|
196 break; |
|
197 |
|
198 case EmultiPtrNext: |
|
199 iAppUi->NextSetOfEventsL(); |
|
200 break; |
|
201 |
|
202 default: |
|
203 User::Leave( KErrArgument ); |
|
204 break; |
|
205 } |
|
206 } |
|
207 |
|
208 |
|
209 void CMultiPtrTestControl::Draw( const TRect& ) const |
|
210 { |
|
211 CWindowGc& gc=SystemGc(); |
|
212 |
|
213 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
214 gc.SetBrushColor(KRgbBlue); |
|
215 gc.DrawRect(Rect()); |
|
216 } |
|
217 |
|
218 |
|
219 |
|
220 CMultiPtrTestControl* CMultiPtrTestControl::NewL( TPoint aOrigin, TSize aSize ) |
|
221 { |
|
222 CMultiPtrTestControl* self = new(ELeave) CMultiPtrTestControl; |
|
223 CleanupStack::PushL( self ); |
|
224 self->ConstructL( aOrigin, aSize ); |
|
225 CleanupStack::Pop(); |
|
226 |
|
227 return self; |
|
228 } |
|
229 |
|
230 |
|
231 CMultiPtrTestControl::CMultiPtrTestControl() |
|
232 { |
|
233 |
|
234 } |
|
235 |
|
236 |
|
237 void CMultiPtrTestControl::ConstructL( TPoint aOrigin, TSize aSize ) |
|
238 { |
|
239 CMultiPtrTestControlBase::ConstructL(); |
|
240 iAppUi = static_cast<CConeMultiPtrTestAppUi*>(ControlEnv()->AppUi()); |
|
241 |
|
242 CreateWindowL(); |
|
243 Window().EnableAdvancedPointers(); |
|
244 SetExtent( aOrigin, aSize ); |
|
245 ActivateL(); |
|
246 } |
|
247 |
|
248 |
|
249 CMultiPtrTestControl::~CMultiPtrTestControl() |
|
250 { |
|
251 } |
|
252 |
|
253 |
|
254 // |
|
255 /** |
|
256 A derived simple control |
|
257 for use with CConeMultiPtrCompoundTestAppUi |
|
258 */ |
|
259 |
|
260 /** |
|
261 PV in CMultiPtrTestControlBase |
|
262 */ |
|
263 void CMultiPtrTestCompoundAppUiControl::NotifyControlL( TInt aNotify ) |
|
264 { |
|
265 switch( aNotify ) |
|
266 { |
|
267 case EMultiPtrTestFailed: |
|
268 iAppUi->Failed(); |
|
269 break; |
|
270 |
|
271 case EmultiPtrNext: |
|
272 iAppUi->NextSetOfEventsL(); |
|
273 break; |
|
274 |
|
275 default: |
|
276 User::Leave( KErrArgument ); |
|
277 break; |
|
278 } |
|
279 } |
|
280 |
|
281 |
|
282 void CMultiPtrTestCompoundAppUiControl::Draw( const TRect& ) const |
|
283 { |
|
284 CWindowGc& gc=SystemGc(); |
|
285 |
|
286 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
287 gc.SetBrushColor(KRgbRed); |
|
288 gc.DrawRect(Rect()); |
|
289 } |
|
290 |
|
291 |
|
292 |
|
293 CMultiPtrTestCompoundAppUiControl* CMultiPtrTestCompoundAppUiControl::NewL( TPoint aOrigin, TSize aSize ) |
|
294 { |
|
295 CMultiPtrTestCompoundAppUiControl* self = new(ELeave) CMultiPtrTestCompoundAppUiControl; |
|
296 CleanupStack::PushL( self ); |
|
297 self->ConstructL( aOrigin, aSize ); |
|
298 CleanupStack::Pop(); |
|
299 |
|
300 return self; |
|
301 } |
|
302 |
|
303 |
|
304 CMultiPtrTestCompoundAppUiControl::CMultiPtrTestCompoundAppUiControl() |
|
305 { |
|
306 |
|
307 } |
|
308 |
|
309 |
|
310 void CMultiPtrTestCompoundAppUiControl::ConstructL( TPoint aOrigin, TSize aSize ) |
|
311 { |
|
312 CMultiPtrTestControlBase::ConstructL(); |
|
313 iAppUi = static_cast<CConeMultiPtrCompoundTestAppUi*>(ControlEnv()->AppUi()); |
|
314 |
|
315 CreateWindowL(); |
|
316 Window().EnableAdvancedPointers(); |
|
317 SetExtent( aOrigin, aSize ); |
|
318 ActivateL(); |
|
319 } |
|
320 |
|
321 |
|
322 CMultiPtrTestCompoundAppUiControl::~CMultiPtrTestCompoundAppUiControl() |
|
323 { |
|
324 } |
|
325 |