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.
21 #include <dali/dali.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/long-press-gesture-event.h>
24 #include <dali/integration-api/system-overlay.h>
25 #include <dali-test-suite-utils.h>
29 void utc_dali_long_press_gesture_detector_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_long_press_gesture_detector_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled( false ),
48 voidFunctorCalled( false ),
49 receivedGesture( Gesture::Clear ),
55 functorCalled = false;
56 voidFunctorCalled = false;
58 receivedGesture.numberOfTouches = 0u;
59 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
60 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
66 bool voidFunctorCalled;
67 LongPressGesture receivedGesture;
71 // Functor that sets the data when called
72 struct GestureReceivedFunctor
74 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
76 void operator()(Actor actor, LongPressGesture longPress)
78 signalData.functorCalled = true;
79 signalData.receivedGesture = longPress;
80 signalData.pressedActor = actor;
85 signalData.voidFunctorCalled = true;
88 SignalData& signalData;
91 // Functor that removes the gestured actor from stage
92 struct UnstageActorFunctor : public GestureReceivedFunctor
94 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
95 : GestureReceivedFunctor( data ),
96 stateToUnstage( stateToUnstage )
100 void operator()( Actor actor, LongPressGesture longPress )
102 GestureReceivedFunctor::operator()( actor, longPress );
104 if ( longPress.state == stateToUnstage )
106 Stage::GetCurrent().Remove( actor );
110 Gesture::State& stateToUnstage;
113 // Functor for receiving a touch event
114 struct TouchEventFunctor
116 bool operator()(Actor actor, const TouchEvent& touch)
119 unsigned int points = touch.GetPointCount();
122 const TouchPoint& touchPoint = touch.GetPoint(0);
123 tet_printf("Touch Point state = %d\n", touchPoint.state);
129 // Generate a LongPressGestureEvent to send to Core
130 Integration::LongPressGestureEvent GenerateLongPress(
131 Gesture::State state,
132 unsigned int numberOfTouches,
135 Integration::LongPressGestureEvent longPress( state );
137 longPress.numberOfTouches = numberOfTouches;
138 longPress.point = point;
145 ///////////////////////////////////////////////////////////////////////////////
148 // Positive test case for a method
149 int UtcDaliLongPressGestureDetectorConstructor(void)
151 TestApplication application;
153 LongPressGestureDetector detector;
154 DALI_TEST_CHECK(!detector);
159 int UtcDaliLongPressGestureDetectorNew(void)
161 TestApplication application;
163 LongPressGestureDetector detector = LongPressGestureDetector::New();
164 DALI_TEST_CHECK(detector);
165 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
166 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
168 LongPressGestureDetector detector2 = LongPressGestureDetector::New(5u);
169 DALI_TEST_CHECK(detector2);
170 DALI_TEST_EQUALS(5u, detector2.GetMinimumTouchesRequired(), TEST_LOCATION);
171 DALI_TEST_EQUALS(5u, detector2.GetMaximumTouchesRequired(), TEST_LOCATION);
173 LongPressGestureDetector detector3 = LongPressGestureDetector::New(5u, 7u);
174 DALI_TEST_CHECK(detector2);
175 DALI_TEST_EQUALS(5u, detector3.GetMinimumTouchesRequired(), TEST_LOCATION);
176 DALI_TEST_EQUALS(7u, detector3.GetMaximumTouchesRequired(), TEST_LOCATION);
178 //Scoped test to test destructor
180 LongPressGestureDetector detector4 = LongPressGestureDetector::New();
181 DALI_TEST_CHECK(detector4);
184 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
185 Actor actor = Actor::New();
186 actor.SetSize(100.0f, 100.0f);
187 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
188 Stage::GetCurrent().Add(actor);
191 application.SendNotification();
192 application.Render();
194 detector.Attach(actor);
196 TouchEventFunctor touchFunctor;
197 actor.TouchedSignal().Connect(&application, touchFunctor);
199 Integration::TouchEvent touchEvent(1);
200 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
201 touchEvent.AddPoint(point);
202 application.ProcessEvent(touchEvent);
205 application.SendNotification();
206 application.Render();
208 // For line coverage, Initialise default constructor
209 TouchEvent touchEvent2;
213 int UtcDaliLongPressGestureDetectorDownCast(void)
215 TestApplication application;
216 tet_infoline("Testing Dali::LongPressGestureDetector::DownCast()");
218 LongPressGestureDetector detector = LongPressGestureDetector::New();
220 BaseHandle object(detector);
222 LongPressGestureDetector detector2 = LongPressGestureDetector::DownCast(object);
223 DALI_TEST_CHECK(detector2);
225 LongPressGestureDetector detector3 = DownCast< LongPressGestureDetector >(object);
226 DALI_TEST_CHECK(detector3);
228 BaseHandle unInitializedObject;
229 LongPressGestureDetector detector4 = LongPressGestureDetector::DownCast(unInitializedObject);
230 DALI_TEST_CHECK(!detector4);
232 LongPressGestureDetector detector5 = DownCast< LongPressGestureDetector >(unInitializedObject);
233 DALI_TEST_CHECK(!detector5);
235 GestureDetector detector6 = LongPressGestureDetector::New();
236 LongPressGestureDetector detector7 = LongPressGestureDetector::DownCast(detector6);
237 DALI_TEST_CHECK(detector7);
241 int UtcDaliLongPressGestureSetTouchesRequired01(void)
243 TestApplication application;
245 LongPressGestureDetector detector = LongPressGestureDetector::New();
247 unsigned int touches = 3;
249 DALI_TEST_CHECK(touches != detector.GetMinimumTouchesRequired());
250 DALI_TEST_CHECK(touches != detector.GetMaximumTouchesRequired());
252 detector.SetTouchesRequired(touches);
254 DALI_TEST_EQUALS(touches, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
255 DALI_TEST_EQUALS(touches, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
257 // Attach an actor and change the required touches
259 Actor actor = Actor::New();
260 actor.SetSize(100.0f, 100.0f);
261 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
262 Stage::GetCurrent().Add(actor);
265 application.SendNotification();
266 application.Render();
269 GestureReceivedFunctor functor(data);
271 detector.Attach(actor);
272 detector.DetectedSignal().Connect(&application, functor);
274 TestGestureManager& gestureManager = application.GetGestureManager();
275 gestureManager.Initialize();
277 detector.SetTouchesRequired(4);
279 // Gesture detection should have been updated only
280 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
281 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
282 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
285 gestureManager.Initialize();
287 // Create a second gesture detector that requires even less maximum touches
288 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
289 secondDetector.Attach(actor);
291 // Gesture detection should have been updated
292 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
293 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
294 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
298 int UtcDaliLongPressGestureSetTouchesRequired02(void)
300 TestApplication application;
302 LongPressGestureDetector detector = LongPressGestureDetector::New();
304 unsigned int min = 3;
305 unsigned int max = 5;
307 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
308 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
310 detector.SetTouchesRequired(min, max);
312 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
313 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
315 // Attach an actor and change the maximum 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.SetTouchesRequired(4, 5);
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 maximum touches
346 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
347 secondDetector.Attach(actor);
349 // Gesture detection should have been updated
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 UtcDaliLongPressGestureGetMinimumTouchesRequired(void)
358 TestApplication application;
360 LongPressGestureDetector detector = LongPressGestureDetector::New();
361 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
365 int UtcDaliLongPressGestureGetMaximumTouchesRequired(void)
367 TestApplication application;
369 LongPressGestureDetector detector = LongPressGestureDetector::New();
370 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
374 int UtcDaliLongPressGestureSignalReceptionNegative(void)
376 TestApplication application;
378 Actor actor = Actor::New();
379 actor.SetSize(100.0f, 100.0f);
380 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
381 Stage::GetCurrent().Add(actor);
384 application.SendNotification();
385 application.Render();
388 GestureReceivedFunctor functor(data);
390 LongPressGestureDetector detector = LongPressGestureDetector::New();
391 detector.Attach(actor);
392 detector.DetectedSignal().Connect(&application, functor);
394 // Do a long press outside actor's area
395 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2(112.0f, 112.0f ) ) );
396 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2(112.0f, 112.0f ) ) );
397 application.ProcessEvent( GenerateLongPress( Gesture::Finished, 1u, Vector2(112.0f, 112.0f ) ) );
398 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
402 int UtcDaliLongPressGestureSignalReceptionPositive(void)
404 TestApplication application;
406 Actor actor = Actor::New();
407 actor.SetSize(100.0f, 100.0f);
408 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
409 Stage::GetCurrent().Add(actor);
412 application.SendNotification();
413 application.Render();
416 GestureReceivedFunctor functor(data);
418 LongPressGestureDetector detector = LongPressGestureDetector::New();
419 detector.Attach(actor);
420 detector.DetectedSignal().Connect(&application, functor);
422 // Do a long press inside actor's area
423 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
424 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
425 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
426 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
427 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
428 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
432 int UtcDaliLongPressGestureSignalReceptionDetach(void)
434 TestApplication application;
436 Actor actor = Actor::New();
437 actor.SetSize(100.0f, 100.0f);
438 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
439 Stage::GetCurrent().Add(actor);
442 application.SendNotification();
443 application.Render();
446 GestureReceivedFunctor functor(data);
448 LongPressGestureDetector detector = LongPressGestureDetector::New();
449 detector.Attach(actor);
450 detector.DetectedSignal().Connect(&application, functor);
452 // Start long press within the actor's area
453 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
454 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
455 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
456 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
457 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
458 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f)));
460 // repeat the long press within the actor's area - we should still receive the signal
462 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
463 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
464 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
465 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
466 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
467 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
470 detector.DetachAll();
472 // Ensure we are no longer signalled
474 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
475 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
476 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
477 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
478 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
482 int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void)
484 TestApplication application;
487 GestureReceivedFunctor functor(data);
489 LongPressGestureDetector detector = LongPressGestureDetector::New();
490 detector.DetectedSignal().Connect(&application, functor);
492 // Actor lifetime is scoped
494 Actor actor = Actor::New();
495 actor.SetSize(100.0f, 100.0f);
496 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
497 Stage::GetCurrent().Add(actor);
500 application.SendNotification();
501 application.Render();
503 detector.Attach(actor);
505 // Start long press within the actor's area
506 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f)));
507 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f)));
508 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
510 // Remove the actor from stage and reset the data
511 Stage::GetCurrent().Remove(actor);
514 application.SendNotification();
515 application.Render();
518 // Actor should now have been destroyed
521 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f)));
522 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
526 int UtcDaliLongPressGestureSignalReceptionRotatedActor(void)
528 TestApplication application;
530 Actor actor = Actor::New();
531 actor.SetSize(100.0f, 100.0f);
532 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
533 Stage::GetCurrent().Add(actor);
536 application.SendNotification();
537 application.Render();
540 GestureReceivedFunctor functor(data);
542 LongPressGestureDetector detector = LongPressGestureDetector::New();
543 detector.Attach(actor);
544 detector.DetectedSignal().Connect(&application, functor);
547 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f)));
548 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f)));
549 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f)));
550 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
551 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
552 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
554 // Rotate actor again and render
555 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
556 application.SendNotification();
557 application.Render();
559 // Do another long press, should still receive event
561 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f)));
562 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f)));
563 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f)));
564 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
565 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
566 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
568 // Rotate actor again and render
569 actor.SetRotation(Dali::Degree(90.0f), Vector3::YAXIS);
570 application.SendNotification();
571 application.Render();
573 // Do a long press, inside where the actor used to be, Should not receive the event
575 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(70.0f, 70.0f)));
576 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(70.0f, 70.0f)));
577 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(70.0f, 70.0f)));
578 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
582 int UtcDaliLongPressGestureSignalReceptionChildHit(void)
584 TestApplication application;
586 Actor parent = Actor::New();
587 parent.SetSize(100.0f, 100.0f);
588 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
589 Stage::GetCurrent().Add(parent);
591 // Set child to completely cover parent.
592 // Change rotation of child to be different from parent so that we can check if our local coordinate
593 // conversion of the parent actor is correct.
594 Actor child = Actor::New();
595 child.SetSize(100.0f, 100.0f);
596 child.SetAnchorPoint(AnchorPoint::CENTER);
597 child.SetParentOrigin(ParentOrigin::CENTER);
598 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
601 TouchEventFunctor touchFunctor;
602 child.TouchedSignal().Connect(&application, touchFunctor);
605 application.SendNotification();
606 application.Render();
609 GestureReceivedFunctor functor(data);
611 LongPressGestureDetector detector = LongPressGestureDetector::New();
612 detector.Attach(parent);
613 detector.DetectedSignal().Connect(&application, functor);
615 // Do long press - hits child area but parent should still receive it
616 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f)));
617 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f)));
618 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f)));
619 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
620 DALI_TEST_EQUALS(true, parent == data.pressedActor, TEST_LOCATION);
621 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
623 // Attach child and generate same touch points
624 // (Also proves that you can detach and then re-attach another actor)
625 detector.Attach(child);
626 detector.Detach(parent);
628 // Do an entire long press, only check finished value
630 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(51.0f, 51.0f)));
631 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(51.0f, 51.0f)));
632 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(51.0f, 51.0f)));
633 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
634 DALI_TEST_EQUALS(true, child == data.pressedActor, TEST_LOCATION);
635 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
639 int UtcDaliLongPressGestureSignalReceptionAttachDetachMany(void)
641 TestApplication application;
643 Actor first = Actor::New();
644 first.SetSize(100.0f, 100.0f);
645 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
646 Stage::GetCurrent().Add(first);
648 Actor second = Actor::New();
649 second.SetSize(100.0f, 100.0f);
651 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
652 Stage::GetCurrent().Add(second);
655 application.SendNotification();
656 application.Render();
659 GestureReceivedFunctor functor(data);
661 LongPressGestureDetector detector = LongPressGestureDetector::New();
662 detector.Attach(first);
663 detector.Attach(second);
664 detector.DetectedSignal().Connect(&application, functor);
666 // LongPress within second actor's area
667 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f)));
668 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f)));
669 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f)));
670 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
671 DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION);
673 // LongPress within first actor's area
675 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f)));
676 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f)));
677 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f)));
678 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
679 DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION);
681 // Detach the second actor
682 detector.Detach(second);
684 // second actor shouldn't receive event
686 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f)));
687 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f)));
688 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f)));
689 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
691 // first actor should continue receiving event
693 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f)));
694 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f)));
695 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f)));
696 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
700 int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void)
702 TestApplication application;
704 Actor actor = Actor::New();
705 actor.SetSize(100.0f, 100.0f);
706 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
707 Stage::GetCurrent().Add(actor);
710 application.SendNotification();
711 application.Render();
714 GestureReceivedFunctor functor(data);
716 LongPressGestureDetector detector = LongPressGestureDetector::New();
717 detector.Attach(actor);
718 detector.DetectedSignal().Connect(&application, functor);
720 // LongPress in actor's area
721 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
722 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
723 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
724 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
726 // Actor becomes invisible - actor should not receive the next long press
727 actor.SetVisible(false);
730 application.SendNotification();
731 application.Render();
733 // LongPress in the same area, shouldn't receive event
735 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
736 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
737 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
738 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
742 int UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors(void)
744 TestApplication application;
745 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
747 Actor first = Actor::New();
748 first.SetSize(100.0f, 100.0f);
749 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
750 Stage::GetCurrent().Add(first);
752 Actor second = Actor::New();
753 second.SetSize(100.0f, 100.0f);
754 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
759 application.SendNotification();
760 application.Render();
763 GestureReceivedFunctor functor(data);
765 LongPressGestureDetector firstDetector = LongPressGestureDetector::New();
766 firstDetector.Attach(first);
767 firstDetector.DetectedSignal().Connect(&application, functor);
769 // secondDetector is scoped
771 // Reset gestureManager statistics
772 gestureManager.Initialize();
774 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
775 secondDetector.SetTouchesRequired(2);
776 secondDetector.Attach(second);
777 secondDetector.DetectedSignal().Connect(&application, functor);
779 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
780 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
781 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
783 // LongPress within second actor's area
784 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(150.0f, 10.0f)));
785 application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(150.0f, 10.0f)));
786 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(150.0f, 10.0f)));
787 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
788 DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION);
790 // LongPress continues as single touch gesture - we should not receive any gesture
792 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(150.0f, 10.0f)));
793 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(150.0f, 10.0f)));
794 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(150.0f, 10.0f)));
795 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
797 // Single touch long press starts - first actor should receive gesture
799 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
800 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
801 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
802 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
803 DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION);
805 // long press changes to double-touch - we shouldn't receive event
807 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(50.0f, 10.0f)));
808 application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(50.0f, 10.0f)));
809 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(50.0f, 10.0f)));
810 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
812 // Reset gesture manager statistics
813 gestureManager.Initialize();
816 // secondDetector has now been deleted. Gesture detection should have been updated only
817 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
818 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
819 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
823 int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void)
825 TestApplication application;
827 Actor actor = Actor::New();
828 actor.SetSize(100.0f, 100.0f);
829 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
830 Stage::GetCurrent().Add(actor);
833 application.SendNotification();
834 application.Render();
836 // Attach actor to one detector
837 SignalData firstData;
838 GestureReceivedFunctor firstFunctor(firstData);
839 LongPressGestureDetector firstDetector = LongPressGestureDetector::New();
840 firstDetector.Attach(actor);
841 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
843 // Attach actor to another detector
844 SignalData secondData;
845 GestureReceivedFunctor secondFunctor(secondData);
846 LongPressGestureDetector secondDetector = LongPressGestureDetector::New();
847 secondDetector.Attach(actor);
848 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
850 // LongPress in actor's area - both detector's functors should be called
851 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
852 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
853 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
854 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
858 int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void)
860 TestApplication application;
862 Actor actor = Actor::New();
863 actor.SetSize(100.0f, 100.0f);
864 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
865 Stage::GetCurrent().Add(actor);
868 application.SendNotification();
869 application.Render();
871 // Attach actor to detector
873 GestureReceivedFunctor functor( data );
874 LongPressGestureDetector detector = LongPressGestureDetector::New();
875 detector.Attach(actor);
876 detector.DetectedSignal().Connect( &application, functor );
878 // LongPress possible in actor's area.
879 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
880 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
882 // Move actor somewhere else
883 actor.SetPosition( 100.0f, 100.0f );
886 application.SendNotification();
887 application.Render();
889 // Emit Started event, we should not receive the long press.
890 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
891 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
892 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
894 // LongPress possible in empty area.
895 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
896 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
898 // Move actor in to the long press position.
899 actor.SetPosition( 0.0f, 0.0f );
902 application.SendNotification();
903 application.Render();
905 // Emit Started event, we should not receive the long press.
906 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
907 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
908 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
910 // Normal long press in actor's area for completeness.
911 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
912 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
913 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
914 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
918 int UtcDaliLongPressGestureEmitIncorrectStateClear(void)
920 TestApplication application;
922 Actor actor = Actor::New();
923 actor.SetSize(100.0f, 100.0f);
924 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
925 Stage::GetCurrent().Add(actor);
928 application.SendNotification();
929 application.Render();
931 // Attach actor to detector
933 GestureReceivedFunctor functor( data );
934 LongPressGestureDetector detector = LongPressGestureDetector::New();
935 detector.Attach(actor);
936 detector.DetectedSignal().Connect( &application, functor );
941 application.ProcessEvent(GenerateLongPress(Gesture::Clear, 1u, Vector2(50.0f, 10.0f)));
942 tet_result(TET_FAIL);
944 catch ( Dali::DaliException& e )
946 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
951 int UtcDaliLongPressGestureEmitIncorrectStateContinuing(void)
953 TestApplication application;
955 Actor actor = Actor::New();
956 actor.SetSize(100.0f, 100.0f);
957 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
958 Stage::GetCurrent().Add(actor);
961 application.SendNotification();
962 application.Render();
964 // Attach actor to detector
966 GestureReceivedFunctor functor( data );
967 LongPressGestureDetector detector = LongPressGestureDetector::New();
968 detector.Attach(actor);
969 detector.DetectedSignal().Connect( &application, functor );
971 // Try a Continuing state
974 application.ProcessEvent(GenerateLongPress(Gesture::Continuing, 1u, Vector2(50.0f, 10.0f)));
975 tet_result(TET_FAIL);
977 catch ( Dali::DaliException& e )
979 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
984 int UtcDaliLongPressGestureRepeatedState(void)
986 TestApplication application;
988 Actor actor = Actor::New();
989 actor.SetSize(100.0f, 100.0f);
990 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
991 Stage::GetCurrent().Add(actor);
994 application.SendNotification();
995 application.Render();
997 // Attach actor to detector
999 GestureReceivedFunctor functor( data );
1000 LongPressGestureDetector detector = LongPressGestureDetector::New();
1001 detector.Attach(actor);
1002 detector.DetectedSignal().Connect( &application, functor );
1005 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1006 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1007 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1008 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1010 // ... Send some finished states, still no signal
1011 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1012 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1013 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1014 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1016 // Send two Started states, should be signalled
1017 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1018 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1019 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1020 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1022 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1023 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1025 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1026 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1029 // Send two cancelled states, should not be signalled
1030 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1031 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1032 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1033 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1037 int UtcDaliLongPressGesturePossibleCancelled(void)
1039 TestApplication application;
1041 Actor actor = Actor::New();
1042 actor.SetSize(100.0f, 100.0f);
1043 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1044 Stage::GetCurrent().Add(actor);
1046 // Render and notify
1047 application.SendNotification();
1048 application.Render();
1050 // Attach actor to detector
1052 GestureReceivedFunctor functor( data );
1053 LongPressGestureDetector detector = LongPressGestureDetector::New();
1054 detector.Attach(actor);
1055 detector.DetectedSignal().Connect( &application, functor );
1057 // Send a possible followed by a cancel, we should not be signalled
1058 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1059 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1060 application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f)));
1061 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1065 int UtcDaliLongPressGestureDetachAfterStarted(void)
1067 TestApplication application;
1069 Actor actor = Actor::New();
1070 actor.SetSize(100.0f, 100.0f);
1071 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1072 Stage::GetCurrent().Add(actor);
1074 // Render and notify
1075 application.SendNotification();
1076 application.Render();
1078 // Attach actor to detector
1080 GestureReceivedFunctor functor( data );
1081 LongPressGestureDetector detector = LongPressGestureDetector::New();
1082 detector.Attach(actor);
1083 detector.DetectedSignal().Connect( &application, functor );
1085 // Emit initial signal
1086 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1087 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1088 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1092 detector.Detach(actor);
1094 // Emit Finished, no signal
1095 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1096 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1100 int UtcDaliLongPressGestureActorUnstaged(void)
1102 TestApplication application;
1104 Actor actor = Actor::New();
1105 actor.SetSize(100.0f, 100.0f);
1106 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1107 Stage::GetCurrent().Add(actor);
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1113 // State to remove actor in.
1114 Gesture::State stateToUnstage( Gesture::Started );
1116 // Attach actor to detector
1118 UnstageActorFunctor functor( data, stateToUnstage );
1119 LongPressGestureDetector detector = LongPressGestureDetector::New();
1120 detector.Attach(actor);
1121 detector.DetectedSignal().Connect( &application, functor );
1124 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1125 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1126 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1128 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1129 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1131 // Render and notify
1132 application.SendNotification();
1133 application.Render();
1135 // Re-add actor to stage
1136 Stage::GetCurrent().Add(actor);
1138 // Render and notify
1139 application.SendNotification();
1140 application.Render();
1142 // Change state to Gesture::Continuing to remove
1143 stateToUnstage = Gesture::Finished;
1146 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1147 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1148 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1150 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1151 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1152 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1156 int UtcDaliLongPressGestureActorStagedAndDestroyed(void)
1158 TestApplication application;
1160 Actor actor = Actor::New();
1161 actor.SetSize(100.0f, 100.0f);
1162 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1163 Stage::GetCurrent().Add(actor);
1165 // Create and add a second actor so that GestureDetector destruction does not come into play.
1166 Actor dummyActor( Actor::New() );
1167 dummyActor.SetSize( 100.0f, 100.0f );
1168 dummyActor.SetPosition( 100.0f, 100.0f );
1169 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1170 Stage::GetCurrent().Add(dummyActor);
1172 // Render and notify
1173 application.SendNotification();
1174 application.Render();
1176 // State to remove actor in.
1177 Gesture::State stateToUnstage( Gesture::Started );
1179 // Attach actor to detector
1181 UnstageActorFunctor functor( data, stateToUnstage );
1182 LongPressGestureDetector detector = LongPressGestureDetector::New();
1183 detector.Attach(actor);
1184 detector.Attach(dummyActor);
1185 detector.DetectedSignal().Connect( &application, functor );
1187 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1188 // before we get a finished state. As we were removed from the stage, even if we're at the same
1189 // position, we should still not be signalled.
1192 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1193 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1194 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Re add to the stage, we should not be signalled
1202 Stage::GetCurrent().Add(actor);
1204 // Render and notify
1205 application.SendNotification();
1206 application.Render();
1208 // Continue signal emission
1209 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1210 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1213 // Here we delete an actor in started, we should not receive any subsequent signalling.
1216 application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f)));
1217 application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f)));
1218 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1221 // Render and notify
1222 application.SendNotification();
1223 application.Render();
1225 // Delete actor as well
1228 // Render and notify
1229 application.SendNotification();
1230 application.Render();
1232 // Continue signal emission
1233 application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f)));
1234 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1238 int UtcDaliLongPressGestureSystemOverlay(void)
1240 TestApplication application;
1241 Dali::Integration::Core& core = application.GetCore();
1242 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1243 systemOverlay.GetOverlayRenderTasks().CreateTask();
1245 Actor actor = Actor::New();
1246 actor.SetSize(100.0f, 100.0f);
1247 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1248 systemOverlay.Add(actor);
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1255 GestureReceivedFunctor functor(data);
1257 LongPressGestureDetector detector = LongPressGestureDetector::New();
1258 detector.Attach(actor);
1259 detector.DetectedSignal().Connect(&application, functor);
1261 // Do a long press inside actor's area
1262 Vector2 screenCoords( 50.0f, 50.0f );
1263 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) );
1264 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) );
1265 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );