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/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/tap-gesture-event.h>
24 #include <dali/integration-api/system-overlay.h>
25 #include <dali-test-suite-utils.h>
26 #include <test-touch-utils.h>
30 void utc_dali_tap_gesture_detector_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_tap_gesture_detector_cleanup(void)
37 test_return_value = TET_PASS;
40 ///////////////////////////////////////////////////////////////////////////////
44 // Stores data that is populated in the callback and will be read by the TET cases
48 : functorCalled(false),
49 voidFunctorCalled(false)
54 functorCalled = false;
55 voidFunctorCalled = false;
57 receivedGesture.numberOfTaps = 0u;
58 receivedGesture.numberOfTouches = 0u;
59 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
60 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
66 bool voidFunctorCalled;
67 TapGesture receivedGesture;
71 // Functor that sets the data when called
72 struct GestureReceivedFunctor
74 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
76 void operator()(Actor actor, const TapGesture& tap)
78 signalData.functorCalled = true;
79 signalData.receivedGesture = tap;
80 signalData.tappedActor = 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 ) : GestureReceivedFunctor( data ) { }
96 void operator()(Actor actor, const TapGesture& tap)
98 GestureReceivedFunctor::operator()( actor, tap );
99 Stage::GetCurrent().Remove( actor );
103 // Functor for receiving a touch event
104 struct TouchEventFunctor
106 bool operator()(Actor actor, const TouchEvent& touch)
109 unsigned int points = touch.GetPointCount();
112 const TouchPoint& touchPoint = touch.GetPoint(0);
113 tet_printf("Touch Point state = %d\n", touchPoint.state);
119 // Generate a TapGestureEvent to send to Core
120 Integration::TapGestureEvent GenerateTap(
121 Gesture::State state,
122 unsigned int numberOfTaps,
123 unsigned int numberOfTouches,
126 Integration::TapGestureEvent tap( state );
128 tap.numberOfTaps = numberOfTaps;
129 tap.numberOfTouches = numberOfTouches;
137 ///////////////////////////////////////////////////////////////////////////////
140 // Positive test case for a method
141 int UtcDaliTapGestureDetectorConstructor(void)
143 TestApplication application;
145 TapGestureDetector detector;
146 DALI_TEST_CHECK(!detector);
151 int UtcDaliTapGestureDetectorNew(void)
153 TestApplication application;
155 TapGestureDetector detector = TapGestureDetector::New();
156 DALI_TEST_CHECK(detector);
157 DALI_TEST_EQUALS(1u, detector.GetTapsRequired(), TEST_LOCATION);
158 DALI_TEST_EQUALS(1u, detector.GetTouchesRequired(), TEST_LOCATION);
160 TapGestureDetector detector2 = TapGestureDetector::New(5u, 5u);
161 DALI_TEST_CHECK(detector2);
162 DALI_TEST_EQUALS(5u, detector2.GetTapsRequired(), TEST_LOCATION);
163 DALI_TEST_EQUALS(5u, detector2.GetTouchesRequired(), TEST_LOCATION);
165 //Scoped test to test destructor
167 TapGestureDetector detector3 = TapGestureDetector::New();
168 DALI_TEST_CHECK(detector3);
171 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
172 Actor actor = Actor::New();
173 actor.SetSize(100.0f, 100.0f);
174 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
175 Stage::GetCurrent().Add(actor);
178 application.SendNotification();
179 application.Render();
181 detector.Attach(actor);
183 TouchEventFunctor touchFunctor;
184 actor.TouchedSignal().Connect( &application, touchFunctor );
186 Integration::TouchEvent touchEvent(1);
187 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
188 touchEvent.AddPoint(point);
189 application.ProcessEvent(touchEvent);
192 application.SendNotification();
193 application.Render();
195 // For line coverage, Initialise default constructor
196 TouchEvent touchEvent2;
200 int UtcDaliTapGestureDetectorDownCast(void)
202 TestApplication application;
203 tet_infoline("Testing Dali::TapGestureDetector::DownCast()");
205 TapGestureDetector detector = TapGestureDetector::New();
207 BaseHandle object(detector);
209 TapGestureDetector detector2 = TapGestureDetector::DownCast(object);
210 DALI_TEST_CHECK(detector2);
212 TapGestureDetector detector3 = DownCast< TapGestureDetector >(object);
213 DALI_TEST_CHECK(detector3);
215 BaseHandle unInitializedObject;
216 TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject);
217 DALI_TEST_CHECK(!detector4);
219 TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject);
220 DALI_TEST_CHECK(!detector5);
222 GestureDetector detector6 = TapGestureDetector::New();
223 TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6);
224 DALI_TEST_CHECK(detector7);
228 int UtcDaliTapGestureSetTapsRequired(void)
230 TestApplication application;
232 TapGestureDetector detector = TapGestureDetector::New();
234 unsigned int taps = 3;
236 DALI_TEST_CHECK(taps != detector.GetTapsRequired());
238 detector.SetTapsRequired(taps);
240 DALI_TEST_EQUALS(taps, detector.GetTapsRequired(), TEST_LOCATION);
242 // Attach an actor and change the required touches
244 Actor actor = Actor::New();
245 actor.SetSize(100.0f, 100.0f);
246 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
247 Stage::GetCurrent().Add(actor);
250 application.SendNotification();
251 application.Render();
254 GestureReceivedFunctor functor(data);
256 detector.Attach(actor);
257 detector.DetectedSignal().Connect( &application, functor );
259 TestGestureManager& gestureManager = application.GetGestureManager();
260 gestureManager.Initialize();
262 detector.SetTapsRequired(4);
264 // Gesture detection should have been updated only
265 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
266 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
267 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
270 gestureManager.Initialize();
272 // Create a second gesture detector that requires even less maximum touches
273 TapGestureDetector secondDetector = TapGestureDetector::New();
274 secondDetector.Attach(actor);
276 // Gesture detection should have been updated
277 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
278 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
279 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
283 int UtcDaliTapGestureGetTapsRequired(void)
285 TestApplication application;
287 TapGestureDetector detector = TapGestureDetector::New();
288 DALI_TEST_EQUALS(1u, detector.GetTapsRequired(), TEST_LOCATION);
292 int UtcDaliTapGestureSetTouchesRequired(void)
294 TestApplication application;
296 TapGestureDetector detector = TapGestureDetector::New();
298 unsigned int max = 3;
300 DALI_TEST_CHECK(max != detector.GetTouchesRequired());
302 detector.SetTouchesRequired(max);
304 DALI_TEST_EQUALS(max, detector.GetTouchesRequired(), TEST_LOCATION);
306 // Attach an actor and change the maximum touches
308 Actor actor = Actor::New();
309 actor.SetSize(100.0f, 100.0f);
310 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
311 Stage::GetCurrent().Add(actor);
314 application.SendNotification();
315 application.Render();
318 GestureReceivedFunctor functor(data);
320 detector.Attach(actor);
321 detector.DetectedSignal().Connect( &application, functor );
323 TestGestureManager& gestureManager = application.GetGestureManager();
324 gestureManager.Initialize();
326 detector.SetTouchesRequired(4);
328 // Gesture detection should have been updated only
329 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
330 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
331 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
334 gestureManager.Initialize();
336 // Create a second gesture detector that requires even less maximum touches
337 TapGestureDetector secondDetector = TapGestureDetector::New();
338 secondDetector.Attach(actor);
340 // Gesture detection should have been updated
341 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
342 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
343 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
347 int UtcDaliTapGestureGetTouchesRequired(void)
349 TestApplication application;
351 TapGestureDetector detector = TapGestureDetector::New();
352 DALI_TEST_EQUALS(1u, detector.GetTouchesRequired(), TEST_LOCATION);
356 int UtcDaliTapGestureSignalReceptionNegative(void)
358 TestApplication application;
360 Actor actor = Actor::New();
361 actor.SetSize(100.0f, 100.0f);
362 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
363 Stage::GetCurrent().Add(actor);
366 application.SendNotification();
367 application.Render();
370 GestureReceivedFunctor functor(data);
372 TapGestureDetector detector = TapGestureDetector::New();
373 detector.Attach(actor);
374 detector.DetectedSignal().Connect( &application, functor );
376 // Do a tap outside actor's area
377 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f)));
378 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f)));
379 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
383 int UtcDaliTapGestureSignalReceptionPositive(void)
385 TestApplication application;
387 Actor actor = Actor::New();
388 actor.SetSize(100.0f, 100.0f);
389 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
390 Stage::GetCurrent().Add(actor);
393 application.SendNotification();
394 application.Render();
397 GestureReceivedFunctor functor(data);
399 TapGestureDetector detector = TapGestureDetector::New();
400 detector.Attach(actor);
401 detector.DetectedSignal().Connect( &application, functor );
403 // Do a tap inside actor's area
404 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
405 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
406 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
407 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
408 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
409 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
413 int UtcDaliTapGestureSignalReceptionDetach(void)
415 TestApplication application;
417 Actor actor = Actor::New();
418 actor.SetSize(100.0f, 100.0f);
419 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
420 Stage::GetCurrent().Add(actor);
423 application.SendNotification();
424 application.Render();
427 GestureReceivedFunctor functor(data);
429 TapGestureDetector detector = TapGestureDetector::New();
430 detector.Attach(actor);
431 detector.DetectedSignal().Connect(&application, functor);
433 // Start tap within the actor's area
434 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
435 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
436 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
437 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
438 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
439 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
441 // repeat the tap within the actor's area - we should still receive the signal
443 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
444 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
445 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
446 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
447 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
448 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
451 detector.DetachAll();
453 // Ensure we are no longer signalled
455 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
456 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
457 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
458 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
459 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
460 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
464 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
466 TestApplication application;
469 GestureReceivedFunctor functor(data);
471 TapGestureDetector detector = TapGestureDetector::New();
472 detector.DetectedSignal().Connect(&application, functor);
474 // Actor lifetime is scoped
476 Actor actor = Actor::New();
477 actor.SetSize(100.0f, 100.0f);
478 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
479 Stage::GetCurrent().Add(actor);
482 application.SendNotification();
483 application.Render();
485 detector.Attach(actor);
487 // Start tap within the actor's area
488 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
489 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
490 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
492 // Remove the actor from stage and reset the data
493 Stage::GetCurrent().Remove(actor);
496 application.SendNotification();
497 application.Render();
500 // Actor should now have been destroyed
503 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
504 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
505 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
509 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
511 TestApplication application;
513 Actor actor = Actor::New();
514 actor.SetSize(100.0f, 100.0f);
515 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
516 Stage::GetCurrent().Add(actor);
519 application.SendNotification();
520 application.Render();
523 GestureReceivedFunctor functor(data);
525 TapGestureDetector detector = TapGestureDetector::New();
526 detector.Attach(actor);
527 detector.DetectedSignal().Connect(&application, functor);
529 // Do tap, only check finished value
530 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
531 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
532 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
533 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
534 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
535 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
537 // Rotate actor again and render
538 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
539 application.SendNotification();
540 application.Render();
542 // Do tap, should still receive event
544 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
545 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
546 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
547 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
548 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
549 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
551 // Rotate actor again and render
552 actor.SetRotation(Dali::Degree(90.0f), Vector3::YAXIS);
553 application.SendNotification();
554 application.Render();
556 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
558 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f)));
559 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f)));
560 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
564 int UtcDaliTapGestureSignalReceptionChildHit(void)
566 TestApplication application;
568 Actor parent = Actor::New();
569 parent.SetSize(100.0f, 100.0f);
570 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
571 Stage::GetCurrent().Add(parent);
573 // Set child to completely cover parent.
574 // Change rotation of child to be different from parent so that we can check if our local coordinate
575 // conversion of the parent actor is correct.
576 Actor child = Actor::New();
577 child.SetSize(100.0f, 100.0f);
578 child.SetAnchorPoint(AnchorPoint::CENTER);
579 child.SetParentOrigin(ParentOrigin::CENTER);
580 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
583 TouchEventFunctor touchFunctor;
584 child.TouchedSignal().Connect(&application, touchFunctor);
587 application.SendNotification();
588 application.Render();
591 GestureReceivedFunctor functor(data);
593 TapGestureDetector detector = TapGestureDetector::New();
594 detector.Attach(parent);
595 detector.DetectedSignal().Connect(&application, functor);
597 // Do tap - hits child area but parent should still receive it
598 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
599 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
600 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
601 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
602 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
604 // Attach child and generate same touch points
605 // (Also proves that you can detach and then re-attach another actor)
606 detector.Attach(child);
607 detector.Detach(parent);
609 // Do an entire tap, only check finished value
611 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f)));
612 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f)));
613 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
614 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
615 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
619 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
621 TestApplication application;
623 Actor first = Actor::New();
624 first.SetSize(100.0f, 100.0f);
625 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
626 Stage::GetCurrent().Add(first);
628 Actor second = Actor::New();
629 second.SetSize(100.0f, 100.0f);
631 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
632 Stage::GetCurrent().Add(second);
635 application.SendNotification();
636 application.Render();
639 GestureReceivedFunctor functor(data);
641 TapGestureDetector detector = TapGestureDetector::New();
642 detector.Attach(first);
643 detector.Attach(second);
644 detector.DetectedSignal().Connect(&application, functor);
646 // Tap within second actor's area
647 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
648 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
649 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
650 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
652 // Tap within first actor's area
654 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
655 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
656 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
657 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
659 // Detach the second actor
660 detector.Detach(second);
662 // second actor shouldn't receive event
664 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
665 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
666 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
668 // first actor should continue receiving event
670 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
671 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
672 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
676 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
678 TestApplication application;
680 Actor actor = Actor::New();
681 actor.SetSize(100.0f, 100.0f);
682 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
683 Stage::GetCurrent().Add(actor);
686 application.SendNotification();
687 application.Render();
690 GestureReceivedFunctor functor(data);
692 TapGestureDetector detector = TapGestureDetector::New();
693 detector.Attach(actor);
694 detector.DetectedSignal().Connect(&application, functor);
696 // Tap in actor's area
697 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
698 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
699 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
701 // Actor become invisible - actor should not receive the next pan
702 actor.SetVisible(false);
705 application.SendNotification();
706 application.Render();
708 // Tap in the same area, shouldn't receive event
710 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
711 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
712 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
716 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
718 TestApplication application;
719 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
721 Actor first = Actor::New();
722 first.SetSize(100.0f, 100.0f);
723 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
724 Stage::GetCurrent().Add(first);
726 Actor second = Actor::New();
727 second.SetSize(100.0f, 100.0f);
728 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
733 application.SendNotification();
734 application.Render();
737 GestureReceivedFunctor functor(data);
739 TapGestureDetector firstDetector = TapGestureDetector::New();
740 firstDetector.Attach(first);
741 firstDetector.DetectedSignal().Connect(&application, functor);
743 // secondDetector is scoped
745 // Reset gestureManager statistics
746 gestureManager.Initialize();
748 TapGestureDetector secondDetector = TapGestureDetector::New();
749 secondDetector.SetTapsRequired(2);
750 secondDetector.SetTouchesRequired(2);
751 secondDetector.Attach(second);
752 secondDetector.DetectedSignal().Connect(&application, functor);
754 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
755 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
756 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
758 // Tap within second actor's area
759 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(150.0f, 10.0f)));
760 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(150.0f, 10.0f)));
761 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
762 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
764 // Tap continues as single touch gesture - we should not receive any gesture
766 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f)));
767 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f)));
768 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
770 // Single touch tap starts - first actor should be panned
772 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
773 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
774 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
775 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
777 // Pan changes to double-touch - we shouldn't receive event
779 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f)));
780 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f)));
781 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
783 // Reset gesture manager statistics
784 gestureManager.Initialize();
787 // secondDetector has now been deleted. Gesture detection should have been updated only
788 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
789 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
790 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
794 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
796 TestApplication application;
798 Actor actor = Actor::New();
799 actor.SetSize(100.0f, 100.0f);
800 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
801 Stage::GetCurrent().Add(actor);
804 application.SendNotification();
805 application.Render();
807 // Attach actor to one detector
808 SignalData firstData;
809 GestureReceivedFunctor firstFunctor(firstData);
810 TapGestureDetector firstDetector = TapGestureDetector::New();
811 firstDetector.Attach(actor);
812 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
814 // Attach actor to another detector
815 SignalData secondData;
816 GestureReceivedFunctor secondFunctor(secondData);
817 TapGestureDetector secondDetector = TapGestureDetector::New();
818 secondDetector.Attach(actor);
819 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
821 // Tap in actor's area - both detector's functors should be called
822 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
823 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
824 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
825 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
829 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
831 TestApplication application;
833 Actor actor = Actor::New();
834 actor.SetSize(100.0f, 100.0f);
835 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836 Stage::GetCurrent().Add(actor);
839 application.SendNotification();
840 application.Render();
842 // Attach actor to detector
844 GestureReceivedFunctor functor( data );
845 TapGestureDetector detector = TapGestureDetector::New();
846 detector.Attach(actor);
847 detector.DetectedSignal().Connect( &application, functor );
849 // Gesture possible in actor's area.
850 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
851 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
853 // Move actor somewhere else
854 actor.SetPosition( 100.0f, 100.0f );
857 application.SendNotification();
858 application.Render();
860 // Emit Started event, we should not receive the long press.
861 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
862 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
864 // LongPress possible in empty area.
865 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
866 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
868 // Move actor in to the long press position.
869 actor.SetPosition( 0.0f, 0.0f );
872 application.SendNotification();
873 application.Render();
875 // Emit Started event, we should not receive the long press.
876 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
877 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
879 // Normal long press in actor's area for completeness.
880 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
881 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
882 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
886 int UtcDaliTapGestureEmitIncorrectStateClear(void)
888 TestApplication application;
890 Actor actor = Actor::New();
891 actor.SetSize(100.0f, 100.0f);
892 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
893 Stage::GetCurrent().Add(actor);
896 application.SendNotification();
897 application.Render();
899 // Attach actor to detector
901 GestureReceivedFunctor functor( data );
902 TapGestureDetector detector = TapGestureDetector::New();
903 detector.Attach(actor);
904 detector.DetectedSignal().Connect( &application, functor );
909 application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f)));
910 tet_result(TET_FAIL);
912 catch ( Dali::DaliException& e )
914 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
919 int UtcDaliTapGestureEmitIncorrectStateContinuing(void)
921 TestApplication application;
923 Actor actor = Actor::New();
924 actor.SetSize(100.0f, 100.0f);
925 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
926 Stage::GetCurrent().Add(actor);
929 application.SendNotification();
930 application.Render();
932 // Attach actor to detector
934 GestureReceivedFunctor functor( data );
935 TapGestureDetector detector = TapGestureDetector::New();
936 detector.Attach(actor);
937 detector.DetectedSignal().Connect( &application, functor );
939 // Try a Continuing state
942 application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f)));
943 tet_result(TET_FAIL);
945 catch ( Dali::DaliException& e )
947 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
952 int UtcDaliTapGestureEmitIncorrectStateFinished(void)
954 TestApplication application;
956 Actor actor = Actor::New();
957 actor.SetSize(100.0f, 100.0f);
958 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
959 Stage::GetCurrent().Add(actor);
962 application.SendNotification();
963 application.Render();
965 // Attach actor to detector
967 GestureReceivedFunctor functor( data );
968 TapGestureDetector detector = TapGestureDetector::New();
969 detector.Attach(actor);
970 detector.DetectedSignal().Connect( &application, functor );
972 // Try a Finished state
975 application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f)));
976 tet_result(TET_FAIL);
978 catch ( Dali::DaliException& e )
980 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
985 int UtcDaliTapGestureActorUnstaged(void)
987 TestApplication application;
989 Actor actor = Actor::New();
990 actor.SetSize(100.0f, 100.0f);
991 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
992 Stage::GetCurrent().Add(actor);
995 application.SendNotification();
996 application.Render();
998 // Attach actor to detector
1000 UnstageActorFunctor functor( data );
1001 TapGestureDetector detector = TapGestureDetector::New();
1002 detector.Attach(actor);
1003 detector.DetectedSignal().Connect( &application, functor );
1005 // Tap in Actor's area, actor removed in signal handler, should be handled gracefully.
1006 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1007 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1008 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1009 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
1013 int UtcDaliTapGestureRepeatedState(void)
1015 TestApplication application;
1017 Actor actor = Actor::New();
1018 actor.SetSize(100.0f, 100.0f);
1019 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1020 Stage::GetCurrent().Add(actor);
1022 // Render and notify
1023 application.SendNotification();
1024 application.Render();
1026 // Attach actor to detector
1028 GestureReceivedFunctor functor( data );
1029 TapGestureDetector detector = TapGestureDetector::New();
1030 detector.Attach(actor);
1031 detector.DetectedSignal().Connect( &application, functor );
1033 // Emit two possibles
1034 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1035 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1036 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1038 // Send a couple of Started states, only first one should be received.
1039 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1040 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1042 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1043 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1045 // Send a couple of cancelled states, no reception
1046 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1047 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1048 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1052 int UtcDaliTapGesturePossibleCancelled(void)
1054 TestApplication application;
1056 Actor actor = Actor::New();
1057 actor.SetSize(100.0f, 100.0f);
1058 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1059 Stage::GetCurrent().Add(actor);
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 // Attach actor to detector
1067 GestureReceivedFunctor functor( data );
1068 TapGestureDetector detector = TapGestureDetector::New();
1069 detector.Attach(actor);
1070 detector.DetectedSignal().Connect( &application, functor );
1072 // Emit a possible and then a cancelled, no reception
1073 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1074 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1075 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1079 int UtcDaliTapGestureDetectorRemovedWhilePossible(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 // Render and notify
1089 application.SendNotification();
1090 application.Render();
1092 // Attach actor to detector
1094 GestureReceivedFunctor functor( data );
1095 TapGestureDetector detector = TapGestureDetector::New();
1096 detector.Attach(actor);
1097 detector.DetectedSignal().Connect( &application, functor );
1100 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1102 // Detach actor and send a Started state, no signal.
1103 detector.DetachAll();
1104 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1105 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1109 int UtcDaliTapGestureActorRemovedWhilePossible(void)
1111 TestApplication application;
1113 Actor actor = Actor::New();
1114 actor.SetSize(100.0f, 100.0f);
1115 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1116 Stage::GetCurrent().Add(actor);
1118 // Render and notify
1119 application.SendNotification();
1120 application.Render();
1122 // Attach actor to detector
1124 GestureReceivedFunctor functor( data );
1125 TapGestureDetector detector = TapGestureDetector::New();
1126 detector.Attach(actor);
1127 detector.DetectedSignal().Connect( &application, functor );
1130 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1132 // Remove, render and delete actor
1133 Stage::GetCurrent().Remove(actor);
1134 application.SendNotification();
1135 application.Render();
1138 // Send a Started state, no signal.
1139 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1140 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1144 int UtcDaliTapGestureSystemOverlay(void)
1146 TestApplication application;
1147 Dali::Integration::Core& core = application.GetCore();
1148 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1149 systemOverlay.GetOverlayRenderTasks().CreateTask();
1151 Actor actor = Actor::New();
1152 actor.SetSize(100.0f, 100.0f);
1153 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1154 systemOverlay.Add(actor);
1156 // Render and notify
1157 application.SendNotification();
1158 application.Render();
1161 GestureReceivedFunctor functor(data);
1163 TapGestureDetector detector = TapGestureDetector::New();
1164 detector.Attach(actor);
1165 detector.DetectedSignal().Connect(&application, functor);
1167 Vector2 screenCoords( 50.0f, 50.0f );
1169 // Do a tap inside actor's area
1170 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1171 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1172 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1176 int UtcDaliTapGestureBehindTouchableSystemOverlay(void)
1178 TestApplication application;
1179 Dali::Integration::Core& core = application.GetCore();
1180 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1181 systemOverlay.GetOverlayRenderTasks().CreateTask();
1183 // SystemOverlay actor
1184 Actor systemOverlayActor = Actor::New();
1185 systemOverlayActor.SetSize(100.0f, 100.0f);
1186 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1187 systemOverlay.Add(systemOverlayActor);
1190 Actor stageActor = Actor::New();
1191 stageActor.SetSize(100.0f, 100.0f);
1192 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1193 Stage::GetCurrent().Add(stageActor);
1195 // Render and notify
1196 application.SendNotification();
1197 application.Render();
1199 // Set system-overlay actor to touchable
1200 TouchEventData touchData;
1201 TouchEventDataFunctor touchFunctor( touchData );
1202 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1204 // Set stage actor to receive the gesture
1206 GestureReceivedFunctor functor(data);
1208 TapGestureDetector detector = TapGestureDetector::New();
1209 detector.Attach(stageActor);
1210 detector.DetectedSignal().Connect(&application, functor);
1212 Vector2 screenCoords( 50.0f, 50.0f );
1214 // Do a tap inside both actors' area
1215 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1216 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1217 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1218 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1223 // Do touch in the same area
1224 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1225 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1226 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1231 int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void)
1233 TestApplication application;
1234 Dali::Integration::Core& core = application.GetCore();
1235 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1236 systemOverlay.GetOverlayRenderTasks().CreateTask();
1238 // SystemOverlay actor
1239 Actor systemOverlayActor = Actor::New();
1240 systemOverlayActor.SetSize(100.0f, 100.0f);
1241 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1242 systemOverlay.Add(systemOverlayActor);
1245 Actor stageActor = Actor::New();
1246 stageActor.SetSize(100.0f, 100.0f);
1247 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1248 Stage::GetCurrent().Add(stageActor);
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Set stage actor to touchable
1255 TouchEventData touchData;
1256 TouchEventDataFunctor touchFunctor( touchData );
1257 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1259 // Set system-overlay actor to have the gesture
1261 GestureReceivedFunctor functor(data);
1263 TapGestureDetector detector = TapGestureDetector::New();
1264 detector.Attach(systemOverlayActor);
1265 detector.DetectedSignal().Connect(&application, functor);
1267 Vector2 screenCoords( 50.0f, 50.0f );
1269 // Do a tap inside both actors' area
1270 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1271 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1272 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1273 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1278 // Do touch in the same area
1279 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1280 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1281 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1286 int UtcDaliTapGestureLayerConsumesTouch(void)
1288 TestApplication application;
1290 Actor actor = Actor::New();
1291 actor.SetSize(100.0f, 100.0f);
1292 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1293 Stage::GetCurrent().Add(actor);
1297 GestureReceivedFunctor functor(data);
1298 TapGestureDetector detector = TapGestureDetector::New();
1299 detector.Attach(actor);
1300 detector.DetectedSignal().Connect( &application, functor );
1302 // Add a layer to overlap the actor
1303 Layer layer = Layer::New();
1304 layer.SetSize(100.0f, 100.0f);
1305 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1306 Stage::GetCurrent().Add( layer );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 Vector2 screenCoords( 50.0f, 50.0f );
1315 // Emit signals, should receive
1316 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1317 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1318 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1321 // Set layer to consume all touch
1322 layer.SetTouchConsumed( true );
1324 // Render and notify
1325 application.SendNotification();
1326 application.Render();
1328 // Emit the same signals again, should not receive
1329 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1330 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1331 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);