2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
20 #include <dali/dali.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/long-press-gesture-event.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali-test-suite-utils.h>
28 void utc_dali_long_press_gesture_detector_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_long_press_gesture_detector_cleanup(void)
35 test_return_value = TET_PASS;
38 ///////////////////////////////////////////////////////////////////////////////
42 // Stores data that is populated in the callback and will be read by the TET cases
46 : functorCalled( false ),
47 voidFunctorCalled( false ),
48 receivedGesture( Gesture::Clear ),
54 functorCalled = false;
55 voidFunctorCalled = false;
57 receivedGesture.numberOfTouches = 0u;
58 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
59 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
65 bool voidFunctorCalled;
66 LongPressGesture receivedGesture;
70 // Functor that sets the data when called
71 struct GestureReceivedFunctor
73 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
75 void operator()(Actor actor, LongPressGesture longPress)
77 signalData.functorCalled = true;
78 signalData.receivedGesture = longPress;
79 signalData.pressedActor = actor;
84 signalData.voidFunctorCalled = true;
87 SignalData& signalData;
90 // Functor that removes the gestured actor from stage
91 struct UnstageActorFunctor : public GestureReceivedFunctor
93 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
94 : GestureReceivedFunctor( data ),
95 stateToUnstage( stateToUnstage )
99 void operator()( Actor actor, LongPressGesture longPress )
101 GestureReceivedFunctor::operator()( actor, longPress );
103 if ( longPress.state == stateToUnstage )
105 Stage::GetCurrent().Remove( actor );
109 Gesture::State& stateToUnstage;
112 // Functor for receiving a touch event
113 struct TouchEventFunctor
115 bool operator()(Actor actor, const TouchEvent& touch)
118 unsigned int points = touch.GetPointCount();
121 const TouchPoint& touchPoint = touch.GetPoint(0);
122 tet_printf("Touch Point state = %d\n", touchPoint.state);
128 // Generate a LongPressGestureEvent to send to Core
129 Integration::LongPressGestureEvent GenerateLongPress(
130 Gesture::State state,
131 unsigned int numberOfTouches,
134 Integration::LongPressGestureEvent longPress( state );
136 longPress.numberOfTouches = numberOfTouches;
137 longPress.point = point;
144 ///////////////////////////////////////////////////////////////////////////////
147 // Positive test case for a method
148 int UtcDaliLongPressGestureDetectorConstructor(void)
150 TestApplication application;
152 LongPressGestureDetector detector;
153 DALI_TEST_CHECK(!detector);
158 int UtcDaliLongPressGestureDetectorNew(void)
160 TestApplication application;
162 LongPressGestureDetector detector = LongPressGestureDetector::New();
163 DALI_TEST_CHECK(detector);
164 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
165 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
167 LongPressGestureDetector detector2 = LongPressGestureDetector::New(5u);
168 DALI_TEST_CHECK(detector2);
169 DALI_TEST_EQUALS(5u, detector2.GetMinimumTouchesRequired(), TEST_LOCATION);
170 DALI_TEST_EQUALS(5u, detector2.GetMaximumTouchesRequired(), TEST_LOCATION);
172 LongPressGestureDetector detector3 = LongPressGestureDetector::New(5u, 7u);
173 DALI_TEST_CHECK(detector2);
174 DALI_TEST_EQUALS(5u, detector3.GetMinimumTouchesRequired(), TEST_LOCATION);
175 DALI_TEST_EQUALS(7u, detector3.GetMaximumTouchesRequired(), TEST_LOCATION);
177 //Scoped test to test destructor
179 LongPressGestureDetector detector4 = LongPressGestureDetector::New();
180 DALI_TEST_CHECK(detector4);
183 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
184 Actor actor = Actor::New();
185 actor.SetSize(100.0f, 100.0f);
186 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
187 Stage::GetCurrent().Add(actor);
190 application.SendNotification();
191 application.Render();
193 detector.Attach(actor);
195 TouchEventFunctor touchFunctor;
196 actor.TouchedSignal().Connect(&application, touchFunctor);
198 Integration::TouchEvent touchEvent(1);
199 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
200 touchEvent.AddPoint(point);
201 application.ProcessEvent(touchEvent);
204 application.SendNotification();
205 application.Render();
207 // For line coverage, Initialise default constructor
208 TouchEvent touchEvent2;
212 int UtcDaliLongPressGestureDetectorDownCast(void)
214 TestApplication application;
215 tet_infoline("Testing Dali::LongPressGestureDetector::DownCast()");
217 LongPressGestureDetector detector = LongPressGestureDetector::New();
219 BaseHandle object(detector);
221 LongPressGestureDetector detector2 = LongPressGestureDetector::DownCast(object);
222 DALI_TEST_CHECK(detector2);
224 LongPressGestureDetector detector3 = DownCast< LongPressGestureDetector >(object);
225 DALI_TEST_CHECK(detector3);
227 BaseHandle unInitializedObject;
228 LongPressGestureDetector detector4 = LongPressGestureDetector::DownCast(unInitializedObject);
229 DALI_TEST_CHECK(!detector4);
231 LongPressGestureDetector detector5 = DownCast< LongPressGestureDetector >(unInitializedObject);
232 DALI_TEST_CHECK(!detector5);
234 GestureDetector detector6 = LongPressGestureDetector::New();
235 LongPressGestureDetector detector7 = LongPressGestureDetector::DownCast(detector6);
236 DALI_TEST_CHECK(detector7);
240 int UtcDaliLongPressGestureSetTouchesRequired01(void)
242 TestApplication application;
244 LongPressGestureDetector detector = LongPressGestureDetector::New();
246 unsigned int touches = 3;
248 DALI_TEST_CHECK(touches != detector.GetMinimumTouchesRequired());
249 DALI_TEST_CHECK(touches != detector.GetMaximumTouchesRequired());
251 detector.SetTouchesRequired(touches);
253 DALI_TEST_EQUALS(touches, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
254 DALI_TEST_EQUALS(touches, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
256 // Attach an actor and change the required touches
258 Actor actor = Actor::New();
259 actor.SetSize(100.0f, 100.0f);
260 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
261 Stage::GetCurrent().Add(actor);
264 application.SendNotification();
265 application.Render();
268 GestureReceivedFunctor functor(data);
270 detector.Attach(actor);
271 detector.DetectedSignal().Connect(&application, functor);
273 TestGestureManager& gestureManager = application.GetGestureManager();
274 gestureManager.Initialize();
276 detector.SetTouchesRequired(4);
278 // Gesture detection should have been updated only
279 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
280 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
281 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
284 gestureManager.Initialize();
286 // Create a second gesture detector that requires even less maximum touches
287 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
288 secondDetector.Attach(actor);
290 // Gesture detection should have been updated
291 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
292 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
293 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
297 int UtcDaliLongPressGestureSetTouchesRequired02(void)
299 TestApplication application;
301 LongPressGestureDetector detector = LongPressGestureDetector::New();
303 unsigned int min = 3;
304 unsigned int max = 5;
306 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
307 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
309 detector.SetTouchesRequired(min, max);
311 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
312 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
314 // Attach an actor and change the maximum touches
316 Actor actor = Actor::New();
317 actor.SetSize(100.0f, 100.0f);
318 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
319 Stage::GetCurrent().Add(actor);
322 application.SendNotification();
323 application.Render();
326 GestureReceivedFunctor functor(data);
328 detector.Attach(actor);
329 detector.DetectedSignal().Connect(&application, functor);
331 TestGestureManager& gestureManager = application.GetGestureManager();
332 gestureManager.Initialize();
334 detector.SetTouchesRequired(4, 5);
336 // Gesture detection should have been updated only
337 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
338 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
339 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
342 gestureManager.Initialize();
344 // Create a second gesture detector that requires even less maximum touches
345 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
346 secondDetector.Attach(actor);
348 // Gesture detection should have been updated
349 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
350 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
351 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
355 int UtcDaliLongPressGestureGetMinimumTouchesRequired(void)
357 TestApplication application;
359 LongPressGestureDetector detector = LongPressGestureDetector::New();
360 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
364 int UtcDaliLongPressGestureGetMaximumTouchesRequired(void)
366 TestApplication application;
368 LongPressGestureDetector detector = LongPressGestureDetector::New();
369 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
373 int UtcDaliLongPressGestureSignalReceptionNegative(void)
375 TestApplication application;
377 Actor actor = Actor::New();
378 actor.SetSize(100.0f, 100.0f);
379 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
380 Stage::GetCurrent().Add(actor);
383 application.SendNotification();
384 application.Render();
387 GestureReceivedFunctor functor(data);
389 LongPressGestureDetector detector = LongPressGestureDetector::New();
390 detector.Attach(actor);
391 detector.DetectedSignal().Connect(&application, functor);
393 // Do a long press outside actor's area
394 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2(112.0f, 112.0f ) ) );
395 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2(112.0f, 112.0f ) ) );
396 application.ProcessEvent( GenerateLongPress( Gesture::Finished, 1u, Vector2(112.0f, 112.0f ) ) );
397 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
401 int UtcDaliLongPressGestureSignalReceptionPositive(void)
403 TestApplication application;
405 Actor actor = Actor::New();
406 actor.SetSize(100.0f, 100.0f);
407 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
408 Stage::GetCurrent().Add(actor);
411 application.SendNotification();
412 application.Render();
415 GestureReceivedFunctor functor(data);
417 LongPressGestureDetector detector = LongPressGestureDetector::New();
418 detector.Attach(actor);
419 detector.DetectedSignal().Connect(&application, functor);
421 // Do a long press inside actor's area
422 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
423 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
424 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
425 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
426 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
427 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
431 int UtcDaliLongPressGestureSignalReceptionDetach(void)
433 TestApplication application;
435 Actor actor = Actor::New();
436 actor.SetSize(100.0f, 100.0f);
437 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
438 Stage::GetCurrent().Add(actor);
441 application.SendNotification();
442 application.Render();
445 GestureReceivedFunctor functor(data);
447 LongPressGestureDetector detector = LongPressGestureDetector::New();
448 detector.Attach(actor);
449 detector.DetectedSignal().Connect(&application, functor);
451 // Start long press within the actor's area
452 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
453 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
454 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
455 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
456 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
457 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f)));
459 // repeat the long press within the actor's area - we should still receive the signal
461 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
462 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
463 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
464 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
465 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
466 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
469 detector.DetachAll();
471 // Ensure we are no longer signalled
473 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
474 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
475 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
476 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
477 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
481 int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void)
483 TestApplication application;
486 GestureReceivedFunctor functor(data);
488 LongPressGestureDetector detector = LongPressGestureDetector::New();
489 detector.DetectedSignal().Connect(&application, functor);
491 // Actor lifetime is scoped
493 Actor actor = Actor::New();
494 actor.SetSize(100.0f, 100.0f);
495 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
496 Stage::GetCurrent().Add(actor);
499 application.SendNotification();
500 application.Render();
502 detector.Attach(actor);
504 // Start long press within the actor's area
505 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
506 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
507 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
509 // Remove the actor from stage and reset the data
510 Stage::GetCurrent().Remove(actor);
513 application.SendNotification();
514 application.Render();
517 // Actor should now have been destroyed
520 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f)));
521 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
525 int UtcDaliLongPressGestureSignalReceptionRotatedActor(void)
527 TestApplication application;
529 Actor actor = Actor::New();
530 actor.SetSize(100.0f, 100.0f);
531 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
532 Stage::GetCurrent().Add(actor);
535 application.SendNotification();
536 application.Render();
539 GestureReceivedFunctor functor(data);
541 LongPressGestureDetector detector = LongPressGestureDetector::New();
542 detector.Attach(actor);
543 detector.DetectedSignal().Connect(&application, functor);
546 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f)));
547 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f)));
548 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f)));
549 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
550 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
551 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
553 // Rotate actor again and render
554 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
555 application.SendNotification();
556 application.Render();
558 // Do another long press, should still receive event
560 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f)));
561 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f)));
562 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f)));
563 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
564 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
565 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
567 // Rotate actor again and render
568 actor.SetRotation(Dali::Degree(90.0f), Vector3::YAXIS);
569 application.SendNotification();
570 application.Render();
572 // Do a long press, inside where the actor used to be, Should not receive the event
574 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(70.0f, 70.0f)));
575 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(70.0f, 70.0f)));
576 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(70.0f, 70.0f)));
577 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
581 int UtcDaliLongPressGestureSignalReceptionChildHit(void)
583 TestApplication application;
585 Actor parent = Actor::New();
586 parent.SetSize(100.0f, 100.0f);
587 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
588 Stage::GetCurrent().Add(parent);
590 // Set child to completely cover parent.
591 // Change rotation of child to be different from parent so that we can check if our local coordinate
592 // conversion of the parent actor is correct.
593 Actor child = Actor::New();
594 child.SetSize(100.0f, 100.0f);
595 child.SetAnchorPoint(AnchorPoint::CENTER);
596 child.SetParentOrigin(ParentOrigin::CENTER);
597 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
600 TouchEventFunctor touchFunctor;
601 child.TouchedSignal().Connect(&application, touchFunctor);
604 application.SendNotification();
605 application.Render();
608 GestureReceivedFunctor functor(data);
610 LongPressGestureDetector detector = LongPressGestureDetector::New();
611 detector.Attach(parent);
612 detector.DetectedSignal().Connect(&application, functor);
614 // Do long press - hits child area but parent should still receive it
615 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
616 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
617 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
618 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
619 DALI_TEST_EQUALS(true, parent == data.pressedActor, TEST_LOCATION);
620 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
622 // Attach child and generate same touch points
623 // (Also proves that you can detach and then re-attach another actor)
624 detector.Attach(child);
625 detector.Detach(parent);
627 // Do an entire long press, only check finished value
629 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(51.0f, 51.0f)));
630 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(51.0f, 51.0f)));
631 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(51.0f, 51.0f)));
632 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
633 DALI_TEST_EQUALS(true, child == data.pressedActor, TEST_LOCATION);
634 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
638 int UtcDaliLongPressGestureSignalReceptionAttachDetachMany(void)
640 TestApplication application;
642 Actor first = Actor::New();
643 first.SetSize(100.0f, 100.0f);
644 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
645 Stage::GetCurrent().Add(first);
647 Actor second = Actor::New();
648 second.SetSize(100.0f, 100.0f);
650 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
651 Stage::GetCurrent().Add(second);
654 application.SendNotification();
655 application.Render();
658 GestureReceivedFunctor functor(data);
660 LongPressGestureDetector detector = LongPressGestureDetector::New();
661 detector.Attach(first);
662 detector.Attach(second);
663 detector.DetectedSignal().Connect(&application, functor);
665 // LongPress within second actor's area
666 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f)));
667 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f)));
668 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f)));
669 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
670 DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION);
672 // LongPress within first actor's area
674 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f)));
675 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f)));
676 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f)));
677 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
678 DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION);
680 // Detach the second actor
681 detector.Detach(second);
683 // second actor shouldn't receive event
685 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f)));
686 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f)));
687 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f)));
688 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
690 // first actor should continue receiving event
692 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f)));
693 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f)));
694 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f)));
695 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
699 int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void)
701 TestApplication application;
703 Actor actor = Actor::New();
704 actor.SetSize(100.0f, 100.0f);
705 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
706 Stage::GetCurrent().Add(actor);
709 application.SendNotification();
710 application.Render();
713 GestureReceivedFunctor functor(data);
715 LongPressGestureDetector detector = LongPressGestureDetector::New();
716 detector.Attach(actor);
717 detector.DetectedSignal().Connect(&application, functor);
719 // LongPress in actor's area
720 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
721 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
722 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
723 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
725 // Actor becomes invisible - actor should not receive the next long press
726 actor.SetVisible(false);
729 application.SendNotification();
730 application.Render();
732 // LongPress in the same area, shouldn't receive event
734 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
735 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
736 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
737 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
741 int UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors(void)
743 TestApplication application;
744 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
746 Actor first = Actor::New();
747 first.SetSize(100.0f, 100.0f);
748 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
749 Stage::GetCurrent().Add(first);
751 Actor second = Actor::New();
752 second.SetSize(100.0f, 100.0f);
753 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
758 application.SendNotification();
759 application.Render();
762 GestureReceivedFunctor functor(data);
764 LongPressGestureDetector firstDetector = LongPressGestureDetector::New();
765 firstDetector.Attach(first);
766 firstDetector.DetectedSignal().Connect(&application, functor);
768 // secondDetector is scoped
770 // Reset gestureManager statistics
771 gestureManager.Initialize();
773 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
774 secondDetector.SetTouchesRequired(2);
775 secondDetector.Attach(second);
776 secondDetector.DetectedSignal().Connect(&application, functor);
778 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
779 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
780 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
782 // LongPress within second actor's area
783 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(150.0f, 10.0f)));
784 application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(150.0f, 10.0f)));
785 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(150.0f, 10.0f)));
786 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
787 DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION);
789 // LongPress continues as single touch gesture - we should not receive any gesture
791 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(150.0f, 10.0f)));
792 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(150.0f, 10.0f)));
793 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(150.0f, 10.0f)));
794 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
796 // Single touch long press starts - first actor should receive gesture
798 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
799 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
800 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
801 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
802 DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION);
804 // long press changes to double-touch - we shouldn't receive event
806 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(50.0f, 10.0f)));
807 application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(50.0f, 10.0f)));
808 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(50.0f, 10.0f)));
809 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
811 // Reset gesture manager statistics
812 gestureManager.Initialize();
815 // secondDetector has now been deleted. Gesture detection should have been updated only
816 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
817 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
818 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
822 int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void)
824 TestApplication application;
826 Actor actor = Actor::New();
827 actor.SetSize(100.0f, 100.0f);
828 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
829 Stage::GetCurrent().Add(actor);
832 application.SendNotification();
833 application.Render();
835 // Attach actor to one detector
836 SignalData firstData;
837 GestureReceivedFunctor firstFunctor(firstData);
838 LongPressGestureDetector firstDetector = LongPressGestureDetector::New();
839 firstDetector.Attach(actor);
840 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
842 // Attach actor to another detector
843 SignalData secondData;
844 GestureReceivedFunctor secondFunctor(secondData);
845 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
846 secondDetector.Attach(actor);
847 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
849 // LongPress in actor's area - both detector's functors should be called
850 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
851 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
852 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
853 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
857 int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void)
859 TestApplication application;
861 Actor actor = Actor::New();
862 actor.SetSize(100.0f, 100.0f);
863 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
864 Stage::GetCurrent().Add(actor);
867 application.SendNotification();
868 application.Render();
870 // Attach actor to detector
872 GestureReceivedFunctor functor( data );
873 LongPressGestureDetector detector = LongPressGestureDetector::New();
874 detector.Attach(actor);
875 detector.DetectedSignal().Connect( &application, functor );
877 // LongPress possible in actor's area.
878 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
879 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
881 // Move actor somewhere else
882 actor.SetPosition( 100.0f, 100.0f );
885 application.SendNotification();
886 application.Render();
888 // Emit Started event, we should not receive the long press.
889 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
890 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
891 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
893 // LongPress possible in empty area.
894 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
895 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
897 // Move actor in to the long press position.
898 actor.SetPosition( 0.0f, 0.0f );
901 application.SendNotification();
902 application.Render();
904 // Emit Started event, we should not receive the long press.
905 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
906 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
907 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
909 // Normal long press in actor's area for completeness.
910 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
911 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
912 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
913 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
917 int UtcDaliLongPressGestureEmitIncorrecteStateClear(void)
919 TestApplication application;
921 Actor actor = Actor::New();
922 actor.SetSize(100.0f, 100.0f);
923 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
924 Stage::GetCurrent().Add(actor);
927 application.SendNotification();
928 application.Render();
930 // Attach actor to detector
932 GestureReceivedFunctor functor( data );
933 LongPressGestureDetector detector = LongPressGestureDetector::New();
934 detector.Attach(actor);
935 detector.DetectedSignal().Connect( &application, functor );
940 application.ProcessEvent(GenerateLongPress(Gesture::Clear, 1u, Vector2(50.0f, 10.0f)));
941 tet_result(TET_FAIL);
943 catch ( Dali::DaliException& e )
945 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
950 int UtcDaliLongPressGestureEmitIncorrectStateContinuing(void)
952 TestApplication application;
954 Actor actor = Actor::New();
955 actor.SetSize(100.0f, 100.0f);
956 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
957 Stage::GetCurrent().Add(actor);
960 application.SendNotification();
961 application.Render();
963 // Attach actor to detector
965 GestureReceivedFunctor functor( data );
966 LongPressGestureDetector detector = LongPressGestureDetector::New();
967 detector.Attach(actor);
968 detector.DetectedSignal().Connect( &application, functor );
970 // Try a Continuing state
973 application.ProcessEvent(GenerateLongPress(Gesture::Continuing, 1u, Vector2(50.0f, 10.0f)));
974 tet_result(TET_FAIL);
976 catch ( Dali::DaliException& e )
978 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
983 int UtcDaliLongPressGestureRepeatedState(void)
985 TestApplication application;
987 Actor actor = Actor::New();
988 actor.SetSize(100.0f, 100.0f);
989 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
990 Stage::GetCurrent().Add(actor);
993 application.SendNotification();
994 application.Render();
996 // Attach actor to detector
998 GestureReceivedFunctor functor( data );
999 LongPressGestureDetector detector = LongPressGestureDetector::New();
1000 detector.Attach(actor);
1001 detector.DetectedSignal().Connect( &application, functor );
1004 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1005 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1006 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1007 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1009 // ... Send some finished states, still no signal
1010 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1011 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1012 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1013 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1015 // Send two Started states, should be signalled
1016 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1017 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1018 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1019 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1021 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1022 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1024 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1025 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1028 // Send two cancelled states, should not be signalled
1029 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1030 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1031 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1032 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1036 int UtcDaliLongPressGesturePossibleCancelled(void)
1038 TestApplication application;
1040 Actor actor = Actor::New();
1041 actor.SetSize(100.0f, 100.0f);
1042 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1043 Stage::GetCurrent().Add(actor);
1045 // Render and notify
1046 application.SendNotification();
1047 application.Render();
1049 // Attach actor to detector
1051 GestureReceivedFunctor functor( data );
1052 LongPressGestureDetector detector = LongPressGestureDetector::New();
1053 detector.Attach(actor);
1054 detector.DetectedSignal().Connect( &application, functor );
1056 // Send a possible followed by a cancel, we should not be signalled
1057 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1058 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1059 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1060 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1064 int UtcDaliLongPressGestureDetachAfterStarted(void)
1066 TestApplication application;
1068 Actor actor = Actor::New();
1069 actor.SetSize(100.0f, 100.0f);
1070 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1071 Stage::GetCurrent().Add(actor);
1073 // Render and notify
1074 application.SendNotification();
1075 application.Render();
1077 // Attach actor to detector
1079 GestureReceivedFunctor functor( data );
1080 LongPressGestureDetector detector = LongPressGestureDetector::New();
1081 detector.Attach(actor);
1082 detector.DetectedSignal().Connect( &application, functor );
1084 // Emit initial signal
1085 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1086 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1087 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1091 detector.Detach(actor);
1093 // Emit Finished, no signal
1094 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1095 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1099 int UtcDaliLongPressGestureActorUnstaged(void)
1101 TestApplication application;
1103 Actor actor = Actor::New();
1104 actor.SetSize(100.0f, 100.0f);
1105 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1106 Stage::GetCurrent().Add(actor);
1108 // Render and notify
1109 application.SendNotification();
1110 application.Render();
1112 // State to remove actor in.
1113 Gesture::State stateToUnstage( Gesture::Started );
1115 // Attach actor to detector
1117 UnstageActorFunctor functor( data, stateToUnstage );
1118 LongPressGestureDetector detector = LongPressGestureDetector::New();
1119 detector.Attach(actor);
1120 detector.DetectedSignal().Connect( &application, functor );
1123 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1124 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1125 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1127 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1128 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Re-add actor to stage
1135 Stage::GetCurrent().Add(actor);
1137 // Render and notify
1138 application.SendNotification();
1139 application.Render();
1141 // Change state to Gesture::Continuing to remove
1142 stateToUnstage = Gesture::Finished;
1145 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1146 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1147 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1149 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1150 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1151 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1155 int UtcDaliLongPressGestureActorStagedAndDestroyed(void)
1157 TestApplication application;
1159 Actor actor = Actor::New();
1160 actor.SetSize(100.0f, 100.0f);
1161 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1162 Stage::GetCurrent().Add(actor);
1164 // Create and add a second actor so that GestureDetector destruction does not come into play.
1165 Actor dummyActor( Actor::New() );
1166 dummyActor.SetSize( 100.0f, 100.0f );
1167 dummyActor.SetPosition( 100.0f, 100.0f );
1168 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1169 Stage::GetCurrent().Add(dummyActor);
1171 // Render and notify
1172 application.SendNotification();
1173 application.Render();
1175 // State to remove actor in.
1176 Gesture::State stateToUnstage( Gesture::Started );
1178 // Attach actor to detector
1180 UnstageActorFunctor functor( data, stateToUnstage );
1181 LongPressGestureDetector detector = LongPressGestureDetector::New();
1182 detector.Attach(actor);
1183 detector.Attach(dummyActor);
1184 detector.DetectedSignal().Connect( &application, functor );
1186 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1187 // before we get a finished state. As we were removed from the stage, even if we're at the same
1188 // position, we should still not be signalled.
1191 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1192 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1193 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 // Re add to the stage, we should not be signalled
1201 Stage::GetCurrent().Add(actor);
1203 // Render and notify
1204 application.SendNotification();
1205 application.Render();
1207 // Continue signal emission
1208 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1209 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1212 // Here we delete an actor in started, we should not receive any subsequent signalling.
1215 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1216 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1217 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1220 // Render and notify
1221 application.SendNotification();
1222 application.Render();
1224 // Delete actor as well
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Continue signal emission
1232 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1233 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1237 int UtcDaliLongPressGestureSystemOverlay(void)
1239 TestApplication application;
1240 Dali::Integration::Core& core = application.GetCore();
1241 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1242 systemOverlay.GetOverlayRenderTasks().CreateTask();
1244 Actor actor = Actor::New();
1245 actor.SetSize(100.0f, 100.0f);
1246 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1247 systemOverlay.Add(actor);
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1254 GestureReceivedFunctor functor(data);
1256 LongPressGestureDetector detector = LongPressGestureDetector::New();
1257 detector.Attach(actor);
1258 detector.DetectedSignal().Connect(&application, functor);
1260 // Do a long press inside actor's area
1261 Vector2 screenCoords( 50.0f, 50.0f );
1262 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) );
1263 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) );
1264 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );