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 assign;
169 DALI_TEST_CHECK( detector );
171 DALI_TEST_CHECK( detector == assign );
175 int UtcDaliTapGestureDetectorNew(void)
177 TestApplication application;
179 TapGestureDetector detector = TapGestureDetector::New();
180 DALI_TEST_CHECK(detector);
181 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
182 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
184 TapGestureDetector detector2 = TapGestureDetector::New( 5u );
185 DALI_TEST_CHECK(detector2);
186 DALI_TEST_EQUALS(5u, detector2.GetMinimumTapsRequired(), TEST_LOCATION);
187 DALI_TEST_EQUALS(5u, detector2.GetMaximumTapsRequired(), TEST_LOCATION);
189 //Scoped test to test destructor
191 TapGestureDetector detector3 = TapGestureDetector::New();
192 DALI_TEST_CHECK(detector3);
195 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
196 Actor actor = Actor::New();
197 actor.SetSize(100.0f, 100.0f);
198 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
199 Stage::GetCurrent().Add(actor);
202 application.SendNotification();
203 application.Render();
205 detector.Attach(actor);
207 TouchEventFunctor touchFunctor;
208 actor.TouchedSignal().Connect( &application, touchFunctor );
210 Integration::TouchEvent touchEvent(1);
211 Integration::Point point;
212 point.SetDeviceId( 1 );
213 point.SetState( PointState::DOWN );
214 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
215 touchEvent.AddPoint(point);
216 application.ProcessEvent(touchEvent);
219 application.SendNotification();
220 application.Render();
222 // For line coverage, Initialise default constructor
223 TouchEvent touchEvent2;
227 int UtcDaliTapGestureDetectorDownCast(void)
229 TestApplication application;
230 tet_infoline("Testing Dali::TapGestureDetector::DownCast()");
232 TapGestureDetector detector = TapGestureDetector::New();
234 BaseHandle object(detector);
236 TapGestureDetector detector2 = TapGestureDetector::DownCast(object);
237 DALI_TEST_CHECK(detector2);
239 TapGestureDetector detector3 = DownCast< TapGestureDetector >(object);
240 DALI_TEST_CHECK(detector3);
242 BaseHandle unInitializedObject;
243 TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject);
244 DALI_TEST_CHECK(!detector4);
246 TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject);
247 DALI_TEST_CHECK(!detector5);
249 GestureDetector detector6 = TapGestureDetector::New();
250 TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6);
251 DALI_TEST_CHECK(detector7);
255 int UtcDaliTapGestureSetTapsRequired(void)
257 TestApplication application;
259 TapGestureDetector detector = TapGestureDetector::New();
261 const unsigned int minTaps = 3;
262 const unsigned int maxTaps = 7;
264 DALI_TEST_CHECK( minTaps != detector.GetMinimumTapsRequired() );
265 DALI_TEST_CHECK( maxTaps != detector.GetMaximumTapsRequired() );
267 detector.SetMinimumTapsRequired( minTaps );
268 detector.SetMaximumTapsRequired( maxTaps );
270 DALI_TEST_EQUALS( minTaps, detector.GetMinimumTapsRequired(), TEST_LOCATION );
271 DALI_TEST_EQUALS( maxTaps, detector.GetMaximumTapsRequired(), TEST_LOCATION );
273 // Attach an actor and change the required touches
275 Actor actor = Actor::New();
276 actor.SetSize(100.0f, 100.0f);
277 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
278 Stage::GetCurrent().Add(actor);
281 application.SendNotification();
282 application.Render();
285 GestureReceivedFunctor functor(data);
287 detector.Attach(actor);
288 detector.DetectedSignal().Connect( &application, functor );
290 // Ensure signal is emitted if minimum taps received
291 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps, 1u, Vector2(50.0f, 50.0f)));
292 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps, 1u, Vector2(50.0f, 50.0f)));
293 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
294 DALI_TEST_EQUALS( minTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
297 // Ensure signal is emitted if maximum taps received
298 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps, 1u, Vector2(50.0f, 50.0f)));
299 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps, 1u, Vector2(50.0f, 50.0f)));
300 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
301 DALI_TEST_EQUALS( maxTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
304 // Ensure signal is NOT emitted if outside the range
305 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
306 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
307 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
309 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
310 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
311 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
314 TestGestureManager& gestureManager = application.GetGestureManager();
315 gestureManager.Initialize();
317 detector.SetMinimumTapsRequired(4);
319 // Gesture detection should have been updated only
320 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
321 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
322 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
325 gestureManager.Initialize();
327 detector.SetMaximumTapsRequired(maxTaps);
329 // Gesture detection should NOT have been updated
330 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
331 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
332 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
335 gestureManager.Initialize();
337 // Create a second gesture detector that requires even less maximum touches
338 TapGestureDetector secondDetector = TapGestureDetector::New();
339 secondDetector.Attach(actor);
341 // Gesture detection should have been updated
342 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
343 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
344 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
347 gestureManager.Initialize();
349 // Delete the second detector so that our detection is updated again
350 secondDetector.Reset();
351 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
352 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
353 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
355 // Set the minimum to be greater than the maximum, should Assert
358 detector.SetMinimumTapsRequired( maxTaps );
359 detector.SetMaximumTapsRequired( minTaps );
360 DALI_TEST_CHECK( false ); // Should not get here
362 catch ( DaliException& e )
364 DALI_TEST_CHECK( true );
370 int UtcDaliTapGestureSetTapsRequiredMinMaxCheck(void)
372 TestApplication application;
374 // Attach an actor and change the required touches
376 Actor actor = Actor::New();
377 actor.SetSize(100.0f, 100.0f);
378 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
379 Stage::GetCurrent().Add(actor);
382 application.SendNotification();
383 application.Render();
385 // Set the minimum to be greater than the maximum, should Assert
389 TapGestureDetector detector = TapGestureDetector::New();
390 detector.SetMinimumTapsRequired( 7u );
391 detector.SetMaximumTapsRequired( 3u );
392 detector.Attach(actor);
393 DALI_TEST_CHECK( false ); // Should not get here
395 catch ( DaliException& e )
397 DALI_TEST_CHECK( true );
403 int UtcDaliTapGestureGetTapsRequired(void)
405 TestApplication application;
407 TapGestureDetector detector = TapGestureDetector::New();
408 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
409 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
413 int UtcDaliTapGestureSignalReceptionNegative(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 outside actor's area
434 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f)));
435 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f)));
436 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
440 int UtcDaliTapGestureSignalReceptionPositive(void)
442 TestApplication application;
444 Actor actor = Actor::New();
445 actor.SetSize(100.0f, 100.0f);
446 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
447 Stage::GetCurrent().Add(actor);
450 application.SendNotification();
451 application.Render();
454 GestureReceivedFunctor functor(data);
456 TapGestureDetector detector = TapGestureDetector::New();
457 detector.Attach(actor);
458 detector.DetectedSignal().Connect( &application, functor );
460 // Do a tap inside actor's area
461 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
462 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
463 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
464 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
465 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
466 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
470 int UtcDaliTapGestureSignalReceptionDetach(void)
472 TestApplication application;
474 Actor actor = Actor::New();
475 actor.SetSize(100.0f, 100.0f);
476 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
477 Stage::GetCurrent().Add(actor);
480 application.SendNotification();
481 application.Render();
484 GestureReceivedFunctor functor(data);
486 TapGestureDetector detector = TapGestureDetector::New();
487 detector.Attach(actor);
488 detector.DetectedSignal().Connect(&application, functor);
490 // Start tap within the actor's area
491 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
492 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
493 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
494 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
495 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
496 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
498 // repeat the tap within the actor's area - we should still receive the signal
500 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
501 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
502 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
503 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
504 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
505 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
508 detector.DetachAll();
510 // Ensure we are no longer signalled
512 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
513 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
514 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
515 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
516 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
517 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
521 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
523 TestApplication application;
526 GestureReceivedFunctor functor(data);
528 TapGestureDetector detector = TapGestureDetector::New();
529 detector.DetectedSignal().Connect(&application, functor);
531 // Actor lifetime is scoped
533 Actor actor = Actor::New();
534 actor.SetSize(100.0f, 100.0f);
535 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
536 Stage::GetCurrent().Add(actor);
539 application.SendNotification();
540 application.Render();
542 detector.Attach(actor);
544 // Start tap within the actor's area
545 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
546 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
547 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
549 // Remove the actor from stage and reset the data
550 Stage::GetCurrent().Remove(actor);
553 application.SendNotification();
554 application.Render();
557 // Actor should now have been destroyed
560 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
561 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
562 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
566 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
568 TestApplication application;
570 Actor actor = Actor::New();
571 actor.SetSize(100.0f, 100.0f);
572 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
573 Stage::GetCurrent().Add(actor);
576 application.SendNotification();
577 application.Render();
580 GestureReceivedFunctor functor(data);
582 TapGestureDetector detector = TapGestureDetector::New();
583 detector.Attach(actor);
584 detector.DetectedSignal().Connect(&application, functor);
586 // Do tap, only check finished value
587 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
588 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
589 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
590 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
591 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
592 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
594 // Rotate actor again and render
595 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
596 application.SendNotification();
597 application.Render();
599 // Do tap, should still receive event
601 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
602 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
603 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
604 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
605 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
606 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
608 // Rotate actor again and render
609 actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
610 application.SendNotification();
611 application.Render();
613 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
615 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f)));
616 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f)));
617 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
621 int UtcDaliTapGestureSignalReceptionChildHit(void)
623 TestApplication application;
625 Actor parent = Actor::New();
626 parent.SetSize(100.0f, 100.0f);
627 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
628 Stage::GetCurrent().Add(parent);
630 // Set child to completely cover parent.
631 // Change rotation of child to be different from parent so that we can check if our local coordinate
632 // conversion of the parent actor is correct.
633 Actor child = Actor::New();
634 child.SetSize(100.0f, 100.0f);
635 child.SetAnchorPoint(AnchorPoint::CENTER);
636 child.SetParentOrigin(ParentOrigin::CENTER);
637 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
640 TouchEventFunctor touchFunctor;
641 child.TouchedSignal().Connect(&application, touchFunctor);
644 application.SendNotification();
645 application.Render();
648 GestureReceivedFunctor functor(data);
650 TapGestureDetector detector = TapGestureDetector::New();
651 detector.Attach(parent);
652 detector.DetectedSignal().Connect(&application, functor);
654 // Do tap - hits child area but parent should still receive it
655 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
656 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
657 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
658 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
659 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
661 // Attach child and generate same touch points
662 // (Also proves that you can detach and then re-attach another actor)
663 detector.Attach(child);
664 detector.Detach(parent);
666 // Do an entire tap, only check finished value
668 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f)));
669 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f)));
670 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
671 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
672 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
676 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
678 TestApplication application;
680 Actor first = Actor::New();
681 first.SetSize(100.0f, 100.0f);
682 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
683 Stage::GetCurrent().Add(first);
685 Actor second = Actor::New();
686 second.SetSize(100.0f, 100.0f);
688 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
689 Stage::GetCurrent().Add(second);
692 application.SendNotification();
693 application.Render();
696 GestureReceivedFunctor functor(data);
698 TapGestureDetector detector = TapGestureDetector::New();
699 detector.Attach(first);
700 detector.Attach(second);
701 detector.DetectedSignal().Connect(&application, functor);
703 // Tap within second actor's area
704 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
705 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
706 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
707 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
709 // Tap within first actor's area
711 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
712 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
713 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
714 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
716 // Detach the second actor
717 detector.Detach(second);
719 // second actor shouldn't receive event
721 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
722 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
723 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
725 // first actor should continue receiving event
727 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
728 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
729 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
733 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
735 TestApplication application;
737 Actor actor = Actor::New();
738 actor.SetSize(100.0f, 100.0f);
739 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
740 Stage::GetCurrent().Add(actor);
743 application.SendNotification();
744 application.Render();
747 GestureReceivedFunctor functor(data);
749 TapGestureDetector detector = TapGestureDetector::New();
750 detector.Attach(actor);
751 detector.DetectedSignal().Connect(&application, functor);
753 // Tap in actor's area
754 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
755 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
756 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
758 // Actor become invisible - actor should not receive the next pan
759 actor.SetVisible(false);
762 application.SendNotification();
763 application.Render();
765 // Tap in the same area, shouldn't receive event
767 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
768 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
769 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
773 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
775 TestApplication application;
776 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
778 Actor first = Actor::New();
779 first.SetSize(100.0f, 100.0f);
780 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
781 Stage::GetCurrent().Add(first);
783 Actor second = Actor::New();
784 second.SetSize(100.0f, 100.0f);
785 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
790 application.SendNotification();
791 application.Render();
794 GestureReceivedFunctor functor(data);
796 TapGestureDetector firstDetector = TapGestureDetector::New();
797 firstDetector.Attach(first);
798 firstDetector.DetectedSignal().Connect(&application, functor);
800 // secondDetector is scoped
802 // Reset gestureManager statistics
803 gestureManager.Initialize();
805 TapGestureDetector secondDetector = TapGestureDetector::New( 2 );
806 secondDetector.Attach(second);
807 secondDetector.DetectedSignal().Connect(&application, functor);
809 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
810 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
811 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
813 // Tap within second actor's area
814 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 1u, Vector2(150.0f, 10.0f)));
815 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 1u, Vector2(150.0f, 10.0f)));
816 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
817 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
819 // Tap continues as single touch gesture - we should not receive any gesture
821 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f)));
822 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f)));
823 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
825 // Single touch tap starts - first actor should be panned
827 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
828 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
829 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
830 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
832 // Pan changes to double-touch - we shouldn't receive event
834 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f)));
835 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f)));
836 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
838 // Reset gesture manager statistics
839 gestureManager.Initialize();
842 // secondDetector has now been deleted. Gesture detection should have been updated only
843 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
844 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
845 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
849 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
851 TestApplication application;
853 Actor actor = Actor::New();
854 actor.SetSize(100.0f, 100.0f);
855 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
856 Stage::GetCurrent().Add(actor);
859 application.SendNotification();
860 application.Render();
862 // Attach actor to one detector
863 SignalData firstData;
864 GestureReceivedFunctor firstFunctor(firstData);
865 TapGestureDetector firstDetector = TapGestureDetector::New();
866 firstDetector.Attach(actor);
867 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
869 // Attach actor to another detector
870 SignalData secondData;
871 GestureReceivedFunctor secondFunctor(secondData);
872 TapGestureDetector secondDetector = TapGestureDetector::New();
873 secondDetector.Attach(actor);
874 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
876 // Tap in actor's area - both detector's functors should be called
877 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
878 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
879 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
880 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
884 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
886 TestApplication application;
888 Actor actor = Actor::New();
889 actor.SetSize(100.0f, 100.0f);
890 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
891 Stage::GetCurrent().Add(actor);
894 application.SendNotification();
895 application.Render();
897 // Attach actor to detector
899 GestureReceivedFunctor functor( data );
900 TapGestureDetector detector = TapGestureDetector::New();
901 detector.Attach(actor);
902 detector.DetectedSignal().Connect( &application, functor );
904 // Gesture possible in actor's area.
905 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
906 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
908 // Move actor somewhere else
909 actor.SetPosition( 100.0f, 100.0f );
912 application.SendNotification();
913 application.Render();
915 // Emit Started event, we should not receive the tap.
916 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
917 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
919 // Tap possible in empty area.
920 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
921 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
923 // Move actor in to the tap position.
924 actor.SetPosition( 0.0f, 0.0f );
927 application.SendNotification();
928 application.Render();
930 // Emit Started event, we should not receive the tap.
931 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
932 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
934 // Normal tap in actor's area for completeness.
935 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
936 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
937 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
941 int UtcDaliTapGestureEmitIncorrectStateClear(void)
943 TestApplication application;
945 Actor actor = Actor::New();
946 actor.SetSize(100.0f, 100.0f);
947 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
948 Stage::GetCurrent().Add(actor);
951 application.SendNotification();
952 application.Render();
954 // Attach actor to detector
956 GestureReceivedFunctor functor( data );
957 TapGestureDetector detector = TapGestureDetector::New();
958 detector.Attach(actor);
959 detector.DetectedSignal().Connect( &application, functor );
964 application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f)));
965 tet_result(TET_FAIL);
967 catch ( Dali::DaliException& e )
969 DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
974 int UtcDaliTapGestureEmitIncorrectStateContinuing(void)
976 TestApplication application;
978 Actor actor = Actor::New();
979 actor.SetSize(100.0f, 100.0f);
980 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
981 Stage::GetCurrent().Add(actor);
984 application.SendNotification();
985 application.Render();
987 // Attach actor to detector
989 GestureReceivedFunctor functor( data );
990 TapGestureDetector detector = TapGestureDetector::New();
991 detector.Attach(actor);
992 detector.DetectedSignal().Connect( &application, functor );
994 // Try a Continuing state
997 application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f)));
998 tet_result(TET_FAIL);
1000 catch ( Dali::DaliException& e )
1002 DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
1007 int UtcDaliTapGestureEmitIncorrectStateFinished(void)
1009 TestApplication application;
1011 Actor actor = Actor::New();
1012 actor.SetSize(100.0f, 100.0f);
1013 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1014 Stage::GetCurrent().Add(actor);
1016 // Render and notify
1017 application.SendNotification();
1018 application.Render();
1020 // Attach actor to detector
1022 GestureReceivedFunctor functor( data );
1023 TapGestureDetector detector = TapGestureDetector::New();
1024 detector.Attach(actor);
1025 detector.DetectedSignal().Connect( &application, functor );
1027 // Try a Finished state
1030 application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f)));
1031 tet_result(TET_FAIL);
1033 catch ( Dali::DaliException& e )
1035 DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
1040 int UtcDaliTapGestureActorUnstaged(void)
1042 TestApplication application;
1044 Actor actor = Actor::New();
1045 actor.SetSize(100.0f, 100.0f);
1046 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1047 Stage::GetCurrent().Add(actor);
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Attach actor to detector
1055 UnstageActorFunctor functor( data );
1056 TapGestureDetector detector = TapGestureDetector::New();
1057 detector.Attach(actor);
1058 detector.DetectedSignal().Connect( &application, functor );
1060 // Tap in Actor's area, actor removed in signal handler, should be handled gracefully.
1061 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1062 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1063 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1064 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
1068 int UtcDaliTapGestureRepeatedState(void)
1070 TestApplication application;
1072 Actor actor = Actor::New();
1073 actor.SetSize(100.0f, 100.0f);
1074 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1075 Stage::GetCurrent().Add(actor);
1077 // Render and notify
1078 application.SendNotification();
1079 application.Render();
1081 // Attach actor to detector
1083 GestureReceivedFunctor functor( data );
1084 TapGestureDetector detector = TapGestureDetector::New();
1085 detector.Attach(actor);
1086 detector.DetectedSignal().Connect( &application, functor );
1088 // Emit two possibles
1089 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1090 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1091 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1093 // Send a couple of Started states, only first one should be received.
1094 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1095 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1097 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1098 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1100 // Send a couple of cancelled states, no reception
1101 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 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 UtcDaliTapGesturePossibleCancelled(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 );
1127 // Emit a possible and then a cancelled, no reception
1128 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1129 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1130 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1134 int UtcDaliTapGestureDetectorRemovedWhilePossible(void)
1136 TestApplication application;
1138 Actor actor = Actor::New();
1139 actor.SetSize(100.0f, 100.0f);
1140 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1141 Stage::GetCurrent().Add(actor);
1143 // Render and notify
1144 application.SendNotification();
1145 application.Render();
1147 // Attach actor to detector
1149 GestureReceivedFunctor functor( data );
1150 TapGestureDetector detector = TapGestureDetector::New();
1151 detector.Attach(actor);
1152 detector.DetectedSignal().Connect( &application, functor );
1155 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1157 // Detach actor and send a Started state, no signal.
1158 detector.DetachAll();
1159 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1160 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1164 int UtcDaliTapGestureActorRemovedWhilePossible(void)
1166 TestApplication application;
1168 Actor actor = Actor::New();
1169 actor.SetSize(100.0f, 100.0f);
1170 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1171 Stage::GetCurrent().Add(actor);
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Attach actor to detector
1179 GestureReceivedFunctor functor( data );
1180 TapGestureDetector detector = TapGestureDetector::New();
1181 detector.Attach(actor);
1182 detector.DetectedSignal().Connect( &application, functor );
1185 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1187 // Remove, render and delete actor
1188 Stage::GetCurrent().Remove(actor);
1189 application.SendNotification();
1190 application.Render();
1193 // Send a Started state, no signal.
1194 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1195 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1199 int UtcDaliTapGestureSystemOverlay(void)
1201 TestApplication application;
1202 Dali::Integration::Core& core = application.GetCore();
1203 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1204 systemOverlay.GetOverlayRenderTasks().CreateTask();
1206 Actor actor = Actor::New();
1207 actor.SetSize(100.0f, 100.0f);
1208 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1209 systemOverlay.Add(actor);
1211 // Render and notify
1212 application.SendNotification();
1213 application.Render();
1216 GestureReceivedFunctor functor(data);
1218 TapGestureDetector detector = TapGestureDetector::New();
1219 detector.Attach(actor);
1220 detector.DetectedSignal().Connect(&application, functor);
1222 Vector2 screenCoords( 50.0f, 50.0f );
1224 // Do a tap inside actor's area
1225 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1226 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1227 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1231 int UtcDaliTapGestureBehindTouchableSystemOverlay(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 system-overlay actor to touchable
1255 TouchEventData touchData;
1256 TouchEventDataFunctor touchFunctor( touchData );
1257 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1259 // Set stage actor to receive the gesture
1261 GestureReceivedFunctor functor(data);
1263 TapGestureDetector detector = TapGestureDetector::New();
1264 detector.Attach(stageActor);
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( PointState::DOWN, screenCoords ) );
1280 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1281 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1286 int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void)
1288 TestApplication application;
1289 Dali::Integration::Core& core = application.GetCore();
1290 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1291 systemOverlay.GetOverlayRenderTasks().CreateTask();
1293 // SystemOverlay actor
1294 Actor systemOverlayActor = Actor::New();
1295 systemOverlayActor.SetSize(100.0f, 100.0f);
1296 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1297 systemOverlay.Add(systemOverlayActor);
1300 Actor stageActor = Actor::New();
1301 stageActor.SetSize(100.0f, 100.0f);
1302 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1303 Stage::GetCurrent().Add(stageActor);
1305 // Render and notify
1306 application.SendNotification();
1307 application.Render();
1309 // Set stage actor to touchable
1310 TouchEventData touchData;
1311 TouchEventDataFunctor touchFunctor( touchData );
1312 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1314 // Set system-overlay actor to have the gesture
1316 GestureReceivedFunctor functor(data);
1318 TapGestureDetector detector = TapGestureDetector::New();
1319 detector.Attach(systemOverlayActor);
1320 detector.DetectedSignal().Connect(&application, functor);
1322 Vector2 screenCoords( 50.0f, 50.0f );
1324 // Do a tap inside both actors' area
1325 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1326 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1327 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1328 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1333 // Do touch in the same area
1334 application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) );
1335 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1336 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1341 int UtcDaliTapGestureLayerConsumesTouch(void)
1343 TestApplication application;
1345 Actor actor = Actor::New();
1346 actor.SetSize(100.0f, 100.0f);
1347 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1348 Stage::GetCurrent().Add(actor);
1352 GestureReceivedFunctor functor(data);
1353 TapGestureDetector detector = TapGestureDetector::New();
1354 detector.Attach(actor);
1355 detector.DetectedSignal().Connect( &application, functor );
1357 // Add a layer to overlap the actor
1358 Layer layer = Layer::New();
1359 layer.SetSize(100.0f, 100.0f);
1360 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1361 Stage::GetCurrent().Add( layer );
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 Vector2 screenCoords( 50.0f, 50.0f );
1370 // Emit signals, should receive
1371 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1372 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1373 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1376 // Set layer to consume all touch
1377 layer.SetTouchConsumed( true );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Emit the same signals again, should not receive
1384 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1385 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1386 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);