|
1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Test aknphysics.h |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] |
|
19 #include "testplatphysics.h" |
|
20 |
|
21 // observer for test |
|
22 class CTestPhysicsObserver : public CBase, public MAknPhysicsObserver |
|
23 { |
|
24 public: |
|
25 /*Constructor*/ |
|
26 CTestPhysicsObserver(){} |
|
27 /*Deconstructor*/ |
|
28 ~CTestPhysicsObserver(){} |
|
29 /** |
|
30 * Physics emulation has moved the view |
|
31 * |
|
32 * @since S60 v5.0 |
|
33 * @param aNewPosition The new position of the view. |
|
34 * @param aDrawNow @c ETrue if client should redraw the screen, |
|
35 * otherwise @c EFalse. |
|
36 * @param aFlags Additional flags, not used currently. |
|
37 */ |
|
38 void ViewPositionChanged( const TPoint& /*aNewPosition*/, |
|
39 TBool /*aDrawNow*/, |
|
40 TUint /*aFlags*/ ){} |
|
41 |
|
42 /** |
|
43 * Physics emulation has stopped moving the view |
|
44 * |
|
45 * @since S60 v5.0 |
|
46 */ |
|
47 void PhysicEmulationEnded(){} |
|
48 |
|
49 /** |
|
50 * Returns the observer view position. |
|
51 * |
|
52 * @since S60 v5.0 |
|
53 * @return Physics observer view position. |
|
54 */ |
|
55 TPoint ViewPosition() const |
|
56 { |
|
57 TPoint point( 0, 0 ); |
|
58 return point; |
|
59 } |
|
60 |
|
61 }; |
|
62 |
|
63 // ============================ MEMBER FUNCTIONS ========================= |
|
64 |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CTestPlatPhysics::TestCAknPhysicsNewL |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 TInt CTestPlatPhysics::TestCAknPhysicsNewL( CStifItemParser& /*aItem*/ ) |
|
71 { |
|
72 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
73 _LIT(Ktestcaknphysicsnewl, "In TestCAknPhysicsNewL"); |
|
74 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsnewl); |
|
75 iLog->Log(Ktestcaknphysicsnewl); |
|
76 |
|
77 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
78 CleanupStack::PushL( ob ); |
|
79 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
80 CleanupStack::PushL( temp ); |
|
81 STIF_ASSERT_NOT_NULL( temp ); |
|
82 CleanupStack::PopAndDestroy( temp ); |
|
83 CleanupStack::PopAndDestroy( ob ); |
|
84 |
|
85 return KErrNone; |
|
86 } |
|
87 |
|
88 // -------------------------------------------------------------------------- |
|
89 // CTestPlatPhysics::TestCAknPhysicsInitPhysicsL |
|
90 // -------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CTestPlatPhysics::TestCAknPhysicsInitPhysicsL( CStifItemParser& /*aItem*/ ) |
|
93 { |
|
94 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
95 _LIT(Ktestcaknphysicsinitphysicsl, "In TestCAknPhysicsInitPhysicsL"); |
|
96 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsinitphysicsl); |
|
97 iLog->Log(Ktestcaknphysicsinitphysicsl); |
|
98 |
|
99 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
100 CleanupStack::PushL( ob ); |
|
101 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
102 CleanupStack::PushL( temp ); |
|
103 TSize workSize; |
|
104 TSize viewSize; |
|
105 TBool landscape = EFalse; |
|
106 temp->InitPhysicsL( workSize, viewSize, landscape ); |
|
107 CleanupStack::PopAndDestroy( temp ); |
|
108 CleanupStack::PopAndDestroy( ob ); |
|
109 |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 // -------------------------------------------------------------------------- |
|
114 // CTestPlatPhysics::TestCAknPhysicsStartPhysicsL |
|
115 // -------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CTestPlatPhysics::TestCAknPhysicsStartPhysicsL( CStifItemParser& /*aItem*/ ) |
|
118 { |
|
119 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
120 _LIT(Ktestcaknphysicsstartphysicsl, "In TestCAknPhysicsStartPhysicsL"); |
|
121 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsstartphysicsl); |
|
122 iLog->Log(Ktestcaknphysicsstartphysicsl); |
|
123 |
|
124 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
125 CleanupStack::PushL( ob ); |
|
126 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
127 CleanupStack::PushL( temp ); |
|
128 TPoint drag; |
|
129 TTime startTime; |
|
130 temp->StartPhysics( drag, startTime ); |
|
131 CleanupStack::PopAndDestroy( temp ); |
|
132 CleanupStack::PopAndDestroy( ob ); |
|
133 |
|
134 |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 // -------------------------------------------------------------------------- |
|
139 // CTestPlatPhysics::TestCAknPhysicsStopPhysicsL |
|
140 // -------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CTestPlatPhysics::TestCAknPhysicsStopPhysicsL( CStifItemParser& /*aItem*/ ) |
|
143 { |
|
144 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
145 _LIT(Ktestcaknphysicsstopphysicsl, "In TestCAknPhysicsStopPhysicsL"); |
|
146 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsstopphysicsl); |
|
147 iLog->Log(Ktestcaknphysicsstopphysicsl); |
|
148 |
|
149 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
150 CleanupStack::PushL( ob ); |
|
151 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
152 CleanupStack::PushL( temp ); |
|
153 temp->StopPhysics(); |
|
154 CleanupStack::PopAndDestroy( temp ); |
|
155 CleanupStack::PopAndDestroy( ob ); |
|
156 |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // -------------------------------------------------------------------------- |
|
161 // CTestPlatPhysics::TestCAknPhysicsOngoingPhysicsActionL |
|
162 // -------------------------------------------------------------------------- |
|
163 // |
|
164 TInt CTestPlatPhysics::TestCAknPhysicsOngoingPhysicsActionL( CStifItemParser& /*aItem*/ ) |
|
165 { |
|
166 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
167 _LIT(Ktestcaknphysicsongoingphysicsactionl, "In TestCAknPhysicsOngoingPhysicsActionL"); |
|
168 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsongoingphysicsactionl); |
|
169 iLog->Log(Ktestcaknphysicsongoingphysicsactionl); |
|
170 |
|
171 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
172 CleanupStack::PushL( ob ); |
|
173 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
174 CleanupStack::PushL( temp ); |
|
175 temp->OngoingPhysicsAction(); |
|
176 CleanupStack::PopAndDestroy( temp ); |
|
177 CleanupStack::PopAndDestroy( ob ); |
|
178 |
|
179 return KErrNone; |
|
180 } |
|
181 |
|
182 // -------------------------------------------------------------------------- |
|
183 // CTestPlatPhysics::TestCAknPhysicsRegisterPanningPositionL |
|
184 // -------------------------------------------------------------------------- |
|
185 // |
|
186 TInt CTestPlatPhysics::TestCAknPhysicsRegisterPanningPositionL( CStifItemParser& /*aItem*/ ) |
|
187 { |
|
188 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
189 _LIT(Ktestcaknphysicsregisterpanningpositionl, "In TestCAknPhysicsRegisterPanningPositionL"); |
|
190 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsregisterpanningpositionl); |
|
191 iLog->Log(Ktestcaknphysicsregisterpanningpositionl); |
|
192 |
|
193 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
194 CleanupStack::PushL( ob ); |
|
195 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
196 CleanupStack::PushL( temp ); |
|
197 TPoint delta; |
|
198 temp->RegisterPanningPosition( delta ); |
|
199 CleanupStack::PopAndDestroy( temp ); |
|
200 CleanupStack::PopAndDestroy( ob ); |
|
201 |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 // -------------------------------------------------------------------------- |
|
206 // CTestPlatPhysics::TestCAknPhysicsSetFrictionL |
|
207 // -------------------------------------------------------------------------- |
|
208 // |
|
209 TInt CTestPlatPhysics::TestCAknPhysicsSetFrictionL( CStifItemParser& /*aItem*/ ) |
|
210 { |
|
211 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
212 _LIT(Ktestcaknphysicssetfrictionl, "In TestCAknPhysicsSetFrictionL"); |
|
213 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicssetfrictionl); |
|
214 iLog->Log(Ktestcaknphysicssetfrictionl); |
|
215 |
|
216 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
217 CleanupStack::PushL( ob ); |
|
218 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
219 CleanupStack::PushL( temp ); |
|
220 TReal friction( 0 ); |
|
221 temp->SetFriction( friction ); |
|
222 CleanupStack::PopAndDestroy( temp ); |
|
223 CleanupStack::PopAndDestroy( ob ); |
|
224 |
|
225 return KErrNone; |
|
226 } |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // CTestPlatPhysics::TestCAknPhysicsResetFrictionL |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 TInt CTestPlatPhysics::TestCAknPhysicsResetFrictionL( CStifItemParser& /*aItem*/ ) |
|
233 { |
|
234 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
235 _LIT(Ktestcaknphysicsresetfrictionl, "In TestCAknPhysicsResetFrictionL"); |
|
236 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsresetfrictionl); |
|
237 iLog->Log(Ktestcaknphysicsresetfrictionl); |
|
238 |
|
239 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
240 CleanupStack::PushL( ob ); |
|
241 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
242 CleanupStack::PushL( temp ); |
|
243 temp->ResetFriction(); |
|
244 CleanupStack::PopAndDestroy( temp ); |
|
245 CleanupStack::PopAndDestroy( ob ); |
|
246 |
|
247 |
|
248 return KErrNone; |
|
249 } |
|
250 |
|
251 // -------------------------------------------------------------------------- |
|
252 // CTestPlatPhysics::TestCAknPhysicsHighlightTimeoutL |
|
253 // -------------------------------------------------------------------------- |
|
254 // |
|
255 TInt CTestPlatPhysics::TestCAknPhysicsHighlightTimeoutL( CStifItemParser& /*aItem*/ ) |
|
256 { |
|
257 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
258 _LIT(Ktestcaknphysicshighlighttimeoutl, "In TestCAknPhysicsHighlightTimeoutL"); |
|
259 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicshighlighttimeoutl); |
|
260 iLog->Log(Ktestcaknphysicshighlighttimeoutl); |
|
261 |
|
262 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
263 CleanupStack::PushL( ob ); |
|
264 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
265 CleanupStack::PushL( temp ); |
|
266 temp->HighlightTimeout(); |
|
267 CleanupStack::PopAndDestroy( temp ); |
|
268 CleanupStack::PopAndDestroy( ob ); |
|
269 |
|
270 return KErrNone; |
|
271 } |
|
272 |
|
273 // -------------------------------------------------------------------------- |
|
274 // CTestPlatPhysics::TestCAknPhysicsDragThresholdL |
|
275 // -------------------------------------------------------------------------- |
|
276 // |
|
277 TInt CTestPlatPhysics::TestCAknPhysicsDragThresholdL( CStifItemParser& /*aItem*/ ) |
|
278 { |
|
279 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
280 _LIT(Ktestcaknphysicsdragthresholdl, "In TestCAknPhysicsDragThresholdL"); |
|
281 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsdragthresholdl); |
|
282 iLog->Log(Ktestcaknphysicsdragthresholdl); |
|
283 |
|
284 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
285 CleanupStack::PushL( ob ); |
|
286 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
287 CleanupStack::PushL( temp ); |
|
288 temp->DragThreshold(); |
|
289 CleanupStack::PopAndDestroy( temp ); |
|
290 CleanupStack::PopAndDestroy( ob ); |
|
291 |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 // -------------------------------------------------------------------------- |
|
296 // CTestPlatPhysics::TestCAknPhysicsFeatureEnabledL |
|
297 // -------------------------------------------------------------------------- |
|
298 // |
|
299 TInt CTestPlatPhysics::TestCAknPhysicsFeatureEnabledL( CStifItemParser& /*aItem*/ ) |
|
300 { |
|
301 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
302 _LIT(Ktestcaknphysicsfeatureenabledl, "In TestCAknPhysicsFeatureEnabledL"); |
|
303 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsfeatureenabledl); |
|
304 iLog->Log(Ktestcaknphysicsfeatureenabledl); |
|
305 |
|
306 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
307 CleanupStack::PushL( ob ); |
|
308 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
309 CleanupStack::PushL( temp ); |
|
310 temp->FeatureEnabled(); |
|
311 CleanupStack::PopAndDestroy( temp ); |
|
312 CleanupStack::PopAndDestroy( ob ); |
|
313 |
|
314 return KErrNone; |
|
315 } |
|
316 |
|
317 // -------------------------------------------------------------------------- |
|
318 // CTestPlatPhysics::TestCAknPhysicsEventHandlingAllowedL |
|
319 // -------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CTestPlatPhysics::TestCAknPhysicsEventHandlingAllowedL( CStifItemParser& /*aItem*/ ) |
|
322 { |
|
323 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
324 _LIT(Ktestcaknphysicseventhandlingallowedl, "In TestCAknPhysicsEventHandlingAllowedL"); |
|
325 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicseventhandlingallowedl); |
|
326 iLog->Log(Ktestcaknphysicseventhandlingallowedl); |
|
327 |
|
328 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
329 CleanupStack::PushL( ob ); |
|
330 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
331 CleanupStack::PushL( temp ); |
|
332 temp->EventHandlingAllowed(); |
|
333 CleanupStack::PopAndDestroy( temp ); |
|
334 CleanupStack::PopAndDestroy( ob ); |
|
335 |
|
336 return KErrNone; |
|
337 } |
|
338 |
|
339 // -------------------------------------------------------------------------- |
|
340 // CTestPlatPhysics::TestCAknPhysicsUpdateViewWindowControlL |
|
341 // -------------------------------------------------------------------------- |
|
342 // |
|
343 TInt CTestPlatPhysics::TestCAknPhysicsUpdateViewWindowControlL( CStifItemParser& /*aItem*/ ) |
|
344 { |
|
345 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
346 _LIT(Ktestcaknphysicsupdateviewwindowcontroll, "In TestCAknPhysicsUpdateViewWindowControlL"); |
|
347 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsupdateviewwindowcontroll); |
|
348 iLog->Log(Ktestcaknphysicsupdateviewwindowcontroll); |
|
349 |
|
350 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
351 CleanupStack::PushL( ob ); |
|
352 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
353 CleanupStack::PushL( temp ); |
|
354 temp->UpdateViewWindowControl(); |
|
355 CleanupStack::PopAndDestroy( temp ); |
|
356 CleanupStack::PopAndDestroy( ob ); |
|
357 |
|
358 return KErrNone; |
|
359 } |
|
360 |
|
361 // -------------------------------------------------------------------------- |
|
362 // CTestPlatPhysics::TestCAknPhysicsSuspendPhysicsL |
|
363 // -------------------------------------------------------------------------- |
|
364 // |
|
365 TInt CTestPlatPhysics::TestCAknPhysicsSuspendPhysicsL( CStifItemParser& /*aItem*/ ) |
|
366 { |
|
367 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
368 _LIT(Ktestcaknphysicssuspendphysicsl, "In TestCAknPhysicsSuspendPhysicsL"); |
|
369 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicssuspendphysicsl); |
|
370 iLog->Log(Ktestcaknphysicssuspendphysicsl); |
|
371 |
|
372 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
373 CleanupStack::PushL( ob ); |
|
374 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
375 CleanupStack::PushL( temp ); |
|
376 temp->SuspendPhysics(); |
|
377 CleanupStack::PopAndDestroy( temp ); |
|
378 CleanupStack::PopAndDestroy( ob ); |
|
379 |
|
380 return KErrNone; |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CTestPlatPhysics::TestCAknPhysicsResumePhysicsL |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 TInt CTestPlatPhysics::TestCAknPhysicsResumePhysicsL( CStifItemParser& /*aItem*/ ) |
|
388 { |
|
389 _LIT(Kctestplatphysics, "CTestPlatPhysics"); |
|
390 _LIT(Ktestcaknphysicsresumephysicsl, "In TestCAknPhysicsResumePhysicsL"); |
|
391 TestModuleIf().Printf(0, Kctestplatphysics, Ktestcaknphysicsresumephysicsl); |
|
392 iLog->Log(Ktestcaknphysicsresumephysicsl); |
|
393 |
|
394 CTestPhysicsObserver* ob = new ( ELeave ) CTestPhysicsObserver; |
|
395 CleanupStack::PushL( ob ); |
|
396 CAknPhysics* temp = CAknPhysics::NewL( *ob, iControl ); |
|
397 CleanupStack::PushL( temp ); |
|
398 temp->ResumePhysics(); |
|
399 CleanupStack::PopAndDestroy( temp ); |
|
400 CleanupStack::PopAndDestroy( ob ); |
|
401 |
|
402 return KErrNone; |
|
403 } |
|
404 |