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 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
212 touchEvent.AddPoint(point);
213 application.ProcessEvent(touchEvent);
216 application.SendNotification();
217 application.Render();
219 // For line coverage, Initialise default constructor
220 TouchEvent touchEvent2;
224 int UtcDaliTapGestureDetectorDownCast(void)
226 TestApplication application;
227 tet_infoline("Testing Dali::TapGestureDetector::DownCast()");
229 TapGestureDetector detector = TapGestureDetector::New();
231 BaseHandle object(detector);
233 TapGestureDetector detector2 = TapGestureDetector::DownCast(object);
234 DALI_TEST_CHECK(detector2);
236 TapGestureDetector detector3 = DownCast< TapGestureDetector >(object);
237 DALI_TEST_CHECK(detector3);
239 BaseHandle unInitializedObject;
240 TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject);
241 DALI_TEST_CHECK(!detector4);
243 TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject);
244 DALI_TEST_CHECK(!detector5);
246 GestureDetector detector6 = TapGestureDetector::New();
247 TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6);
248 DALI_TEST_CHECK(detector7);
252 int UtcDaliTapGestureSetTapsRequired(void)
254 TestApplication application;
256 TapGestureDetector detector = TapGestureDetector::New();
258 const unsigned int minTaps = 3;
259 const unsigned int maxTaps = 7;
261 DALI_TEST_CHECK( minTaps != detector.GetMinimumTapsRequired() );
262 DALI_TEST_CHECK( maxTaps != detector.GetMaximumTapsRequired() );
264 detector.SetMinimumTapsRequired( minTaps );
265 detector.SetMaximumTapsRequired( maxTaps );
267 DALI_TEST_EQUALS( minTaps, detector.GetMinimumTapsRequired(), TEST_LOCATION );
268 DALI_TEST_EQUALS( maxTaps, detector.GetMaximumTapsRequired(), TEST_LOCATION );
270 // Attach an actor and change the required touches
272 Actor actor = Actor::New();
273 actor.SetSize(100.0f, 100.0f);
274 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
275 Stage::GetCurrent().Add(actor);
278 application.SendNotification();
279 application.Render();
282 GestureReceivedFunctor functor(data);
284 detector.Attach(actor);
285 detector.DetectedSignal().Connect( &application, functor );
287 // Ensure signal is emitted if minimum taps received
288 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps, 1u, Vector2(50.0f, 50.0f)));
289 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps, 1u, Vector2(50.0f, 50.0f)));
290 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
291 DALI_TEST_EQUALS( minTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
294 // Ensure signal is emitted if maximum taps received
295 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps, 1u, Vector2(50.0f, 50.0f)));
296 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps, 1u, Vector2(50.0f, 50.0f)));
297 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
298 DALI_TEST_EQUALS( maxTaps, data.receivedGesture.numberOfTaps, TEST_LOCATION );
301 // Ensure signal is NOT emitted if outside the range
302 application.ProcessEvent(GenerateTap(Gesture::Possible, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
303 application.ProcessEvent(GenerateTap(Gesture::Started, minTaps - 1, 1u, Vector2(50.0f, 50.0f)));
304 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
306 application.ProcessEvent(GenerateTap(Gesture::Possible, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
307 application.ProcessEvent(GenerateTap(Gesture::Started, maxTaps + 1, 1u, Vector2(50.0f, 50.0f)));
308 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
311 TestGestureManager& gestureManager = application.GetGestureManager();
312 gestureManager.Initialize();
314 detector.SetMinimumTapsRequired(4);
316 // Gesture detection should have been updated only
317 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
318 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
319 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
322 gestureManager.Initialize();
324 detector.SetMaximumTapsRequired(maxTaps);
326 // Gesture detection should NOT have been updated
327 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
328 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
329 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
332 gestureManager.Initialize();
334 // Create a second gesture detector that requires even less maximum touches
335 TapGestureDetector secondDetector = TapGestureDetector::New();
336 secondDetector.Attach(actor);
338 // Gesture detection should have been updated
339 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
340 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
341 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
344 gestureManager.Initialize();
346 // Delete the second detector so that our detection is updated again
347 secondDetector.Reset();
348 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
349 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
350 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
352 // Set the minimum to be greater than the maximum, should Assert
355 detector.SetMinimumTapsRequired( maxTaps );
356 detector.SetMaximumTapsRequired( minTaps );
357 DALI_TEST_CHECK( false ); // Should not get here
359 catch ( DaliException& e )
361 DALI_TEST_CHECK( true );
367 int UtcDaliTapGestureSetTapsRequiredMinMaxCheck(void)
369 TestApplication application;
371 // Attach an actor and change the required touches
373 Actor actor = Actor::New();
374 actor.SetSize(100.0f, 100.0f);
375 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
376 Stage::GetCurrent().Add(actor);
379 application.SendNotification();
380 application.Render();
382 // Set the minimum to be greater than the maximum, should Assert
386 TapGestureDetector detector = TapGestureDetector::New();
387 detector.SetMinimumTapsRequired( 7u );
388 detector.SetMaximumTapsRequired( 3u );
389 detector.Attach(actor);
390 DALI_TEST_CHECK( false ); // Should not get here
392 catch ( DaliException& e )
394 DALI_TEST_CHECK( true );
400 int UtcDaliTapGestureGetTapsRequired(void)
402 TestApplication application;
404 TapGestureDetector detector = TapGestureDetector::New();
405 DALI_TEST_EQUALS(1u, detector.GetMinimumTapsRequired(), TEST_LOCATION);
406 DALI_TEST_EQUALS(1u, detector.GetMaximumTapsRequired(), TEST_LOCATION);
410 int UtcDaliTapGestureSignalReceptionNegative(void)
412 TestApplication application;
414 Actor actor = Actor::New();
415 actor.SetSize(100.0f, 100.0f);
416 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
417 Stage::GetCurrent().Add(actor);
420 application.SendNotification();
421 application.Render();
424 GestureReceivedFunctor functor(data);
426 TapGestureDetector detector = TapGestureDetector::New();
427 detector.Attach(actor);
428 detector.DetectedSignal().Connect( &application, functor );
430 // Do a tap outside actor's area
431 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f)));
432 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f)));
433 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
437 int UtcDaliTapGestureSignalReceptionPositive(void)
439 TestApplication application;
441 Actor actor = Actor::New();
442 actor.SetSize(100.0f, 100.0f);
443 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
444 Stage::GetCurrent().Add(actor);
447 application.SendNotification();
448 application.Render();
451 GestureReceivedFunctor functor(data);
453 TapGestureDetector detector = TapGestureDetector::New();
454 detector.Attach(actor);
455 detector.DetectedSignal().Connect( &application, functor );
457 // Do a tap inside actor's area
458 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
459 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
460 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
461 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
462 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
463 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
467 int UtcDaliTapGestureSignalReceptionDetach(void)
469 TestApplication application;
471 Actor actor = Actor::New();
472 actor.SetSize(100.0f, 100.0f);
473 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
474 Stage::GetCurrent().Add(actor);
477 application.SendNotification();
478 application.Render();
481 GestureReceivedFunctor functor(data);
483 TapGestureDetector detector = TapGestureDetector::New();
484 detector.Attach(actor);
485 detector.DetectedSignal().Connect(&application, functor);
487 // Start tap within the actor's area
488 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
489 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
490 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
491 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
492 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
493 DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
495 // repeat the tap within the actor's area - we should still receive the signal
497 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
498 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
499 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
500 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
501 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
502 DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
505 detector.DetachAll();
507 // Ensure we are no longer signalled
509 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
510 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
511 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
512 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
513 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
514 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
518 int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void)
520 TestApplication application;
523 GestureReceivedFunctor functor(data);
525 TapGestureDetector detector = TapGestureDetector::New();
526 detector.DetectedSignal().Connect(&application, functor);
528 // Actor lifetime is scoped
530 Actor actor = Actor::New();
531 actor.SetSize(100.0f, 100.0f);
532 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
533 Stage::GetCurrent().Add(actor);
536 application.SendNotification();
537 application.Render();
539 detector.Attach(actor);
541 // Start tap within the actor's area
542 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
543 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
544 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
546 // Remove the actor from stage and reset the data
547 Stage::GetCurrent().Remove(actor);
550 application.SendNotification();
551 application.Render();
554 // Actor should now have been destroyed
557 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f)));
558 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f)));
559 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
563 int UtcDaliTapGestureSignalReceptionRotatedActor(void)
565 TestApplication application;
567 Actor actor = Actor::New();
568 actor.SetSize(100.0f, 100.0f);
569 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
570 Stage::GetCurrent().Add(actor);
573 application.SendNotification();
574 application.Render();
577 GestureReceivedFunctor functor(data);
579 TapGestureDetector detector = TapGestureDetector::New();
580 detector.Attach(actor);
581 detector.DetectedSignal().Connect(&application, functor);
583 // Do tap, only check finished value
584 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
585 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
586 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
587 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
588 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
589 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
591 // Rotate actor again and render
592 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
593 application.SendNotification();
594 application.Render();
596 // Do tap, should still receive event
598 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f)));
599 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f)));
600 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
601 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION);
602 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
603 DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
605 // Rotate actor again and render
606 actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
607 application.SendNotification();
608 application.Render();
610 // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event
612 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f)));
613 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f)));
614 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
618 int UtcDaliTapGestureSignalReceptionChildHit(void)
620 TestApplication application;
622 Actor parent = Actor::New();
623 parent.SetSize(100.0f, 100.0f);
624 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
625 Stage::GetCurrent().Add(parent);
627 // Set child to completely cover parent.
628 // Change rotation of child to be different from parent so that we can check if our local coordinate
629 // conversion of the parent actor is correct.
630 Actor child = Actor::New();
631 child.SetSize(100.0f, 100.0f);
632 child.SetAnchorPoint(AnchorPoint::CENTER);
633 child.SetParentOrigin(ParentOrigin::CENTER);
634 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
637 TouchEventFunctor touchFunctor;
638 child.TouchedSignal().Connect(&application, touchFunctor);
641 application.SendNotification();
642 application.Render();
645 GestureReceivedFunctor functor(data);
647 TapGestureDetector detector = TapGestureDetector::New();
648 detector.Attach(parent);
649 detector.DetectedSignal().Connect(&application, functor);
651 // Do tap - hits child area but parent should still receive it
652 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f)));
653 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f)));
654 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
655 DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION);
656 DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
658 // Attach child and generate same touch points
659 // (Also proves that you can detach and then re-attach another actor)
660 detector.Attach(child);
661 detector.Detach(parent);
663 // Do an entire tap, only check finished value
665 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f)));
666 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f)));
667 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
668 DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION);
669 DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
673 int UtcDaliTapGestureSignalReceptionAttachDetachMany(void)
675 TestApplication application;
677 Actor first = Actor::New();
678 first.SetSize(100.0f, 100.0f);
679 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
680 Stage::GetCurrent().Add(first);
682 Actor second = Actor::New();
683 second.SetSize(100.0f, 100.0f);
685 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
686 Stage::GetCurrent().Add(second);
689 application.SendNotification();
690 application.Render();
693 GestureReceivedFunctor functor(data);
695 TapGestureDetector detector = TapGestureDetector::New();
696 detector.Attach(first);
697 detector.Attach(second);
698 detector.DetectedSignal().Connect(&application, functor);
700 // Tap within second actor's area
701 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
702 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
703 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
704 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
706 // Tap within first actor's area
708 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
709 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
710 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
711 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
713 // Detach the second actor
714 detector.Detach(second);
716 // second actor shouldn't receive event
718 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f)));
719 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f)));
720 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
722 // first actor should continue receiving event
724 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f)));
725 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f)));
726 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
730 int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void)
732 TestApplication application;
734 Actor actor = Actor::New();
735 actor.SetSize(100.0f, 100.0f);
736 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
737 Stage::GetCurrent().Add(actor);
740 application.SendNotification();
741 application.Render();
744 GestureReceivedFunctor functor(data);
746 TapGestureDetector detector = TapGestureDetector::New();
747 detector.Attach(actor);
748 detector.DetectedSignal().Connect(&application, functor);
750 // Tap in actor's area
751 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
752 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
753 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
755 // Actor become invisible - actor should not receive the next pan
756 actor.SetVisible(false);
759 application.SendNotification();
760 application.Render();
762 // Tap in the same area, shouldn't receive event
764 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
765 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
766 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
770 int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void)
772 TestApplication application;
773 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
775 Actor first = Actor::New();
776 first.SetSize(100.0f, 100.0f);
777 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
778 Stage::GetCurrent().Add(first);
780 Actor second = Actor::New();
781 second.SetSize(100.0f, 100.0f);
782 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
787 application.SendNotification();
788 application.Render();
791 GestureReceivedFunctor functor(data);
793 TapGestureDetector firstDetector = TapGestureDetector::New();
794 firstDetector.Attach(first);
795 firstDetector.DetectedSignal().Connect(&application, functor);
797 // secondDetector is scoped
799 // Reset gestureManager statistics
800 gestureManager.Initialize();
802 TapGestureDetector secondDetector = TapGestureDetector::New( 2 );
803 secondDetector.Attach(second);
804 secondDetector.DetectedSignal().Connect(&application, functor);
806 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
807 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
808 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
810 // Tap within second actor's area
811 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 1u, Vector2(150.0f, 10.0f)));
812 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 1u, Vector2(150.0f, 10.0f)));
813 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
814 DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION);
816 // Tap continues as single touch gesture - we should not receive any gesture
818 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f)));
819 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f)));
820 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
822 // Single touch tap starts - first actor should be panned
824 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
825 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
826 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
827 DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION);
829 // Pan changes to double-touch - we shouldn't receive event
831 application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f)));
832 application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f)));
833 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
835 // Reset gesture manager statistics
836 gestureManager.Initialize();
839 // secondDetector has now been deleted. Gesture detection should have been updated only
840 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
841 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
842 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
846 int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void)
848 TestApplication application;
850 Actor actor = Actor::New();
851 actor.SetSize(100.0f, 100.0f);
852 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
853 Stage::GetCurrent().Add(actor);
856 application.SendNotification();
857 application.Render();
859 // Attach actor to one detector
860 SignalData firstData;
861 GestureReceivedFunctor firstFunctor(firstData);
862 TapGestureDetector firstDetector = TapGestureDetector::New();
863 firstDetector.Attach(actor);
864 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
866 // Attach actor to another detector
867 SignalData secondData;
868 GestureReceivedFunctor secondFunctor(secondData);
869 TapGestureDetector secondDetector = TapGestureDetector::New();
870 secondDetector.Attach(actor);
871 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
873 // Tap in actor's area - both detector's functors should be called
874 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
875 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
876 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
877 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
881 int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
883 TestApplication application;
885 Actor actor = Actor::New();
886 actor.SetSize(100.0f, 100.0f);
887 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
888 Stage::GetCurrent().Add(actor);
891 application.SendNotification();
892 application.Render();
894 // Attach actor to detector
896 GestureReceivedFunctor functor( data );
897 TapGestureDetector detector = TapGestureDetector::New();
898 detector.Attach(actor);
899 detector.DetectedSignal().Connect( &application, functor );
901 // Gesture possible in actor's area.
902 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
903 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
905 // Move actor somewhere else
906 actor.SetPosition( 100.0f, 100.0f );
909 application.SendNotification();
910 application.Render();
912 // Emit Started event, we should not receive the tap.
913 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
914 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
916 // Tap possible in empty area.
917 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
918 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
920 // Move actor in to the tap position.
921 actor.SetPosition( 0.0f, 0.0f );
924 application.SendNotification();
925 application.Render();
927 // Emit Started event, we should not receive the tap.
928 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
929 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
931 // Normal tap in actor's area for completeness.
932 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
933 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
934 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
938 int UtcDaliTapGestureEmitIncorrectStateClear(void)
940 TestApplication application;
942 Actor actor = Actor::New();
943 actor.SetSize(100.0f, 100.0f);
944 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
945 Stage::GetCurrent().Add(actor);
948 application.SendNotification();
949 application.Render();
951 // Attach actor to detector
953 GestureReceivedFunctor functor( data );
954 TapGestureDetector detector = TapGestureDetector::New();
955 detector.Attach(actor);
956 detector.DetectedSignal().Connect( &application, functor );
961 application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f)));
962 tet_result(TET_FAIL);
964 catch ( Dali::DaliException& e )
966 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
971 int UtcDaliTapGestureEmitIncorrectStateContinuing(void)
973 TestApplication application;
975 Actor actor = Actor::New();
976 actor.SetSize(100.0f, 100.0f);
977 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
978 Stage::GetCurrent().Add(actor);
981 application.SendNotification();
982 application.Render();
984 // Attach actor to detector
986 GestureReceivedFunctor functor( data );
987 TapGestureDetector detector = TapGestureDetector::New();
988 detector.Attach(actor);
989 detector.DetectedSignal().Connect( &application, functor );
991 // Try a Continuing state
994 application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f)));
995 tet_result(TET_FAIL);
997 catch ( Dali::DaliException& e )
999 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1004 int UtcDaliTapGestureEmitIncorrectStateFinished(void)
1006 TestApplication application;
1008 Actor actor = Actor::New();
1009 actor.SetSize(100.0f, 100.0f);
1010 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1011 Stage::GetCurrent().Add(actor);
1013 // Render and notify
1014 application.SendNotification();
1015 application.Render();
1017 // Attach actor to detector
1019 GestureReceivedFunctor functor( data );
1020 TapGestureDetector detector = TapGestureDetector::New();
1021 detector.Attach(actor);
1022 detector.DetectedSignal().Connect( &application, functor );
1024 // Try a Finished state
1027 application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f)));
1028 tet_result(TET_FAIL);
1030 catch ( Dali::DaliException& e )
1032 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1037 int UtcDaliTapGestureActorUnstaged(void)
1039 TestApplication application;
1041 Actor actor = Actor::New();
1042 actor.SetSize(100.0f, 100.0f);
1043 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1044 Stage::GetCurrent().Add(actor);
1046 // Render and notify
1047 application.SendNotification();
1048 application.Render();
1050 // Attach actor to detector
1052 UnstageActorFunctor functor( data );
1053 TapGestureDetector detector = TapGestureDetector::New();
1054 detector.Attach(actor);
1055 detector.DetectedSignal().Connect( &application, functor );
1057 // Tap in Actor's area, actor removed in signal handler, should be handled gracefully.
1058 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1059 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1060 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1061 tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully.
1065 int UtcDaliTapGestureRepeatedState(void)
1067 TestApplication application;
1069 Actor actor = Actor::New();
1070 actor.SetSize(100.0f, 100.0f);
1071 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1072 Stage::GetCurrent().Add(actor);
1074 // Render and notify
1075 application.SendNotification();
1076 application.Render();
1078 // Attach actor to detector
1080 GestureReceivedFunctor functor( data );
1081 TapGestureDetector detector = TapGestureDetector::New();
1082 detector.Attach(actor);
1083 detector.DetectedSignal().Connect( &application, functor );
1085 // Emit two possibles
1086 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1087 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1088 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1090 // Send a couple of Started states, only first one should be received.
1091 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1092 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1094 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1095 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1097 // Send a couple of cancelled states, no reception
1098 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1099 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1100 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1104 int UtcDaliTapGesturePossibleCancelled(void)
1106 TestApplication application;
1108 Actor actor = Actor::New();
1109 actor.SetSize(100.0f, 100.0f);
1110 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1111 Stage::GetCurrent().Add(actor);
1113 // Render and notify
1114 application.SendNotification();
1115 application.Render();
1117 // Attach actor to detector
1119 GestureReceivedFunctor functor( data );
1120 TapGestureDetector detector = TapGestureDetector::New();
1121 detector.Attach(actor);
1122 detector.DetectedSignal().Connect( &application, functor );
1124 // Emit a possible and then a cancelled, no reception
1125 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1126 application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f)));
1127 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1131 int UtcDaliTapGestureDetectorRemovedWhilePossible(void)
1133 TestApplication application;
1135 Actor actor = Actor::New();
1136 actor.SetSize(100.0f, 100.0f);
1137 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1138 Stage::GetCurrent().Add(actor);
1140 // Render and notify
1141 application.SendNotification();
1142 application.Render();
1144 // Attach actor to detector
1146 GestureReceivedFunctor functor( data );
1147 TapGestureDetector detector = TapGestureDetector::New();
1148 detector.Attach(actor);
1149 detector.DetectedSignal().Connect( &application, functor );
1152 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1154 // Detach actor and send a Started state, no signal.
1155 detector.DetachAll();
1156 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1157 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1161 int UtcDaliTapGestureActorRemovedWhilePossible(void)
1163 TestApplication application;
1165 Actor actor = Actor::New();
1166 actor.SetSize(100.0f, 100.0f);
1167 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1168 Stage::GetCurrent().Add(actor);
1170 // Render and notify
1171 application.SendNotification();
1172 application.Render();
1174 // Attach actor to detector
1176 GestureReceivedFunctor functor( data );
1177 TapGestureDetector detector = TapGestureDetector::New();
1178 detector.Attach(actor);
1179 detector.DetectedSignal().Connect( &application, functor );
1182 application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
1184 // Remove, render and delete actor
1185 Stage::GetCurrent().Remove(actor);
1186 application.SendNotification();
1187 application.Render();
1190 // Send a Started state, no signal.
1191 application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
1192 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1196 int UtcDaliTapGestureSystemOverlay(void)
1198 TestApplication application;
1199 Dali::Integration::Core& core = application.GetCore();
1200 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1201 systemOverlay.GetOverlayRenderTasks().CreateTask();
1203 Actor actor = Actor::New();
1204 actor.SetSize(100.0f, 100.0f);
1205 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1206 systemOverlay.Add(actor);
1208 // Render and notify
1209 application.SendNotification();
1210 application.Render();
1213 GestureReceivedFunctor functor(data);
1215 TapGestureDetector detector = TapGestureDetector::New();
1216 detector.Attach(actor);
1217 detector.DetectedSignal().Connect(&application, functor);
1219 Vector2 screenCoords( 50.0f, 50.0f );
1221 // Do a tap inside actor's area
1222 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1223 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1224 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1228 int UtcDaliTapGestureBehindTouchableSystemOverlay(void)
1230 TestApplication application;
1231 Dali::Integration::Core& core = application.GetCore();
1232 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1233 systemOverlay.GetOverlayRenderTasks().CreateTask();
1235 // SystemOverlay actor
1236 Actor systemOverlayActor = Actor::New();
1237 systemOverlayActor.SetSize(100.0f, 100.0f);
1238 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1239 systemOverlay.Add(systemOverlayActor);
1242 Actor stageActor = Actor::New();
1243 stageActor.SetSize(100.0f, 100.0f);
1244 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1245 Stage::GetCurrent().Add(stageActor);
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Set system-overlay actor to touchable
1252 TouchEventData touchData;
1253 TouchEventDataFunctor touchFunctor( touchData );
1254 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1256 // Set stage actor to receive the gesture
1258 GestureReceivedFunctor functor(data);
1260 TapGestureDetector detector = TapGestureDetector::New();
1261 detector.Attach(stageActor);
1262 detector.DetectedSignal().Connect(&application, functor);
1264 Vector2 screenCoords( 50.0f, 50.0f );
1266 // Do a tap inside both actors' area
1267 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1268 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1269 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1270 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1275 // Do touch in the same area
1276 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1277 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1278 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1283 int UtcDaliTapGestureTouchBehindGesturedSystemOverlay(void)
1285 TestApplication application;
1286 Dali::Integration::Core& core = application.GetCore();
1287 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1288 systemOverlay.GetOverlayRenderTasks().CreateTask();
1290 // SystemOverlay actor
1291 Actor systemOverlayActor = Actor::New();
1292 systemOverlayActor.SetSize(100.0f, 100.0f);
1293 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1294 systemOverlay.Add(systemOverlayActor);
1297 Actor stageActor = Actor::New();
1298 stageActor.SetSize(100.0f, 100.0f);
1299 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1300 Stage::GetCurrent().Add(stageActor);
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Set stage actor to touchable
1307 TouchEventData touchData;
1308 TouchEventDataFunctor touchFunctor( touchData );
1309 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1311 // Set system-overlay actor to have the gesture
1313 GestureReceivedFunctor functor(data);
1315 TapGestureDetector detector = TapGestureDetector::New();
1316 detector.Attach(systemOverlayActor);
1317 detector.DetectedSignal().Connect(&application, functor);
1319 Vector2 screenCoords( 50.0f, 50.0f );
1321 // Do a tap inside both actors' area
1322 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1323 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1324 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1325 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1330 // Do touch in the same area
1331 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1332 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1333 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1338 int UtcDaliTapGestureLayerConsumesTouch(void)
1340 TestApplication application;
1342 Actor actor = Actor::New();
1343 actor.SetSize(100.0f, 100.0f);
1344 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1345 Stage::GetCurrent().Add(actor);
1349 GestureReceivedFunctor functor(data);
1350 TapGestureDetector detector = TapGestureDetector::New();
1351 detector.Attach(actor);
1352 detector.DetectedSignal().Connect( &application, functor );
1354 // Add a layer to overlap the actor
1355 Layer layer = Layer::New();
1356 layer.SetSize(100.0f, 100.0f);
1357 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1358 Stage::GetCurrent().Add( layer );
1361 // Render and notify
1362 application.SendNotification();
1363 application.Render();
1365 Vector2 screenCoords( 50.0f, 50.0f );
1367 // Emit signals, should receive
1368 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1369 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1370 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1373 // Set layer to consume all touch
1374 layer.SetTouchConsumed( true );
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Emit the same signals again, should not receive
1381 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) );
1382 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) );
1383 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);