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.GetMinimumTapsRequired(), TEST_LOCATION);
158 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
160 TapGestureDetector detector2 = TapGestureDetector::New( 5u );
161 DALI_TEST_CHECK(detector2);
162 DALI_TEST_EQUALS(5u, detector2.GetMinimumTapsRequired(), TEST_LOCATION);
163 DALI_TEST_EQUALS(5u, detector2.GetMaximumTapsRequired(), 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 const unsigned int minTaps = 3;
235 const unsigned int maxTaps = 7;
237 DALI_TEST_CHECK( minTaps != detector.GetMinimumTapsRequired() );
238 DALI_TEST_CHECK( maxTaps != detector.GetMaximumTapsRequired() );
240 detector.SetMinimumTapsRequired( minTaps );
241 detector.SetMaximumTapsRequired( maxTaps );
243 DALI_TEST_EQUALS( minTaps, detector.GetMinimumTapsRequired(), TEST_LOCATION );
244 DALI_TEST_EQUALS( maxTaps, detector.GetMaximumTapsRequired(), TEST_LOCATION );
246 // Attach an actor and change the required touches
248 Actor actor = Actor::New();
249 actor.SetSize(100.0f, 100.0f);
250 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
251 Stage::GetCurrent().Add(actor);
254 application.SendNotification();
255 application.Render();
258 GestureReceivedFunctor functor(data);
260 detector.Attach(actor);
261 detector.DetectedSignal().Connect( &application, functor );
263 // Ensure signal is emitted if minimum taps received
264 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps, 1u, Vector2(50.0f, 50.0f)));
265 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps, 1u, Vector2(50.0f, 50.0f)));
266 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
267 DALI_TEST_EQUALS( minTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
270 // Ensure signal is emitted if maximum taps received
271 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps, 1u, Vector2(50.0f, 50.0f)));
272 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps, 1u, Vector2(50.0f, 50.0f)));
273 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
274 DALI_TEST_EQUALS( maxTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
277 // Ensure signal is NOT emitted if outside the range
278 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
279 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
280 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
282 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
283 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
284 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
287 TestGestureManager& gestureManager = application.GetGestureManager();
288 gestureManager.Initialize();
290 detector.SetMinimumTapsRequired(4);
292 // Gesture detection should have been updated only
293 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
294 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
295 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
298 gestureManager.Initialize();
300 detector.SetMaximumTapsRequired(maxTaps);
302 // Gesture detection should NOT have been updated
303 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
304 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
305 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
308 gestureManager.Initialize();
310 // Create a second gesture detector that requires even less maximum touches
311 TapGestureDetector secondDetector = TapGestureDetector::New();
312 secondDetector.Attach(actor);
314 // Gesture detection should have been updated
315 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
316 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
317 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
320 gestureManager.Initialize();
322 // Delete the second detector so that our detection is updated again
323 secondDetector.Reset();
324 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
325 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
326 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
328 // Set the minimum to be greater than the maximum, should Assert
331 detector.SetMinimumTapsRequired( maxTaps );
332 detector.SetMaximumTapsRequired( minTaps );
333 DALI_TEST_CHECK( false ); // Should not get here
335 catch ( DaliException& e )
337 DALI_TEST_CHECK( true );
343 int UtcDaliTapGestureSetTapsRequiredMinMaxCheck(void)
345 TestApplication application;
347 // Attach an actor and change the required touches
349 Actor actor = Actor::New();
350 actor.SetSize(100.0f, 100.0f);
351 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
352 Stage::GetCurrent().Add(actor);
355 application.SendNotification();
356 application.Render();
358 // Set the minimum to be greater than the maximum, should Assert
362 TapGestureDetector detector = TapGestureDetector::New();
363 detector.SetMinimumTapsRequired( 7u );
364 detector.SetMaximumTapsRequired( 3u );
365 detector.Attach(actor);
366 DALI_TEST_CHECK( false ); // Should not get here
368 catch ( DaliException& e )
370 DALI_TEST_CHECK( true );
376 int UtcDaliTapGestureGetTapsRequired(void)
378 TestApplication application;
380 TapGestureDetector detector = TapGestureDetector::New();
381 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
382 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
386 int UtcDaliTapGestureSignalReceptionNegative(void)
388 TestApplication application;
390 Actor actor = Actor::New();
391 actor.SetSize(100.0f, 100.0f);
392 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
393 Stage::GetCurrent().Add(actor);
396 application.SendNotification();
397 application.Render();
400 GestureReceivedFunctor functor(data);
402 TapGestureDetector detector = TapGestureDetector::New();
403 detector.Attach(actor);
404 detector.DetectedSignal().Connect( &application, functor );
406 // Do a tap outside actor's area
407 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f)));
408 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f)));
409 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
413 int UtcDaliTapGestureSignalReceptionPositive(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 // Do a tap inside actor's area
434 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
435 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.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(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
443 int UtcDaliTapGestureSignalReceptionDetach(void)
445 TestApplication application;
447 Actor actor = Actor::New();
448 actor.SetSize(100.0f, 100.0f);
449 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
450 Stage::GetCurrent().Add(actor);
453 application.SendNotification();
454 application.Render();
457 GestureReceivedFunctor functor(data);
459 TapGestureDetector detector = TapGestureDetector::New();
460 detector.Attach(actor);
461 detector.DetectedSignal().Connect(&application, functor);
463 // Start tap within the actor's area
464 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
465 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
466 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
467 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
468 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
469 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
471 // repeat the tap within the actor's area - we should still receive the signal
473 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
474 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
475 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
476 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
477 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
478 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
481 detector.DetachAll();
483 // Ensure we are no longer signalled
485 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
486 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
487 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
488 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
489 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
490 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
494 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
496 TestApplication application;
499 GestureReceivedFunctor functor(data);
501 TapGestureDetector detector = TapGestureDetector::New();
502 detector.DetectedSignal().Connect(&application, functor);
504 // Actor lifetime is scoped
506 Actor actor = Actor::New();
507 actor.SetSize(100.0f, 100.0f);
508 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
509 Stage::GetCurrent().Add(actor);
512 application.SendNotification();
513 application.Render();
515 detector.Attach(actor);
517 // Start tap within the actor's area
518 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
519 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
520 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
522 // Remove the actor from stage and reset the data
523 Stage::GetCurrent().Remove(actor);
526 application.SendNotification();
527 application.Render();
530 // Actor should now have been destroyed
533 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
534 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
535 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
539 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
541 TestApplication application;
543 Actor actor = Actor::New();
544 actor.SetSize(100.0f, 100.0f);
545 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
546 Stage::GetCurrent().Add(actor);
549 application.SendNotification();
550 application.Render();
553 GestureReceivedFunctor functor(data);
555 TapGestureDetector detector = TapGestureDetector::New();
556 detector.Attach(actor);
557 detector.DetectedSignal().Connect(&application, functor);
559 // Do tap, only check finished value
560 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
561 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
562 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
563 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
564 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
565 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
567 // Rotate actor again and render
568 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
569 application.SendNotification();
570 application.Render();
572 // Do tap, should still receive event
574 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
575 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
576 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
577 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
578 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
579 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
581 // Rotate actor again and render
582 actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
583 application.SendNotification();
584 application.Render();
586 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
588 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f)));
589 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f)));
590 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
594 int UtcDaliTapGestureSignalReceptionChildHit(void)
596 TestApplication application;
598 Actor parent = Actor::New();
599 parent.SetSize(100.0f, 100.0f);
600 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
601 Stage::GetCurrent().Add(parent);
603 // Set child to completely cover parent.
604 // Change rotation of child to be different from parent so that we can check if our local coordinate
605 // conversion of the parent actor is correct.
606 Actor child = Actor::New();
607 child.SetSize(100.0f, 100.0f);
608 child.SetAnchorPoint(AnchorPoint::CENTER);
609 child.SetParentOrigin(ParentOrigin::CENTER);
610 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
613 TouchEventFunctor touchFunctor;
614 child.TouchedSignal().Connect(&application, touchFunctor);
617 application.SendNotification();
618 application.Render();
621 GestureReceivedFunctor functor(data);
623 TapGestureDetector detector = TapGestureDetector::New();
624 detector.Attach(parent);
625 detector.DetectedSignal().Connect(&application, functor);
627 // Do tap - hits child area but parent should still receive it
628 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
629 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
630 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
631 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
632 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
634 // Attach child and generate same touch points
635 // (Also proves that you can detach and then re-attach another actor)
636 detector.Attach(child);
637 detector.Detach(parent);
639 // Do an entire tap, only check finished value
641 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f)));
642 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f)));
643 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
644 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
645 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
649 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
651 TestApplication application;
653 Actor first = Actor::New();
654 first.SetSize(100.0f, 100.0f);
655 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
656 Stage::GetCurrent().Add(first);
658 Actor second = Actor::New();
659 second.SetSize(100.0f, 100.0f);
661 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
662 Stage::GetCurrent().Add(second);
665 application.SendNotification();
666 application.Render();
669 GestureReceivedFunctor functor(data);
671 TapGestureDetector detector = TapGestureDetector::New();
672 detector.Attach(first);
673 detector.Attach(second);
674 detector.DetectedSignal().Connect(&application, functor);
676 // Tap within second actor's area
677 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
678 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
679 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
680 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
682 // Tap within first actor's area
684 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
685 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
686 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
687 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
689 // Detach the second actor
690 detector.Detach(second);
692 // second actor shouldn't receive event
694 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
695 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
696 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
698 // first actor should continue receiving event
700 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
701 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
702 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
706 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
708 TestApplication application;
710 Actor actor = Actor::New();
711 actor.SetSize(100.0f, 100.0f);
712 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
713 Stage::GetCurrent().Add(actor);
716 application.SendNotification();
717 application.Render();
720 GestureReceivedFunctor functor(data);
722 TapGestureDetector detector = TapGestureDetector::New();
723 detector.Attach(actor);
724 detector.DetectedSignal().Connect(&application, functor);
726 // Tap in actor's area
727 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
728 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
729 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
731 // Actor become invisible - actor should not receive the next pan
732 actor.SetVisible(false);
735 application.SendNotification();
736 application.Render();
738 // Tap in the same area, shouldn't receive event
740 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
741 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
742 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
746 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
748 TestApplication application;
749 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
751 Actor first = Actor::New();
752 first.SetSize(100.0f, 100.0f);
753 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
754 Stage::GetCurrent().Add(first);
756 Actor second = Actor::New();
757 second.SetSize(100.0f, 100.0f);
758 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
763 application.SendNotification();
764 application.Render();
767 GestureReceivedFunctor functor(data);
769 TapGestureDetector firstDetector = TapGestureDetector::New();
770 firstDetector.Attach(first);
771 firstDetector.DetectedSignal().Connect(&application, functor);
773 // secondDetector is scoped
775 // Reset gestureManager statistics
776 gestureManager.Initialize();
778 TapGestureDetector secondDetector = TapGestureDetector::New( 2 );
779 secondDetector.Attach(second);
780 secondDetector.DetectedSignal().Connect(&application, functor);
782 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
783 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
784 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
786 // Tap within second actor's area
787 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 1u, Vector2(150.0f, 10.0f)));
788 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 1u, Vector2(150.0f, 10.0f)));
789 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
790 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
792 // Tap continues as single touch gesture - we should not receive any gesture
794 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f)));
795 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f)));
796 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
798 // Single touch tap starts - first actor should be panned
800 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
801 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
802 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
803 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
805 // Pan changes to double-touch - we shouldn't receive event
807 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f)));
808 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f)));
809 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
811 // Reset gesture manager statistics
812 gestureManager.Initialize();
815 // secondDetector has now been deleted. Gesture detection should have been updated only
816 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
817 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
818 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
822 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
824 TestApplication application;
826 Actor actor = Actor::New();
827 actor.SetSize(100.0f, 100.0f);
828 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
829 Stage::GetCurrent().Add(actor);
832 application.SendNotification();
833 application.Render();
835 // Attach actor to one detector
836 SignalData firstData;
837 GestureReceivedFunctor firstFunctor(firstData);
838 TapGestureDetector firstDetector = TapGestureDetector::New();
839 firstDetector.Attach(actor);
840 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
842 // Attach actor to another detector
843 SignalData secondData;
844 GestureReceivedFunctor secondFunctor(secondData);
845 TapGestureDetector secondDetector = TapGestureDetector::New();
846 secondDetector.Attach(actor);
847 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
849 // Tap in actor's area - both detector's functors should be called
850 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
851 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
852 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
853 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
857 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
859 TestApplication application;
861 Actor actor = Actor::New();
862 actor.SetSize(100.0f, 100.0f);
863 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
864 Stage::GetCurrent().Add(actor);
867 application.SendNotification();
868 application.Render();
870 // Attach actor to detector
872 GestureReceivedFunctor functor( data );
873 TapGestureDetector detector = TapGestureDetector::New();
874 detector.Attach(actor);
875 detector.DetectedSignal().Connect( &application, functor );
877 // Gesture possible in actor's area.
878 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
879 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
881 // Move actor somewhere else
882 actor.SetPosition( 100.0f, 100.0f );
885 application.SendNotification();
886 application.Render();
888 // Emit Started event, we should not receive the tap.
889 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
890 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
892 // Tap possible in empty area.
893 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
894 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
896 // Move actor in to the tap position.
897 actor.SetPosition( 0.0f, 0.0f );
900 application.SendNotification();
901 application.Render();
903 // Emit Started event, we should not receive the tap.
904 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
905 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
907 // Normal tap in actor's area for completeness.
908 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
909 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
910 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
914 int UtcDaliTapGestureEmitIncorrectStateClear(void)
916 TestApplication application;
918 Actor actor = Actor::New();
919 actor.SetSize(100.0f, 100.0f);
920 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
921 Stage::GetCurrent().Add(actor);
924 application.SendNotification();
925 application.Render();
927 // Attach actor to detector
929 GestureReceivedFunctor functor( data );
930 TapGestureDetector detector = TapGestureDetector::New();
931 detector.Attach(actor);
932 detector.DetectedSignal().Connect( &application, functor );
937 application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f)));
938 tet_result(TET_FAIL);
940 catch ( Dali::DaliException& e )
942 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
947 int UtcDaliTapGestureEmitIncorrectStateContinuing(void)
949 TestApplication application;
951 Actor actor = Actor::New();
952 actor.SetSize(100.0f, 100.0f);
953 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
954 Stage::GetCurrent().Add(actor);
957 application.SendNotification();
958 application.Render();
960 // Attach actor to detector
962 GestureReceivedFunctor functor( data );
963 TapGestureDetector detector = TapGestureDetector::New();
964 detector.Attach(actor);
965 detector.DetectedSignal().Connect( &application, functor );
967 // Try a Continuing state
970 application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f)));
971 tet_result(TET_FAIL);
973 catch ( Dali::DaliException& e )
975 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
980 int UtcDaliTapGestureEmitIncorrectStateFinished(void)
982 TestApplication application;
984 Actor actor = Actor::New();
985 actor.SetSize(100.0f, 100.0f);
986 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
987 Stage::GetCurrent().Add(actor);
990 application.SendNotification();
991 application.Render();
993 // Attach actor to detector
995 GestureReceivedFunctor functor( data );
996 TapGestureDetector detector = TapGestureDetector::New();
997 detector.Attach(actor);
998 detector.DetectedSignal().Connect( &application, functor );
1000 // Try a Finished state
1003 application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f)));
1004 tet_result(TET_FAIL);
1006 catch ( Dali::DaliException& e )
1008 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1013 int UtcDaliTapGestureActorUnstaged(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 UnstageActorFunctor functor( data );
1029 TapGestureDetector detector = TapGestureDetector::New();
1030 detector.Attach(actor);
1031 detector.DetectedSignal().Connect( &application, functor );
1033 // Tap in Actor's area, actor removed in signal handler, should be handled gracefully.
1034 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1035 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1036 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1037 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
1041 int UtcDaliTapGestureRepeatedState(void)
1043 TestApplication application;
1045 Actor actor = Actor::New();
1046 actor.SetSize(100.0f, 100.0f);
1047 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1048 Stage::GetCurrent().Add(actor);
1050 // Render and notify
1051 application.SendNotification();
1052 application.Render();
1054 // Attach actor to detector
1056 GestureReceivedFunctor functor( data );
1057 TapGestureDetector detector = TapGestureDetector::New();
1058 detector.Attach(actor);
1059 detector.DetectedSignal().Connect( &application, functor );
1061 // Emit two possibles
1062 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1063 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1064 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1066 // Send a couple of Started states, only first one should be received.
1067 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1068 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1070 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1071 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1073 // Send a couple of cancelled states, no reception
1074 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1075 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1076 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1080 int UtcDaliTapGesturePossibleCancelled(void)
1082 TestApplication application;
1084 Actor actor = Actor::New();
1085 actor.SetSize(100.0f, 100.0f);
1086 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1087 Stage::GetCurrent().Add(actor);
1089 // Render and notify
1090 application.SendNotification();
1091 application.Render();
1093 // Attach actor to detector
1095 GestureReceivedFunctor functor( data );
1096 TapGestureDetector detector = TapGestureDetector::New();
1097 detector.Attach(actor);
1098 detector.DetectedSignal().Connect( &application, functor );
1100 // Emit a possible and then a cancelled, no reception
1101 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1102 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1103 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1107 int UtcDaliTapGestureDetectorRemovedWhilePossible(void)
1109 TestApplication application;
1111 Actor actor = Actor::New();
1112 actor.SetSize(100.0f, 100.0f);
1113 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1114 Stage::GetCurrent().Add(actor);
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Attach actor to detector
1122 GestureReceivedFunctor functor( data );
1123 TapGestureDetector detector = TapGestureDetector::New();
1124 detector.Attach(actor);
1125 detector.DetectedSignal().Connect( &application, functor );
1128 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1130 // Detach actor and send a Started state, no signal.
1131 detector.DetachAll();
1132 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1133 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1137 int UtcDaliTapGestureActorRemovedWhilePossible(void)
1139 TestApplication application;
1141 Actor actor = Actor::New();
1142 actor.SetSize(100.0f, 100.0f);
1143 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1144 Stage::GetCurrent().Add(actor);
1146 // Render and notify
1147 application.SendNotification();
1148 application.Render();
1150 // Attach actor to detector
1152 GestureReceivedFunctor functor( data );
1153 TapGestureDetector detector = TapGestureDetector::New();
1154 detector.Attach(actor);
1155 detector.DetectedSignal().Connect( &application, functor );
1158 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1160 // Remove, render and delete actor
1161 Stage::GetCurrent().Remove(actor);
1162 application.SendNotification();
1163 application.Render();
1166 // Send a Started state, no signal.
1167 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1168 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1172 int UtcDaliTapGestureSystemOverlay(void)
1174 TestApplication application;
1175 Dali::Integration::Core& core = application.GetCore();
1176 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1177 systemOverlay.GetOverlayRenderTasks().CreateTask();
1179 Actor actor = Actor::New();
1180 actor.SetSize(100.0f, 100.0f);
1181 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1182 systemOverlay.Add(actor);
1184 // Render and notify
1185 application.SendNotification();
1186 application.Render();
1189 GestureReceivedFunctor functor(data);
1191 TapGestureDetector detector = TapGestureDetector::New();
1192 detector.Attach(actor);
1193 detector.DetectedSignal().Connect(&application, functor);
1195 Vector2 screenCoords( 50.0f, 50.0f );
1197 // Do a tap inside actor's area
1198 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1199 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1200 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1204 int UtcDaliTapGestureBehindTouchableSystemOverlay(void)
1206 TestApplication application;
1207 Dali::Integration::Core& core = application.GetCore();
1208 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1209 systemOverlay.GetOverlayRenderTasks().CreateTask();
1211 // SystemOverlay actor
1212 Actor systemOverlayActor = Actor::New();
1213 systemOverlayActor.SetSize(100.0f, 100.0f);
1214 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1215 systemOverlay.Add(systemOverlayActor);
1218 Actor stageActor = Actor::New();
1219 stageActor.SetSize(100.0f, 100.0f);
1220 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1221 Stage::GetCurrent().Add(stageActor);
1223 // Render and notify
1224 application.SendNotification();
1225 application.Render();
1227 // Set system-overlay actor to touchable
1228 TouchEventData touchData;
1229 TouchEventDataFunctor touchFunctor( touchData );
1230 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1232 // Set stage actor to receive the gesture
1234 GestureReceivedFunctor functor(data);
1236 TapGestureDetector detector = TapGestureDetector::New();
1237 detector.Attach(stageActor);
1238 detector.DetectedSignal().Connect(&application, functor);
1240 Vector2 screenCoords( 50.0f, 50.0f );
1242 // Do a tap inside both actors' area
1243 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1244 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1245 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1246 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1251 // Do touch in the same area
1252 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1253 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1254 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1259 int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void)
1261 TestApplication application;
1262 Dali::Integration::Core& core = application.GetCore();
1263 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1264 systemOverlay.GetOverlayRenderTasks().CreateTask();
1266 // SystemOverlay actor
1267 Actor systemOverlayActor = Actor::New();
1268 systemOverlayActor.SetSize(100.0f, 100.0f);
1269 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1270 systemOverlay.Add(systemOverlayActor);
1273 Actor stageActor = Actor::New();
1274 stageActor.SetSize(100.0f, 100.0f);
1275 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1276 Stage::GetCurrent().Add(stageActor);
1278 // Render and notify
1279 application.SendNotification();
1280 application.Render();
1282 // Set stage actor to touchable
1283 TouchEventData touchData;
1284 TouchEventDataFunctor touchFunctor( touchData );
1285 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1287 // Set system-overlay actor to have the gesture
1289 GestureReceivedFunctor functor(data);
1291 TapGestureDetector detector = TapGestureDetector::New();
1292 detector.Attach(systemOverlayActor);
1293 detector.DetectedSignal().Connect(&application, functor);
1295 Vector2 screenCoords( 50.0f, 50.0f );
1297 // Do a tap inside both actors' area
1298 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1299 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1300 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1301 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1306 // Do touch in the same area
1307 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1308 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1309 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1314 int UtcDaliTapGestureLayerConsumesTouch(void)
1316 TestApplication application;
1318 Actor actor = Actor::New();
1319 actor.SetSize(100.0f, 100.0f);
1320 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1321 Stage::GetCurrent().Add(actor);
1325 GestureReceivedFunctor functor(data);
1326 TapGestureDetector detector = TapGestureDetector::New();
1327 detector.Attach(actor);
1328 detector.DetectedSignal().Connect( &application, functor );
1330 // Add a layer to overlap the actor
1331 Layer layer = Layer::New();
1332 layer.SetSize(100.0f, 100.0f);
1333 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1334 Stage::GetCurrent().Add( layer );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 Vector2 screenCoords( 50.0f, 50.0f );
1343 // Emit signals, should receive
1344 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1345 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1346 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1349 // Set layer to consume all touch
1350 layer.SetTouchConsumed( true );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Emit the same signals again, should not receive
1357 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1358 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1359 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);