2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/dali.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
24 #include <dali/integration-api/system-overlay.h>
25 #include <dali/integration-api/profiling.h>
26 #include <dali-test-suite-utils.h>
27 #include <test-touch-utils.h>
31 void utc_dali_pan_gesture_detector_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_pan_gesture_detector_cleanup(void)
38 test_return_value = TET_PASS;
41 ///////////////////////////////////////////////////////////////////////////////
44 typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType;
47 // Stores data that is populated in the callback and will be read by the test cases
51 : functorCalled(false),
52 voidFunctorCalled(false),
53 receivedGesture(Gesture::Clear)
58 functorCalled = false;
59 voidFunctorCalled = false;
61 receivedGesture.state = Gesture::Clear;
62 receivedGesture.velocity = Vector2(0.0f, 0.0f);
63 receivedGesture.displacement = Vector2(0.0f, 0.0f);
64 receivedGesture.position = Vector2(0.0f, 0.0f);
65 receivedGesture.screenPosition = Vector2(0.0f, 0.0f);
66 receivedGesture.numberOfTouches = 0;
72 bool voidFunctorCalled;
73 PanGesture receivedGesture;
77 // Functor that sets the data when called
78 struct GestureReceivedFunctor
80 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
82 void operator()(Actor actor, PanGesture pan)
84 signalData.functorCalled = true;
85 signalData.receivedGesture = pan;
86 signalData.pannedActor = actor;
91 signalData.voidFunctorCalled = true;
94 SignalData& signalData;
97 // Functor that removes the gestured actor from stage
98 struct UnstageActorFunctor : public GestureReceivedFunctor
100 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
101 : GestureReceivedFunctor( data ),
102 stateToUnstage( stateToUnstage )
106 void operator()( Actor actor, PanGesture pan )
108 GestureReceivedFunctor::operator()( actor, pan );
110 if ( pan.state == stateToUnstage )
112 Stage::GetCurrent().Remove( actor );
116 Gesture::State& stateToUnstage;
119 // Functor for receiving a touch event
120 struct TouchEventFunctor
122 bool operator()(Actor actor, const TouchEvent& touch)
128 // Data for constraints
129 struct ConstraintData
136 Vector2 screenPosition;
137 Vector2 screenDisplacement;
138 Vector2 screenVelocity;
139 Vector2 localPosition;
140 Vector2 localDisplacement;
141 Vector2 localVelocity;
146 screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
151 // Constraint used with panning properties
154 PanConstraint( ConstraintData& data ) : constraintData(data) { }
156 Vector3 operator()(const Vector3& current,
157 const PropertyInput& screenPositionProperty,
158 const PropertyInput& screenDisplacementProperty,
159 const PropertyInput& screenVelocityProperty,
160 const PropertyInput& localPositionProperty,
161 const PropertyInput& localDisplacementProperty,
162 const PropertyInput& localVelocityProperty)
164 constraintData.screenPosition = screenPositionProperty.GetVector2();
165 constraintData.screenDisplacement = screenDisplacementProperty.GetVector2();
166 constraintData.screenVelocity = screenVelocityProperty.GetVector2();
167 constraintData.localPosition = localPositionProperty.GetVector2();
168 constraintData.localDisplacement = localDisplacementProperty.GetVector2();
169 constraintData.localVelocity = localVelocityProperty.GetVector2();
170 constraintData.called = true;
171 return Vector3::ZERO;
174 ConstraintData& constraintData;
177 // Generate a PanGestureEvent to send to Core
178 Integration::PanGestureEvent GeneratePan(
179 Gesture::State state,
180 Vector2 previousPosition,
181 Vector2 currentPosition,
182 unsigned long timeDelta,
183 unsigned int numberOfTouches = 1,
184 unsigned int time = 1u)
186 Integration::PanGestureEvent pan(state);
188 pan.previousPosition = previousPosition;
189 pan.currentPosition = currentPosition;
190 pan.timeDelta = timeDelta;
191 pan.numberOfTouches = numberOfTouches;
197 // Generate a PanGesture
198 PanGesture GeneratePan( unsigned int time,
199 Gesture::State state,
200 Vector2 screenPosition,
201 Vector2 localPosition,
202 Vector2 screenDisplacement = Vector2::ONE,
203 Vector2 localDisplacement = Vector2::ONE,
204 Vector2 screenVelocity = Vector2::ONE,
205 Vector2 localVelocity = Vector2::ONE,
206 unsigned int numberOfTouches = 1 )
208 PanGesture pan( state );
212 pan.screenPosition = screenPosition;
213 pan.position = localPosition;
215 pan.screenDisplacement = screenDisplacement;
216 pan.displacement = localDisplacement;
218 pan.screenVelocity = screenVelocity;
219 pan.velocity = localVelocity;
221 pan.numberOfTouches = numberOfTouches;
228 ///////////////////////////////////////////////////////////////////////////////
230 // Positive test case for a method
231 int UtcDaliPanGestureDetectorConstructor(void)
233 TestApplication application;
235 PanGestureDetector detector;
236 DALI_TEST_CHECK(!detector);
241 // Negative test case for a method
242 int UtcDaliPanGestureDetectorNew(void)
244 TestApplication application;
246 PanGestureDetector detector = PanGestureDetector::New();
248 DALI_TEST_CHECK(detector);
250 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
251 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
253 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
254 Actor actor = Actor::New();
255 actor.SetSize(100.0f, 100.0f);
256 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
257 detector.Attach(actor);
259 Stage::GetCurrent().Add(actor);
262 application.SendNotification();
263 application.Render();
265 Integration::TouchEvent touchEvent(1);
266 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
267 touchEvent.AddPoint(point);
268 application.ProcessEvent(touchEvent);
272 int UtcDaliPanGestureDetectorDownCast(void)
274 TestApplication application;
275 tet_infoline("Testing Dali::GestureDetector::DownCast()");
277 PanGestureDetector detector = PanGestureDetector::New();
279 BaseHandle object(detector);
281 PanGestureDetector detector2 = PanGestureDetector::DownCast(object);
282 DALI_TEST_CHECK(detector2);
284 PanGestureDetector detector3 = DownCast< PanGestureDetector >(object);
285 DALI_TEST_CHECK(detector3);
287 BaseHandle unInitializedObject;
288 PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject);
289 DALI_TEST_CHECK(!detector4);
291 PanGestureDetector detector5 = DownCast< PanGestureDetector >(unInitializedObject);
292 DALI_TEST_CHECK(!detector5);
294 GestureDetector detector6 = PanGestureDetector::New();
295 PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6);
296 DALI_TEST_CHECK(detector7);
300 int UtcDaliPanGestureSetMinimumTouchesRequired(void)
302 TestApplication application;
304 PanGestureDetector detector = PanGestureDetector::New();
306 unsigned int min = 2;
308 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
310 detector.SetMinimumTouchesRequired(min);
312 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
314 // Attach an actor and change the minimum touches
316 Actor actor = Actor::New();
317 actor.SetSize(100.0f, 100.0f);
318 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
319 Stage::GetCurrent().Add(actor);
322 application.SendNotification();
323 application.Render();
326 GestureReceivedFunctor functor(data);
328 detector.Attach(actor);
329 detector.DetectedSignal().Connect(&application, functor);
331 TestGestureManager& gestureManager = application.GetGestureManager();
332 gestureManager.Initialize();
334 detector.SetMinimumTouchesRequired(3);
336 // Gesture detection should have been updated only
337 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
338 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
339 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
342 gestureManager.Initialize();
344 // Create a second gesture detector that requires even less minimum touches
345 PanGestureDetector secondDetector = PanGestureDetector::New();
346 secondDetector.Attach(actor);
348 // Gesture detection should have been updated only
349 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
350 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
351 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
355 int UtcDaliPanGestureSetMaximumTouchesRequired(void)
357 TestApplication application;
359 PanGestureDetector detector = PanGestureDetector::New();
361 unsigned int max = 3;
363 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
365 detector.SetMaximumTouchesRequired(max);
367 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
369 // Attach an actor and change the maximum touches
371 Actor actor = Actor::New();
372 actor.SetSize(100.0f, 100.0f);
373 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
374 Stage::GetCurrent().Add(actor);
377 application.SendNotification();
378 application.Render();
381 GestureReceivedFunctor functor(data);
383 detector.Attach(actor);
384 detector.DetectedSignal().Connect(&application, functor);
386 TestGestureManager& gestureManager = application.GetGestureManager();
387 gestureManager.Initialize();
389 detector.SetMaximumTouchesRequired(4);
391 // Gesture detection should have been updated only
392 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
393 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
394 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
397 gestureManager.Initialize();
399 // Create a second gesture detector that requires even less maximum touches
400 PanGestureDetector secondDetector = PanGestureDetector::New();
401 secondDetector.Attach(actor);
403 // Gesture detection should NOT have been updated
404 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
405 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
406 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
410 int UtcDaliPanGestureGetMinimumTouchesRequired(void)
412 TestApplication application;
414 PanGestureDetector detector = PanGestureDetector::New();
415 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
419 int UtcDaliPanGestureGetMaximumTouchesRequired(void)
421 TestApplication application;
423 PanGestureDetector detector = PanGestureDetector::New();
424 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
428 int UtcDaliPanGestureSignalReceptionNegative(void)
430 TestApplication application;
432 Actor actor = Actor::New();
433 actor.SetSize(100.0f, 100.0f);
434 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
435 Stage::GetCurrent().Add(actor);
438 application.SendNotification();
439 application.Render();
442 GestureReceivedFunctor functor(data);
444 PanGestureDetector detector = PanGestureDetector::New();
445 detector.Attach(actor);
446 detector.DetectedSignal().Connect(&application, functor);
448 // Do a pan outside actor's area
449 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
450 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
451 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
453 // Continue pan into actor's area - we should still not receive the signal
455 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(112.0f, 112.0f), Vector2(20.0f, 20.0f), 10));
456 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
458 // Stop panning - we should still not receive the signal
460 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(12.0f, 12.0f), 10));
461 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
465 int UtcDaliPanGestureSignalReceptionDownMotionLeave(void)
467 TestApplication application;
469 Actor actor = Actor::New();
470 actor.SetSize(100.0f, 100.0f);
471 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
472 Stage::GetCurrent().Add(actor);
475 application.SendNotification();
476 application.Render();
479 GestureReceivedFunctor functor(data);
481 PanGestureDetector detector = PanGestureDetector::New();
482 detector.Attach(actor);
483 detector.DetectedSignal().Connect(&application, functor);
485 // Start pan within the actor's area
486 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
487 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
488 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
489 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
490 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
491 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
492 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
493 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
494 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
496 // Continue the pan within the actor's area - we should still receive the signal
498 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
499 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
500 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
501 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
502 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
503 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
504 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
505 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
507 // Pan Gesture leaves actor's area - we should still receive the signal
509 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(320.0f, 10.0f), 10));
510 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
511 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
512 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
513 DALI_TEST_EQUALS(Vector2(300.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
514 DALI_TEST_EQUALS(Vector2(30.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
515 DALI_TEST_EQUALS(300.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
516 DALI_TEST_EQUALS(30.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
518 // Gesture ends - we would receive a finished state
520 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(320.0f, 10.0f), Vector2(310.0f, 10.0f), 10));
521 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
522 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
523 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
524 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
525 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
526 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
527 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
531 int UtcDaliPanGestureSignalReceptionDownMotionUp(void)
533 TestApplication application;
535 Actor actor = Actor::New();
536 actor.SetSize(100.0f, 100.0f);
537 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
538 Stage::GetCurrent().Add(actor);
541 application.SendNotification();
542 application.Render();
545 GestureReceivedFunctor functor(data);
547 PanGestureDetector detector = PanGestureDetector::New();
548 detector.Attach(actor);
549 detector.DetectedSignal().Connect(&application, functor);
551 // Start pan within the actor's area
552 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
553 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
554 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
555 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
556 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
557 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
558 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
559 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
560 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
562 // Continue the pan within the actor's area - we should still receive the signal
564 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
565 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
566 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
567 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
568 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
569 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
570 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
571 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
573 // Gesture ends within actor's area - we would receive a finished state
575 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
576 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
577 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
578 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
579 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
580 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
581 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
582 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
586 int UtcDaliPanGestureSignalReceptionCancelled(void)
588 TestApplication application;
590 Actor actor = Actor::New();
591 actor.SetSize(100.0f, 100.0f);
592 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
593 Stage::GetCurrent().Add(actor);
596 application.SendNotification();
597 application.Render();
600 GestureReceivedFunctor functor(data);
602 PanGestureDetector detector = PanGestureDetector::New();
603 detector.Attach(actor);
604 detector.DetectedSignal().Connect(&application, functor);
606 // Start pan within the actor's area
607 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
608 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
609 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
610 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
612 // Continue the pan within the actor's area - we should still receive the signal
614 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
615 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
616 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
618 // The gesture is cancelled
620 application.ProcessEvent(GeneratePan(Gesture::Cancelled, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
621 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
622 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
626 int UtcDaliPanGestureSignalReceptionDetach(void)
628 TestApplication application;
630 Actor actor = Actor::New();
631 actor.SetSize(100.0f, 100.0f);
632 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
633 Stage::GetCurrent().Add(actor);
636 application.SendNotification();
637 application.Render();
640 GestureReceivedFunctor functor(data);
642 PanGestureDetector detector = PanGestureDetector::New();
643 detector.Attach(actor);
644 detector.DetectedSignal().Connect(&application, functor);
646 // Start pan within the actor's area
647 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
648 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
649 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
651 // Continue the pan within the actor's area - we should still receive the signal
653 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
654 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
656 // Gesture ends within actor's area
658 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
659 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
662 detector.DetachAll();
664 // Ensure we are no longer signalled
666 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
667 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
668 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
669 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
670 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
674 int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void)
676 TestApplication application;
678 Actor actor = Actor::New();
679 actor.SetSize(100.0f, 100.0f);
680 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
681 Stage::GetCurrent().Add(actor);
684 application.SendNotification();
685 application.Render();
688 GestureReceivedFunctor functor(data);
690 PanGestureDetector detector = PanGestureDetector::New();
691 detector.Attach(actor);
692 detector.DetectedSignal().Connect(&application, functor);
694 // Start pan within the actor's area
695 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
696 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
697 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
699 // Continue the pan within the actor's area - we should still receive the signal
701 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
702 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
704 // Detach actor during the pan, we should not receive the next event
705 detector.DetachAll();
707 // Gesture ends within actor's area
709 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
710 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
714 int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void)
716 TestApplication application;
719 GestureReceivedFunctor functor(data);
721 PanGestureDetector detector = PanGestureDetector::New();
722 detector.DetectedSignal().Connect(&application, functor);
724 // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor
726 Actor tempActor = Actor::New();
727 tempActor.SetSize(100.0f, 100.0f);
728 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
729 Stage::GetCurrent().Add(tempActor);
730 detector.Attach(tempActor);
732 // Actor lifetime is scoped
734 Actor actor = Actor::New();
735 actor.SetSize(100.0f, 100.0f);
736 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
737 Stage::GetCurrent().Add(actor);
740 application.SendNotification();
741 application.Render();
743 detector.Attach(actor);
745 // Start pan within the actor's area
746 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
747 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
748 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
750 // Continue the pan within the actor's area - we should still receive the signal
752 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
753 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
755 // Remove the actor from stage and reset the data
756 Stage::GetCurrent().Remove(actor);
759 application.SendNotification();
760 application.Render();
763 // Actor should now have been destroyed
765 // Gesture ends within the area where the actor used to be
767 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
768 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
772 int UtcDaliPanGestureSignalReceptionRotatedActor(void)
774 TestApplication application;
776 Actor actor = Actor::New();
777 actor.SetSize(100.0f, 100.0f);
778 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
779 Stage::GetCurrent().Add(actor);
782 application.SendNotification();
783 application.Render();
786 GestureReceivedFunctor functor(data);
788 PanGestureDetector detector = PanGestureDetector::New();
789 detector.Attach(actor);
790 detector.DetectedSignal().Connect(&application, functor);
792 // Do an entire pan, only check finished value
793 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
794 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
796 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
797 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
798 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
800 // Rotate actor again and render a couple of times
801 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
802 application.SendNotification();
803 application.Render();
805 // Do an entire pan, only check finished value
806 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
807 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
809 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
810 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
811 DALI_TEST_EQUALS(Vector2(-5.0f, -8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
813 // Rotate actor again and render a couple of times
814 actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS);
815 application.SendNotification();
816 application.Render();
818 // Do an entire pan, only check finished value
819 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
820 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
822 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
823 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
824 DALI_TEST_EQUALS(Vector2(-8.0f, 5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
828 int UtcDaliPanGestureSignalReceptionChildHit(void)
830 TestApplication application;
832 Actor parent = Actor::New();
833 parent.SetSize(100.0f, 100.0f);
834 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
835 Stage::GetCurrent().Add(parent);
837 // Set child to completely cover parent.
838 // Change rotation of child to be different from parent so that we can check if our local coordinate
839 // conversion of the parent actor is correct.
840 Actor child = Actor::New();
841 child.SetSize(100.0f, 100.0f);
842 child.SetAnchorPoint(AnchorPoint::CENTER);
843 child.SetParentOrigin(ParentOrigin::CENTER);
844 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
847 TouchEventFunctor touchFunctor;
848 child.TouchedSignal().Connect(&application, touchFunctor);
851 application.SendNotification();
852 application.Render();
855 GestureReceivedFunctor functor(data);
857 PanGestureDetector detector = PanGestureDetector::New();
858 detector.Attach(parent);
859 detector.DetectedSignal().Connect(&application, functor);
861 // Do an entire pan, only check finished value - hits child area but parent should still receive it
862 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
863 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
865 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
866 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
867 DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION);
868 DALI_TEST_EQUALS(Vector2(5.0f, 8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
870 // Attach child and generate same touch points to yield a different displacement
871 // (Also proves that you can detach and then re-attach another actor)
872 detector.Attach(child);
873 detector.Detach(parent);
875 // Do an entire pan, only check finished value
876 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
877 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
879 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
880 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
881 DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION);
882 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
886 int UtcDaliPanGestureSignalReceptionAttachDetachMany(void)
888 TestApplication application;
890 Actor first = Actor::New();
891 first.SetSize(100.0f, 100.0f);
892 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
893 Stage::GetCurrent().Add(first);
895 Actor second = Actor::New();
896 second.SetSize(100.0f, 100.0f);
898 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
899 Stage::GetCurrent().Add(second);
902 application.SendNotification();
903 application.Render();
906 GestureReceivedFunctor functor(data);
908 PanGestureDetector detector = PanGestureDetector::New();
909 detector.Attach(first);
910 detector.Attach(second);
911 detector.DetectedSignal().Connect(&application, functor);
913 // Start pan within second actor's area
914 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
915 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
916 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
917 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
919 // Pan moves into first actor's area - second actor should receive the pan
921 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(120.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
922 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
923 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
925 // Detach the second actor during the pan, we should not receive the next event
926 detector.Detach(second);
928 // Gesture ends within actor's area
930 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
931 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
935 int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void)
937 TestApplication application;
939 Actor actor = Actor::New();
940 actor.SetSize(100.0f, 100.0f);
941 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
942 Stage::GetCurrent().Add(actor);
945 application.SendNotification();
946 application.Render();
949 GestureReceivedFunctor functor(data);
951 PanGestureDetector detector = PanGestureDetector::New();
952 detector.Attach(actor);
953 detector.DetectedSignal().Connect(&application, functor);
955 // Start pan in actor's area
956 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
957 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
958 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
960 // Pan continues within actor's area
962 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
963 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
965 // Actor become invisible - actor should not receive the next pan
966 actor.SetVisible(false);
969 application.SendNotification();
970 application.Render();
972 // Gesture ends within actor's area
974 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
975 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
979 int UtcDaliPanGestureSignalReceptionMultipleGestureDetectors(void)
981 TestApplication application;
982 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
984 Actor first = Actor::New();
985 first.SetSize(100.0f, 100.0f);
986 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
987 Stage::GetCurrent().Add(first);
989 Actor second = Actor::New();
990 second.SetSize(100.0f, 100.0f);
991 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
995 application.SendNotification();
996 application.Render();
999 GestureReceivedFunctor functor(data);
1001 PanGestureDetector firstDetector = PanGestureDetector::New();
1002 firstDetector.Attach(first);
1003 firstDetector.DetectedSignal().Connect(&application, functor);
1005 // secondDetector is scoped
1007 // Reset gestureManager statistics
1008 gestureManager.Initialize();
1010 PanGestureDetector secondDetector = PanGestureDetector::New();
1011 secondDetector.SetMinimumTouchesRequired(2);
1012 secondDetector.SetMaximumTouchesRequired(2);
1013 secondDetector.Attach(second);
1014 secondDetector.DetectedSignal().Connect(&application, functor);
1016 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1017 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1018 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1020 // Start pan within second actor's area
1021 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1022 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1023 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1024 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1026 // Two touch pan changes to single touch - we should receive a finished state
1028 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
1029 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1030 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1031 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1033 // Pan continues as single touch gesture - we should not receive any gesture
1035 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1036 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1038 // Pan ends - still no signal
1040 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1041 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1043 // Single touch pan starts - first actor should be panned
1045 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1046 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1047 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1048 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1050 // Pan changes to double-touch - we should receive a finished state
1052 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10, 2));
1053 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1054 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1055 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1057 // Pan continues as double touch gesture - we should not receive any gesture
1059 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1060 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1062 // Pan ends - still no signal
1064 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1065 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1067 // Reset gesture manager statistics
1068 gestureManager.Initialize();
1071 // secondDetector has now been deleted. Gesture detection should have been updated only
1072 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1073 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1074 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1078 int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void)
1080 TestApplication application;
1082 Actor actor = Actor::New();
1083 actor.SetSize(100.0f, 100.0f);
1084 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1085 Stage::GetCurrent().Add(actor);
1087 Actor actor2 = Actor::New();
1088 actor2.SetSize(100.0f, 100.0f);
1089 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1090 Stage::GetCurrent().Add(actor2);
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Attach actor to one detector
1097 SignalData firstData;
1098 GestureReceivedFunctor firstFunctor(firstData);
1099 PanGestureDetector firstDetector = PanGestureDetector::New();
1100 firstDetector.Attach(actor);
1101 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
1103 // Attach actor to another detector
1104 SignalData secondData;
1105 GestureReceivedFunctor secondFunctor(secondData);
1106 PanGestureDetector secondDetector = PanGestureDetector::New();
1107 secondDetector.Attach(actor);
1108 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
1110 // Add second actor to second detector, when we remove the actor, this will make sure that this
1111 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
1112 // functor should still not be called (which is what we're also testing).
1113 secondDetector.Attach(actor2);
1115 // Pan in actor's area - both detector's functors should be called
1116 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1117 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1118 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1119 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1121 // Pan continues in actor's area - both detector's functors should be called
1124 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1125 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1126 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1128 // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called.
1129 firstDetector.Detach(actor);
1132 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1133 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1134 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1136 // New pan on actor, only secondDetector has actor attached
1139 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1140 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1141 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1142 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1144 // Detach actor from secondDetector
1145 secondDetector.Detach(actor);
1148 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1149 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1150 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
1154 int UtcDaliPanGestureSignalReceptionMultipleStarted(void)
1156 // Should handle two started events gracefully.
1158 TestApplication application;
1160 Actor actor = Actor::New();
1161 actor.SetSize(100.0f, 100.0f);
1162 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1163 Stage::GetCurrent().Add(actor);
1166 GestureReceivedFunctor functor(data);
1168 PanGestureDetector detector = PanGestureDetector::New();
1169 detector.Attach(actor);
1170 detector.DetectedSignal().Connect(&application, functor);
1172 // Render and notify
1173 application.SendNotification();
1174 application.Render();
1176 // Start pan in actor's area
1177 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1178 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1179 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1181 // Send another start in actor's area
1183 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1184 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1186 // Add a child actor to overlap actor and send another start in actor's area
1187 Actor child = Actor::New();
1188 child.SetSize(100.0f, 100.0f);
1189 child.SetAnchorPoint(AnchorPoint::CENTER);
1190 child.SetParentOrigin(ParentOrigin::CENTER);
1193 TouchEventFunctor touchFunctor;
1194 child.TouchedSignal().Connect(&application, touchFunctor);
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 // Send another possible and start in actor's area
1202 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1203 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1204 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1206 // Send another start in actor's area
1208 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1209 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1210 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1214 int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void)
1216 TestApplication application;
1218 Actor actor1 = Actor::New();
1219 actor1.SetSize(100.0f, 100.0f);
1220 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1221 Stage::GetCurrent().Add(actor1);
1223 GestureReceivedFunctor functor1(data1);
1224 PanGestureDetector detector1 = PanGestureDetector::New();
1225 detector1.Attach(actor1);
1226 detector1.DetectedSignal().Connect(&application, functor1);
1228 Actor actor2 = Actor::New();
1229 actor2.SetSize(100.0f, 100.0f);
1230 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1231 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
1232 Stage::GetCurrent().Add(actor2);
1234 GestureReceivedFunctor functor2(data2);
1235 PanGestureDetector detector2 = PanGestureDetector::New();
1236 detector2.Attach(actor2);
1237 detector2.DetectedSignal().Connect(&application, functor2);
1239 // Render and notify
1240 application.SendNotification();
1241 application.Render();
1243 // Start pan in actor1's area, only data1 should be set
1244 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1245 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1246 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
1247 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
1251 int UtcDaliPanGestureSignalReceptionDifferentPossible(void)
1253 TestApplication application;
1255 Actor actor = Actor::New();
1256 actor.SetSize(100.0f, 100.0f);
1257 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1258 Stage::GetCurrent().Add(actor);
1260 // Render and notify
1261 application.SendNotification();
1262 application.Render();
1264 // Attach actor to detector
1266 GestureReceivedFunctor functor( data );
1267 PanGestureDetector detector = PanGestureDetector::New();
1268 detector.Attach(actor);
1269 detector.DetectedSignal().Connect( &application, functor );
1271 // Gesture possible in actor's area.
1272 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1273 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1275 // Move actor somewhere else
1276 actor.SetPosition( 100.0f, 100.0f );
1278 // Render and notify
1279 application.SendNotification();
1280 application.Render();
1282 // Emit Started event, we should not receive the long press.
1283 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1284 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1285 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1287 // LongPress possible in empty area.
1288 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1289 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1291 // Move actor in to the long press position.
1292 actor.SetPosition( 0.0f, 0.0f );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Emit Started event, we should not receive the long press.
1299 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1300 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1301 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1303 // Normal long press in actor's area for completeness.
1304 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1305 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1306 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1307 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1311 int UtcDaliPanGestureEmitIncorrectState(void)
1313 TestApplication application;
1315 Actor actor = Actor::New();
1316 actor.SetSize(100.0f, 100.0f);
1317 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1318 Stage::GetCurrent().Add(actor);
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Attach actor to detector
1326 GestureReceivedFunctor functor( data );
1327 PanGestureDetector detector = PanGestureDetector::New();
1328 detector.Attach(actor);
1329 detector.DetectedSignal().Connect( &application, functor );
1331 // Try a Clear state
1334 application.ProcessEvent(GeneratePan(Gesture::Clear, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1335 tet_result(TET_FAIL);
1337 catch ( Dali::DaliException& e )
1339 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1344 int UtcDaliPanGestureActorUnstaged(void)
1346 TestApplication application;
1348 Actor actor = Actor::New();
1349 actor.SetSize(100.0f, 100.0f);
1350 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1351 Stage::GetCurrent().Add(actor);
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // State to remove actor in.
1358 Gesture::State stateToUnstage( Gesture::Started );
1360 // Attach actor to detector
1362 UnstageActorFunctor functor( data, stateToUnstage );
1363 PanGestureDetector detector = PanGestureDetector::New();
1364 detector.Attach(actor);
1365 detector.DetectedSignal().Connect( &application, functor );
1368 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1369 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1370 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1372 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1373 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Re-add actor to stage
1381 Stage::GetCurrent().Add(actor);
1383 // Render and notify
1384 application.SendNotification();
1385 application.Render();
1387 // Change state to Gesture::Continuing to remove
1388 stateToUnstage = Gesture::Continuing;
1391 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1392 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1393 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1395 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1396 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1398 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1399 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Re-add actor to stage
1407 Stage::GetCurrent().Add(actor);
1409 // Render and notify
1410 application.SendNotification();
1411 application.Render();
1413 // Change state to Gesture::Finished to remove
1414 stateToUnstage = Gesture::Finished;
1417 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1418 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1419 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1421 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1422 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1424 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1425 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1426 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1430 int UtcDaliPanGestureActorStagedAndDestroyed(void)
1432 TestApplication application;
1434 Actor actor = Actor::New();
1435 actor.SetSize(100.0f, 100.0f);
1436 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1437 Stage::GetCurrent().Add(actor);
1439 // Create and add a second actor so that GestureDetector destruction does not come into play.
1440 Actor dummyActor( Actor::New() );
1441 dummyActor.SetSize( 100.0f, 100.0f );
1442 dummyActor.SetPosition( 100.0f, 100.0f );
1443 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1444 Stage::GetCurrent().Add(dummyActor);
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // State to remove actor in.
1451 Gesture::State stateToUnstage( Gesture::Started );
1453 // Attach actor to detector
1455 UnstageActorFunctor functor( data, stateToUnstage );
1456 PanGestureDetector detector = PanGestureDetector::New();
1457 detector.Attach(actor);
1458 detector.Attach(dummyActor);
1459 detector.DetectedSignal().Connect( &application, functor );
1461 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1462 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1463 // position, we should still not be signalled.
1466 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1467 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1468 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1471 // Render and notify
1472 application.SendNotification();
1473 application.Render();
1475 // Re add to the stage, we should not be signalled
1476 Stage::GetCurrent().Add(actor);
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Continue signal emission
1483 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1484 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1486 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1487 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1490 // Here we delete an actor in started, we should not receive any subsequent signalling.
1493 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1494 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1495 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 // Delete actor as well
1505 // Render and notify
1506 application.SendNotification();
1507 application.Render();
1509 // Continue signal emission
1510 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1511 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1513 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1514 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1518 int UtcDaliPanGestureSystemOverlay(void)
1520 TestApplication application;
1521 Dali::Integration::Core& core = application.GetCore();
1522 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1523 systemOverlay.GetOverlayRenderTasks().CreateTask();
1525 Actor actor = Actor::New();
1526 actor.SetSize(100.0f, 100.0f);
1527 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1528 systemOverlay.Add(actor);
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1535 GestureReceivedFunctor functor(data);
1537 PanGestureDetector detector = PanGestureDetector::New();
1538 detector.Attach(actor);
1539 detector.DetectedSignal().Connect(&application, functor);
1541 Vector2 screenCoordsStart( 10.0f, 20.0f );
1542 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1544 // Start pan within the actor's area
1545 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1546 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1547 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1551 int UtcDaliPanGestureBehindTouchableSystemOverlay(void)
1553 TestApplication application;
1554 Dali::Integration::Core& core = application.GetCore();
1555 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1556 systemOverlay.GetOverlayRenderTasks().CreateTask();
1558 // SystemOverlay actor
1559 Actor systemOverlayActor = Actor::New();
1560 systemOverlayActor.SetSize(100.0f, 100.0f);
1561 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1562 systemOverlay.Add(systemOverlayActor);
1565 Actor stageActor = Actor::New();
1566 stageActor.SetSize(100.0f, 100.0f);
1567 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1568 Stage::GetCurrent().Add(stageActor);
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Set system-overlay actor to touchable
1575 TouchEventData touchData;
1576 TouchEventDataFunctor touchFunctor( touchData );
1577 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1579 // Set stage actor to receive the gesture
1581 GestureReceivedFunctor functor(data);
1583 PanGestureDetector detector = PanGestureDetector::New();
1584 detector.Attach(stageActor);
1585 detector.DetectedSignal().Connect(&application, functor);
1587 Vector2 screenCoordsStart( 10.0f, 20.0f );
1588 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1590 // Start pan within the two actors' area
1591 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1592 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1593 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1594 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1595 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1600 // Do touch in the same area
1601 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1602 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1603 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1608 int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void)
1610 TestApplication application;
1611 Dali::Integration::Core& core = application.GetCore();
1612 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1613 systemOverlay.GetOverlayRenderTasks().CreateTask();
1615 // SystemOverlay actor
1616 Actor systemOverlayActor = Actor::New();
1617 systemOverlayActor.SetSize(100.0f, 100.0f);
1618 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1619 systemOverlay.Add(systemOverlayActor);
1622 Actor stageActor = Actor::New();
1623 stageActor.SetSize(100.0f, 100.0f);
1624 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1625 Stage::GetCurrent().Add(stageActor);
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 // Set stage actor to touchable
1632 TouchEventData touchData;
1633 TouchEventDataFunctor touchFunctor( touchData );
1634 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1636 // Set system-overlay actor to have the gesture
1638 GestureReceivedFunctor functor(data);
1640 PanGestureDetector detector = PanGestureDetector::New();
1641 detector.Attach(systemOverlayActor);
1642 detector.DetectedSignal().Connect(&application, functor);
1644 Vector2 screenCoordsStart( 10.0f, 20.0f );
1645 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1647 // Start pan within the two actors' area
1648 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1649 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1650 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1651 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1652 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1657 // Do touch in the same area
1658 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1659 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1660 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1665 int UtcDaliPanGestureAngleHandling(void)
1667 TestApplication application;
1669 PanGestureDetector detector = PanGestureDetector::New();
1670 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1671 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1673 detector.AddAngle( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1674 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1675 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1677 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1679 tet_result( TET_PASS );
1683 if ( iter == endIter )
1685 tet_printf("%s, angle not added\n", TEST_LOCATION );
1686 tet_result( TET_FAIL );
1690 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Radian( Math::PI * 0.25 ) );
1691 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1693 // Remove something not in the container.
1694 detector.RemoveAngle( PanGestureDetector::DIRECTION_UP );
1695 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1697 detector.RemoveAngle( PanGestureDetector::DIRECTION_RIGHT );
1698 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1699 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1701 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1703 tet_printf("%s, angle not removed\n", TEST_LOCATION );
1704 tet_result( TET_FAIL );
1709 detector.ClearAngles();
1710 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1714 inline float RadiansToDegrees( float radian )
1716 return radian * 180.0f / Math::PI;
1719 int UtcDaliPanGestureAngleOutOfRange(void)
1721 TestApplication application;
1723 PanGestureDetector detector = PanGestureDetector::New();
1724 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1725 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1731 detector.AddAngle( Degree(180.0f) );
1732 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION );
1733 detector.ClearAngles();
1735 detector.AddAngle( Degree(190.0f) );
1736 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION );
1737 detector.ClearAngles();
1739 detector.AddAngle( Degree(-190.0f) );
1740 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION );
1741 detector.ClearAngles();
1743 detector.AddAngle( Degree(350.0f) );
1744 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1745 detector.ClearAngles();
1747 detector.AddAngle( Degree(-350.0f) );
1748 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1749 detector.ClearAngles();
1751 detector.AddAngle( Degree(370.0f) );
1752 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1753 detector.ClearAngles();
1755 detector.AddAngle( Degree(-370.0f) );
1756 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1757 detector.ClearAngles();
1763 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 0.0f ) );
1764 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION );
1765 detector.ClearAngles();
1767 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -10.0f ) );
1768 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1769 detector.ClearAngles();
1771 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -181.0f ) );
1772 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1773 detector.ClearAngles();
1775 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 181.0f ) );
1776 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1777 detector.ClearAngles();
1781 int UtcDaliPanGestureAngleProcessing(void)
1783 TestApplication application;
1785 Actor parent = Actor::New();
1786 parent.SetSize(100.0f, 100.0f);
1787 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1788 Stage::GetCurrent().Add(parent);
1790 Actor child = Actor::New();
1791 child.SetSize(100.0f, 100.0f);
1792 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1795 // Render and notify
1796 application.SendNotification();
1797 application.Render();
1799 // Parent detector only requires up pans
1800 PanGestureDetector parentDetector = PanGestureDetector::New();
1801 parentDetector.Attach( parent );
1802 parentDetector.AddAngle( PanGestureDetector::DIRECTION_UP, Degree( 30.0f ) );
1803 SignalData parentData;
1804 GestureReceivedFunctor parentFunctor(parentData);
1805 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1807 // Child detector only requires right pans
1808 PanGestureDetector childDetector = PanGestureDetector::New();
1809 childDetector.Attach( child );
1810 childDetector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 30.0f ) );
1811 SignalData childData;
1812 GestureReceivedFunctor childFunctor(childData);
1813 childDetector.DetectedSignal().Connect(&application, childFunctor);
1815 // Generate an Up pan gesture, only parent should receive it.
1816 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1817 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1818 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1819 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1820 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1824 // Generate a Right pan gesture, only child should receive it.
1825 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1826 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1827 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1828 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1829 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1833 // Generate a Down pan gesture, no one should receive it.
1834 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1835 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1836 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1837 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1838 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1842 // Generate a Left pan gesture, no one should receive it.
1843 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1844 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1845 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1846 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1847 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1853 int UtcDaliPanGestureDirectionHandling(void)
1855 TestApplication application;
1857 PanGestureDetector detector = PanGestureDetector::New();
1858 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1859 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1861 detector.AddDirection( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1862 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1863 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1865 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1867 tet_result( TET_PASS );
1871 if ( iter == endIter )
1873 tet_printf("%s, angle not added\n", TEST_LOCATION );
1874 tet_result( TET_FAIL );
1878 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1880 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1882 tet_result( TET_PASS );
1886 if ( iter == endIter )
1888 tet_printf("%s, angle not added\n", TEST_LOCATION );
1889 tet_result( TET_FAIL );
1893 // Remove something not in the container.
1894 detector.RemoveDirection( PanGestureDetector::DIRECTION_UP );
1895 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1897 detector.RemoveDirection( PanGestureDetector::DIRECTION_RIGHT );
1898 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1902 int UtcDaliPanGestureDirectionProcessing(void)
1904 TestApplication application;
1906 Actor parent = Actor::New();
1907 parent.SetSize(100.0f, 100.0f);
1908 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1909 Stage::GetCurrent().Add(parent);
1911 Actor child = Actor::New();
1912 child.SetSize(100.0f, 100.0f);
1913 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 // Parent detector only requires vertical panning
1921 PanGestureDetector parentDetector = PanGestureDetector::New();
1922 parentDetector.Attach( parent );
1923 parentDetector.AddDirection( PanGestureDetector::DIRECTION_VERTICAL, Degree( 30.0f ) );
1924 SignalData parentData;
1925 GestureReceivedFunctor parentFunctor(parentData);
1926 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1928 // Child detector only requires horizontal panning
1929 PanGestureDetector childDetector = PanGestureDetector::New();
1930 childDetector.Attach( child );
1931 childDetector.AddDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 30.0f ) );
1932 SignalData childData;
1933 GestureReceivedFunctor childFunctor(childData);
1934 childDetector.DetectedSignal().Connect(&application, childFunctor);
1936 // Generate an Up pan gesture, only parent should receive it.
1937 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1938 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1939 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1940 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1941 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1945 // Generate a Right pan gesture, only child should receive it.
1946 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1947 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1948 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1949 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1950 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1954 // Generate a Down pan gesture, only parent should receive it.
1955 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1956 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1957 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1958 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1959 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1963 // Generate a Left pan gesture, only child should receive it.
1964 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1965 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1966 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1967 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1968 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1972 // Generate a pan at -45 degrees, no one should receive it.
1973 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1974 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1975 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1976 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1977 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1981 // Generate a pan at 45 degrees, no one should receive it.
1982 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1983 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 30.0f), 10 ) );
1984 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1985 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1986 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1990 // Generate a pan at 135 degrees, no one should receive it.
1991 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1992 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1993 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1994 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1995 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1999 // Generate a pan at -135 degrees, no one should receive it.
2000 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
2001 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 10.0f), 10 ) );
2002 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
2003 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
2004 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
2010 int UtcDaliPanGestureSetProperties(void)
2012 TestApplication application;
2013 TestRenderController& renderController( application.GetRenderController() );
2014 Integration::SetPanGesturePredictionMode(0);
2016 Actor actor = Actor::New();
2017 actor.SetSize(100.0f, 100.0f);
2018 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2019 Stage::GetCurrent().Add(actor);
2021 // Add a pan detector
2022 PanGestureDetector detector = PanGestureDetector::New();
2023 detector.Attach( actor );
2025 GestureReceivedFunctor functor( data );
2026 detector.DetectedSignal().Connect( &application, functor );
2028 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2030 ConstraintData constraintData;
2031 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2032 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2033 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2034 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2035 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2036 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2037 PanConstraint( constraintData ) ) );
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 renderController.Initialize();
2044 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), false, TEST_LOCATION );
2046 Vector2 screenPosition( 20.0f, 20.0f );
2047 Vector2 screenDisplacement( 1.0f, 1.0f );
2048 Vector2 screenVelocity( 1.3f, 4.0f );
2049 Vector2 localPosition( 21.0f, 21.0f );
2050 Vector2 localDisplacement( 0.5f, 0.5f );
2051 Vector2 localVelocity( 1.5f, 2.5f );
2053 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity ) );
2054 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2061 DALI_TEST_EQUALS( constraintData.screenPosition, screenPosition, TEST_LOCATION );
2062 DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION );
2063 DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION );
2064 DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION );
2065 DALI_TEST_EQUALS( constraintData.screenVelocity, screenVelocity, TEST_LOCATION );
2066 DALI_TEST_EQUALS( constraintData.localVelocity, localVelocity, TEST_LOCATION );
2067 constraintData.Reset();
2071 int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
2073 TestApplication application;
2074 Integration::SetPanGesturePredictionMode(0);
2076 Actor actor = Actor::New();
2077 actor.SetSize(100.0f, 100.0f);
2078 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2079 Stage::GetCurrent().Add(actor);
2081 // Add a pan detector
2082 PanGestureDetector detector = PanGestureDetector::New();
2083 detector.Attach( actor );
2085 GestureReceivedFunctor functor( data );
2086 detector.DetectedSignal().Connect( &application, functor );
2088 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2090 ConstraintData constraintData;
2091 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2092 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2093 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2094 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2095 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2096 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2097 PanConstraint( constraintData ) ) );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 Vector2 previousPosition( 20.0f, 20.0f );
2104 Vector2 currentPosition( 20.0f, 10.0f );
2105 application.ProcessEvent( GeneratePan( Gesture::Possible, previousPosition, previousPosition, 10 ) );
2106 application.ProcessEvent( GeneratePan( Gesture::Started, previousPosition, currentPosition, 10 ) );
2107 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2109 Vector2 screenPosition( 100.0f, 20.0f );
2110 Vector2 localPosition( 110.0f, 110.0f );
2112 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition ) );
2114 // Render and notify
2115 application.SendNotification();
2116 application.Render();
2118 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2119 DALI_TEST_EQUALS( constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION );
2120 DALI_TEST_EQUALS( constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION );
2121 constraintData.Reset();
2125 int UtcDaliPanGesturePropertyIndices(void)
2127 TestApplication application;
2128 PanGestureDetector detector = PanGestureDetector::New();
2130 Property::IndexContainer indices;
2131 detector.GetPropertyIndices( indices );
2132 DALI_TEST_CHECK( ! indices.empty() );
2133 DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION );
2137 int UtcDaliPanGestureLayerConsumesTouch(void)
2139 TestApplication application;
2141 Actor actor = Actor::New();
2142 actor.SetSize(100.0f, 100.0f);
2143 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2144 Stage::GetCurrent().Add(actor);
2146 // Add a pan detector
2147 PanGestureDetector detector = PanGestureDetector::New();
2148 detector.Attach( actor );
2150 GestureReceivedFunctor functor( data );
2151 detector.DetectedSignal().Connect( &application, functor );
2153 // Add a layer to overlap the actor
2154 Layer layer = Layer::New();
2155 layer.SetSize(100.0f, 100.0f);
2156 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2157 Stage::GetCurrent().Add( layer );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Emit signals, should receive
2165 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2166 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2167 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2168 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2171 // Set layer to consume all touch
2172 layer.SetTouchConsumed( true );
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 // Emit the same signals again, should not receive
2179 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2180 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2181 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2182 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);