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);
150 int UtcDaliTapGestureDetectorCopyConstructorP(void)
152 TestApplication application;
154 TapGestureDetector detector = TapGestureDetector::New();;
156 TapGestureDetector copy( detector );
157 DALI_TEST_CHECK( detector );
161 int UtcDaliTapGestureDetectorAssignmentOperatorP(void)
163 TestApplication application;
165 TapGestureDetector detector = TapGestureDetector::New();;
167 TapGestureDetector copy = detector;
168 DALI_TEST_CHECK( detector );
170 DALI_TEST_CHECK( detector == copy );
174 int UtcDaliTapGestureDetectorNew(void)
176 TestApplication application;
178 TapGestureDetector detector = TapGestureDetector::New();
179 DALI_TEST_CHECK(detector);
180 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
181 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
183 TapGestureDetector detector2 = TapGestureDetector::New( 5u );
184 DALI_TEST_CHECK(detector2);
185 DALI_TEST_EQUALS(5u, detector2.GetMinimumTapsRequired(), TEST_LOCATION);
186 DALI_TEST_EQUALS(5u, detector2.GetMaximumTapsRequired(), TEST_LOCATION);
188 //Scoped test to test destructor
190 TapGestureDetector detector3 = TapGestureDetector::New();
191 DALI_TEST_CHECK(detector3);
194 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
195 Actor actor = Actor::New();
196 actor.SetSize(100.0f, 100.0f);
197 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
198 Stage::GetCurrent().Add(actor);
201 application.SendNotification();
202 application.Render();
204 detector.Attach(actor);
206 TouchEventFunctor touchFunctor;
207 actor.TouchedSignal().Connect( &application, touchFunctor );
209 Integration::TouchEvent touchEvent(1);
210 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
211 touchEvent.AddPoint(point);
212 application.ProcessEvent(touchEvent);
215 application.SendNotification();
216 application.Render();
218 // For line coverage, Initialise default constructor
219 TouchEvent touchEvent2;
223 int UtcDaliTapGestureDetectorDownCast(void)
225 TestApplication application;
226 tet_infoline("Testing Dali::TapGestureDetector::DownCast()");
228 TapGestureDetector detector = TapGestureDetector::New();
230 BaseHandle object(detector);
232 TapGestureDetector detector2 = TapGestureDetector::DownCast(object);
233 DALI_TEST_CHECK(detector2);
235 TapGestureDetector detector3 = DownCast< TapGestureDetector >(object);
236 DALI_TEST_CHECK(detector3);
238 BaseHandle unInitializedObject;
239 TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject);
240 DALI_TEST_CHECK(!detector4);
242 TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject);
243 DALI_TEST_CHECK(!detector5);
245 GestureDetector detector6 = TapGestureDetector::New();
246 TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6);
247 DALI_TEST_CHECK(detector7);
251 int UtcDaliTapGestureSetTapsRequired(void)
253 TestApplication application;
255 TapGestureDetector detector = TapGestureDetector::New();
257 const unsigned int minTaps = 3;
258 const unsigned int maxTaps = 7;
260 DALI_TEST_CHECK( minTaps != detector.GetMinimumTapsRequired() );
261 DALI_TEST_CHECK( maxTaps != detector.GetMaximumTapsRequired() );
263 detector.SetMinimumTapsRequired( minTaps );
264 detector.SetMaximumTapsRequired( maxTaps );
266 DALI_TEST_EQUALS( minTaps, detector.GetMinimumTapsRequired(), TEST_LOCATION );
267 DALI_TEST_EQUALS( maxTaps, detector.GetMaximumTapsRequired(), TEST_LOCATION );
269 // Attach an actor and change the required touches
271 Actor actor = Actor::New();
272 actor.SetSize(100.0f, 100.0f);
273 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
274 Stage::GetCurrent().Add(actor);
277 application.SendNotification();
278 application.Render();
281 GestureReceivedFunctor functor(data);
283 detector.Attach(actor);
284 detector.DetectedSignal().Connect( &application, functor );
286 // Ensure signal is emitted if minimum taps received
287 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps, 1u, Vector2(50.0f, 50.0f)));
288 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps, 1u, Vector2(50.0f, 50.0f)));
289 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
290 DALI_TEST_EQUALS( minTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
293 // Ensure signal is emitted if maximum taps received
294 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps, 1u, Vector2(50.0f, 50.0f)));
295 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps, 1u, Vector2(50.0f, 50.0f)));
296 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
297 DALI_TEST_EQUALS( maxTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
300 // Ensure signal is NOT emitted if outside the range
301 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
302 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
303 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
305 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
306 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
307 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
310 TestGestureManager& gestureManager = application.GetGestureManager();
311 gestureManager.Initialize();
313 detector.SetMinimumTapsRequired(4);
315 // Gesture detection should have been updated only
316 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
317 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
318 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
321 gestureManager.Initialize();
323 detector.SetMaximumTapsRequired(maxTaps);
325 // Gesture detection should NOT have been updated
326 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
327 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
328 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
331 gestureManager.Initialize();
333 // Create a second gesture detector that requires even less maximum touches
334 TapGestureDetector secondDetector = TapGestureDetector::New();
335 secondDetector.Attach(actor);
337 // Gesture detection should have been updated
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 // Delete the second detector so that our detection is updated again
346 secondDetector.Reset();
347 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
348 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
349 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
351 // Set the minimum to be greater than the maximum, should Assert
354 detector.SetMinimumTapsRequired( maxTaps );
355 detector.SetMaximumTapsRequired( minTaps );
356 DALI_TEST_CHECK( false ); // Should not get here
358 catch ( DaliException& e )
360 DALI_TEST_CHECK( true );
366 int UtcDaliTapGestureSetTapsRequiredMinMaxCheck(void)
368 TestApplication application;
370 // Attach an actor and change the required touches
372 Actor actor = Actor::New();
373 actor.SetSize(100.0f, 100.0f);
374 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
375 Stage::GetCurrent().Add(actor);
378 application.SendNotification();
379 application.Render();
381 // Set the minimum to be greater than the maximum, should Assert
385 TapGestureDetector detector = TapGestureDetector::New();
386 detector.SetMinimumTapsRequired( 7u );
387 detector.SetMaximumTapsRequired( 3u );
388 detector.Attach(actor);
389 DALI_TEST_CHECK( false ); // Should not get here
391 catch ( DaliException& e )
393 DALI_TEST_CHECK( true );
399 int UtcDaliTapGestureGetTapsRequired(void)
401 TestApplication application;
403 TapGestureDetector detector = TapGestureDetector::New();
404 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
405 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
409 int UtcDaliTapGestureSignalReceptionNegative(void)
411 TestApplication application;
413 Actor actor = Actor::New();
414 actor.SetSize(100.0f, 100.0f);
415 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
416 Stage::GetCurrent().Add(actor);
419 application.SendNotification();
420 application.Render();
423 GestureReceivedFunctor functor(data);
425 TapGestureDetector detector = TapGestureDetector::New();
426 detector.Attach(actor);
427 detector.DetectedSignal().Connect( &application, functor );
429 // Do a tap outside actor's area
430 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f)));
431 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f)));
432 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
436 int UtcDaliTapGestureSignalReceptionPositive(void)
438 TestApplication application;
440 Actor actor = Actor::New();
441 actor.SetSize(100.0f, 100.0f);
442 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
443 Stage::GetCurrent().Add(actor);
446 application.SendNotification();
447 application.Render();
450 GestureReceivedFunctor functor(data);
452 TapGestureDetector detector = TapGestureDetector::New();
453 detector.Attach(actor);
454 detector.DetectedSignal().Connect( &application, functor );
456 // Do a tap inside actor's area
457 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
458 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
459 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
460 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
461 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
462 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
466 int UtcDaliTapGestureSignalReceptionDetach(void)
468 TestApplication application;
470 Actor actor = Actor::New();
471 actor.SetSize(100.0f, 100.0f);
472 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
473 Stage::GetCurrent().Add(actor);
476 application.SendNotification();
477 application.Render();
480 GestureReceivedFunctor functor(data);
482 TapGestureDetector detector = TapGestureDetector::New();
483 detector.Attach(actor);
484 detector.DetectedSignal().Connect(&application, functor);
486 // Start tap within the actor's area
487 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
488 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
489 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
490 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
491 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
492 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
494 // repeat the tap within the actor's area - we should still receive the signal
496 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
497 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
498 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
499 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
500 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
501 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
504 detector.DetachAll();
506 // Ensure we are no longer signalled
508 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
509 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
510 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
511 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
512 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
513 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
517 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
519 TestApplication application;
522 GestureReceivedFunctor functor(data);
524 TapGestureDetector detector = TapGestureDetector::New();
525 detector.DetectedSignal().Connect(&application, functor);
527 // Actor lifetime is scoped
529 Actor actor = Actor::New();
530 actor.SetSize(100.0f, 100.0f);
531 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
532 Stage::GetCurrent().Add(actor);
535 application.SendNotification();
536 application.Render();
538 detector.Attach(actor);
540 // Start tap within the actor's area
541 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
542 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
543 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
545 // Remove the actor from stage and reset the data
546 Stage::GetCurrent().Remove(actor);
549 application.SendNotification();
550 application.Render();
553 // Actor should now have been destroyed
556 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
557 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
558 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
562 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
564 TestApplication application;
566 Actor actor = Actor::New();
567 actor.SetSize(100.0f, 100.0f);
568 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
569 Stage::GetCurrent().Add(actor);
572 application.SendNotification();
573 application.Render();
576 GestureReceivedFunctor functor(data);
578 TapGestureDetector detector = TapGestureDetector::New();
579 detector.Attach(actor);
580 detector.DetectedSignal().Connect(&application, functor);
582 // Do tap, only check finished value
583 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
584 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
585 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
586 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
587 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
588 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
590 // Rotate actor again and render
591 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
592 application.SendNotification();
593 application.Render();
595 // Do tap, should still receive event
597 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
598 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
599 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
600 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
601 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
602 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
604 // Rotate actor again and render
605 actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
606 application.SendNotification();
607 application.Render();
609 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
611 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f)));
612 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f)));
613 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
617 int UtcDaliTapGestureSignalReceptionChildHit(void)
619 TestApplication application;
621 Actor parent = Actor::New();
622 parent.SetSize(100.0f, 100.0f);
623 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
624 Stage::GetCurrent().Add(parent);
626 // Set child to completely cover parent.
627 // Change rotation of child to be different from parent so that we can check if our local coordinate
628 // conversion of the parent actor is correct.
629 Actor child = Actor::New();
630 child.SetSize(100.0f, 100.0f);
631 child.SetAnchorPoint(AnchorPoint::CENTER);
632 child.SetParentOrigin(ParentOrigin::CENTER);
633 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
636 TouchEventFunctor touchFunctor;
637 child.TouchedSignal().Connect(&application, touchFunctor);
640 application.SendNotification();
641 application.Render();
644 GestureReceivedFunctor functor(data);
646 TapGestureDetector detector = TapGestureDetector::New();
647 detector.Attach(parent);
648 detector.DetectedSignal().Connect(&application, functor);
650 // Do tap - hits child area but parent should still receive it
651 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
652 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
653 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
654 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
655 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
657 // Attach child and generate same touch points
658 // (Also proves that you can detach and then re-attach another actor)
659 detector.Attach(child);
660 detector.Detach(parent);
662 // Do an entire tap, only check finished value
664 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f)));
665 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f)));
666 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
667 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
668 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
672 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
674 TestApplication application;
676 Actor first = Actor::New();
677 first.SetSize(100.0f, 100.0f);
678 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
679 Stage::GetCurrent().Add(first);
681 Actor second = Actor::New();
682 second.SetSize(100.0f, 100.0f);
684 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
685 Stage::GetCurrent().Add(second);
688 application.SendNotification();
689 application.Render();
692 GestureReceivedFunctor functor(data);
694 TapGestureDetector detector = TapGestureDetector::New();
695 detector.Attach(first);
696 detector.Attach(second);
697 detector.DetectedSignal().Connect(&application, functor);
699 // Tap within second actor's area
700 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
701 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
702 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
703 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
705 // Tap within first actor's area
707 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
708 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
709 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
710 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
712 // Detach the second actor
713 detector.Detach(second);
715 // second actor shouldn't receive event
717 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
718 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
719 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
721 // first actor should continue receiving event
723 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
724 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
725 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
729 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
731 TestApplication application;
733 Actor actor = Actor::New();
734 actor.SetSize(100.0f, 100.0f);
735 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
736 Stage::GetCurrent().Add(actor);
739 application.SendNotification();
740 application.Render();
743 GestureReceivedFunctor functor(data);
745 TapGestureDetector detector = TapGestureDetector::New();
746 detector.Attach(actor);
747 detector.DetectedSignal().Connect(&application, functor);
749 // Tap in actor's area
750 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
751 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
752 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
754 // Actor become invisible - actor should not receive the next pan
755 actor.SetVisible(false);
758 application.SendNotification();
759 application.Render();
761 // Tap in the same area, shouldn't receive event
763 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
764 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
765 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
769 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
771 TestApplication application;
772 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
774 Actor first = Actor::New();
775 first.SetSize(100.0f, 100.0f);
776 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
777 Stage::GetCurrent().Add(first);
779 Actor second = Actor::New();
780 second.SetSize(100.0f, 100.0f);
781 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
786 application.SendNotification();
787 application.Render();
790 GestureReceivedFunctor functor(data);
792 TapGestureDetector firstDetector = TapGestureDetector::New();
793 firstDetector.Attach(first);
794 firstDetector.DetectedSignal().Connect(&application, functor);
796 // secondDetector is scoped
798 // Reset gestureManager statistics
799 gestureManager.Initialize();
801 TapGestureDetector secondDetector = TapGestureDetector::New( 2 );
802 secondDetector.Attach(second);
803 secondDetector.DetectedSignal().Connect(&application, functor);
805 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
806 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
807 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
809 // Tap within second actor's area
810 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 1u, Vector2(150.0f, 10.0f)));
811 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 1u, Vector2(150.0f, 10.0f)));
812 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
813 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
815 // Tap continues as single touch gesture - we should not receive any gesture
817 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f)));
818 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f)));
819 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
821 // Single touch tap starts - first actor should be panned
823 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
824 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
825 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
826 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
828 // Pan changes to double-touch - we shouldn't receive event
830 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f)));
831 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f)));
832 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
834 // Reset gesture manager statistics
835 gestureManager.Initialize();
838 // secondDetector has now been deleted. Gesture detection should have been updated only
839 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
840 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
841 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
845 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
847 TestApplication application;
849 Actor actor = Actor::New();
850 actor.SetSize(100.0f, 100.0f);
851 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
852 Stage::GetCurrent().Add(actor);
855 application.SendNotification();
856 application.Render();
858 // Attach actor to one detector
859 SignalData firstData;
860 GestureReceivedFunctor firstFunctor(firstData);
861 TapGestureDetector firstDetector = TapGestureDetector::New();
862 firstDetector.Attach(actor);
863 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
865 // Attach actor to another detector
866 SignalData secondData;
867 GestureReceivedFunctor secondFunctor(secondData);
868 TapGestureDetector secondDetector = TapGestureDetector::New();
869 secondDetector.Attach(actor);
870 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
872 // Tap in actor's area - both detector's functors should be called
873 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
874 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
875 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
876 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
880 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
882 TestApplication application;
884 Actor actor = Actor::New();
885 actor.SetSize(100.0f, 100.0f);
886 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
887 Stage::GetCurrent().Add(actor);
890 application.SendNotification();
891 application.Render();
893 // Attach actor to detector
895 GestureReceivedFunctor functor( data );
896 TapGestureDetector detector = TapGestureDetector::New();
897 detector.Attach(actor);
898 detector.DetectedSignal().Connect( &application, functor );
900 // Gesture possible in actor's area.
901 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
902 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
904 // Move actor somewhere else
905 actor.SetPosition( 100.0f, 100.0f );
908 application.SendNotification();
909 application.Render();
911 // Emit Started event, we should not receive the tap.
912 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
913 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
915 // Tap possible in empty area.
916 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
917 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
919 // Move actor in to the tap position.
920 actor.SetPosition( 0.0f, 0.0f );
923 application.SendNotification();
924 application.Render();
926 // Emit Started event, we should not receive the tap.
927 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
928 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
930 // Normal tap in actor's area for completeness.
931 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
932 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
933 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
937 int UtcDaliTapGestureEmitIncorrectStateClear(void)
939 TestApplication application;
941 Actor actor = Actor::New();
942 actor.SetSize(100.0f, 100.0f);
943 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
944 Stage::GetCurrent().Add(actor);
947 application.SendNotification();
948 application.Render();
950 // Attach actor to detector
952 GestureReceivedFunctor functor( data );
953 TapGestureDetector detector = TapGestureDetector::New();
954 detector.Attach(actor);
955 detector.DetectedSignal().Connect( &application, functor );
960 application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f)));
961 tet_result(TET_FAIL);
963 catch ( Dali::DaliException& e )
965 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
970 int UtcDaliTapGestureEmitIncorrectStateContinuing(void)
972 TestApplication application;
974 Actor actor = Actor::New();
975 actor.SetSize(100.0f, 100.0f);
976 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
977 Stage::GetCurrent().Add(actor);
980 application.SendNotification();
981 application.Render();
983 // Attach actor to detector
985 GestureReceivedFunctor functor( data );
986 TapGestureDetector detector = TapGestureDetector::New();
987 detector.Attach(actor);
988 detector.DetectedSignal().Connect( &application, functor );
990 // Try a Continuing state
993 application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f)));
994 tet_result(TET_FAIL);
996 catch ( Dali::DaliException& e )
998 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1003 int UtcDaliTapGestureEmitIncorrectStateFinished(void)
1005 TestApplication application;
1007 Actor actor = Actor::New();
1008 actor.SetSize(100.0f, 100.0f);
1009 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1010 Stage::GetCurrent().Add(actor);
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Attach actor to detector
1018 GestureReceivedFunctor functor( data );
1019 TapGestureDetector detector = TapGestureDetector::New();
1020 detector.Attach(actor);
1021 detector.DetectedSignal().Connect( &application, functor );
1023 // Try a Finished state
1026 application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f)));
1027 tet_result(TET_FAIL);
1029 catch ( Dali::DaliException& e )
1031 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1036 int UtcDaliTapGestureActorUnstaged(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 UnstageActorFunctor functor( data );
1052 TapGestureDetector detector = TapGestureDetector::New();
1053 detector.Attach(actor);
1054 detector.DetectedSignal().Connect( &application, functor );
1056 // Tap in Actor's area, actor removed in signal handler, should be handled gracefully.
1057 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1058 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1059 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1060 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
1064 int UtcDaliTapGestureRepeatedState(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 TapGestureDetector detector = TapGestureDetector::New();
1081 detector.Attach(actor);
1082 detector.DetectedSignal().Connect( &application, functor );
1084 // Emit two possibles
1085 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1086 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1087 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1089 // Send a couple of Started states, only first one should be received.
1090 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1091 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1093 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1094 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1096 // Send a couple of cancelled states, no reception
1097 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1098 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1099 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1103 int UtcDaliTapGesturePossibleCancelled(void)
1105 TestApplication application;
1107 Actor actor = Actor::New();
1108 actor.SetSize(100.0f, 100.0f);
1109 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1110 Stage::GetCurrent().Add(actor);
1112 // Render and notify
1113 application.SendNotification();
1114 application.Render();
1116 // Attach actor to detector
1118 GestureReceivedFunctor functor( data );
1119 TapGestureDetector detector = TapGestureDetector::New();
1120 detector.Attach(actor);
1121 detector.DetectedSignal().Connect( &application, functor );
1123 // Emit a possible and then a cancelled, no reception
1124 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1125 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1126 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1130 int UtcDaliTapGestureDetectorRemovedWhilePossible(void)
1132 TestApplication application;
1134 Actor actor = Actor::New();
1135 actor.SetSize(100.0f, 100.0f);
1136 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1137 Stage::GetCurrent().Add(actor);
1139 // Render and notify
1140 application.SendNotification();
1141 application.Render();
1143 // Attach actor to detector
1145 GestureReceivedFunctor functor( data );
1146 TapGestureDetector detector = TapGestureDetector::New();
1147 detector.Attach(actor);
1148 detector.DetectedSignal().Connect( &application, functor );
1151 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1153 // Detach actor and send a Started state, no signal.
1154 detector.DetachAll();
1155 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1156 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1160 int UtcDaliTapGestureActorRemovedWhilePossible(void)
1162 TestApplication application;
1164 Actor actor = Actor::New();
1165 actor.SetSize(100.0f, 100.0f);
1166 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1167 Stage::GetCurrent().Add(actor);
1169 // Render and notify
1170 application.SendNotification();
1171 application.Render();
1173 // Attach actor to detector
1175 GestureReceivedFunctor functor( data );
1176 TapGestureDetector detector = TapGestureDetector::New();
1177 detector.Attach(actor);
1178 detector.DetectedSignal().Connect( &application, functor );
1181 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1183 // Remove, render and delete actor
1184 Stage::GetCurrent().Remove(actor);
1185 application.SendNotification();
1186 application.Render();
1189 // Send a Started state, no signal.
1190 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1191 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1195 int UtcDaliTapGestureSystemOverlay(void)
1197 TestApplication application;
1198 Dali::Integration::Core& core = application.GetCore();
1199 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1200 systemOverlay.GetOverlayRenderTasks().CreateTask();
1202 Actor actor = Actor::New();
1203 actor.SetSize(100.0f, 100.0f);
1204 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1205 systemOverlay.Add(actor);
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1212 GestureReceivedFunctor functor(data);
1214 TapGestureDetector detector = TapGestureDetector::New();
1215 detector.Attach(actor);
1216 detector.DetectedSignal().Connect(&application, functor);
1218 Vector2 screenCoords( 50.0f, 50.0f );
1220 // Do a tap inside actor's area
1221 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1222 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1223 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1227 int UtcDaliTapGestureBehindTouchableSystemOverlay(void)
1229 TestApplication application;
1230 Dali::Integration::Core& core = application.GetCore();
1231 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1232 systemOverlay.GetOverlayRenderTasks().CreateTask();
1234 // SystemOverlay actor
1235 Actor systemOverlayActor = Actor::New();
1236 systemOverlayActor.SetSize(100.0f, 100.0f);
1237 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1238 systemOverlay.Add(systemOverlayActor);
1241 Actor stageActor = Actor::New();
1242 stageActor.SetSize(100.0f, 100.0f);
1243 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1244 Stage::GetCurrent().Add(stageActor);
1246 // Render and notify
1247 application.SendNotification();
1248 application.Render();
1250 // Set system-overlay actor to touchable
1251 TouchEventData touchData;
1252 TouchEventDataFunctor touchFunctor( touchData );
1253 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1255 // Set stage actor to receive the gesture
1257 GestureReceivedFunctor functor(data);
1259 TapGestureDetector detector = TapGestureDetector::New();
1260 detector.Attach(stageActor);
1261 detector.DetectedSignal().Connect(&application, functor);
1263 Vector2 screenCoords( 50.0f, 50.0f );
1265 // Do a tap inside both actors' area
1266 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1267 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1268 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1269 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1274 // Do touch in the same area
1275 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1276 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1277 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1282 int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void)
1284 TestApplication application;
1285 Dali::Integration::Core& core = application.GetCore();
1286 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1287 systemOverlay.GetOverlayRenderTasks().CreateTask();
1289 // SystemOverlay actor
1290 Actor systemOverlayActor = Actor::New();
1291 systemOverlayActor.SetSize(100.0f, 100.0f);
1292 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1293 systemOverlay.Add(systemOverlayActor);
1296 Actor stageActor = Actor::New();
1297 stageActor.SetSize(100.0f, 100.0f);
1298 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1299 Stage::GetCurrent().Add(stageActor);
1301 // Render and notify
1302 application.SendNotification();
1303 application.Render();
1305 // Set stage actor to touchable
1306 TouchEventData touchData;
1307 TouchEventDataFunctor touchFunctor( touchData );
1308 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1310 // Set system-overlay actor to have the gesture
1312 GestureReceivedFunctor functor(data);
1314 TapGestureDetector detector = TapGestureDetector::New();
1315 detector.Attach(systemOverlayActor);
1316 detector.DetectedSignal().Connect(&application, functor);
1318 Vector2 screenCoords( 50.0f, 50.0f );
1320 // Do a tap inside both actors' area
1321 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1322 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1323 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1324 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1329 // Do touch in the same area
1330 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1331 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1332 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1337 int UtcDaliTapGestureLayerConsumesTouch(void)
1339 TestApplication application;
1341 Actor actor = Actor::New();
1342 actor.SetSize(100.0f, 100.0f);
1343 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1344 Stage::GetCurrent().Add(actor);
1348 GestureReceivedFunctor functor(data);
1349 TapGestureDetector detector = TapGestureDetector::New();
1350 detector.Attach(actor);
1351 detector.DetectedSignal().Connect( &application, functor );
1353 // Add a layer to overlap the actor
1354 Layer layer = Layer::New();
1355 layer.SetSize(100.0f, 100.0f);
1356 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1357 Stage::GetCurrent().Add( layer );
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 Vector2 screenCoords( 50.0f, 50.0f );
1366 // Emit signals, should receive
1367 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1368 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1369 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1372 // Set layer to consume all touch
1373 layer.SetTouchConsumed( true );
1375 // Render and notify
1376 application.SendNotification();
1377 application.Render();
1379 // Emit the same signals again, should not receive
1380 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1381 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1382 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);