2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/dali.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/pan-gesture-event.h>
25 #include <dali/integration-api/system-overlay.h>
26 #include <dali/integration-api/profiling.h>
27 #include <dali-test-suite-utils.h>
28 #include <test-touch-utils.h>
32 void utc_dali_pan_gesture_detector_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_pan_gesture_detector_cleanup(void)
39 test_return_value = TET_PASS;
42 ///////////////////////////////////////////////////////////////////////////////
45 typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType;
48 // Stores data that is populated in the callback and will be read by the test cases
52 : functorCalled(false),
53 voidFunctorCalled(false),
54 receivedGesture(Gesture::Clear)
59 functorCalled = false;
60 voidFunctorCalled = false;
62 receivedGesture.state = Gesture::Clear;
63 receivedGesture.velocity = Vector2(0.0f, 0.0f);
64 receivedGesture.displacement = Vector2(0.0f, 0.0f);
65 receivedGesture.position = Vector2(0.0f, 0.0f);
66 receivedGesture.screenPosition = Vector2(0.0f, 0.0f);
67 receivedGesture.numberOfTouches = 0;
73 bool voidFunctorCalled;
74 PanGesture receivedGesture;
78 // Functor that sets the data when called
79 struct GestureReceivedFunctor
81 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
83 void operator()(Actor actor, PanGesture pan)
85 signalData.functorCalled = true;
86 signalData.receivedGesture = pan;
87 signalData.pannedActor = actor;
92 signalData.voidFunctorCalled = true;
95 SignalData& signalData;
98 // Functor that removes the gestured actor from stage
99 struct UnstageActorFunctor : public GestureReceivedFunctor
101 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
102 : GestureReceivedFunctor( data ),
103 stateToUnstage( stateToUnstage )
107 void operator()( Actor actor, PanGesture pan )
109 GestureReceivedFunctor::operator()( actor, pan );
111 if ( pan.state == stateToUnstage )
113 Stage::GetCurrent().Remove( actor );
117 Gesture::State& stateToUnstage;
120 // Functor for receiving a touch event
121 struct TouchEventFunctor
123 bool operator()(Actor actor, const TouchEvent& touch)
129 // Data for constraints
130 struct ConstraintData
137 Vector2 screenPosition;
138 Vector2 screenDisplacement;
139 Vector2 screenVelocity;
140 Vector2 localPosition;
141 Vector2 localDisplacement;
142 Vector2 localVelocity;
147 screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
152 // Constraint used with panning properties
155 PanConstraint( ConstraintData& data ) : constraintData(data) { }
157 Vector3 operator()(const Vector3& current,
158 const PropertyInput& screenPositionProperty,
159 const PropertyInput& screenDisplacementProperty,
160 const PropertyInput& screenVelocityProperty,
161 const PropertyInput& localPositionProperty,
162 const PropertyInput& localDisplacementProperty,
163 const PropertyInput& localVelocityProperty)
165 constraintData.screenPosition = screenPositionProperty.GetVector2();
166 constraintData.screenDisplacement = screenDisplacementProperty.GetVector2();
167 constraintData.screenVelocity = screenVelocityProperty.GetVector2();
168 constraintData.localPosition = localPositionProperty.GetVector2();
169 constraintData.localDisplacement = localDisplacementProperty.GetVector2();
170 constraintData.localVelocity = localVelocityProperty.GetVector2();
171 constraintData.called = true;
172 return Vector3::ZERO;
175 ConstraintData& constraintData;
178 // Generate a PanGestureEvent to send to Core
179 Integration::PanGestureEvent GeneratePan(
180 Gesture::State state,
181 Vector2 previousPosition,
182 Vector2 currentPosition,
183 unsigned long timeDelta,
184 unsigned int numberOfTouches = 1,
185 unsigned int time = 1u)
187 Integration::PanGestureEvent pan(state);
189 pan.previousPosition = previousPosition;
190 pan.currentPosition = currentPosition;
191 pan.timeDelta = timeDelta;
192 pan.numberOfTouches = numberOfTouches;
198 // Generate a PanGesture
199 PanGesture GeneratePan( unsigned int time,
200 Gesture::State state,
201 Vector2 screenPosition,
202 Vector2 localPosition,
203 Vector2 screenDisplacement = Vector2::ONE,
204 Vector2 localDisplacement = Vector2::ONE,
205 Vector2 screenVelocity = Vector2::ONE,
206 Vector2 localVelocity = Vector2::ONE,
207 unsigned int numberOfTouches = 1 )
209 PanGesture pan( state );
213 pan.screenPosition = screenPosition;
214 pan.position = localPosition;
216 pan.screenDisplacement = screenDisplacement;
217 pan.displacement = localDisplacement;
219 pan.screenVelocity = screenVelocity;
220 pan.velocity = localVelocity;
222 pan.numberOfTouches = numberOfTouches;
229 ///////////////////////////////////////////////////////////////////////////////
231 // Positive test case for a method
232 int UtcDaliPanGestureDetectorConstructor(void)
234 TestApplication application;
236 PanGestureDetector detector;
237 DALI_TEST_CHECK(!detector);
242 // Negative test case for a method
243 int UtcDaliPanGestureDetectorNew(void)
245 TestApplication application;
247 PanGestureDetector detector = PanGestureDetector::New();
249 DALI_TEST_CHECK(detector);
251 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
252 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
254 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
255 Actor actor = Actor::New();
256 actor.SetSize(100.0f, 100.0f);
257 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
258 detector.Attach(actor);
260 Stage::GetCurrent().Add(actor);
263 application.SendNotification();
264 application.Render();
266 Integration::TouchEvent touchEvent(1);
267 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
268 touchEvent.AddPoint(point);
269 application.ProcessEvent(touchEvent);
273 int UtcDaliPanGestureDetectorDownCast(void)
275 TestApplication application;
276 tet_infoline("Testing Dali::GestureDetector::DownCast()");
278 PanGestureDetector detector = PanGestureDetector::New();
280 BaseHandle object(detector);
282 PanGestureDetector detector2 = PanGestureDetector::DownCast(object);
283 DALI_TEST_CHECK(detector2);
285 PanGestureDetector detector3 = DownCast< PanGestureDetector >(object);
286 DALI_TEST_CHECK(detector3);
288 BaseHandle unInitializedObject;
289 PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject);
290 DALI_TEST_CHECK(!detector4);
292 PanGestureDetector detector5 = DownCast< PanGestureDetector >(unInitializedObject);
293 DALI_TEST_CHECK(!detector5);
295 GestureDetector detector6 = PanGestureDetector::New();
296 PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6);
297 DALI_TEST_CHECK(detector7);
301 int UtcDaliPanGestureSetMinimumTouchesRequired(void)
303 TestApplication application;
305 PanGestureDetector detector = PanGestureDetector::New();
307 unsigned int min = 2;
309 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
311 detector.SetMinimumTouchesRequired(min);
313 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
315 // Attach an actor and change the minimum touches
317 Actor actor = Actor::New();
318 actor.SetSize(100.0f, 100.0f);
319 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
320 Stage::GetCurrent().Add(actor);
323 application.SendNotification();
324 application.Render();
327 GestureReceivedFunctor functor(data);
329 detector.Attach(actor);
330 detector.DetectedSignal().Connect(&application, functor);
332 TestGestureManager& gestureManager = application.GetGestureManager();
333 gestureManager.Initialize();
335 detector.SetMinimumTouchesRequired(3);
337 // Gesture detection should have been updated only
338 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
339 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
340 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
343 gestureManager.Initialize();
345 // Create a second gesture detector that requires even less minimum touches
346 PanGestureDetector secondDetector = PanGestureDetector::New();
347 secondDetector.Attach(actor);
349 // Gesture detection should have been updated only
350 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
351 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
352 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
356 int UtcDaliPanGestureSetMaximumTouchesRequired(void)
358 TestApplication application;
360 PanGestureDetector detector = PanGestureDetector::New();
362 unsigned int max = 3;
364 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
366 detector.SetMaximumTouchesRequired(max);
368 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
370 // Attach an actor and change the maximum touches
372 Actor actor = Actor::New();
373 actor.SetSize(100.0f, 100.0f);
374 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
375 Stage::GetCurrent().Add(actor);
378 application.SendNotification();
379 application.Render();
382 GestureReceivedFunctor functor(data);
384 detector.Attach(actor);
385 detector.DetectedSignal().Connect(&application, functor);
387 TestGestureManager& gestureManager = application.GetGestureManager();
388 gestureManager.Initialize();
390 detector.SetMaximumTouchesRequired(4);
392 // Gesture detection should have been updated only
393 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
394 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
395 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
398 gestureManager.Initialize();
400 // Create a second gesture detector that requires even less maximum touches
401 PanGestureDetector secondDetector = PanGestureDetector::New();
402 secondDetector.Attach(actor);
404 // Gesture detection should NOT have been updated
405 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
406 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
407 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
411 int UtcDaliPanGestureGetMinimumTouchesRequired(void)
413 TestApplication application;
415 PanGestureDetector detector = PanGestureDetector::New();
416 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
420 int UtcDaliPanGestureGetMaximumTouchesRequired(void)
422 TestApplication application;
424 PanGestureDetector detector = PanGestureDetector::New();
425 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
429 int UtcDaliPanGestureSignalReceptionNegative(void)
431 TestApplication application;
433 Actor actor = Actor::New();
434 actor.SetSize(100.0f, 100.0f);
435 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
436 Stage::GetCurrent().Add(actor);
439 application.SendNotification();
440 application.Render();
443 GestureReceivedFunctor functor(data);
445 PanGestureDetector detector = PanGestureDetector::New();
446 detector.Attach(actor);
447 detector.DetectedSignal().Connect(&application, functor);
449 // Do a pan outside actor's area
450 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
451 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
452 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
454 // Continue pan into actor's area - we should still not receive the signal
456 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(112.0f, 112.0f), Vector2(20.0f, 20.0f), 10));
457 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
459 // Stop panning - we should still not receive the signal
461 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(12.0f, 12.0f), 10));
462 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
466 int UtcDaliPanGestureSignalReceptionDownMotionLeave(void)
468 TestApplication application;
470 Actor actor = Actor::New();
471 actor.SetSize(100.0f, 100.0f);
472 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
473 Stage::GetCurrent().Add(actor);
476 application.SendNotification();
477 application.Render();
480 GestureReceivedFunctor functor(data);
482 PanGestureDetector detector = PanGestureDetector::New();
483 detector.Attach(actor);
484 detector.DetectedSignal().Connect(&application, functor);
486 // Start pan within the actor's area
487 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
488 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
489 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
490 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
491 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
492 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
493 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
494 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
495 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
497 // Continue the pan within the actor's area - we should still receive the signal
499 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
500 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
501 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
502 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
503 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
504 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
505 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
506 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
508 // Pan Gesture leaves actor's area - we should still receive the signal
510 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(320.0f, 10.0f), 10));
511 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
512 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
513 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
514 DALI_TEST_EQUALS(Vector2(300.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
515 DALI_TEST_EQUALS(Vector2(30.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
516 DALI_TEST_EQUALS(300.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
517 DALI_TEST_EQUALS(30.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
519 // Gesture ends - we would receive a finished state
521 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(320.0f, 10.0f), Vector2(310.0f, 10.0f), 10));
522 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
523 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
524 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
525 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
526 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
527 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
528 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
532 int UtcDaliPanGestureSignalReceptionDownMotionUp(void)
534 TestApplication application;
536 Actor actor = Actor::New();
537 actor.SetSize(100.0f, 100.0f);
538 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
539 Stage::GetCurrent().Add(actor);
542 application.SendNotification();
543 application.Render();
546 GestureReceivedFunctor functor(data);
548 PanGestureDetector detector = PanGestureDetector::New();
549 detector.Attach(actor);
550 detector.DetectedSignal().Connect(&application, functor);
552 // Start pan within the actor's area
553 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
554 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
555 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
556 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
557 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
558 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
559 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
560 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
561 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
563 // Continue the pan within the actor's area - we should still receive the signal
565 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
566 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
567 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
568 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
569 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
570 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
571 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
572 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
574 // Gesture ends within actor's area - we would receive a finished state
576 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
577 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
578 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
579 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
580 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
581 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
582 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
583 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
587 int UtcDaliPanGestureSignalReceptionCancelled(void)
589 TestApplication application;
591 Actor actor = Actor::New();
592 actor.SetSize(100.0f, 100.0f);
593 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
594 Stage::GetCurrent().Add(actor);
597 application.SendNotification();
598 application.Render();
601 GestureReceivedFunctor functor(data);
603 PanGestureDetector detector = PanGestureDetector::New();
604 detector.Attach(actor);
605 detector.DetectedSignal().Connect(&application, functor);
607 // Start pan within the actor's area
608 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
609 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
610 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
611 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
613 // Continue the pan within the actor's area - we should still receive the signal
615 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
616 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
617 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
619 // The gesture is cancelled
621 application.ProcessEvent(GeneratePan(Gesture::Cancelled, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
622 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
623 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
627 int UtcDaliPanGestureSignalReceptionDetach(void)
629 TestApplication application;
631 Actor actor = Actor::New();
632 actor.SetSize(100.0f, 100.0f);
633 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
634 Stage::GetCurrent().Add(actor);
637 application.SendNotification();
638 application.Render();
641 GestureReceivedFunctor functor(data);
643 PanGestureDetector detector = PanGestureDetector::New();
644 detector.Attach(actor);
645 detector.DetectedSignal().Connect(&application, functor);
647 // Start pan within the actor's area
648 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
649 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
650 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
652 // Continue the pan within the actor's area - we should still receive the signal
654 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
655 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
657 // Gesture ends within actor's area
659 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
660 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
663 detector.DetachAll();
665 // Ensure we are no longer signalled
667 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
668 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
669 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
670 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
671 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
675 int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void)
677 TestApplication application;
679 Actor actor = Actor::New();
680 actor.SetSize(100.0f, 100.0f);
681 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
682 Stage::GetCurrent().Add(actor);
685 application.SendNotification();
686 application.Render();
689 GestureReceivedFunctor functor(data);
691 PanGestureDetector detector = PanGestureDetector::New();
692 detector.Attach(actor);
693 detector.DetectedSignal().Connect(&application, functor);
695 // Start pan within the actor's area
696 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
697 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
698 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
700 // Continue the pan within the actor's area - we should still receive the signal
702 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
703 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
705 // Detach actor during the pan, we should not receive the next event
706 detector.DetachAll();
708 // Gesture ends within actor's area
710 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
711 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
715 int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void)
717 TestApplication application;
720 GestureReceivedFunctor functor(data);
722 PanGestureDetector detector = PanGestureDetector::New();
723 detector.DetectedSignal().Connect(&application, functor);
725 // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor
727 Actor tempActor = Actor::New();
728 tempActor.SetSize(100.0f, 100.0f);
729 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
730 Stage::GetCurrent().Add(tempActor);
731 detector.Attach(tempActor);
733 // Actor lifetime is scoped
735 Actor actor = Actor::New();
736 actor.SetSize(100.0f, 100.0f);
737 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
738 Stage::GetCurrent().Add(actor);
741 application.SendNotification();
742 application.Render();
744 detector.Attach(actor);
746 // Start pan within the actor's area
747 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
748 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
749 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
751 // Continue the pan within the actor's area - we should still receive the signal
753 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
754 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
756 // Remove the actor from stage and reset the data
757 Stage::GetCurrent().Remove(actor);
760 application.SendNotification();
761 application.Render();
764 // Actor should now have been destroyed
766 // Gesture ends within the area where the actor used to be
768 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
769 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
773 int UtcDaliPanGestureSignalReceptionRotatedActor(void)
775 TestApplication application;
777 Actor actor = Actor::New();
778 actor.SetSize(100.0f, 100.0f);
779 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
780 Stage::GetCurrent().Add(actor);
783 application.SendNotification();
784 application.Render();
787 GestureReceivedFunctor functor(data);
789 PanGestureDetector detector = PanGestureDetector::New();
790 detector.Attach(actor);
791 detector.DetectedSignal().Connect(&application, functor);
793 // Do an entire pan, only check finished value
794 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
795 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
797 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
798 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
799 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
801 // Rotate actor again and render a couple of times
802 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
803 application.SendNotification();
804 application.Render();
806 // Do an entire pan, only check finished value
807 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
808 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
810 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
811 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
812 DALI_TEST_EQUALS(Vector2(-5.0f, -8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
814 // Rotate actor again and render a couple of times
815 actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS);
816 application.SendNotification();
817 application.Render();
819 // Do an entire pan, only check finished value
820 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
821 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
823 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
824 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
825 DALI_TEST_EQUALS(Vector2(-8.0f, 5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
829 int UtcDaliPanGestureSignalReceptionChildHit(void)
831 TestApplication application;
833 Actor parent = Actor::New();
834 parent.SetSize(100.0f, 100.0f);
835 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836 Stage::GetCurrent().Add(parent);
838 // Set child to completely cover parent.
839 // Change rotation of child to be different from parent so that we can check if our local coordinate
840 // conversion of the parent actor is correct.
841 Actor child = Actor::New();
842 child.SetSize(100.0f, 100.0f);
843 child.SetAnchorPoint(AnchorPoint::CENTER);
844 child.SetParentOrigin(ParentOrigin::CENTER);
845 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
848 TouchEventFunctor touchFunctor;
849 child.TouchedSignal().Connect(&application, touchFunctor);
852 application.SendNotification();
853 application.Render();
856 GestureReceivedFunctor functor(data);
858 PanGestureDetector detector = PanGestureDetector::New();
859 detector.Attach(parent);
860 detector.DetectedSignal().Connect(&application, functor);
862 // Do an entire pan, only check finished value - hits child area but parent should still receive it
863 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
864 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
866 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
867 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
868 DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION);
869 DALI_TEST_EQUALS(Vector2(5.0f, 8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
871 // Attach child and generate same touch points to yield a different displacement
872 // (Also proves that you can detach and then re-attach another actor)
873 detector.Attach(child);
874 detector.Detach(parent);
876 // Do an entire pan, only check finished value
877 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
878 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
880 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
881 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
882 DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION);
883 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
887 int UtcDaliPanGestureSignalReceptionAttachDetachMany(void)
889 TestApplication application;
891 Actor first = Actor::New();
892 first.SetSize(100.0f, 100.0f);
893 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
894 Stage::GetCurrent().Add(first);
896 Actor second = Actor::New();
897 second.SetSize(100.0f, 100.0f);
899 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
900 Stage::GetCurrent().Add(second);
903 application.SendNotification();
904 application.Render();
907 GestureReceivedFunctor functor(data);
909 PanGestureDetector detector = PanGestureDetector::New();
910 detector.Attach(first);
911 detector.Attach(second);
912 detector.DetectedSignal().Connect(&application, functor);
914 // Start pan within second actor's area
915 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
916 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
917 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
918 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
920 // Pan moves into first actor's area - second actor should receive the pan
922 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(120.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
923 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
924 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
926 // Detach the second actor during the pan, we should not receive the next event
927 detector.Detach(second);
929 // Gesture ends within actor's area
931 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
932 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
936 int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void)
938 TestApplication application;
940 Actor actor = Actor::New();
941 actor.SetSize(100.0f, 100.0f);
942 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
943 Stage::GetCurrent().Add(actor);
946 application.SendNotification();
947 application.Render();
950 GestureReceivedFunctor functor(data);
952 PanGestureDetector detector = PanGestureDetector::New();
953 detector.Attach(actor);
954 detector.DetectedSignal().Connect(&application, functor);
956 // Start pan in actor's area
957 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
958 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
959 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
961 // Pan continues within actor's area
963 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
964 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
966 // Actor become invisible - actor should not receive the next pan
967 actor.SetVisible(false);
970 application.SendNotification();
971 application.Render();
973 // Gesture ends within actor's area
975 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
976 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
980 int UtcDaliPanGestureSignalReceptionMultipleGestureDetectors(void)
982 TestApplication application;
983 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
985 Actor first = Actor::New();
986 first.SetSize(100.0f, 100.0f);
987 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
988 Stage::GetCurrent().Add(first);
990 Actor second = Actor::New();
991 second.SetSize(100.0f, 100.0f);
992 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
996 application.SendNotification();
997 application.Render();
1000 GestureReceivedFunctor functor(data);
1002 PanGestureDetector firstDetector = PanGestureDetector::New();
1003 firstDetector.Attach(first);
1004 firstDetector.DetectedSignal().Connect(&application, functor);
1006 // secondDetector is scoped
1008 // Reset gestureManager statistics
1009 gestureManager.Initialize();
1011 PanGestureDetector secondDetector = PanGestureDetector::New();
1012 secondDetector.SetMinimumTouchesRequired(2);
1013 secondDetector.SetMaximumTouchesRequired(2);
1014 secondDetector.Attach(second);
1015 secondDetector.DetectedSignal().Connect(&application, functor);
1017 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1018 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1019 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1021 // Start pan within second actor's area
1022 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1023 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1024 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1025 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1027 // Two touch pan changes to single touch - we should receive a finished state
1029 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
1030 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1031 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1032 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1034 // Pan continues as single touch gesture - we should not receive any gesture
1036 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1037 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1039 // Pan ends - still no signal
1041 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1042 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1044 // Single touch pan starts - first actor should be panned
1046 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1047 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1048 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1049 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1051 // Pan changes to double-touch - we should receive a finished state
1053 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10, 2));
1054 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1055 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1056 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1058 // Pan continues as double touch gesture - we should not receive any gesture
1060 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1061 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1063 // Pan ends - still no signal
1065 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1066 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1068 // Reset gesture manager statistics
1069 gestureManager.Initialize();
1072 // secondDetector has now been deleted. Gesture detection should have been updated only
1073 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1074 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1075 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1079 int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void)
1081 TestApplication application;
1083 Actor actor = Actor::New();
1084 actor.SetSize(100.0f, 100.0f);
1085 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1086 Stage::GetCurrent().Add(actor);
1088 Actor actor2 = Actor::New();
1089 actor2.SetSize(100.0f, 100.0f);
1090 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1091 Stage::GetCurrent().Add(actor2);
1093 // Render and notify
1094 application.SendNotification();
1095 application.Render();
1097 // Attach actor to one detector
1098 SignalData firstData;
1099 GestureReceivedFunctor firstFunctor(firstData);
1100 PanGestureDetector firstDetector = PanGestureDetector::New();
1101 firstDetector.Attach(actor);
1102 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
1104 // Attach actor to another detector
1105 SignalData secondData;
1106 GestureReceivedFunctor secondFunctor(secondData);
1107 PanGestureDetector secondDetector = PanGestureDetector::New();
1108 secondDetector.Attach(actor);
1109 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
1111 // Add second actor to second detector, when we remove the actor, this will make sure that this
1112 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
1113 // functor should still not be called (which is what we're also testing).
1114 secondDetector.Attach(actor2);
1116 // Pan in actor's area - both detector's functors should be called
1117 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1118 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1119 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1120 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1122 // Pan continues in actor's area - both detector's functors should be called
1125 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1126 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1127 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1129 // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called.
1130 firstDetector.Detach(actor);
1133 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1134 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1135 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1137 // New pan on actor, only secondDetector has actor attached
1140 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1141 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1142 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1143 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1145 // Detach actor from secondDetector
1146 secondDetector.Detach(actor);
1149 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1150 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1151 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
1155 int UtcDaliPanGestureSignalReceptionMultipleStarted(void)
1157 // Should handle two started events gracefully.
1159 TestApplication application;
1161 Actor actor = Actor::New();
1162 actor.SetSize(100.0f, 100.0f);
1163 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1164 Stage::GetCurrent().Add(actor);
1167 GestureReceivedFunctor functor(data);
1169 PanGestureDetector detector = PanGestureDetector::New();
1170 detector.Attach(actor);
1171 detector.DetectedSignal().Connect(&application, functor);
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Start pan in actor's area
1178 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1179 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1180 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1182 // Send another start in actor's area
1184 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1185 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1187 // Add a child actor to overlap actor and send another start in actor's area
1188 Actor child = Actor::New();
1189 child.SetSize(100.0f, 100.0f);
1190 child.SetAnchorPoint(AnchorPoint::CENTER);
1191 child.SetParentOrigin(ParentOrigin::CENTER);
1194 TouchEventFunctor touchFunctor;
1195 child.TouchedSignal().Connect(&application, touchFunctor);
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Send another possible and start in actor's area
1203 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1204 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1205 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1207 // Send another start in actor's area
1209 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1210 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1211 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1215 int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void)
1217 TestApplication application;
1219 Actor actor1 = Actor::New();
1220 actor1.SetSize(100.0f, 100.0f);
1221 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1222 Stage::GetCurrent().Add(actor1);
1224 GestureReceivedFunctor functor1(data1);
1225 PanGestureDetector detector1 = PanGestureDetector::New();
1226 detector1.Attach(actor1);
1227 detector1.DetectedSignal().Connect(&application, functor1);
1229 Actor actor2 = Actor::New();
1230 actor2.SetSize(100.0f, 100.0f);
1231 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1232 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
1233 Stage::GetCurrent().Add(actor2);
1235 GestureReceivedFunctor functor2(data2);
1236 PanGestureDetector detector2 = PanGestureDetector::New();
1237 detector2.Attach(actor2);
1238 detector2.DetectedSignal().Connect(&application, functor2);
1240 // Render and notify
1241 application.SendNotification();
1242 application.Render();
1244 // Start pan in actor1's area, only data1 should be set
1245 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1246 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1247 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
1248 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
1252 int UtcDaliPanGestureSignalReceptionDifferentPossible(void)
1254 TestApplication application;
1256 Actor actor = Actor::New();
1257 actor.SetSize(100.0f, 100.0f);
1258 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1259 Stage::GetCurrent().Add(actor);
1261 // Render and notify
1262 application.SendNotification();
1263 application.Render();
1265 // Attach actor to detector
1267 GestureReceivedFunctor functor( data );
1268 PanGestureDetector detector = PanGestureDetector::New();
1269 detector.Attach(actor);
1270 detector.DetectedSignal().Connect( &application, functor );
1272 // Gesture possible in actor's area.
1273 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1274 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1276 // Move actor somewhere else
1277 actor.SetPosition( 100.0f, 100.0f );
1279 // Render and notify
1280 application.SendNotification();
1281 application.Render();
1283 // Emit Started event, we should not receive the long press.
1284 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1285 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1286 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1288 // LongPress possible in empty area.
1289 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1290 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1292 // Move actor in to the long press position.
1293 actor.SetPosition( 0.0f, 0.0f );
1295 // Render and notify
1296 application.SendNotification();
1297 application.Render();
1299 // Emit Started event, we should not receive the long press.
1300 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1301 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1302 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1304 // Normal long press in actor's area for completeness.
1305 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1306 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1307 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1308 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1312 int UtcDaliPanGestureEmitIncorrectState(void)
1314 TestApplication application;
1316 Actor actor = Actor::New();
1317 actor.SetSize(100.0f, 100.0f);
1318 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1319 Stage::GetCurrent().Add(actor);
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Attach actor to detector
1327 GestureReceivedFunctor functor( data );
1328 PanGestureDetector detector = PanGestureDetector::New();
1329 detector.Attach(actor);
1330 detector.DetectedSignal().Connect( &application, functor );
1332 // Try a Clear state
1335 application.ProcessEvent(GeneratePan(Gesture::Clear, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1336 tet_result(TET_FAIL);
1338 catch ( Dali::DaliException& e )
1340 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1345 int UtcDaliPanGestureActorUnstaged(void)
1347 TestApplication application;
1349 Actor actor = Actor::New();
1350 actor.SetSize(100.0f, 100.0f);
1351 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1352 Stage::GetCurrent().Add(actor);
1354 // Render and notify
1355 application.SendNotification();
1356 application.Render();
1358 // State to remove actor in.
1359 Gesture::State stateToUnstage( Gesture::Started );
1361 // Attach actor to detector
1363 UnstageActorFunctor functor( data, stateToUnstage );
1364 PanGestureDetector detector = PanGestureDetector::New();
1365 detector.Attach(actor);
1366 detector.DetectedSignal().Connect( &application, functor );
1369 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1370 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1371 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1373 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1374 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Re-add actor to stage
1382 Stage::GetCurrent().Add(actor);
1384 // Render and notify
1385 application.SendNotification();
1386 application.Render();
1388 // Change state to Gesture::Continuing to remove
1389 stateToUnstage = Gesture::Continuing;
1392 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1393 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1394 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1396 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1397 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1399 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1400 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Re-add actor to stage
1408 Stage::GetCurrent().Add(actor);
1410 // Render and notify
1411 application.SendNotification();
1412 application.Render();
1414 // Change state to Gesture::Finished to remove
1415 stateToUnstage = Gesture::Finished;
1418 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1419 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1420 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1422 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1423 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1425 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1426 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1427 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1431 int UtcDaliPanGestureActorStagedAndDestroyed(void)
1433 TestApplication application;
1435 Actor actor = Actor::New();
1436 actor.SetSize(100.0f, 100.0f);
1437 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1438 Stage::GetCurrent().Add(actor);
1440 // Create and add a second actor so that GestureDetector destruction does not come into play.
1441 Actor dummyActor( Actor::New() );
1442 dummyActor.SetSize( 100.0f, 100.0f );
1443 dummyActor.SetPosition( 100.0f, 100.0f );
1444 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1445 Stage::GetCurrent().Add(dummyActor);
1447 // Render and notify
1448 application.SendNotification();
1449 application.Render();
1451 // State to remove actor in.
1452 Gesture::State stateToUnstage( Gesture::Started );
1454 // Attach actor to detector
1456 UnstageActorFunctor functor( data, stateToUnstage );
1457 PanGestureDetector detector = PanGestureDetector::New();
1458 detector.Attach(actor);
1459 detector.Attach(dummyActor);
1460 detector.DetectedSignal().Connect( &application, functor );
1462 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1463 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1464 // position, we should still not be signalled.
1467 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1468 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1469 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Re add to the stage, we should not be signalled
1477 Stage::GetCurrent().Add(actor);
1479 // Render and notify
1480 application.SendNotification();
1481 application.Render();
1483 // Continue signal emission
1484 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1485 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1487 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1488 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1491 // Here we delete an actor in started, we should not receive any subsequent signalling.
1494 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1495 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1496 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Delete actor as well
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Continue signal emission
1511 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1512 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1514 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1515 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1519 int UtcDaliPanGestureSystemOverlay(void)
1521 TestApplication application;
1522 Dali::Integration::Core& core = application.GetCore();
1523 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1524 systemOverlay.GetOverlayRenderTasks().CreateTask();
1526 Actor actor = Actor::New();
1527 actor.SetSize(100.0f, 100.0f);
1528 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1529 systemOverlay.Add(actor);
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1536 GestureReceivedFunctor functor(data);
1538 PanGestureDetector detector = PanGestureDetector::New();
1539 detector.Attach(actor);
1540 detector.DetectedSignal().Connect(&application, functor);
1542 Vector2 screenCoordsStart( 10.0f, 20.0f );
1543 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1545 // Start pan within the actor's area
1546 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1547 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1548 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1552 int UtcDaliPanGestureBehindTouchableSystemOverlay(void)
1554 TestApplication application;
1555 Dali::Integration::Core& core = application.GetCore();
1556 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1557 systemOverlay.GetOverlayRenderTasks().CreateTask();
1559 // SystemOverlay actor
1560 Actor systemOverlayActor = Actor::New();
1561 systemOverlayActor.SetSize(100.0f, 100.0f);
1562 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1563 systemOverlay.Add(systemOverlayActor);
1566 Actor stageActor = Actor::New();
1567 stageActor.SetSize(100.0f, 100.0f);
1568 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1569 Stage::GetCurrent().Add(stageActor);
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Set system-overlay actor to touchable
1576 TouchEventData touchData;
1577 TouchEventDataFunctor touchFunctor( touchData );
1578 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1580 // Set stage actor to receive the gesture
1582 GestureReceivedFunctor functor(data);
1584 PanGestureDetector detector = PanGestureDetector::New();
1585 detector.Attach(stageActor);
1586 detector.DetectedSignal().Connect(&application, functor);
1588 Vector2 screenCoordsStart( 10.0f, 20.0f );
1589 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1591 // Start pan within the two actors' area
1592 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1593 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1594 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1595 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1596 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1601 // Do touch in the same area
1602 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1603 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1604 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1609 int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void)
1611 TestApplication application;
1612 Dali::Integration::Core& core = application.GetCore();
1613 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1614 systemOverlay.GetOverlayRenderTasks().CreateTask();
1616 // SystemOverlay actor
1617 Actor systemOverlayActor = Actor::New();
1618 systemOverlayActor.SetSize(100.0f, 100.0f);
1619 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1620 systemOverlay.Add(systemOverlayActor);
1623 Actor stageActor = Actor::New();
1624 stageActor.SetSize(100.0f, 100.0f);
1625 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1626 Stage::GetCurrent().Add(stageActor);
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Set stage actor to touchable
1633 TouchEventData touchData;
1634 TouchEventDataFunctor touchFunctor( touchData );
1635 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1637 // Set system-overlay actor to have the gesture
1639 GestureReceivedFunctor functor(data);
1641 PanGestureDetector detector = PanGestureDetector::New();
1642 detector.Attach(systemOverlayActor);
1643 detector.DetectedSignal().Connect(&application, functor);
1645 Vector2 screenCoordsStart( 10.0f, 20.0f );
1646 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1648 // Start pan within the two actors' area
1649 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1650 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1651 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1652 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1653 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1658 // Do touch in the same area
1659 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1660 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1661 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1666 int UtcDaliPanGestureAngleHandling(void)
1668 TestApplication application;
1670 PanGestureDetector detector = PanGestureDetector::New();
1671 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1672 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1674 detector.AddAngle( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1675 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1676 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1678 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1680 tet_result( TET_PASS );
1684 if ( iter == endIter )
1686 tet_printf("%s, angle not added\n", TEST_LOCATION );
1687 tet_result( TET_FAIL );
1691 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Radian( Math::PI * 0.25 ) );
1692 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1694 // Remove something not in the container.
1695 detector.RemoveAngle( PanGestureDetector::DIRECTION_UP );
1696 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1698 detector.RemoveAngle( PanGestureDetector::DIRECTION_RIGHT );
1699 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1700 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1702 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1704 tet_printf("%s, angle not removed\n", TEST_LOCATION );
1705 tet_result( TET_FAIL );
1710 detector.ClearAngles();
1711 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1715 inline float RadiansToDegrees( float radian )
1717 return radian * 180.0f / Math::PI;
1720 int UtcDaliPanGestureAngleOutOfRange(void)
1722 TestApplication application;
1724 PanGestureDetector detector = PanGestureDetector::New();
1725 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1726 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1732 detector.AddAngle( Degree(180.0f) );
1733 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION );
1734 detector.ClearAngles();
1736 detector.AddAngle( Degree(190.0f) );
1737 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION );
1738 detector.ClearAngles();
1740 detector.AddAngle( Degree(-190.0f) );
1741 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION );
1742 detector.ClearAngles();
1744 detector.AddAngle( Degree(350.0f) );
1745 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1746 detector.ClearAngles();
1748 detector.AddAngle( Degree(-350.0f) );
1749 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1750 detector.ClearAngles();
1752 detector.AddAngle( Degree(370.0f) );
1753 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1754 detector.ClearAngles();
1756 detector.AddAngle( Degree(-370.0f) );
1757 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1758 detector.ClearAngles();
1764 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 0.0f ) );
1765 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION );
1766 detector.ClearAngles();
1768 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -10.0f ) );
1769 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1770 detector.ClearAngles();
1772 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -181.0f ) );
1773 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1774 detector.ClearAngles();
1776 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 181.0f ) );
1777 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1778 detector.ClearAngles();
1782 int UtcDaliPanGestureAngleProcessing(void)
1784 TestApplication application;
1786 Actor parent = Actor::New();
1787 parent.SetSize(100.0f, 100.0f);
1788 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1789 Stage::GetCurrent().Add(parent);
1791 Actor child = Actor::New();
1792 child.SetSize(100.0f, 100.0f);
1793 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Parent detector only requires up pans
1801 PanGestureDetector parentDetector = PanGestureDetector::New();
1802 parentDetector.Attach( parent );
1803 parentDetector.AddAngle( PanGestureDetector::DIRECTION_UP, Degree( 30.0f ) );
1804 SignalData parentData;
1805 GestureReceivedFunctor parentFunctor(parentData);
1806 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1808 // Child detector only requires right pans
1809 PanGestureDetector childDetector = PanGestureDetector::New();
1810 childDetector.Attach( child );
1811 childDetector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 30.0f ) );
1812 SignalData childData;
1813 GestureReceivedFunctor childFunctor(childData);
1814 childDetector.DetectedSignal().Connect(&application, childFunctor);
1816 // Generate an Up pan gesture, only parent should receive it.
1817 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1818 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1819 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1820 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1821 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1825 // Generate a Right pan gesture, only child should receive it.
1826 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1827 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1828 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1829 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1830 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1834 // Generate a Down pan gesture, no one should receive it.
1835 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1836 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1837 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1838 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1839 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1843 // Generate a Left pan gesture, no one should receive it.
1844 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1845 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1846 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1847 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1848 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1854 int UtcDaliPanGestureDirectionHandling(void)
1856 TestApplication application;
1858 PanGestureDetector detector = PanGestureDetector::New();
1859 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1860 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1862 detector.AddDirection( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1863 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1864 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1866 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1868 tet_result( TET_PASS );
1872 if ( iter == endIter )
1874 tet_printf("%s, angle not added\n", TEST_LOCATION );
1875 tet_result( TET_FAIL );
1879 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1881 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1883 tet_result( TET_PASS );
1887 if ( iter == endIter )
1889 tet_printf("%s, angle not added\n", TEST_LOCATION );
1890 tet_result( TET_FAIL );
1894 // Remove something not in the container.
1895 detector.RemoveDirection( PanGestureDetector::DIRECTION_UP );
1896 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1898 detector.RemoveDirection( PanGestureDetector::DIRECTION_RIGHT );
1899 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1903 int UtcDaliPanGestureDirectionProcessing(void)
1905 TestApplication application;
1907 Actor parent = Actor::New();
1908 parent.SetSize(100.0f, 100.0f);
1909 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1910 Stage::GetCurrent().Add(parent);
1912 Actor child = Actor::New();
1913 child.SetSize(100.0f, 100.0f);
1914 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 // Parent detector only requires vertical panning
1922 PanGestureDetector parentDetector = PanGestureDetector::New();
1923 parentDetector.Attach( parent );
1924 parentDetector.AddDirection( PanGestureDetector::DIRECTION_VERTICAL, Degree( 30.0f ) );
1925 SignalData parentData;
1926 GestureReceivedFunctor parentFunctor(parentData);
1927 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1929 // Child detector only requires horizontal panning
1930 PanGestureDetector childDetector = PanGestureDetector::New();
1931 childDetector.Attach( child );
1932 childDetector.AddDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 30.0f ) );
1933 SignalData childData;
1934 GestureReceivedFunctor childFunctor(childData);
1935 childDetector.DetectedSignal().Connect(&application, childFunctor);
1937 // Generate an Up pan gesture, only parent should receive it.
1938 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1939 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1940 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1941 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1942 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1946 // Generate a Right pan gesture, only child should receive it.
1947 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1948 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1949 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1950 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1951 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1955 // Generate a Down pan gesture, only parent should receive it.
1956 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1957 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1958 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1959 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1960 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1964 // Generate a Left pan gesture, only child should receive it.
1965 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1966 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1967 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1968 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1969 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1973 // Generate a pan at -45 degrees, no one should receive it.
1974 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1975 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1976 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1977 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1978 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1982 // Generate a pan at 45 degrees, no one should receive it.
1983 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1984 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 30.0f), 10 ) );
1985 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1986 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1987 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1991 // Generate a pan at 135 degrees, no one should receive it.
1992 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1993 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1994 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1995 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1996 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
2000 // Generate a pan at -135 degrees, no one should receive it.
2001 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
2002 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 10.0f), 10 ) );
2003 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
2004 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
2005 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
2011 int UtcDaliPanGestureSetProperties(void)
2013 TestApplication application;
2014 TestRenderController& renderController( application.GetRenderController() );
2015 Integration::SetPanGesturePredictionMode(0);
2016 Integration::SetPanGestureSmoothingMode(0);
2018 Actor actor = Actor::New();
2019 actor.SetSize(100.0f, 100.0f);
2020 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2021 Stage::GetCurrent().Add(actor);
2023 // Add a pan detector
2024 PanGestureDetector detector = PanGestureDetector::New();
2025 detector.Attach( actor );
2027 GestureReceivedFunctor functor( data );
2028 detector.DetectedSignal().Connect( &application, functor );
2030 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2032 ConstraintData constraintData;
2033 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2034 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2035 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2036 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2037 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2038 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2039 PanConstraint( constraintData ) ) );
2041 // Render and notify
2042 application.SendNotification();
2043 application.Render();
2045 renderController.Initialize();
2046 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), false, TEST_LOCATION );
2048 Vector2 screenPosition( 20.0f, 20.0f );
2049 Vector2 screenDisplacement( 1.0f, 1.0f );
2050 Vector2 screenVelocity( 1.3f, 4.0f );
2051 Vector2 localPosition( 21.0f, 21.0f );
2052 Vector2 localDisplacement( 0.5f, 0.5f );
2053 Vector2 localVelocity( 1.5f, 2.5f );
2055 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity ) );
2056 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2063 DALI_TEST_EQUALS( constraintData.screenPosition, screenPosition, TEST_LOCATION );
2064 DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION );
2065 DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION );
2066 DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION );
2067 DALI_TEST_EQUALS( constraintData.screenVelocity, screenVelocity, TEST_LOCATION );
2068 DALI_TEST_EQUALS( constraintData.localVelocity, localVelocity, TEST_LOCATION );
2069 constraintData.Reset();
2073 int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
2075 TestApplication application;
2076 Integration::SetPanGesturePredictionMode(0);
2078 Actor actor = Actor::New();
2079 actor.SetSize(100.0f, 100.0f);
2080 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2081 Stage::GetCurrent().Add(actor);
2083 // Add a pan detector
2084 PanGestureDetector detector = PanGestureDetector::New();
2085 detector.Attach( actor );
2087 GestureReceivedFunctor functor( data );
2088 detector.DetectedSignal().Connect( &application, functor );
2090 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2092 ConstraintData constraintData;
2093 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2094 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2095 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2096 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2097 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2098 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2099 PanConstraint( constraintData ) ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 Vector2 previousPosition( 20.0f, 20.0f );
2106 Vector2 currentPosition( 20.0f, 10.0f );
2107 application.ProcessEvent( GeneratePan( Gesture::Possible, previousPosition, previousPosition, 10 ) );
2108 application.ProcessEvent( GeneratePan( Gesture::Started, previousPosition, currentPosition, 10 ) );
2109 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2111 Vector2 screenPosition( 100.0f, 20.0f );
2112 Vector2 localPosition( 110.0f, 110.0f );
2114 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition ) );
2116 // Render and notify
2117 application.SendNotification();
2118 application.Render();
2120 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2121 DALI_TEST_EQUALS( constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION );
2122 DALI_TEST_EQUALS( constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION );
2123 constraintData.Reset();
2127 int UtcDaliPanGesturePropertyIndices(void)
2129 TestApplication application;
2130 PanGestureDetector detector = PanGestureDetector::New();
2132 Property::IndexContainer indices;
2133 detector.GetPropertyIndices( indices );
2134 DALI_TEST_CHECK( ! indices.empty() );
2135 DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION );
2139 int UtcDaliPanGestureLayerConsumesTouch(void)
2141 TestApplication application;
2143 Actor actor = Actor::New();
2144 actor.SetSize(100.0f, 100.0f);
2145 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2146 Stage::GetCurrent().Add(actor);
2148 // Add a pan detector
2149 PanGestureDetector detector = PanGestureDetector::New();
2150 detector.Attach( actor );
2152 GestureReceivedFunctor functor( data );
2153 detector.DetectedSignal().Connect( &application, functor );
2155 // Add a layer to overlap the actor
2156 Layer layer = Layer::New();
2157 layer.SetSize(100.0f, 100.0f);
2158 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2159 Stage::GetCurrent().Add( layer );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Emit signals, should receive
2167 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2168 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2169 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2170 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2173 // Set layer to consume all touch
2174 layer.SetTouchConsumed( true );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 // Emit the same signals again, should not receive
2181 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2182 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2183 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2184 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2190 int UtcDaliPanGestureNoTimeDiff(void)
2192 TestApplication application;
2194 Actor actor = Actor::New();
2195 actor.SetSize(100.0f, 100.0f);
2196 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2197 Stage::GetCurrent().Add(actor);
2199 // Add a pan detector
2200 PanGestureDetector detector = PanGestureDetector::New();
2201 detector.Attach( actor );
2203 GestureReceivedFunctor functor( data );
2204 detector.DetectedSignal().Connect( &application, functor );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Emit signals, should receive
2211 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2212 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2213 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2214 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2215 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.x ) );
2216 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.y ) );
2217 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.x ) );
2218 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.y ) );