2 * Copyright (c) 2022 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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/actors/actor-devel.h>
20 #include <dali/devel-api/events/pan-gesture-devel.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/touch-integ.h>
23 #include <dali/integration-api/input-options.h>
24 #include <dali/integration-api/profiling.h>
25 #include <dali/integration-api/render-task-list-integ.h>
26 #include <dali/internal/event/events/touch-event-impl.h>
27 #include <dali/internal/event/render-tasks/render-task-impl.h>
28 #include <dali/public-api/dali-core.h>
30 #include <test-touch-event-utils.h>
37 void utc_dali_pan_gesture_detector_startup(void)
39 test_return_value = TET_UNDEF;
42 void utc_dali_pan_gesture_detector_cleanup(void)
44 test_return_value = TET_PASS;
47 ///////////////////////////////////////////////////////////////////////////////
50 const int PAN_EVENT_TIME_DELTA = 8;
51 const int PAN_GESTURE_UPDATE_COUNT = 50;
53 // Stores data that is populated in the callback and will be read by the test cases
57 : functorCalled(false),
58 voidFunctorCalled(false),
65 functorCalled = false;
66 voidFunctorCalled = false;
68 receivedGesture.Reset();
74 bool voidFunctorCalled;
75 PanGesture receivedGesture;
79 // Functor that sets the data when called
80 struct GestureReceivedFunctor
82 GestureReceivedFunctor(SignalData& data)
87 void operator()(Actor actor, const PanGesture& pan)
89 signalData.functorCalled = true;
90 signalData.receivedGesture = pan;
91 signalData.pannedActor = actor;
96 signalData.voidFunctorCalled = true;
99 SignalData& signalData;
102 // Functor that removes the gestured actor from stage
103 struct UnstageActorFunctor : public GestureReceivedFunctor
105 UnstageActorFunctor(SignalData& data, GestureState& stateToUnstage, Integration::Scene scene)
106 : GestureReceivedFunctor(data),
107 stateToUnstage(stateToUnstage),
112 void operator()(Actor actor, const PanGesture& pan)
114 GestureReceivedFunctor::operator()(actor, pan);
116 if(pan.GetState() == stateToUnstage)
122 GestureState& stateToUnstage;
123 Integration::Scene scene;
126 // Functor that removes the gestured actor from stage
127 struct PropagationActorFunctor : public GestureReceivedFunctor
129 PropagationActorFunctor(SignalData& data, bool propagation)
130 : GestureReceivedFunctor(data),
131 propagation(propagation)
135 void operator()(Actor actor, const PanGesture& pan)
137 GestureReceivedFunctor::operator()(actor, pan);
138 Dali::DevelActor::SetNeedGesturePropagation(actor, propagation);
145 // Data for constraints
146 struct ConstraintData
154 Vector2 screenPosition;
155 Vector2 screenDisplacement;
156 Vector2 screenVelocity;
157 Vector2 localPosition;
158 Vector2 localDisplacement;
159 Vector2 localVelocity;
165 screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
171 // Constraint used with panning properties
174 PanConstraint(ConstraintData& data)
175 : constraintData(data)
179 void operator()(Vector3& current, const PropertyInputContainer& inputs)
181 constraintData.screenPosition = inputs[0]->GetVector2();
182 constraintData.screenDisplacement = inputs[1]->GetVector2();
183 constraintData.screenVelocity = inputs[2]->GetVector2();
184 constraintData.localPosition = inputs[3]->GetVector2();
185 constraintData.localDisplacement = inputs[4]->GetVector2();
186 constraintData.localVelocity = inputs[5]->GetVector2();
187 constraintData.panning = inputs[6]->GetBoolean();
188 constraintData.called = true;
189 current = Vector3::ZERO;
192 ConstraintData& constraintData;
195 // Generate a PanGesture
196 PanGesture GeneratePan(unsigned int time,
198 Vector2 screenPosition,
199 Vector2 localPosition,
200 Vector2 screenDisplacement = Vector2::ONE,
201 Vector2 localDisplacement = Vector2::ONE,
202 Vector2 screenVelocity = Vector2::ONE,
203 Vector2 localVelocity = Vector2::ONE,
204 unsigned int numberOfTouches = 1)
206 Dali::PanGesture pan = DevelPanGesture::New(state);
208 DevelPanGesture::SetTime(pan, time);
210 DevelPanGesture::SetScreenPosition(pan, screenPosition);
211 DevelPanGesture::SetPosition(pan, localPosition);
213 DevelPanGesture::SetScreenDisplacement(pan, screenDisplacement);
214 DevelPanGesture::SetDisplacement(pan, localDisplacement);
216 DevelPanGesture::SetScreenVelocity(pan, screenVelocity);
217 DevelPanGesture::SetVelocity(pan, localVelocity);
219 DevelPanGesture::SetNumberOfTouches(pan, numberOfTouches);
224 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time)
226 Integration::TouchEvent touchEvent;
227 Integration::Point point;
228 point.SetState(state);
229 point.SetDeviceId(4);
230 point.SetScreenPosition(screenPosition);
231 point.SetDeviceClass(Device::Class::TOUCH);
232 point.SetDeviceSubclass(Device::Subclass::NONE);
233 touchEvent.points.push_back(point);
234 touchEvent.time = time;
239 ///////////////////////////////////////////////////////////////////////////////
241 // Positive test case for a method
242 int UtcDaliPanGestureDetectorConstructor(void)
244 TestApplication application;
246 PanGestureDetector detector;
247 DALI_TEST_CHECK(!detector);
251 int UtcDaliPanGestureDetectorCopyConstructorP(void)
253 TestApplication application;
255 PanGestureDetector detector = PanGestureDetector::New();
257 PanGestureDetector copy(detector);
258 DALI_TEST_CHECK(detector);
262 int UtcDaliPanGestureDetectorAssignmentOperatorP(void)
264 TestApplication application;
266 PanGestureDetector detector = PanGestureDetector::New();
268 PanGestureDetector assign;
270 DALI_TEST_CHECK(detector);
272 DALI_TEST_CHECK(detector == assign);
276 int UtcDaliPanGestureDetectorMoveConstructorP(void)
278 TestApplication application;
280 PanGestureDetector detector = PanGestureDetector::New();
281 DALI_TEST_CHECK(detector);
283 PanGestureDetector moved = std::move(detector);
284 DALI_TEST_CHECK(moved);
285 DALI_TEST_CHECK(!detector);
289 int UtcDaliPanGestureDetectorMoveAssignmentOperatorP(void)
291 TestApplication application;
293 PanGestureDetector detector;
294 detector = PanGestureDetector::New();
295 DALI_TEST_CHECK(detector);
297 PanGestureDetector moved;
298 moved = std::move(detector);
299 DALI_TEST_CHECK(moved);
300 DALI_TEST_CHECK(!detector);
304 // Negative test case for a method
305 int UtcDaliPanGestureDetectorNew(void)
307 TestApplication application;
309 PanGestureDetector detector = PanGestureDetector::New();
311 DALI_TEST_CHECK(detector);
313 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
314 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
315 DALI_TEST_EQUALS(std::numeric_limits<uint32_t>::max(), detector.GetMaximumMotionEventAge(), TEST_LOCATION);
317 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
318 Actor actor = Actor::New();
319 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
320 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
321 detector.Attach(actor);
323 application.GetScene().Add(actor);
326 application.SendNotification();
327 application.Render();
329 // Use long press function for touch event
330 TestStartLongPress(application);
335 int UtcDaliPanGestureDetectorDownCast(void)
337 TestApplication application;
338 tet_infoline("Testing Dali::GestureDetector::DownCast()");
340 PanGestureDetector detector = PanGestureDetector::New();
342 BaseHandle object(detector);
344 PanGestureDetector detector2 = PanGestureDetector::DownCast(object);
345 DALI_TEST_CHECK(detector2);
347 PanGestureDetector detector3 = DownCast<PanGestureDetector>(object);
348 DALI_TEST_CHECK(detector3);
350 BaseHandle unInitializedObject;
351 PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject);
352 DALI_TEST_CHECK(!detector4);
354 PanGestureDetector detector5 = DownCast<PanGestureDetector>(unInitializedObject);
355 DALI_TEST_CHECK(!detector5);
357 GestureDetector detector6 = PanGestureDetector::New();
358 PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6);
359 DALI_TEST_CHECK(detector7);
363 int UtcDaliPanGestureSetMinimumTouchesRequired(void)
365 TestApplication application;
367 PanGestureDetector detector = PanGestureDetector::New();
369 unsigned int min = 2;
371 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
373 detector.SetMinimumTouchesRequired(min);
375 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
377 // Attach an actor and change the minimum touches
379 Actor actor = Actor::New();
380 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
381 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
382 application.GetScene().Add(actor);
385 application.SendNotification();
386 application.Render();
389 GestureReceivedFunctor functor(data);
391 detector.Attach(actor);
392 detector.DetectedSignal().Connect(&application, functor);
394 detector.SetMinimumTouchesRequired(3);
396 // Create a second gesture detector that requires even less minimum touches
397 PanGestureDetector secondDetector = PanGestureDetector::New();
398 secondDetector.Attach(actor);
400 DALI_TEST_EQUALS(3, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
405 int UtcDaliPanGestureSetMaximumTouchesRequired(void)
407 TestApplication application;
409 PanGestureDetector detector = PanGestureDetector::New();
411 unsigned int max = 3;
413 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
415 detector.SetMaximumTouchesRequired(max);
417 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
419 // Attach an actor and change the maximum touches
421 Actor actor = Actor::New();
422 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
423 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
424 application.GetScene().Add(actor);
427 application.SendNotification();
428 application.Render();
431 GestureReceivedFunctor functor(data);
433 detector.Attach(actor);
434 detector.DetectedSignal().Connect(&application, functor);
436 detector.SetMaximumTouchesRequired(4);
438 DALI_TEST_EQUALS(4, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
443 int UtcDaliPanGestureSetMaximumMotionEventAge(void)
445 TestApplication application;
447 PanGestureDetector detector = PanGestureDetector::New();
449 uint32_t minTime = 20;
451 DALI_TEST_CHECK(minTime != detector.GetMaximumMotionEventAge());
453 detector.SetMaximumMotionEventAge(minTime);
455 DALI_TEST_EQUALS(minTime, detector.GetMaximumMotionEventAge(), TEST_LOCATION);
457 // Attach an actor and change the maximum touches
459 Actor actor = Actor::New();
460 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
461 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
462 application.GetScene().Add(actor);
465 application.SendNotification();
466 application.Render();
469 GestureReceivedFunctor functor(data);
471 detector.Attach(actor);
472 detector.DetectedSignal().Connect(&application, functor);
474 detector.SetMaximumMotionEventAge(minTime * 2);
476 DALI_TEST_EQUALS(minTime * 2, detector.GetMaximumMotionEventAge(), TEST_LOCATION);
481 int UtcDaliPanGestureGetMinimumTouchesRequired(void)
483 TestApplication application;
485 PanGestureDetector detector = PanGestureDetector::New();
486 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
490 int UtcDaliPanGestureGetMaximumTouchesRequired(void)
492 TestApplication application;
494 PanGestureDetector detector = PanGestureDetector::New();
495 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
499 int UtcDaliPanGestureGetMaximumMotionEventAge(void)
501 TestApplication application;
503 PanGestureDetector detector = PanGestureDetector::New();
504 DALI_TEST_EQUALS(std::numeric_limits<uint32_t>::max(), detector.GetMaximumMotionEventAge(), TEST_LOCATION);
508 int UtcDaliPanGestureSignalReceptionNegative(void)
510 TestApplication application;
512 Actor actor = Actor::New();
513 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
514 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
515 application.GetScene().Add(actor);
518 application.SendNotification();
519 application.Render();
522 GestureReceivedFunctor functor(data);
524 PanGestureDetector detector = PanGestureDetector::New();
525 detector.Attach(actor);
526 detector.DetectedSignal().Connect(&application, functor);
528 // Do a pan outside actor's area
530 TestStartPan(application, Vector2(110.0f, 110.0f), Vector2(121.0f, 121.0f), time);
532 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
534 // Continue pan into actor's area - we should still not receive the signal
536 TestMovePan(application, Vector2(20.0f, 20.0f), time);
538 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
540 // Stop panning - we should still not receive the signal
542 TestEndPan(application, Vector2(12.0f, 12.0f), time);
544 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
548 int UtcDaliPanGestureSignalReceptionDownMotionLeave(void)
550 TestApplication application;
552 Actor actor = Actor::New();
553 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
554 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
555 application.GetScene().Add(actor);
558 application.SendNotification();
559 application.Render();
562 GestureReceivedFunctor functor(data);
564 PanGestureDetector detector = PanGestureDetector::New();
565 detector.Attach(actor);
566 detector.DetectedSignal().Connect(&application, functor);
568 // Start pan within the actor's area
570 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
572 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
573 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
574 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
575 DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
576 DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
577 DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
578 DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
580 // Continue the pan within the actor's area - we should still receive the signal
583 TestMovePan(application, Vector2(26.0f, 4.0f), time);
584 time += TestGetFrameInterval();
586 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
587 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
588 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
589 DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
590 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
591 DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
592 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
594 // Pan Gesture leaves actor's area - we should still receive the signal
597 TestMovePan(application, Vector2(346.0f, 4.0f), time);
598 time += TestGetFrameInterval();
600 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
601 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
602 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
603 DALI_TEST_EQUALS(Vector2(320.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
604 DALI_TEST_EQUALS(Vector2(20.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
605 DALI_TEST_EQUALS(320.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
606 DALI_TEST_EQUALS(20.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
608 // Gesture ends - we would receive a finished state
611 TestEndPan(application, Vector2(314.0f, 4.0f), time);
613 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
614 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
615 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
616 DALI_TEST_EQUALS(Vector2(-32.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
617 DALI_TEST_EQUALS(Vector2(-2.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
618 DALI_TEST_EQUALS(32.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
619 DALI_TEST_EQUALS(2.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
623 int UtcDaliPanGestureSignalReceptionDownMotionUp(void)
625 TestApplication application;
627 Actor actor = Actor::New();
628 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
629 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
630 application.GetScene().Add(actor);
633 application.SendNotification();
634 application.Render();
637 GestureReceivedFunctor functor(data);
639 PanGestureDetector detector = PanGestureDetector::New();
640 detector.Attach(actor);
641 detector.DetectedSignal().Connect(&application, functor);
643 // Start pan within the actor's area
645 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
647 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
648 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
649 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
650 DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
651 DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
652 DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
653 DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
655 // Continue the pan within the actor's area - we should still receive the signal
658 TestMovePan(application, Vector2(26.0f, 4.0f), time);
659 time += TestGetFrameInterval();
661 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
662 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
663 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
664 DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
665 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
666 DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
667 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
669 // Gesture ends within actor's area - we would receive a finished state
672 TestEndPan(application, Vector2(10.0f, 4.0f), time);
674 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
675 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
676 DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
677 DALI_TEST_EQUALS(Vector2(-16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
678 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
679 DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
680 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
684 int UtcDaliPanGestureSignalReceptionDetach(void)
686 TestApplication application;
688 Actor actor = Actor::New();
689 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
690 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
691 application.GetScene().Add(actor);
694 application.SendNotification();
695 application.Render();
698 GestureReceivedFunctor functor(data);
700 PanGestureDetector detector = PanGestureDetector::New();
701 detector.Attach(actor);
702 detector.DetectedSignal().Connect(&application, functor);
704 // Start pan within the actor's area
706 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
707 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
709 // Continue the pan within the actor's area - we should still receive the signal
712 TestMovePan(application, Vector2(26.0f, 4.0f), time);
713 time += TestGetFrameInterval();
715 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
717 // Gesture ends within actor's area
720 TestEndPan(application, Vector2(10.0f, 4.0f), time);
721 time += TestGetFrameInterval();
723 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
726 detector.DetachAll();
728 // Ensure we are no longer signalled
731 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
732 TestMovePan(application, Vector2(26.0f, 4.0f), time);
733 time += TestGetFrameInterval();
734 TestEndPan(application, Vector2(10.0f, 4.0f), time);
736 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
740 int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void)
742 TestApplication application;
744 Actor actor = Actor::New();
745 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
746 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
747 application.GetScene().Add(actor);
750 application.SendNotification();
751 application.Render();
754 GestureReceivedFunctor functor(data);
756 PanGestureDetector detector = PanGestureDetector::New();
757 detector.Attach(actor);
758 detector.DetectedSignal().Connect(&application, functor);
760 // Start pan within the actor's area
762 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
763 application.SendNotification();
765 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
767 // Continue the pan within the actor's area - we should still receive the signal
770 TestMovePan(application, Vector2(26.0f, 4.0f), time);
771 time += TestGetFrameInterval();
773 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
775 // Detach actor during the pan, we should not receive the next event
776 detector.DetachAll();
778 // Gesture ends within actor's area
781 TestEndPan(application, Vector2(10.0f, 4.0f), time);
783 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
787 int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void)
789 TestApplication application;
792 GestureReceivedFunctor functor(data);
794 PanGestureDetector detector = PanGestureDetector::New();
795 detector.DetectedSignal().Connect(&application, functor);
797 // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor
799 Actor tempActor = Actor::New();
800 tempActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
801 tempActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
802 application.GetScene().Add(tempActor);
803 detector.Attach(tempActor);
807 // Actor lifetime is scoped
809 Actor actor = Actor::New();
810 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
811 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
812 application.GetScene().Add(actor);
815 application.SendNotification();
816 application.Render();
818 detector.Attach(actor);
820 // Start pan within the actor's area
821 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
823 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
825 // Continue the pan within the actor's area - we should still receive the signal
828 TestMovePan(application, Vector2(26.0f, 4.0f), time);
829 time += TestGetFrameInterval();
831 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
833 // Remove the actor from stage and reset the data
834 application.GetScene().Remove(actor);
837 application.SendNotification();
838 application.Render();
841 // Actor should now have been destroyed
843 // Gesture ends within the area where the actor used to be
846 TestEndPan(application, Vector2(10.0f, 4.0f), time);
848 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
852 int UtcDaliPanGestureSignalReceptionRotatedActor(void)
854 TestApplication application;
856 Actor actor = Actor::New();
857 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
858 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
859 application.GetScene().Add(actor);
862 application.SendNotification();
863 application.Render();
866 GestureReceivedFunctor functor(data);
868 PanGestureDetector detector = PanGestureDetector::New();
869 detector.Attach(actor);
870 detector.DetectedSignal().Connect(&application, functor);
872 // Do an entire pan, only check finished value
874 TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
878 TestEndPan(application, Vector2(25.0f, 28.0f), time);
880 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
881 DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
883 // Rotate actor again and render a couple of times
884 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS));
885 application.SendNotification();
886 application.Render();
888 // Do an entire pan, only check finished value
889 TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
893 TestEndPan(application, Vector2(25.0f, 28.0f), time);
895 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
896 DALI_TEST_EQUALS(Vector2(2.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
898 // Rotate actor again and render a couple of times
899 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS));
900 application.SendNotification();
901 application.Render();
903 // Do an entire pan, only check finished value
904 TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
908 TestEndPan(application, Vector2(25.0f, 28.0f), time);
910 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
911 DALI_TEST_EQUALS(Vector2(-16.0f, -2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
915 int UtcDaliPanGestureSignalReceptionChildHit(void)
917 TestApplication application;
919 Actor parent = Actor::New();
920 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
921 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
922 application.GetScene().Add(parent);
924 // Set child to completely cover parent.
925 // Change rotation of child to be different from parent so that we can check if our local coordinate
926 // conversion of the parent actor is correct.
927 Actor child = Actor::New();
928 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
929 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
930 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
931 child.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
935 application.SendNotification();
936 application.Render();
939 GestureReceivedFunctor functor(data);
941 PanGestureDetector detector = PanGestureDetector::New();
942 detector.Attach(parent);
943 detector.DetectedSignal().Connect(&application, functor);
945 // Do an entire pan, only check finished value - hits child area but parent should still receive it
947 TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
951 TestEndPan(application, Vector2(25.0f, 28.0f), time);
953 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
954 DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION);
955 DALI_TEST_EQUALS(Vector2(-2.0f, 16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
957 // Attach child and generate same touch points to yield a different displacement
958 // (Also proves that you can detach and then re-attach another actor)
959 detector.Attach(child);
960 detector.Detach(parent);
962 // Do an entire pan, only check finished value
963 TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
967 TestEndPan(application, Vector2(25.0f, 28.0f), time);
969 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
970 DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION);
971 DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
975 int UtcDaliPanGestureSignalReceptionAttachDetachMany(void)
977 TestApplication application;
979 Actor first = Actor::New();
980 first.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
981 first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
982 application.GetScene().Add(first);
984 Actor second = Actor::New();
985 second.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
986 second.SetProperty(Actor::Property::POSITION_X, 100.0f);
987 second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
988 application.GetScene().Add(second);
991 application.SendNotification();
992 application.Render();
995 GestureReceivedFunctor functor(data);
997 PanGestureDetector detector = PanGestureDetector::New();
998 detector.Attach(first);
999 detector.Attach(second);
1000 detector.DetectedSignal().Connect(&application, functor);
1002 DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), first.GetParent(), TEST_LOCATION);
1003 DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), second.GetParent(), TEST_LOCATION);
1005 // Start pan within second actor's area
1006 uint32_t time = 100;
1007 TestStartPan(application, Vector2(110.0f, 20.0f), Vector2(126.0f, 20.0f), time);
1009 DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), first.GetParent(), TEST_LOCATION);
1010 DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), second.GetParent(), TEST_LOCATION);
1012 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1013 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1015 // Pan moves into first actor's area - second actor should receive the pan
1018 TestMovePan(application, Vector2(126.0f, 20.0f), time);
1019 time += TestGetFrameInterval();
1021 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1022 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1024 // Detach the second actor during the pan, we should not receive the next event
1025 detector.Detach(second);
1027 // Gesture ends within actor's area
1030 TestMovePan(application, Vector2(26.0f, 20.0f), time);
1031 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1033 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1038 int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void)
1040 TestApplication application;
1042 Actor actor = Actor::New();
1043 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1044 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1045 application.GetScene().Add(actor);
1047 // Render and notify
1048 application.SendNotification();
1049 application.Render();
1052 GestureReceivedFunctor functor(data);
1054 PanGestureDetector detector = PanGestureDetector::New();
1055 detector.Attach(actor);
1056 detector.DetectedSignal().Connect(&application, functor);
1058 // Start pan in actor's area
1059 uint32_t time = 100;
1060 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1062 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1064 // Pan continues within actor's area
1067 TestMovePan(application, Vector2(26.0f, 4.0f), time);
1068 time += TestGetFrameInterval();
1070 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1072 // Actor become invisible - actor should not receive the next pan
1073 actor.SetProperty(Actor::Property::VISIBLE, false);
1075 // Render and notify
1076 application.SendNotification();
1077 application.Render();
1079 // Gesture ends within actor's area
1082 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1084 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1088 int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void)
1090 TestApplication application;
1092 Actor actor = Actor::New();
1093 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1094 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1095 application.GetScene().Add(actor);
1097 Actor actor2 = Actor::New();
1098 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1099 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
1100 application.GetScene().Add(actor2);
1102 // Render and notify
1103 application.SendNotification();
1104 application.Render();
1106 // Attach actor to one detector
1107 SignalData firstData;
1108 GestureReceivedFunctor firstFunctor(firstData);
1109 PanGestureDetector firstDetector = PanGestureDetector::New();
1110 firstDetector.Attach(actor);
1111 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
1113 // Attach actor to another detector
1114 SignalData secondData;
1115 GestureReceivedFunctor secondFunctor(secondData);
1116 PanGestureDetector secondDetector = PanGestureDetector::New();
1117 secondDetector.Attach(actor);
1118 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
1120 // Add second actor to second detector, when we remove the actor, this will make sure that this
1121 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
1122 // functor should still not be called (which is what we're also testing).
1123 secondDetector.Attach(actor2);
1125 // Pan in actor's area - both detector's functors should be called
1126 uint32_t time = 100;
1127 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1129 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1130 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1132 // Pan continues in actor's area - both detector's functors should be called
1136 TestMovePan(application, Vector2(10.0f, 20.0f), time);
1137 time += TestGetFrameInterval();
1139 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1140 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1142 // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called.
1143 firstDetector.Detach(actor);
1147 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1149 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1150 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1152 // New pan on actor, only secondDetector has actor attached
1156 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1158 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1159 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1161 // Detach actor from secondDetector
1162 secondDetector.Detach(actor);
1166 TestMovePan(application, Vector2(10.0f, 20.0f), time);
1168 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1169 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
1174 int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void)
1176 TestApplication application;
1178 Actor actor1 = Actor::New();
1179 actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1180 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1181 application.GetScene().Add(actor1);
1183 GestureReceivedFunctor functor1(data1);
1184 PanGestureDetector detector1 = PanGestureDetector::New();
1185 detector1.Attach(actor1);
1186 detector1.DetectedSignal().Connect(&application, functor1);
1188 Actor actor2 = Actor::New();
1189 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1190 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
1191 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT);
1192 application.GetScene().Add(actor2);
1194 GestureReceivedFunctor functor2(data2);
1195 PanGestureDetector detector2 = PanGestureDetector::New();
1196 detector2.Attach(actor2);
1197 detector2.DetectedSignal().Connect(&application, functor2);
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1203 // Start pan in actor1's area, only data1 should be set
1204 uint32_t time = 100;
1205 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1207 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
1208 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
1212 int UtcDaliPanGestureSignalReceptionAttachActorAfterDown(void)
1214 // This test checks to ensure a pan is possible after attaching an actor after a down (possible) event
1216 TestApplication application;
1218 Actor actor = Actor::New();
1219 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1220 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1221 application.GetScene().Add(actor);
1223 // Render and notify
1224 application.SendNotification();
1225 application.Render();
1227 // Gesture possible in actor's area (using long-press)
1228 uint32_t time = 100;
1229 TestStartLongPress(application, 10.0f, 20.0f, time);
1230 time += TestGetFrameInterval();
1232 // Attach actor to detector
1234 GestureReceivedFunctor functor(data);
1235 PanGestureDetector detector = PanGestureDetector::New();
1236 detector.DetectedSignal().Connect(&application, functor);
1237 detector.Attach(actor);
1239 // Start a pan, initially it'll only be possible, we shouldn't receive it
1240 TestMovePan(application, Vector2(10.0f, 20.0f), time);
1241 time += TestGetFrameInterval();
1242 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1244 // Now the pan truly starts, we should receive a signal
1245 TestMovePan(application, Vector2(26.0f, 20.0f), time);
1246 time += TestGetFrameInterval();
1247 TestMovePan(application, Vector2(32.0f, 32.0f), time);
1248 time += TestGetFrameInterval();
1249 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1251 // Finish the pan, we should still receive a signal
1253 TestEndPan(application, Vector2(32.0f, 32.0f), time);
1254 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1259 int UtcDaliPanGestureSignalReceptionAttachActorAfterDownAfterInitialPanToAnotherActor(void)
1261 // This test checks to ensure a pan is possible after attaching an actor after a down (possible) event even if another
1262 // pan actor was there before (parent)
1264 TestApplication application;
1266 Actor parent = Actor::New();
1267 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1268 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1269 application.GetScene().Add(parent);
1271 Actor child = Actor::New();
1272 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1273 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1274 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1277 // Create detector for parent and attach
1278 SignalData parentData;
1279 GestureReceivedFunctor parentFunctor(parentData);
1280 PanGestureDetector parentDetector = PanGestureDetector::New();
1281 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1282 parentDetector.Attach(parent);
1284 // Create detector for child but do not attach
1285 SignalData childData;
1286 GestureReceivedFunctor childFunctor(childData);
1287 PanGestureDetector childDetector = PanGestureDetector::New();
1288 childDetector.DetectedSignal().Connect(&application, childFunctor);
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Do a full pan in both actors' area, only the parent's functor should be called
1295 uint32_t time = 100;
1296 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1297 DALI_TEST_EQUALS(parentData.functorCalled, true, TEST_LOCATION);
1298 DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1301 TestEndPan(application, Vector2(26.0f, 20.0f), time);
1302 DALI_TEST_EQUALS(parentData.functorCalled, true, TEST_LOCATION);
1303 DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1307 // Gesture possible in both actors' area (using long-press), no functors called
1308 TestStartLongPress(application, 10.0f, 20.0f, time);
1309 time += TestGetFrameInterval();
1310 DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1311 DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1313 // Attach the child as well now
1314 childDetector.Attach(child);
1316 // Now the pan truly starts, we should receive a signal for the child only
1317 TestMovePan(application, Vector2(26.0f, 20.0f), time);
1318 time += TestGetFrameInterval();
1319 TestMovePan(application, Vector2(32.0f, 32.0f), time);
1320 time += TestGetFrameInterval();
1321 DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1322 DALI_TEST_EQUALS(childData.functorCalled, true, TEST_LOCATION);
1326 // Finish the pan, again only the child should still receive a signal
1327 TestEndPan(application, Vector2(32.0f, 32.0f), time);
1328 DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1329 DALI_TEST_EQUALS(childData.functorCalled, true, TEST_LOCATION);
1334 int UtcDaliPanGestureSignalReceptionDifferentPossible(void)
1336 TestApplication application;
1338 Actor actor = Actor::New();
1339 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1340 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1341 application.GetScene().Add(actor);
1343 // Render and notify
1344 application.SendNotification();
1345 application.Render();
1347 // Attach actor to detector
1349 GestureReceivedFunctor functor(data);
1350 PanGestureDetector detector = PanGestureDetector::New();
1351 detector.Attach(actor);
1352 detector.DetectedSignal().Connect(&application, functor);
1354 // Gesture possible in actor's area.
1355 uint32_t time = 100;
1356 TestStartLongPress(application, 10.0f, 20.0f, time);
1357 time += TestGetFrameInterval();
1359 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1361 // Move actor somewhere else
1362 actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 // Emit STARTED event, we should not receive the pan.
1369 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1370 TestEndPan(application, Vector2(26.0f, 20.0f), time);
1371 time += TestGetFrameInterval();
1373 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1375 // LONG_PRESS possible in empty area.
1376 TestStartLongPress(application, 10.0f, 20.0f, time);
1377 time += TestGetFrameInterval();
1379 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1381 // Move actor in to the long press position.
1382 actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
1384 // Render and notify
1385 application.SendNotification();
1386 application.Render();
1388 // Emit STARTED event, we should be receiving the pan now.
1389 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1390 TestEndPan(application, Vector2(26.0f, 20.0f), time);
1391 time += TestGetFrameInterval();
1393 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1395 // Normal pan in actor's area for completeness.
1397 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1398 TestEndPan(application, Vector2(26.0f, 20.0f), time);
1399 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1403 int UtcDaliPanGestureActorUnstaged(void)
1405 TestApplication application;
1407 Actor actor = Actor::New();
1408 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1409 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1410 application.GetScene().Add(actor);
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // State to remove actor in.
1417 GestureState stateToUnstage(GestureState::STARTED);
1419 // Attach actor to detector
1421 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
1422 PanGestureDetector detector = PanGestureDetector::New();
1423 detector.Attach(actor);
1424 detector.DetectedSignal().Connect(&application, functor);
1427 uint32_t time = 100;
1428 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1430 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1433 TestEndPan(application, Vector2(26.0f, 20.0f), time);
1435 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1438 // Render and notify
1439 application.SendNotification();
1440 application.Render();
1442 // Re-add actor to stage
1443 application.GetScene().Add(actor);
1445 // Render and notify
1446 application.SendNotification();
1447 application.Render();
1449 // Change state to GestureState::CONTINUING to remove
1450 stateToUnstage = GestureState::CONTINUING;
1453 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1455 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1458 TestMovePan(application, Vector2(26.0f, 4.0f), time);
1459 time += TestGetFrameInterval();
1461 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1465 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1467 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
1474 // Re-add actor to stage
1475 application.GetScene().Add(actor);
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 // Change state to GestureState::FINISHED to remove
1482 stateToUnstage = GestureState::FINISHED;
1485 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1487 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1490 TestMovePan(application, Vector2(26.0f, 4.0f), time);
1491 time += TestGetFrameInterval();
1493 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1496 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1498 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1499 tet_result(TET_PASS); // If we get here then we have handled actor stage removal gracefully.
1503 int UtcDaliPanGestureActorStagedAndDestroyed(void)
1505 TestApplication application;
1507 Actor actor = Actor::New();
1508 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1509 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1510 application.GetScene().Add(actor);
1512 // Create and add a second actor so that GestureDetector destruction does not come into play.
1513 Actor dummyActor(Actor::New());
1514 dummyActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1515 dummyActor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
1516 dummyActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1517 application.GetScene().Add(dummyActor);
1519 // Render and notify
1520 application.SendNotification();
1521 application.Render();
1523 // State to remove actor in.
1524 GestureState stateToUnstage(GestureState::STARTED);
1526 // Attach actor to detector
1528 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
1529 PanGestureDetector detector = PanGestureDetector::New();
1530 detector.Attach(actor);
1531 detector.Attach(dummyActor);
1532 detector.DetectedSignal().Connect(&application, functor);
1534 // Here we are testing a STARTED actor which is removed in the STARTED callback, but then added back
1535 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1536 // position, we should still not be signalled.
1539 uint32_t time = 100;
1540 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1542 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 // Re add to the stage, we should not be signalled
1550 application.GetScene().Add(actor);
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 // Continue signal emission
1557 TestMovePan(application, Vector2(26.0f, 4.0f), time);
1558 time += TestGetFrameInterval();
1560 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1563 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1564 time += TestGetFrameInterval();
1566 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1569 // Here we delete an actor in started, we should not receive any subsequent signalling.
1572 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1574 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1581 // Delete actor as well
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Continue signal emission
1589 TestMovePan(application, Vector2(26.0f, 4.0f), time);
1590 time += TestGetFrameInterval();
1592 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1595 TestEndPan(application, Vector2(10.0f, 4.0f), time);
1597 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1601 int UtcDaliPanGestureAngleHandling(void)
1603 TestApplication application;
1605 PanGestureDetector detector = PanGestureDetector::New();
1606 DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1608 detector.AddAngle(PanGestureDetector::DIRECTION_LEFT, Radian(Math::PI * 0.25));
1609 DALI_TEST_EQUALS(detector.GetAngleCount(), 1u, TEST_LOCATION);
1611 for(size_t i = 0; i < detector.GetAngleCount(); i++)
1613 if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT)
1615 tet_result(TET_PASS);
1623 tet_printf("%s, angle not added\n", TEST_LOCATION);
1624 tet_result(TET_FAIL);
1627 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Radian(Math::PI * 0.25));
1628 DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1630 // Remove something not in the container.
1631 detector.RemoveAngle(PanGestureDetector::DIRECTION_UP);
1632 DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1634 detector.RemoveAngle(PanGestureDetector::DIRECTION_RIGHT);
1635 DALI_TEST_EQUALS(detector.GetAngleCount(), 1u, TEST_LOCATION);
1636 for(size_t i = 0; i < detector.GetAngleCount(); i++)
1638 if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT)
1640 tet_printf("%s, angle not removed\n", TEST_LOCATION);
1641 tet_result(TET_FAIL);
1646 detector.ClearAngles();
1647 DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1651 int UtcDaliPanGestureGetAngle(void)
1653 TestApplication application;
1655 PanGestureDetector detector = PanGestureDetector::New();
1656 DALI_TEST_EQUALS(detector.GetAngleCount(), 0, TEST_LOCATION);
1658 detector.AddAngle(PanGestureDetector::DIRECTION_LEFT);
1659 DALI_TEST_EQUALS(detector.GetAngleCount(), 1, TEST_LOCATION);
1661 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT);
1662 DALI_TEST_EQUALS(detector.GetAngleCount(), 2, TEST_LOCATION);
1664 detector.AddAngle(PanGestureDetector::DIRECTION_UP);
1665 DALI_TEST_EQUALS(detector.GetAngleCount(), 3, TEST_LOCATION);
1667 detector.AddAngle(PanGestureDetector::DIRECTION_DOWN);
1668 DALI_TEST_EQUALS(detector.GetAngleCount(), 4, TEST_LOCATION);
1670 DALI_TEST_EQUALS(detector.GetAngle(0).first, PanGestureDetector::DIRECTION_LEFT, TEST_LOCATION);
1671 DALI_TEST_EQUALS(detector.GetAngle(1).first, PanGestureDetector::DIRECTION_RIGHT, TEST_LOCATION);
1672 DALI_TEST_EQUALS(detector.GetAngle(2).first, PanGestureDetector::DIRECTION_UP, TEST_LOCATION);
1673 DALI_TEST_EQUALS(detector.GetAngle(3).first, PanGestureDetector::DIRECTION_DOWN, TEST_LOCATION);
1678 inline float RadiansToDegrees(float radian)
1680 return radian * 180.0f / Math::PI;
1683 int UtcDaliPanGestureAngleOutOfRange(void)
1685 TestApplication application;
1687 PanGestureDetector detector = PanGestureDetector::New();
1688 DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1694 detector.AddAngle(Degree(180.0f));
1695 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-180.0f)), 0.000001, TEST_LOCATION);
1696 detector.ClearAngles();
1698 detector.AddAngle(Degree(190.0f));
1699 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-170.0f)), 0.000001, TEST_LOCATION);
1700 detector.ClearAngles();
1702 detector.AddAngle(Degree(-190.0f));
1703 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(170.0f)), 0.000001, TEST_LOCATION);
1704 detector.ClearAngles();
1706 detector.AddAngle(Degree(350.0f));
1707 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-10.0f)), 0.000001, TEST_LOCATION);
1708 detector.ClearAngles();
1710 detector.AddAngle(Degree(-350.0f));
1711 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1712 detector.ClearAngles();
1714 detector.AddAngle(Degree(370.0f));
1715 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1716 detector.ClearAngles();
1718 detector.AddAngle(Degree(-370.0f));
1719 DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-10.0f)), 0.000001, TEST_LOCATION);
1720 detector.ClearAngles();
1726 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(0.0f));
1727 DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(0.0f)), 0.000001, TEST_LOCATION);
1728 detector.ClearAngles();
1730 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(-10.0f));
1731 DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1732 detector.ClearAngles();
1734 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(-181.0f));
1735 DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(180.0f)), 0.000001, TEST_LOCATION);
1736 detector.ClearAngles();
1738 detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(181.0f));
1739 DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(180.0f)), 0.000001, TEST_LOCATION);
1740 detector.ClearAngles();
1744 int UtcDaliPanGestureAngleProcessing(void)
1746 TestApplication application;
1748 Actor parent = Actor::New();
1749 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1750 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1751 application.GetScene().Add(parent);
1753 Actor child = Actor::New();
1754 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1755 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1762 // Parent detector only requires up pans
1763 PanGestureDetector parentDetector = PanGestureDetector::New();
1764 parentDetector.Attach(parent);
1765 parentDetector.AddAngle(PanGestureDetector::DIRECTION_UP, Degree(30.0f));
1766 SignalData parentData;
1767 GestureReceivedFunctor parentFunctor(parentData);
1768 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1770 // Child detector only requires right pans
1771 PanGestureDetector childDetector = PanGestureDetector::New();
1772 childDetector.Attach(child);
1773 childDetector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(30.0f));
1774 SignalData childData;
1775 GestureReceivedFunctor childFunctor(childData);
1776 childDetector.DetectedSignal().Connect(&application, childFunctor);
1778 // Generate an Up pan gesture, only parent should receive it.
1779 uint32_t time = 100;
1780 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 4.0f), time);
1782 DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1783 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1785 TestEndPan(application, Vector2(20.0f, 4.0f), time);
1786 time += TestGetFrameInterval();
1790 // Generate a Right pan gesture, only child should receive it.
1791 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(36.0f, 20.0f), time);
1793 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1794 DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1796 TestEndPan(application, Vector2(4.0f, 20.0f), time);
1797 time += TestGetFrameInterval();
1801 // Generate a Down pan gesture, no one should receive it.
1802 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 36.0f), time);
1804 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1805 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1807 TestEndPan(application, Vector2(20.0f, 36.0f), time);
1808 time += TestGetFrameInterval();
1812 // Generate a Left pan gesture, no one should receive it.
1813 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 20.0f), time);
1815 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1816 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1818 TestEndPan(application, Vector2(4.0f, 20.0f), time);
1824 int UtcDaliPanGestureDirectionHandling(void)
1826 TestApplication application;
1828 PanGestureDetector detector = PanGestureDetector::New();
1829 DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1831 detector.AddDirection(PanGestureDetector::DIRECTION_LEFT, Radian(Math::PI * 0.25));
1832 DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1834 for(size_t i = 0; detector.GetAngleCount(); i++)
1836 if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT)
1838 tet_result(TET_PASS);
1846 tet_printf("%s, angle not added\n", TEST_LOCATION);
1847 tet_result(TET_FAIL);
1851 for(size_t i = 0; i < detector.GetAngleCount(); i++)
1853 if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT)
1855 tet_result(TET_PASS);
1863 tet_printf("%s, angle not added\n", TEST_LOCATION);
1864 tet_result(TET_FAIL);
1867 // Remove something not in the container.
1868 detector.RemoveDirection(PanGestureDetector::DIRECTION_UP);
1869 DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1871 detector.RemoveDirection(PanGestureDetector::DIRECTION_RIGHT);
1872 DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1876 int UtcDaliPanGestureDirectionProcessing(void)
1878 TestApplication application;
1880 Actor parent = Actor::New();
1881 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1882 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1883 application.GetScene().Add(parent);
1885 Actor child = Actor::New();
1886 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1887 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 // Parent detector only requires vertical panning
1895 PanGestureDetector parentDetector = PanGestureDetector::New();
1896 parentDetector.Attach(parent);
1897 parentDetector.AddDirection(PanGestureDetector::DIRECTION_VERTICAL, Degree(30.0f));
1898 SignalData parentData;
1899 GestureReceivedFunctor parentFunctor(parentData);
1900 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1902 // Child detector only requires horizontal panning
1903 PanGestureDetector childDetector = PanGestureDetector::New();
1904 childDetector.Attach(child);
1905 childDetector.AddDirection(PanGestureDetector::DIRECTION_HORIZONTAL, Degree(30.0f));
1906 SignalData childData;
1907 GestureReceivedFunctor childFunctor(childData);
1908 childDetector.DetectedSignal().Connect(&application, childFunctor);
1910 // Generate an Up pan gesture, only parent should receive it.
1911 uint32_t time = 100;
1912 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 4.0f), time);
1914 DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1915 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1917 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1918 time += TestGetFrameInterval();
1922 // Generate a Right pan gesture, only child should receive it.
1923 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(36.0f, 20.0f), time);
1925 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1926 DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1928 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1929 time += TestGetFrameInterval();
1933 // Generate a Down pan gesture, only parent should receive it.
1934 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 36.0f), time);
1936 DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1937 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1939 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1940 time += TestGetFrameInterval();
1944 // Generate a Left pan gesture, only child should receive it.
1945 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 20.0f), time);
1947 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1948 DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1950 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1951 time += TestGetFrameInterval();
1955 // Generate a pan at -45 degrees, no one should receive it.
1956 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(9.0f, 31.0f), time);
1958 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1959 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1961 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1962 time += TestGetFrameInterval();
1966 // Generate a pan at 45 degrees, no one should receive it.
1967 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(31.0f, 31.0f), time);
1969 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1970 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1972 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1973 time += TestGetFrameInterval();
1977 // Generate a pan at -135 degrees, no one should receive it.
1978 TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 4.0f), time);
1980 DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1981 DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1983 TestEndPan(application, Vector2(20.0f, 20.0f), time);
1989 int UtcDaliPanGestureNoPredictionNoSmoothing(void)
1991 TestApplication application;
1992 Integration::SetPanGesturePredictionMode(0);
1993 Integration::SetPanGestureSmoothingMode(0);
1995 Actor actor = Actor::New();
1996 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1997 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1998 application.GetScene().Add(actor);
2000 // Add a pan detector
2001 PanGestureDetector detector = PanGestureDetector::New();
2002 detector.Attach(actor);
2004 GestureReceivedFunctor functor(data);
2005 detector.DetectedSignal().Connect(&application, functor);
2007 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2009 ConstraintData constraintData;
2010 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2011 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2012 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2013 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2014 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2015 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2016 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2017 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 Vector2 startPosition(1.0f, 1.0f);
2025 Vector2 position(-14.0f, 1.0f);
2026 Vector2 direction(Vector2::XAXIS * -5.0f);
2027 uint32_t time = 100;
2029 TestStartPan(application, startPosition, position, time);
2031 for(int i = 0; i < 47; i++)
2033 position += direction;
2034 TestMovePan(application, position, time);
2035 time += TestGetFrameInterval();
2036 application.SendNotification();
2037 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2040 TestEndPan(application, position, time);
2041 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2043 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2044 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2045 DALI_TEST_EQUALS(constraintData.screenPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION);
2046 DALI_TEST_EQUALS(constraintData.localPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION);
2048 constraintData.Reset();
2052 int UtcDaliPanGestureNoPredictionSmoothing(void)
2054 TestApplication application;
2055 Integration::SetPanGesturePredictionMode(0);
2056 Integration::SetPanGestureSmoothingMode(1);
2058 Actor actor = Actor::New();
2059 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2060 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2061 application.GetScene().Add(actor);
2063 // Add a pan detector
2064 PanGestureDetector detector = PanGestureDetector::New();
2065 detector.Attach(actor);
2067 GestureReceivedFunctor functor(data);
2068 detector.DetectedSignal().Connect(&application, functor);
2070 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2072 ConstraintData constraintData;
2073 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2074 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2075 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2076 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2077 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2078 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2079 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2080 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 Vector2 startPosition(1.0f, 1.0f);
2088 Vector2 position(-14.0f, 1.0f);
2089 Vector2 direction(Vector2::XAXIS * -5.0f);
2090 uint32_t time = 100;
2092 TestStartPan(application, startPosition, position, time);
2094 for(int i = 0; i < 47; i++)
2096 position += direction;
2097 TestMovePan(application, position, time);
2098 time += TestGetFrameInterval();
2099 application.SendNotification();
2100 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2103 TestEndPan(application, position, time);
2104 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2106 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2107 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2108 // Take into account resampling done when prediction is off.
2109 DALI_TEST_EQUALS(constraintData.screenPosition, startPosition + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION);
2110 DALI_TEST_EQUALS(constraintData.localPosition, startPosition + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION);
2112 constraintData.Reset();
2116 int UtcDaliPanGesturePredictionNoSmoothing(void)
2118 TestApplication application;
2119 Integration::SetPanGesturePredictionMode(1);
2120 Integration::SetPanGestureSmoothingMode(0);
2122 Actor actor = Actor::New();
2123 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2124 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2125 application.GetScene().Add(actor);
2127 // Add a pan detector
2128 PanGestureDetector detector = PanGestureDetector::New();
2129 detector.Attach(actor);
2131 GestureReceivedFunctor functor(data);
2132 detector.DetectedSignal().Connect(&application, functor);
2134 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2136 ConstraintData constraintData;
2137 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2138 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2139 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2140 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2141 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2142 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2143 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2144 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 Vector2 startPosition(1.0f, 1.0f);
2152 Vector2 position(-1.0f, 1.0f);
2153 Vector2 direction(Vector2::XAXIS * -1.0f);
2154 uint32_t time = 100;
2156 TestStartPan(application, startPosition, position, time);
2158 for(int i = 0; i < 47; i++)
2160 position += direction;
2161 TestMovePan(application, position, time);
2162 time += TestGetFrameInterval();
2163 application.SendNotification();
2164 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2167 TestEndPan(application, position, time);
2168 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2170 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2171 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2172 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2173 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2175 constraintData.Reset();
2179 int UtcDaliPanGesturePredictionSmoothing01(void)
2181 TestApplication application;
2182 Integration::SetPanGesturePredictionMode(1);
2183 Integration::SetPanGestureSmoothingMode(1);
2185 Actor actor = Actor::New();
2186 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2187 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2188 application.GetScene().Add(actor);
2190 // Add a pan detector
2191 PanGestureDetector detector = PanGestureDetector::New();
2192 detector.Attach(actor);
2194 GestureReceivedFunctor functor(data);
2195 detector.DetectedSignal().Connect(&application, functor);
2197 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2199 ConstraintData constraintData;
2200 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2201 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2202 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2203 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2204 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2205 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2206 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2207 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 Vector2 startPosition(1.0f, 1.0f);
2215 Vector2 position(-1.0f, 1.0f);
2216 Vector2 direction(Vector2::XAXIS * -1.0f);
2217 uint32_t time = 100;
2219 TestStartPan(application, startPosition, position, time);
2221 for(int i = 0; i < 47; i++)
2223 position += direction;
2224 TestMovePan(application, position, time);
2225 time += TestGetFrameInterval();
2226 application.SendNotification();
2227 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2230 TestEndPan(application, position, time);
2231 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2233 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2234 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2235 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2236 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2238 constraintData.Reset();
2242 int UtcDaliPanGesturePredictionSmoothing02(void)
2244 TestApplication application;
2245 Integration::SetPanGesturePredictionMode(1);
2246 Integration::SetPanGestureMaximumPredictionAmount(1);
2247 Integration::SetPanGesturePredictionAmountAdjustment(2);
2248 Integration::SetPanGestureSmoothingMode(1);
2249 Integration::SetPanGestureSmoothingAmount(0.25f);
2251 Actor actor = Actor::New();
2252 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2253 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2254 application.GetScene().Add(actor);
2256 // Add a pan detector
2257 PanGestureDetector detector = PanGestureDetector::New();
2258 detector.Attach(actor);
2260 GestureReceivedFunctor functor(data);
2261 detector.DetectedSignal().Connect(&application, functor);
2263 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2265 ConstraintData constraintData;
2266 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2267 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2268 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2269 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2270 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2271 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2272 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2273 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2276 // Render and notify
2277 application.SendNotification();
2278 application.Render();
2280 Vector2 startPosition(2.0f, 2.0f);
2281 Vector2 position(4.0f, 2.0f);
2282 Vector2 directionX(Vector2::XAXIS);
2283 Vector2 directionY(Vector2::YAXIS);
2284 uint32_t time = 100;
2286 TestStartPan(application, startPosition, position, time);
2288 for(int i = 0; i < 7; i++)
2290 position += directionX;
2291 TestMovePan(application, position, time);
2292 time += TestGetFrameInterval();
2293 application.SendNotification();
2294 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2297 position += directionX * 10.0f;
2298 TestMovePan(application, position, time);
2299 time += TestGetFrameInterval();
2300 application.SendNotification();
2301 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2303 for(int i = 0; i < 2; i++)
2305 position += (directionX * -1.0f);
2306 TestMovePan(application, position, time);
2307 time += TestGetFrameInterval();
2308 application.SendNotification();
2309 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2312 for(int i = 0; i < 10; i++)
2314 position += directionX;
2315 TestMovePan(application, position, time);
2316 time += TestGetFrameInterval();
2317 application.SendNotification();
2318 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2321 for(int i = 0; i < 10; i++)
2323 position += directionY;
2324 TestMovePan(application, position, time);
2325 time += TestGetFrameInterval();
2326 application.SendNotification();
2327 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2330 TestEndPan(application, position, time);
2331 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2333 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2334 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2335 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2336 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2338 constraintData.Reset();
2342 int UtcDaliPanGesturePrediction2SmoothingMultiTap01(void)
2344 TestApplication application;
2346 Integration::SetPanGesturePredictionMode(2);
2347 Integration::SetPanGesturePredictionAmount(57);
2348 Integration::SetPanGestureSmoothingMode(2);
2349 Integration::SetPanGestureUseActualTimes(false);
2350 Integration::SetPanGestureInterpolationTimeRange(10);
2351 Integration::SetPanGestureScalarOnlyPredictionEnabled(false);
2352 Integration::SetPanGestureTwoPointPredictionEnabled(true);
2353 Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2354 Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2355 Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2356 Integration::SetPanGestureMultitapSmoothingRange(34);
2358 Actor actor = Actor::New();
2359 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2360 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2361 application.GetScene().Add(actor);
2363 // Add a pan detector
2364 PanGestureDetector detector = PanGestureDetector::New();
2365 detector.Attach(actor);
2367 GestureReceivedFunctor functor(data);
2368 detector.DetectedSignal().Connect(&application, functor);
2370 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2372 ConstraintData constraintData;
2373 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2374 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2375 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2376 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2377 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2378 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2379 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2380 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 Vector2 startPosition(2.0f, 2.0f);
2388 Vector2 position(-1.0f, 2.0f);
2389 Vector2 direction(Vector2::XAXIS * -1.0f);
2390 uint32_t time = 100;
2392 TestStartPan(application, startPosition, position, time);
2394 for(int i = 0; i < 27; i++)
2396 position += direction;
2397 TestMovePan(application, position, time);
2398 time += TestGetFrameInterval();
2399 application.SendNotification();
2400 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2403 TestEndPan(application, position, time);
2404 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2406 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2407 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2408 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2409 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2411 constraintData.Reset();
2415 int UtcDaliPanGesturePrediction2SmoothingMultiTap02(void)
2417 TestApplication application;
2419 Integration::SetPanGesturePredictionMode(2);
2420 Integration::SetPanGestureSmoothingMode(2);
2421 Integration::SetPanGestureUseActualTimes(true);
2422 Integration::SetPanGestureInterpolationTimeRange(10);
2423 Integration::SetPanGestureScalarOnlyPredictionEnabled(true);
2424 Integration::SetPanGestureTwoPointPredictionEnabled(true);
2425 Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2426 Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2427 Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2428 Integration::SetPanGestureMultitapSmoothingRange(34);
2430 Integration::EnableProfiling(Integration::PROFILING_TYPE_PAN_GESTURE);
2432 Actor actor = Actor::New();
2433 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2434 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2435 application.GetScene().Add(actor);
2437 // Add a pan detector
2438 PanGestureDetector detector = PanGestureDetector::New();
2439 detector.Attach(actor);
2441 GestureReceivedFunctor functor(data);
2442 detector.DetectedSignal().Connect(&application, functor);
2444 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2446 ConstraintData constraintData;
2447 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2448 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2449 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2450 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2451 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2452 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2453 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2454 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2461 Vector2 startPosition(2.0f, 2.0f);
2462 Vector2 position(17.0f, 2.0f);
2463 Vector2 direction(Vector2::XAXIS * -1.0f);
2464 uint32_t time = 100;
2466 TestStartPan(application, startPosition, position, time);
2468 for(int i = 0; i < 10; i++)
2470 position += direction;
2471 TestMovePan(application, position, time);
2472 time += TestGetFrameInterval();
2474 position += direction;
2475 TestMovePan(application, position, time);
2476 time += TestGetFrameInterval();
2478 position += direction;
2479 TestMovePan(application, position, time);
2480 time += TestGetFrameInterval();
2482 application.SendNotification();
2483 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2486 for(int i = 0; i < 10; i++)
2488 application.SendNotification();
2489 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2492 for(int i = 0; i < 10; i++)
2494 position += direction;
2495 TestMovePan(application, position, time);
2496 application.SendNotification();
2497 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2500 for(int i = 0; i < 10; i++)
2502 position += direction;
2503 TestMovePan(application, position, time);
2504 time += TestGetFrameInterval();
2505 application.SendNotification();
2506 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2509 TestEndPan(application, position, time);
2510 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2512 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2513 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2514 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2515 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2517 constraintData.Reset();
2521 int UtcDaliPanGesturePrediction2Smoothing(void)
2523 TestApplication application;
2525 Integration::SetPanGesturePredictionMode(2);
2526 Integration::SetPanGesturePredictionAmount(57);
2527 Integration::SetPanGestureSmoothingMode(1);
2528 Integration::SetPanGestureUseActualTimes(false);
2529 Integration::SetPanGestureInterpolationTimeRange(10);
2530 Integration::SetPanGestureScalarOnlyPredictionEnabled(true);
2531 Integration::SetPanGestureTwoPointPredictionEnabled(true);
2532 Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2533 Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2534 Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2535 Integration::SetPanGestureMultitapSmoothingRange(34);
2537 Actor actor = Actor::New();
2538 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2539 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2540 application.GetScene().Add(actor);
2542 // Add a pan detector
2543 PanGestureDetector detector = PanGestureDetector::New();
2544 detector.Attach(actor);
2546 GestureReceivedFunctor functor(data);
2547 detector.DetectedSignal().Connect(&application, functor);
2549 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2551 ConstraintData constraintData;
2552 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2553 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2554 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2555 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2556 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2557 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2558 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2559 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 Vector2 startPosition(2.0f, 2.0f);
2567 Vector2 position(17.0f, 2.0f);
2568 Vector2 direction(Vector2::XAXIS * -1.0f);
2569 uint32_t time = 100;
2571 TestStartPan(application, startPosition, position, time);
2573 for(int i = 0; i < 10; i++)
2575 position += direction;
2576 TestMovePan(application, position, time);
2577 time += TestGetFrameInterval();
2578 application.SendNotification();
2579 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2582 position += direction;
2583 TestMovePan(application, position, time);
2584 time += TestGetFrameInterval();
2586 position += direction;
2587 TestMovePan(application, position, time);
2588 time += TestGetFrameInterval();
2590 position += direction;
2591 TestMovePan(application, position, time);
2592 time += TestGetFrameInterval();
2594 application.SendNotification();
2595 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2597 for(int i = 0; i < 5; i++)
2599 application.SendNotification();
2600 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2603 for(int i = 0; i < 10; i++)
2605 position += direction;
2606 TestMovePan(application, position, time);
2607 time += TestGetFrameInterval();
2608 application.SendNotification();
2609 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2612 TestEndPan(application, position, time);
2613 application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2615 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2616 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2617 DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2618 DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2620 constraintData.Reset();
2624 int UtcDaliPanGestureSetProperties(void)
2626 TestApplication application;
2627 TestRenderController& renderController(application.GetRenderController());
2628 Integration::SetPanGesturePredictionMode(0);
2629 Integration::SetPanGestureSmoothingMode(0);
2631 Actor actor = Actor::New();
2632 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2633 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2634 application.GetScene().Add(actor);
2636 // Add a pan detector
2637 PanGestureDetector detector = PanGestureDetector::New();
2638 detector.Attach(actor);
2640 GestureReceivedFunctor functor(data);
2641 detector.DetectedSignal().Connect(&application, functor);
2643 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2644 Property::Index animatableGestureProperty = detector.RegisterProperty("Dummy Property", Vector3::ZERO); // For code coverage
2646 ConstraintData constraintData;
2647 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2648 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2649 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2650 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2651 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2652 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2653 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2654 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2655 constraint.AddSource(Source(detector, animatableGestureProperty));
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 renderController.Initialize();
2663 DALI_TEST_EQUALS(renderController.WasCalled(TestRenderController::RequestUpdateFunc), false, TEST_LOCATION);
2665 Vector2 screenPosition(20.0f, 20.0f);
2666 Vector2 screenDisplacement(1.0f, 1.0f);
2667 Vector2 screenVelocity(1.3f, 4.0f);
2668 Vector2 localPosition(21.0f, 21.0f);
2669 Vector2 localDisplacement(0.5f, 0.5f);
2670 Vector2 localVelocity(1.5f, 2.5f);
2672 PanGestureDetector::SetPanGestureProperties(GeneratePan(1u, GestureState::STARTED, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity));
2673 DALI_TEST_EQUALS(renderController.WasCalled(TestRenderController::RequestUpdateFunc), true, TEST_LOCATION);
2675 // Render and notify
2676 application.SendNotification();
2677 application.Render();
2679 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2680 DALI_TEST_EQUALS(constraintData.screenPosition, screenPosition, TEST_LOCATION);
2681 DALI_TEST_EQUALS(constraintData.localPosition, localPosition, TEST_LOCATION);
2682 DALI_TEST_EQUALS(constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION);
2683 DALI_TEST_EQUALS(constraintData.localDisplacement, localDisplacement, TEST_LOCATION);
2684 DALI_TEST_EQUALS(constraintData.screenVelocity, screenVelocity, TEST_LOCATION);
2685 DALI_TEST_EQUALS(constraintData.localVelocity, localVelocity, TEST_LOCATION);
2686 constraintData.Reset();
2690 int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
2692 TestApplication application;
2693 Integration::SetPanGesturePredictionMode(0);
2695 Actor actor = Actor::New();
2696 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2697 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2698 application.GetScene().Add(actor);
2700 // Add a pan detector
2701 PanGestureDetector detector = PanGestureDetector::New();
2702 detector.Attach(actor);
2704 GestureReceivedFunctor functor(data);
2705 detector.DetectedSignal().Connect(&application, functor);
2707 Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2709 ConstraintData constraintData;
2710 Constraint constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2711 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2712 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2713 constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2714 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2715 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2716 constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2717 constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 Vector2 currentPosition(20.0f, 4.0f);
2725 uint32_t time = 100;
2726 TestStartPan(application, Vector2(20.0f, 20.0f), currentPosition, time);
2727 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2729 Vector2 screenPosition(100.0f, 20.0f);
2730 Vector2 localPosition(110.0f, 110.0f);
2732 PanGestureDetector::SetPanGestureProperties(GeneratePan(1u, GestureState::STARTED, screenPosition, localPosition));
2734 // Render and notify
2735 application.SendNotification();
2736 application.Render();
2738 DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2739 DALI_TEST_EQUALS(constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION);
2740 DALI_TEST_EQUALS(constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION);
2741 constraintData.Reset();
2745 int UtcDaliPanGesturePropertyIndices(void)
2747 TestApplication application;
2748 PanGestureDetector detector = PanGestureDetector::New();
2750 Property::IndexContainer indices;
2751 detector.GetPropertyIndices(indices);
2752 DALI_TEST_CHECK(indices.Size());
2753 DALI_TEST_EQUALS(indices.Size(), detector.GetPropertyCount(), TEST_LOCATION);
2759 struct PropertyStringIndex
2761 const char* const name;
2762 const Property::Index index;
2763 const Property::Type type;
2764 const Property::Value value;
2767 const PropertyStringIndex PROPERTY_TABLE[] =
2769 {"screenPosition", PanGestureDetector::Property::SCREEN_POSITION, Property::VECTOR2, Vector2::ZERO},
2770 {"screenDisplacement", PanGestureDetector::Property::SCREEN_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO},
2771 {"screenVelocity", PanGestureDetector::Property::SCREEN_VELOCITY, Property::VECTOR2, Vector2::ZERO},
2772 {"localPosition", PanGestureDetector::Property::LOCAL_POSITION, Property::VECTOR2, Vector2::ZERO},
2773 {"localDisplacement", PanGestureDetector::Property::LOCAL_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO},
2774 {"localVelocity", PanGestureDetector::Property::LOCAL_VELOCITY, Property::VECTOR2, Vector2::ZERO},
2775 {"panning", PanGestureDetector::Property::PANNING, Property::BOOLEAN, false},
2777 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
2778 } // unnamed namespace
2780 int UtcDaliPanGestureProperties(void)
2782 TestApplication application;
2783 PanGestureDetector detector = PanGestureDetector::New();
2785 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2787 DALI_TEST_EQUALS(detector.GetPropertyName(PROPERTY_TABLE[i].index), std::string(PROPERTY_TABLE[i].name), TEST_LOCATION);
2788 DALI_TEST_EQUALS(detector.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
2789 DALI_TEST_EQUALS(detector.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
2790 DALI_TEST_EQUALS(detector.IsPropertyWritable(PROPERTY_TABLE[i].index), false, TEST_LOCATION);
2791 DALI_TEST_EQUALS(detector.IsPropertyAnimatable(PROPERTY_TABLE[i].index), false, TEST_LOCATION);
2792 DALI_TEST_EQUALS(detector.IsPropertyAConstraintInput(PROPERTY_TABLE[i].index), true, TEST_LOCATION);
2793 detector.SetProperty(PROPERTY_TABLE[i].index, Property::Value()); // Just for Coverage
2799 int UtcDaliPanGestureGetProperty(void)
2801 TestApplication application;
2802 PanGestureDetector detector = PanGestureDetector::New();
2804 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2806 if(PROPERTY_TABLE[i].type == Property::VECTOR2)
2808 bool value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<bool>();
2809 DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<bool>(), value, TEST_LOCATION);
2811 else if(PROPERTY_TABLE[i].type == Property::BOOLEAN)
2813 Vector2 value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<Vector2>();
2814 DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<Vector2>(), value, TEST_LOCATION);
2821 int UtcDaliPanGestureGetPropertyWithSceneObject(void)
2823 TestApplication application;
2825 Actor actor = Actor::New();
2826 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2827 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2828 application.GetScene().Add(actor);
2830 // Add a pan detector
2831 PanGestureDetector detector = PanGestureDetector::New();
2832 detector.Attach(actor);
2834 // Render and notify
2835 application.SendNotification();
2836 application.Render();
2838 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2840 detector.SetProperty(PROPERTY_TABLE[i].index, Property::Value()); // Just for Coverage
2842 if(PROPERTY_TABLE[i].type == Property::VECTOR2)
2844 bool value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<bool>();
2845 DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<bool>(), value, TEST_LOCATION);
2847 else if(PROPERTY_TABLE[i].type == Property::BOOLEAN)
2849 Vector2 value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<Vector2>();
2850 DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<Vector2>(), value, TEST_LOCATION);
2857 int UtcDaliPanGestureLayerConsumesTouch(void)
2859 TestApplication application;
2861 Actor actor = Actor::New();
2862 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2863 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2864 application.GetScene().Add(actor);
2866 // Add a pan detector
2867 PanGestureDetector detector = PanGestureDetector::New();
2868 detector.Attach(actor);
2870 GestureReceivedFunctor functor(data);
2871 detector.DetectedSignal().Connect(&application, functor);
2873 // Add a layer to overlap the actor
2874 Layer layer = Layer::New();
2875 layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2876 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2877 application.GetScene().Add(layer);
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 // Emit signals, should receive
2885 uint32_t time = 100;
2886 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2887 TestEndPan(application, Vector2(26.0f, 20.0f), time);
2888 time += TestGetFrameInterval();
2890 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2893 // Set layer to consume all touch
2894 layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
2896 // Render and notify
2897 application.SendNotification();
2898 application.Render();
2900 // Emit the same signals again, should not receive
2901 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2902 TestEndPan(application, Vector2(26.0f, 20.0f), time);
2904 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2910 int UtcDaliPanGestureNoTimeDiff(void)
2912 TestApplication application;
2914 Actor actor = Actor::New();
2915 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2916 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2917 application.GetScene().Add(actor);
2919 // Add a pan detector
2920 PanGestureDetector detector = PanGestureDetector::New();
2921 detector.Attach(actor);
2923 GestureReceivedFunctor functor(data);
2924 detector.DetectedSignal().Connect(&application, functor);
2926 // Render and notify
2927 application.SendNotification();
2928 application.Render();
2930 // As normal helper function adds intervals between presses we must generate the sequence
2931 // using other helper functions
2932 TestStartLongPress(application, 10.0f, 20.0f, 100); // Used to send a down press event
2933 TestMovePan(application, Vector2(26.0f, 20.0f), 100);
2934 TestMovePan(application, Vector2(26.0f, 20.0f), 100); // 2 motions required to trigger
2935 TestEndPan(application, Vector2(26.0f, 20.0f), 100);
2937 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2938 DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetVelocity().x));
2939 DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetVelocity().y));
2940 DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetScreenVelocity().x));
2941 DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetScreenVelocity().y));
2949 int UtcDaliPanGestureDisableDetectionDuringPanN(void)
2951 // Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
2953 TestApplication application;
2955 Actor actor = Actor::New();
2956 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2957 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2958 application.GetScene().Add(actor);
2960 // Add a pan detector
2961 PanGestureDetector detector = PanGestureDetector::New();
2962 bool functorCalled = false;
2963 detector.Attach(actor);
2964 detector.DetectedSignal().Connect(
2966 [&detector, &functorCalled](Actor actor, const PanGesture& pan) {
2967 if(pan.GetState() == GestureState::FINISHED)
2969 detector.Detach(actor);
2970 functorCalled = true;
2974 // Render and notify
2975 application.SendNotification();
2976 application.Render();
2978 // Try the gesture, should not crash
2981 uint32_t time = 100;
2982 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2983 TestEndPan(application, Vector2(26.0f, 20.0f));
2985 DALI_TEST_CHECK(true); // No crash, test has passed
2986 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
2990 DALI_TEST_CHECK(false); // If we crash, the test has failed
2996 int UtcDaliPanGestureWhenGesturePropargation(void)
2998 TestApplication application;
3000 Actor parentActor = Actor::New();
3001 parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3002 parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3004 Actor childActor = Actor::New();
3005 childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3006 childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3008 parentActor.Add(childActor);
3009 application.GetScene().Add(parentActor);
3011 // Render and notify
3012 application.SendNotification();
3013 application.Render();
3016 GestureReceivedFunctor pFunctor(pData);
3018 PanGestureDetector parentDetector = PanGestureDetector::New();
3019 parentDetector.Attach(parentActor);
3020 parentDetector.DetectedSignal().Connect(&application, pFunctor);
3023 GestureReceivedFunctor cFunctor(cData);
3025 PanGestureDetector childDetector = PanGestureDetector::New();
3026 childDetector.Attach(childActor);
3027 childDetector.DetectedSignal().Connect(&application, cFunctor);
3029 // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
3030 uint32_t time = 100;
3031 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3033 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3034 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3038 TestMovePan(application, Vector2(26.0f, 4.0f), time);
3039 time += TestGetFrameInterval();
3041 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3042 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3046 TestEndPan(application, Vector2(26.0f, 20.0f), time);
3048 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3049 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3053 // If GesturePropargation is set, a gesture event is to pass over to the parent.
3054 Dali::DevelActor::SetNeedGesturePropagation(childActor, true);
3056 // So now the parent got the gesture event.
3057 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3058 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3059 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3063 TestMovePan(application, Vector2(26.0f, 4.0f), time);
3064 time += TestGetFrameInterval();
3066 // child does not receive gestures. This is because we have passed the permission of the gesture to the parent.
3067 DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
3068 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3072 TestEndPan(application, Vector2(26.0f, 20.0f), time);
3073 DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
3074 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3081 int UtcDaliPanGestureHandleEvent(void)
3083 TestApplication application;
3084 Integration::Scene scene = application.GetScene();
3085 RenderTaskList taskList = scene.GetRenderTaskList();
3086 Dali::RenderTask task = taskList.GetTask(0);
3088 Actor parentActor = Actor::New();
3089 parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3090 parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3092 Actor childActor = Actor::New();
3093 childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3094 childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3096 parentActor.Add(childActor);
3097 application.GetScene().Add(parentActor);
3099 // Render and notify
3100 application.SendNotification();
3101 application.Render();
3104 GestureReceivedFunctor pFunctor(pData);
3106 PanGestureDetector parentDetector = PanGestureDetector::New();
3107 parentDetector.DetectedSignal().Connect(&application, pFunctor);
3110 Integration::TouchEvent tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3111 Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(100));
3112 touchEventImpl->AddPoint(tp.GetPoint(0));
3113 touchEventImpl->SetRenderTask(task);
3114 Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
3115 parentDetector.HandleEvent(parentActor, touchEventHandle);
3118 tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 150);
3119 touchEventImpl = new Internal::TouchEvent(150);
3120 touchEventImpl->AddPoint(tp.GetPoint(0));
3121 touchEventImpl->SetRenderTask(task);
3122 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3123 parentDetector.HandleEvent(parentActor, touchEventHandle);
3126 tp = GenerateSingleTouch(PointState::MOTION, Vector2(90.0f, 90.0f), 200);
3127 touchEventImpl = new Internal::TouchEvent(200);
3128 touchEventImpl->AddPoint(tp.GetPoint(0));
3129 touchEventImpl->SetRenderTask(task);
3130 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3131 parentDetector.HandleEvent(parentActor, touchEventHandle);
3133 tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 250);
3134 touchEventImpl = new Internal::TouchEvent(250);
3135 touchEventImpl->AddPoint(tp.GetPoint(0));
3136 touchEventImpl->SetRenderTask(task);
3137 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3138 parentDetector.HandleEvent(parentActor, touchEventHandle);
3141 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3147 int UtcDaliPanGestureSignalReceptionWithGeometryHittest(void)
3149 TestApplication application;
3150 application.GetScene().SetGeometryHittestEnabled(true);
3152 Actor actor = Actor::New();
3153 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3154 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3155 application.GetScene().Add(actor);
3157 // Render and notify
3158 application.SendNotification();
3159 application.Render();
3162 GestureReceivedFunctor functor(data);
3164 PanGestureDetector detector = PanGestureDetector::New();
3165 detector.Attach(actor);
3166 detector.DetectedSignal().Connect(&application, functor);
3168 // Start pan within the actor's area
3169 uint32_t time = 100;
3170 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3171 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3173 // Continue the pan within the actor's area - we should still receive the signal
3176 TestMovePan(application, Vector2(26.0f, 4.0f), time);
3177 time += TestGetFrameInterval();
3179 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3181 // Gesture ends within actor's area
3184 TestEndPan(application, Vector2(10.0f, 4.0f), time);
3185 time += TestGetFrameInterval();
3187 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3190 detector.DetachAll();
3192 // Ensure we are no longer signalled
3195 TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3196 TestMovePan(application, Vector2(26.0f, 4.0f), time);
3197 time += TestGetFrameInterval();
3198 TestEndPan(application, Vector2(10.0f, 4.0f), time);
3200 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
3204 int UtcDaliPanGestureFeedTouchWhenGesturePropagation(void)
3206 TestApplication application;
3207 Integration::Scene scene = application.GetScene();
3208 RenderTaskList taskList = scene.GetRenderTaskList();
3209 Dali::RenderTask task = taskList.GetTask(0);
3211 Actor parentActor = Actor::New();
3212 parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3213 parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3215 Actor childActor = Actor::New();
3216 childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3217 childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3219 parentActor.Add(childActor);
3220 application.GetScene().Add(parentActor);
3222 // Render and notify
3223 application.SendNotification();
3224 application.Render();
3227 GestureReceivedFunctor pFunctor(pData);
3229 PanGestureDetector parentDetector = PanGestureDetector::New();
3230 parentDetector.DetectedSignal().Connect(&application, pFunctor);
3233 GestureReceivedFunctor cFunctor(cData);
3235 PanGestureDetector childDetector = PanGestureDetector::New();
3236 childDetector.DetectedSignal().Connect(&application, cFunctor);
3238 // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
3239 Integration::TouchEvent tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3240 Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(100));
3241 touchEventImpl->AddPoint(tp.GetPoint(0));
3242 touchEventImpl->SetRenderTask(task);
3243 Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
3244 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3246 parentDetector.HandleEvent(parentActor, touchEventHandle);
3249 tp = GenerateSingleTouch(PointState::MOTION, Vector2(60.0f, 60.0f), 150);
3250 touchEventImpl = new Internal::TouchEvent(150);
3251 touchEventImpl->AddPoint(tp.GetPoint(0));
3252 touchEventImpl->SetRenderTask(task);
3253 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3254 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3256 parentDetector.HandleEvent(parentActor, touchEventHandle);
3259 tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 200);
3260 touchEventImpl = new Internal::TouchEvent(200);
3261 touchEventImpl->AddPoint(tp.GetPoint(0));
3262 touchEventImpl->SetRenderTask(task);
3263 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3264 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3266 parentDetector.HandleEvent(parentActor, touchEventHandle);
3269 tp = GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f), 250);
3270 touchEventImpl = new Internal::TouchEvent(200);
3271 touchEventImpl->AddPoint(tp.GetPoint(0));
3272 touchEventImpl->SetRenderTask(task);
3273 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3274 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3276 parentDetector.HandleEvent(parentActor, touchEventHandle);
3279 tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 300);
3280 touchEventImpl = new Internal::TouchEvent(250);
3281 touchEventImpl->AddPoint(tp.GetPoint(0));
3282 touchEventImpl->SetRenderTask(task);
3283 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3284 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3286 parentDetector.HandleEvent(parentActor, touchEventHandle);
3289 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3290 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3295 // If GesturePropargation is set, a gesture event is to pass over to the parent.
3297 PropagationActorFunctor cPFunctor(cPData, true);
3298 childDetector.DetectedSignal().Connect(&application, cPFunctor);
3300 // So now the parent got the gesture event.
3301 tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3302 touchEventImpl = new Internal::TouchEvent(100);
3303 touchEventImpl->AddPoint(tp.GetPoint(0));
3304 touchEventImpl->SetRenderTask(task);
3305 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3306 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3308 parentDetector.HandleEvent(parentActor, touchEventHandle);
3311 tp = GenerateSingleTouch(PointState::MOTION, Vector2(60.0f, 60.0f), 150);
3312 touchEventImpl = new Internal::TouchEvent(150);
3313 touchEventImpl->AddPoint(tp.GetPoint(0));
3314 touchEventImpl->SetRenderTask(task);
3315 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3316 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3318 parentDetector.HandleEvent(parentActor, touchEventHandle);
3321 tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 200);
3322 touchEventImpl = new Internal::TouchEvent(200);
3323 touchEventImpl->AddPoint(tp.GetPoint(0));
3324 touchEventImpl->SetRenderTask(task);
3325 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3326 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3328 parentDetector.HandleEvent(parentActor, touchEventHandle);
3331 tp = GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f), 250);
3332 touchEventImpl = new Internal::TouchEvent(250);
3333 touchEventImpl->AddPoint(tp.GetPoint(0));
3334 touchEventImpl->SetRenderTask(task);
3335 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3336 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3338 parentDetector.HandleEvent(parentActor, touchEventHandle);
3341 tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 300);
3342 touchEventImpl = new Internal::TouchEvent(300);
3343 touchEventImpl->AddPoint(tp.GetPoint(0));
3344 touchEventImpl->SetRenderTask(task);
3345 touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3346 if(!childDetector.HandleEvent(childActor, touchEventHandle))
3348 parentDetector.HandleEvent(parentActor, touchEventHandle);
3351 DALI_TEST_EQUALS(true, cPData.functorCalled, TEST_LOCATION);
3352 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);