2 * Copyright (c) 2019 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/render-task-list-integ.h>
24 #include <dali-test-suite-utils.h>
25 #include <test-touch-utils.h>
29 void utc_dali_tap_gesture_detector_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_tap_gesture_detector_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled(false),
48 voidFunctorCalled(false)
53 functorCalled = false;
54 voidFunctorCalled = false;
56 receivedGesture.numberOfTaps = 0u;
57 receivedGesture.numberOfTouches = 0u;
58 receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
59 receivedGesture.localPoint = Vector2(0.0f, 0.0f);
65 bool voidFunctorCalled;
66 TapGesture receivedGesture;
70 // Functor that sets the data when called
71 struct GestureReceivedFunctor
73 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
75 void operator()(Actor actor, const TapGesture& tap)
77 signalData.functorCalled = true;
78 signalData.receivedGesture = tap;
79 signalData.tappedActor = actor;
84 signalData.voidFunctorCalled = true;
87 SignalData& signalData;
90 // Functor that removes the gestured actor from stage
91 struct UnstageActorFunctor : public GestureReceivedFunctor
93 UnstageActorFunctor( SignalData& data ) : GestureReceivedFunctor( data ) { }
95 void operator()(Actor actor, const TapGesture& tap)
97 GestureReceivedFunctor::operator()( actor, tap );
98 Stage::GetCurrent().Remove( actor );
102 // Functor for receiving a touch event
103 struct TouchEventFunctor
105 bool operator()(Actor actor, const TouchEvent& touch)
108 unsigned int points = touch.GetPointCount();
111 const TouchPoint& touchPoint = touch.GetPoint(0);
112 tet_printf("Touch Point state = %d\n", touchPoint.state);
120 ///////////////////////////////////////////////////////////////////////////////
123 // Positive test case for a method
124 int UtcDaliTapGestureDetectorConstructor(void)
126 TestApplication application;
128 TapGestureDetector detector;
129 DALI_TEST_CHECK(!detector);
133 int UtcDaliTapGestureDetectorCopyConstructorP(void)
135 TestApplication application;
137 TapGestureDetector detector = TapGestureDetector::New();
139 TapGestureDetector copy( detector );
140 DALI_TEST_CHECK( detector );
144 int UtcDaliTapGestureDetectorAssignmentOperatorP(void)
146 TestApplication application;
148 TapGestureDetector detector = TapGestureDetector::New();;
150 TapGestureDetector assign;
152 DALI_TEST_CHECK( detector );
154 DALI_TEST_CHECK( detector == assign );
158 int UtcDaliTapGestureDetectorNew(void)
160 TestApplication application;
162 TapGestureDetector detector = TapGestureDetector::New();
163 DALI_TEST_CHECK(detector);
164 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
165 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
167 TapGestureDetector detector2 = TapGestureDetector::New( 5u );
168 DALI_TEST_CHECK(detector2);
169 DALI_TEST_EQUALS(5u, detector2.GetMinimumTapsRequired(), TEST_LOCATION);
170 DALI_TEST_EQUALS(5u, detector2.GetMaximumTapsRequired(), TEST_LOCATION);
172 //Scoped test to test destructor
174 TapGestureDetector detector3 = TapGestureDetector::New();
175 DALI_TEST_CHECK(detector3);
178 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
179 Actor actor = Actor::New();
180 actor.SetSize(100.0f, 100.0f);
181 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
182 Stage::GetCurrent().Add(actor);
185 application.SendNotification();
186 application.Render();
188 detector.Attach(actor);
190 TouchEventFunctor touchFunctor;
191 actor.TouchedSignal().Connect( &application, touchFunctor );
193 Integration::TouchEvent touchEvent(1);
194 Integration::Point point;
195 point.SetDeviceId( 1 );
196 point.SetState( PointState::DOWN );
197 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
198 touchEvent.AddPoint(point);
199 application.ProcessEvent(touchEvent);
202 application.SendNotification();
203 application.Render();
205 // For line coverage, Initialise default constructor
206 TouchEvent touchEvent2;
210 int UtcDaliTapGestureDetectorDownCast(void)
212 TestApplication application;
213 tet_infoline("Testing Dali::TapGestureDetector::DownCast()");
215 TapGestureDetector detector = TapGestureDetector::New();
217 BaseHandle object(detector);
219 TapGestureDetector detector2 = TapGestureDetector::DownCast(object);
220 DALI_TEST_CHECK(detector2);
222 TapGestureDetector detector3 = DownCast< TapGestureDetector >(object);
223 DALI_TEST_CHECK(detector3);
225 BaseHandle unInitializedObject;
226 TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject);
227 DALI_TEST_CHECK(!detector4);
229 TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject);
230 DALI_TEST_CHECK(!detector5);
232 GestureDetector detector6 = TapGestureDetector::New();
233 TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6);
234 DALI_TEST_CHECK(detector7);
238 int UtcDaliTapGestureSetTapsRequiredMinMaxCheck(void)
240 TestApplication application;
242 // Attach an actor and change the required touches
244 Actor actor = Actor::New();
245 actor.SetSize(100.0f, 100.0f);
246 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
247 Stage::GetCurrent().Add(actor);
250 application.SendNotification();
251 application.Render();
253 // Set the minimum to be greater than the maximum, should Assert
257 TapGestureDetector detector = TapGestureDetector::New();
258 detector.SetMinimumTapsRequired( 7u );
259 detector.SetMaximumTapsRequired( 3u );
260 detector.Attach(actor);
261 DALI_TEST_CHECK( false ); // Should not get here
263 catch ( DaliException& e )
265 DALI_TEST_CHECK( true );
271 int UtcDaliTapGestureGetTapsRequired(void)
273 TestApplication application;
275 TapGestureDetector detector = TapGestureDetector::New();
276 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
277 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
281 int UtcDaliTapGestureSignalReceptionNegative(void)
283 TestApplication application;
285 Actor actor = Actor::New();
286 actor.SetSize(100.0f, 100.0f);
287 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
288 Stage::GetCurrent().Add(actor);
291 application.SendNotification();
292 application.Render();
295 GestureReceivedFunctor functor(data);
297 TapGestureDetector detector = TapGestureDetector::New();
298 detector.Attach(actor);
299 detector.DetectedSignal().Connect( &application, functor );
301 // Do a tap outside actor's area
302 TestGenerateTap( application, 112.0f, 112.0f, 100 );
303 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
307 int UtcDaliTapGestureSignalReceptionPositive(void)
309 TestApplication application;
311 Actor actor = Actor::New();
312 actor.SetSize(100.0f, 100.0f);
313 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
314 Stage::GetCurrent().Add(actor);
317 application.SendNotification();
318 application.Render();
321 GestureReceivedFunctor functor(data);
323 TapGestureDetector detector = TapGestureDetector::New();
324 detector.Attach(actor);
325 detector.DetectedSignal().Connect( &application, functor );
327 // Do a tap inside actor's area
328 TestGenerateTap( application, 50.0f, 50.0f, 100 );
329 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
330 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
331 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
332 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
336 int UtcDaliTapGestureSignalReceptionDetach(void)
338 TestApplication application;
340 Actor actor = Actor::New();
341 actor.SetSize(100.0f, 100.0f);
342 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
343 Stage::GetCurrent().Add(actor);
346 application.SendNotification();
347 application.Render();
350 GestureReceivedFunctor functor(data);
352 TapGestureDetector detector = TapGestureDetector::New();
353 detector.Attach(actor);
354 detector.DetectedSignal().Connect(&application, functor);
356 // Start tap within the actor's area
357 TestGenerateTap( application, 20.0f, 20.0f, 100 );
358 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
359 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
360 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
361 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
363 // repeat the tap within the actor's area - we should still receive the signal
365 TestGenerateTap( application, 50.0f, 50.0f, 700 );
366 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
367 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
368 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
369 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
372 detector.DetachAll();
374 // Ensure we are no longer signalled
376 TestGenerateTap( application, 20.0f, 20.0f, 1300 );
377 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
378 TestGenerateTap( application, 50.0f, 50.0f, 1900 );
379 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
383 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
385 TestApplication application;
388 GestureReceivedFunctor functor(data);
390 TapGestureDetector detector = TapGestureDetector::New();
391 detector.DetectedSignal().Connect(&application, functor);
393 // Actor lifetime is scoped
395 Actor actor = Actor::New();
396 actor.SetSize(100.0f, 100.0f);
397 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
398 Stage::GetCurrent().Add(actor);
401 application.SendNotification();
402 application.Render();
404 detector.Attach(actor);
406 // Start tap within the actor's area
407 TestGenerateTap( application, 20.0f, 20.0f, 100 );
408 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
410 // Remove the actor from stage and reset the data
411 Stage::GetCurrent().Remove(actor);
414 application.SendNotification();
415 application.Render();
418 // Actor should now have been destroyed
421 TestGenerateTap( application, 20.0f, 20.0f, 700 );
422 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
426 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
428 TestApplication application;
430 Actor actor = Actor::New();
431 actor.SetSize(100.0f, 100.0f);
432 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
433 Stage::GetCurrent().Add(actor);
436 application.SendNotification();
437 application.Render();
440 GestureReceivedFunctor functor(data);
442 TapGestureDetector detector = TapGestureDetector::New();
443 detector.Attach(actor);
444 detector.DetectedSignal().Connect(&application, functor);
446 // Do tap, only check finished value
447 TestGenerateTap( application, 5.0f, 5.0f, 100 );
448 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
449 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
450 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
451 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
453 // Rotate actor again and render
454 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
455 application.SendNotification();
456 application.Render();
458 // Do tap, should still receive event
460 TestGenerateTap( application, 5.0f, 5.0f, 700 );
461 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
462 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
463 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
464 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
466 // Rotate actor again and render
467 actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
468 application.SendNotification();
469 application.Render();
471 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
473 TestGenerateTap( application, 70.0f, 70.0f, 1300 );
474 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
478 int UtcDaliTapGestureSignalReceptionChildHit(void)
480 TestApplication application;
482 Actor parent = Actor::New();
483 parent.SetSize(100.0f, 100.0f);
484 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
485 Stage::GetCurrent().Add(parent);
487 // Set child to completely cover parent.
488 // Change rotation of child to be different from parent so that we can check if our local coordinate
489 // conversion of the parent actor is correct.
490 Actor child = Actor::New();
491 child.SetSize(100.0f, 100.0f);
492 child.SetAnchorPoint(AnchorPoint::CENTER);
493 child.SetParentOrigin(ParentOrigin::CENTER);
494 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
497 TouchEventFunctor touchFunctor;
498 child.TouchedSignal().Connect(&application, touchFunctor);
501 application.SendNotification();
502 application.Render();
505 GestureReceivedFunctor functor(data);
507 TapGestureDetector detector = TapGestureDetector::New();
508 detector.Attach(parent);
509 detector.DetectedSignal().Connect(&application, functor);
511 // Do tap - hits child area but parent should still receive it
512 TestGenerateTap( application, 50.0f, 50.0f, 100 );
513 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
514 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
515 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
517 // Attach child and generate same touch points
518 // (Also proves that you can detach and then re-attach another actor)
519 detector.Attach(child);
520 detector.Detach(parent);
522 // Do an entire tap, only check finished value
524 TestGenerateTap( application, 51.0f, 51.0f, 700 );
525 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
526 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
527 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
531 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
533 TestApplication application;
535 Actor first = Actor::New();
536 first.SetSize(100.0f, 100.0f);
537 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
538 Stage::GetCurrent().Add(first);
540 Actor second = Actor::New();
541 second.SetSize(100.0f, 100.0f);
543 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
544 Stage::GetCurrent().Add(second);
547 application.SendNotification();
548 application.Render();
551 GestureReceivedFunctor functor(data);
553 TapGestureDetector detector = TapGestureDetector::New();
554 detector.Attach(first);
555 detector.Attach(second);
556 detector.DetectedSignal().Connect(&application, functor);
558 // Tap within second actor's area
559 TestGenerateTap( application, 120.0f, 10.0f, 100 );
560 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
561 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
563 // Tap within first actor's area
565 TestGenerateTap( application, 20.0f, 10.0f, 700 );
566 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
567 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
569 // Detach the second actor
570 detector.Detach(second);
572 // second actor shouldn't receive event
574 TestGenerateTap( application, 120.0f, 10.0f, 1300 );
575 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
577 // first actor should continue receiving event
579 TestGenerateTap( application, 20.0f, 10.0f, 1900 );
580 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
584 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
586 TestApplication application;
588 Actor actor = Actor::New();
589 actor.SetSize(100.0f, 100.0f);
590 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
591 Stage::GetCurrent().Add(actor);
594 application.SendNotification();
595 application.Render();
598 GestureReceivedFunctor functor(data);
600 TapGestureDetector detector = TapGestureDetector::New();
601 detector.Attach(actor);
602 detector.DetectedSignal().Connect(&application, functor);
604 // Tap in actor's area
605 TestGenerateTap( application, 50.0f, 10.0f, 100 );
606 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
608 // Actor become invisible - actor should not receive the next pan
609 actor.SetVisible(false);
612 application.SendNotification();
613 application.Render();
615 // Tap in the same area, shouldn't receive event
617 TestGenerateTap( application, 50.0f, 10.0f, 700 );
618 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
622 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
624 TestApplication application;
626 Actor first = Actor::New();
627 first.SetSize(100.0f, 100.0f);
628 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
629 Stage::GetCurrent().Add(first);
631 Actor second = Actor::New();
632 second.SetSize(100.0f, 100.0f);
633 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
638 application.SendNotification();
639 application.Render();
642 GestureReceivedFunctor functor(data);
644 TapGestureDetector firstDetector = TapGestureDetector::New();
645 firstDetector.Attach(first);
646 firstDetector.DetectedSignal().Connect(&application, functor);
648 // secondDetector is scoped
650 TapGestureDetector secondDetector = TapGestureDetector::New( 2 );
651 secondDetector.Attach(second);
652 secondDetector.DetectedSignal().Connect(&application, functor);
654 // Tap within second actor's area
655 TestGenerateTap( application, 150.0f, 10.0f, 100 );
656 TestGenerateTap( application, 150.0f, 10.0f, 200 );
658 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
659 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
661 // Tap continues as single touch gesture - we should not receive any gesture
663 TestGenerateTap( application, 150.0f, 10.0f, 800 );
664 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
666 // Single touch tap starts - first actor should be panned
668 TestGenerateTap( application, 50.0f, 10.0f, 1400 );
669 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
670 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
672 // Pan changes to double-touch - we shouldn't receive event
675 TestGenerateTwoPointTap( application, 50.0f, 10.0f, 60.0f, 20.0f, 2000 );
677 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
683 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
685 TestApplication application;
687 Actor actor = Actor::New();
688 actor.SetSize(100.0f, 100.0f);
689 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
690 Stage::GetCurrent().Add(actor);
693 application.SendNotification();
694 application.Render();
696 // Attach actor to one detector
697 SignalData firstData;
698 GestureReceivedFunctor firstFunctor(firstData);
699 TapGestureDetector firstDetector = TapGestureDetector::New();
700 firstDetector.Attach(actor);
701 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
703 // Attach actor to another detector
704 SignalData secondData;
705 GestureReceivedFunctor secondFunctor(secondData);
706 TapGestureDetector secondDetector = TapGestureDetector::New();
707 secondDetector.Attach(actor);
708 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
710 // Tap in actor's area - both detector's functors should be called
711 TestGenerateTap( application, 50.0f, 10.0f, 100 );
712 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
713 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
717 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
719 TestApplication application;
721 Actor actor = Actor::New();
722 actor.SetSize(100.0f, 100.0f);
723 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
724 Stage::GetCurrent().Add(actor);
727 application.SendNotification();
728 application.Render();
730 // Attach actor to detector
732 GestureReceivedFunctor functor( data );
733 TapGestureDetector detector = TapGestureDetector::New();
734 detector.Attach(actor);
735 detector.DetectedSignal().Connect( &application, functor );
737 // Gesture possible in actor's area.
738 TestStartLongPress( application, 50.0f, 10.0f, 100 );
739 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
741 // Move actor somewhere else
742 actor.SetPosition( 100.0f, 100.0f );
745 application.SendNotification();
746 application.Render();
748 // Emit Started event, we should not receive the tap.
749 TestEndPan( application, Vector2(50.0f, 10.0f), 120 );
750 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
752 // Tap possible in empty area.
753 TestStartLongPress( application, 50.0f, 10.0f, 700 );
754 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
756 // Move actor in to the tap position.
757 actor.SetPosition( 0.0f, 0.0f );
760 application.SendNotification();
761 application.Render();
763 // Emit Started event, we should not receive the tap.
764 TestEndPan( application, Vector2(50.0f, 10.0f), 720 );
765 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
767 // Normal tap in actor's area for completeness.
768 TestGenerateTap( application, 50.0f, 10.0f, 1300 );
769 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
773 int UtcDaliTapGestureActorUnstaged(void)
775 TestApplication application;
777 Actor actor = Actor::New();
778 actor.SetSize(100.0f, 100.0f);
779 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
780 Stage::GetCurrent().Add(actor);
783 application.SendNotification();
784 application.Render();
786 // Attach actor to detector
788 UnstageActorFunctor functor( data );
789 TapGestureDetector detector = TapGestureDetector::New();
790 detector.Attach(actor);
791 detector.DetectedSignal().Connect( &application, functor );
793 TestGenerateTap( application, 50.0f, 10.0f, 100 );
794 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
795 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
799 int UtcDaliTapGestureDetectorRemovedWhilePossible(void)
801 TestApplication application;
803 Actor actor = Actor::New();
804 actor.SetSize(100.0f, 100.0f);
805 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
806 Stage::GetCurrent().Add(actor);
809 application.SendNotification();
810 application.Render();
812 // Attach actor to detector
814 GestureReceivedFunctor functor( data );
815 TapGestureDetector detector = TapGestureDetector::New();
816 detector.Attach(actor);
817 detector.DetectedSignal().Connect( &application, functor );
819 // Emit a possible - Down press, as emitted by long press function
820 TestStartLongPress( application, 50.0f, 10.0f, 100 );
822 // Detach actor and send a Started state, no signal.
823 detector.DetachAll();
824 TestEndPan( application, Vector2(50.0f, 10.0f), 120 );
825 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
829 int UtcDaliTapGestureActorRemovedWhilePossible(void)
831 TestApplication application;
833 Actor actor = Actor::New();
834 actor.SetSize(100.0f, 100.0f);
835 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836 Stage::GetCurrent().Add(actor);
839 application.SendNotification();
840 application.Render();
842 // Attach actor to detector
844 GestureReceivedFunctor functor( data );
845 TapGestureDetector detector = TapGestureDetector::New();
846 detector.Attach(actor);
847 detector.DetectedSignal().Connect( &application, functor );
849 // Emit a possible - Down press, as emitted by long press function
850 TestStartLongPress( application, 50.0f, 10.0f, 100 );
852 // Remove, render and delete actor
853 Stage::GetCurrent().Remove(actor);
854 application.SendNotification();
855 application.Render();
858 // Send a Started state, no signal - Up motion as provided by end pan function
859 TestEndPan( application, Vector2(50.0f, 10.0f), 120 );
860 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
864 int UtcDaliTapGestureLayerConsumesTouch(void)
866 TestApplication application;
868 Actor actor = Actor::New();
869 actor.SetSize(100.0f, 100.0f);
870 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
871 Stage::GetCurrent().Add(actor);
875 GestureReceivedFunctor functor(data);
876 TapGestureDetector detector = TapGestureDetector::New();
877 detector.Attach(actor);
878 detector.DetectedSignal().Connect( &application, functor );
880 // Add a layer to overlap the actor
881 Layer layer = Layer::New();
882 layer.SetSize(100.0f, 100.0f);
883 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
884 Stage::GetCurrent().Add( layer );
888 application.SendNotification();
889 application.Render();
891 // Emit signals, should receive
892 TestGenerateTap( application, 50.0f, 50.0f, 100 );
893 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
896 // Set layer to consume all touch
897 layer.SetTouchConsumed( true );
900 application.SendNotification();
901 application.Render();
903 // Emit the same signals again, should not receive
904 TestGenerateTap( application, 50.0f, 50.0f, 700 );
905 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);