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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/pan-gesture-event.h>
25 #include <dali/integration-api/system-overlay.h>
26 #include <dali/integration-api/profiling.h>
27 #include <dali/integration-api/input-options.h>
28 #include <dali-test-suite-utils.h>
29 #include <test-touch-utils.h>
33 void utc_dali_pan_gesture_detector_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_pan_gesture_detector_cleanup(void)
40 test_return_value = TET_PASS;
43 ///////////////////////////////////////////////////////////////////////////////
46 typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType;
49 // Stores data that is populated in the callback and will be read by the test cases
53 : functorCalled(false),
54 voidFunctorCalled(false),
55 receivedGesture(Gesture::Clear)
60 functorCalled = false;
61 voidFunctorCalled = false;
63 receivedGesture.state = Gesture::Clear;
64 receivedGesture.velocity = Vector2(0.0f, 0.0f);
65 receivedGesture.displacement = Vector2(0.0f, 0.0f);
66 receivedGesture.position = Vector2(0.0f, 0.0f);
67 receivedGesture.screenPosition = Vector2(0.0f, 0.0f);
68 receivedGesture.numberOfTouches = 0;
74 bool voidFunctorCalled;
75 PanGesture receivedGesture;
79 // Functor that sets the data when called
80 struct GestureReceivedFunctor
82 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
84 void operator()(Actor actor, PanGesture pan)
86 signalData.functorCalled = true;
87 signalData.receivedGesture = pan;
88 signalData.pannedActor = actor;
93 signalData.voidFunctorCalled = true;
96 SignalData& signalData;
99 // Functor that removes the gestured actor from stage
100 struct UnstageActorFunctor : public GestureReceivedFunctor
102 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
103 : GestureReceivedFunctor( data ),
104 stateToUnstage( stateToUnstage )
108 void operator()( Actor actor, PanGesture pan )
110 GestureReceivedFunctor::operator()( actor, pan );
112 if ( pan.state == stateToUnstage )
114 Stage::GetCurrent().Remove( actor );
118 Gesture::State& stateToUnstage;
121 // Functor for receiving a touch event
122 struct TouchEventFunctor
124 bool operator()(Actor actor, const TouchEvent& touch)
130 // Data for constraints
131 struct ConstraintData
138 Vector2 screenPosition;
139 Vector2 screenDisplacement;
140 Vector2 screenVelocity;
141 Vector2 localPosition;
142 Vector2 localDisplacement;
143 Vector2 localVelocity;
148 screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
153 // Constraint used with panning properties
156 PanConstraint( ConstraintData& data ) : constraintData(data) { }
158 Vector3 operator()(const Vector3& current,
159 const PropertyInput& screenPositionProperty,
160 const PropertyInput& screenDisplacementProperty,
161 const PropertyInput& screenVelocityProperty,
162 const PropertyInput& localPositionProperty,
163 const PropertyInput& localDisplacementProperty,
164 const PropertyInput& localVelocityProperty)
166 constraintData.screenPosition = screenPositionProperty.GetVector2();
167 constraintData.screenDisplacement = screenDisplacementProperty.GetVector2();
168 constraintData.screenVelocity = screenVelocityProperty.GetVector2();
169 constraintData.localPosition = localPositionProperty.GetVector2();
170 constraintData.localDisplacement = localDisplacementProperty.GetVector2();
171 constraintData.localVelocity = localVelocityProperty.GetVector2();
172 constraintData.called = true;
173 return Vector3::ZERO;
176 ConstraintData& constraintData;
179 // Generate a PanGestureEvent to send to Core
180 Integration::PanGestureEvent GeneratePan(
181 Gesture::State state,
182 Vector2 previousPosition,
183 Vector2 currentPosition,
184 unsigned long timeDelta,
185 unsigned int numberOfTouches = 1,
186 unsigned int time = 1u)
188 Integration::PanGestureEvent pan(state);
190 pan.previousPosition = previousPosition;
191 pan.currentPosition = currentPosition;
192 pan.timeDelta = timeDelta;
193 pan.numberOfTouches = numberOfTouches;
199 // Generate a PanGesture
200 PanGesture GeneratePan( unsigned int time,
201 Gesture::State state,
202 Vector2 screenPosition,
203 Vector2 localPosition,
204 Vector2 screenDisplacement = Vector2::ONE,
205 Vector2 localDisplacement = Vector2::ONE,
206 Vector2 screenVelocity = Vector2::ONE,
207 Vector2 localVelocity = Vector2::ONE,
208 unsigned int numberOfTouches = 1 )
210 PanGesture pan( state );
214 pan.screenPosition = screenPosition;
215 pan.position = localPosition;
217 pan.screenDisplacement = screenDisplacement;
218 pan.displacement = localDisplacement;
220 pan.screenVelocity = screenVelocity;
221 pan.velocity = localVelocity;
223 pan.numberOfTouches = numberOfTouches;
230 ///////////////////////////////////////////////////////////////////////////////
232 // Positive test case for a method
233 int UtcDaliPanGestureDetectorConstructor(void)
235 TestApplication application;
237 PanGestureDetector detector;
238 DALI_TEST_CHECK(!detector);
243 // Negative test case for a method
244 int UtcDaliPanGestureDetectorNew(void)
246 TestApplication application;
248 PanGestureDetector detector = PanGestureDetector::New();
250 DALI_TEST_CHECK(detector);
252 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
253 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
255 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
256 Actor actor = Actor::New();
257 actor.SetSize(100.0f, 100.0f);
258 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
259 detector.Attach(actor);
261 Stage::GetCurrent().Add(actor);
264 application.SendNotification();
265 application.Render();
267 Integration::TouchEvent touchEvent(1);
268 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
269 touchEvent.AddPoint(point);
270 application.ProcessEvent(touchEvent);
274 int UtcDaliPanGestureDetectorDownCast(void)
276 TestApplication application;
277 tet_infoline("Testing Dali::GestureDetector::DownCast()");
279 PanGestureDetector detector = PanGestureDetector::New();
281 BaseHandle object(detector);
283 PanGestureDetector detector2 = PanGestureDetector::DownCast(object);
284 DALI_TEST_CHECK(detector2);
286 PanGestureDetector detector3 = DownCast< PanGestureDetector >(object);
287 DALI_TEST_CHECK(detector3);
289 BaseHandle unInitializedObject;
290 PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject);
291 DALI_TEST_CHECK(!detector4);
293 PanGestureDetector detector5 = DownCast< PanGestureDetector >(unInitializedObject);
294 DALI_TEST_CHECK(!detector5);
296 GestureDetector detector6 = PanGestureDetector::New();
297 PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6);
298 DALI_TEST_CHECK(detector7);
302 int UtcDaliPanGestureSetMinimumTouchesRequired(void)
304 TestApplication application;
306 PanGestureDetector detector = PanGestureDetector::New();
308 unsigned int min = 2;
310 DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
312 detector.SetMinimumTouchesRequired(min);
314 DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
316 // Attach an actor and change the minimum touches
318 Actor actor = Actor::New();
319 actor.SetSize(100.0f, 100.0f);
320 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
321 Stage::GetCurrent().Add(actor);
324 application.SendNotification();
325 application.Render();
328 GestureReceivedFunctor functor(data);
330 detector.Attach(actor);
331 detector.DetectedSignal().Connect(&application, functor);
333 TestGestureManager& gestureManager = application.GetGestureManager();
334 gestureManager.Initialize();
336 detector.SetMinimumTouchesRequired(3);
338 // Gesture detection should have been updated only
339 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
340 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
341 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
344 gestureManager.Initialize();
346 // Create a second gesture detector that requires even less minimum touches
347 PanGestureDetector secondDetector = PanGestureDetector::New();
348 secondDetector.Attach(actor);
350 // Gesture detection should have been updated only
351 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
352 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
353 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
357 int UtcDaliPanGestureSetMaximumTouchesRequired(void)
359 TestApplication application;
361 PanGestureDetector detector = PanGestureDetector::New();
363 unsigned int max = 3;
365 DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
367 detector.SetMaximumTouchesRequired(max);
369 DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
371 // Attach an actor and change the maximum touches
373 Actor actor = Actor::New();
374 actor.SetSize(100.0f, 100.0f);
375 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
376 Stage::GetCurrent().Add(actor);
379 application.SendNotification();
380 application.Render();
383 GestureReceivedFunctor functor(data);
385 detector.Attach(actor);
386 detector.DetectedSignal().Connect(&application, functor);
388 TestGestureManager& gestureManager = application.GetGestureManager();
389 gestureManager.Initialize();
391 detector.SetMaximumTouchesRequired(4);
393 // Gesture detection should have been updated only
394 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
395 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
396 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
399 gestureManager.Initialize();
401 // Create a second gesture detector that requires even less maximum touches
402 PanGestureDetector secondDetector = PanGestureDetector::New();
403 secondDetector.Attach(actor);
405 // Gesture detection should NOT have been updated
406 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
407 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
408 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
412 int UtcDaliPanGestureGetMinimumTouchesRequired(void)
414 TestApplication application;
416 PanGestureDetector detector = PanGestureDetector::New();
417 DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
421 int UtcDaliPanGestureGetMaximumTouchesRequired(void)
423 TestApplication application;
425 PanGestureDetector detector = PanGestureDetector::New();
426 DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
430 int UtcDaliPanGestureSignalReceptionNegative(void)
432 TestApplication application;
434 Actor actor = Actor::New();
435 actor.SetSize(100.0f, 100.0f);
436 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
437 Stage::GetCurrent().Add(actor);
440 application.SendNotification();
441 application.Render();
444 GestureReceivedFunctor functor(data);
446 PanGestureDetector detector = PanGestureDetector::New();
447 detector.Attach(actor);
448 detector.DetectedSignal().Connect(&application, functor);
450 // Do a pan outside actor's area
451 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
452 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10));
453 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
455 // Continue pan into actor's area - we should still not receive the signal
457 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(112.0f, 112.0f), Vector2(20.0f, 20.0f), 10));
458 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
460 // Stop panning - we should still not receive the signal
462 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(12.0f, 12.0f), 10));
463 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
467 int UtcDaliPanGestureSignalReceptionDownMotionLeave(void)
469 TestApplication application;
471 Actor actor = Actor::New();
472 actor.SetSize(100.0f, 100.0f);
473 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
474 Stage::GetCurrent().Add(actor);
477 application.SendNotification();
478 application.Render();
481 GestureReceivedFunctor functor(data);
483 PanGestureDetector detector = PanGestureDetector::New();
484 detector.Attach(actor);
485 detector.DetectedSignal().Connect(&application, functor);
487 // Start pan within the actor's area
488 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
489 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
490 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
491 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
492 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
493 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
494 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
495 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
496 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
498 // Continue the pan within the actor's area - we should still receive the signal
500 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
501 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
502 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
503 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
504 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
505 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
506 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
507 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
509 // Pan Gesture leaves actor's area - we should still receive the signal
511 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(320.0f, 10.0f), 10));
512 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
513 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
514 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
515 DALI_TEST_EQUALS(Vector2(300.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
516 DALI_TEST_EQUALS(Vector2(30.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
517 DALI_TEST_EQUALS(300.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
518 DALI_TEST_EQUALS(30.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
520 // Gesture ends - we would receive a finished state
522 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(320.0f, 10.0f), Vector2(310.0f, 10.0f), 10));
523 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
524 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
525 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
526 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
527 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
528 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
529 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
533 int UtcDaliPanGestureSignalReceptionDownMotionUp(void)
535 TestApplication application;
537 Actor actor = Actor::New();
538 actor.SetSize(100.0f, 100.0f);
539 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
540 Stage::GetCurrent().Add(actor);
543 application.SendNotification();
544 application.Render();
547 GestureReceivedFunctor functor(data);
549 PanGestureDetector detector = PanGestureDetector::New();
550 detector.Attach(actor);
551 detector.DetectedSignal().Connect(&application, functor);
553 // Start pan within the actor's area
554 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
555 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
556 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
557 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
558 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
559 DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
560 DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
561 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
562 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
564 // Continue the pan within the actor's area - we should still receive the signal
566 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
567 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
568 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
569 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
570 DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
571 DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
572 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
573 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
575 // Gesture ends within actor's area - we would receive a finished state
577 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
578 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
579 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
580 DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
581 DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION);
582 DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION);
583 DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
584 DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
588 int UtcDaliPanGestureSignalReceptionCancelled(void)
590 TestApplication application;
592 Actor actor = Actor::New();
593 actor.SetSize(100.0f, 100.0f);
594 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
595 Stage::GetCurrent().Add(actor);
598 application.SendNotification();
599 application.Render();
602 GestureReceivedFunctor functor(data);
604 PanGestureDetector detector = PanGestureDetector::New();
605 detector.Attach(actor);
606 detector.DetectedSignal().Connect(&application, functor);
608 // Start pan within the actor's area
609 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
610 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
611 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
612 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
614 // Continue the pan within the actor's area - we should still receive the signal
616 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
617 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
618 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
620 // The gesture is cancelled
622 application.ProcessEvent(GeneratePan(Gesture::Cancelled, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
623 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
624 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
628 int UtcDaliPanGestureSignalReceptionDetach(void)
630 TestApplication application;
632 Actor actor = Actor::New();
633 actor.SetSize(100.0f, 100.0f);
634 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
635 Stage::GetCurrent().Add(actor);
638 application.SendNotification();
639 application.Render();
642 GestureReceivedFunctor functor(data);
644 PanGestureDetector detector = PanGestureDetector::New();
645 detector.Attach(actor);
646 detector.DetectedSignal().Connect(&application, functor);
648 // Start pan within the actor's area
649 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
650 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
651 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
653 // Continue the pan within the actor's area - we should still receive the signal
655 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
656 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
658 // Gesture ends within actor's area
660 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
661 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
664 detector.DetachAll();
666 // Ensure we are no longer signalled
668 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
669 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
670 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
671 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
672 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
676 int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void)
678 TestApplication application;
680 Actor actor = Actor::New();
681 actor.SetSize(100.0f, 100.0f);
682 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
683 Stage::GetCurrent().Add(actor);
686 application.SendNotification();
687 application.Render();
690 GestureReceivedFunctor functor(data);
692 PanGestureDetector detector = PanGestureDetector::New();
693 detector.Attach(actor);
694 detector.DetectedSignal().Connect(&application, functor);
696 // Start pan within the actor's area
697 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
698 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
699 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
701 // Continue the pan within the actor's area - we should still receive the signal
703 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
704 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
706 // Detach actor during the pan, we should not receive the next event
707 detector.DetachAll();
709 // Gesture ends within actor's area
711 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
712 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
716 int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void)
718 TestApplication application;
721 GestureReceivedFunctor functor(data);
723 PanGestureDetector detector = PanGestureDetector::New();
724 detector.DetectedSignal().Connect(&application, functor);
726 // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor
728 Actor tempActor = Actor::New();
729 tempActor.SetSize(100.0f, 100.0f);
730 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
731 Stage::GetCurrent().Add(tempActor);
732 detector.Attach(tempActor);
734 // Actor lifetime is scoped
736 Actor actor = Actor::New();
737 actor.SetSize(100.0f, 100.0f);
738 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
739 Stage::GetCurrent().Add(actor);
742 application.SendNotification();
743 application.Render();
745 detector.Attach(actor);
747 // Start pan within the actor's area
748 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
749 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
750 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
752 // Continue the pan within the actor's area - we should still receive the signal
754 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
755 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
757 // Remove the actor from stage and reset the data
758 Stage::GetCurrent().Remove(actor);
761 application.SendNotification();
762 application.Render();
765 // Actor should now have been destroyed
767 // Gesture ends within the area where the actor used to be
769 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
770 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
774 int UtcDaliPanGestureSignalReceptionRotatedActor(void)
776 TestApplication application;
778 Actor actor = Actor::New();
779 actor.SetSize(100.0f, 100.0f);
780 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
781 Stage::GetCurrent().Add(actor);
784 application.SendNotification();
785 application.Render();
788 GestureReceivedFunctor functor(data);
790 PanGestureDetector detector = PanGestureDetector::New();
791 detector.Attach(actor);
792 detector.DetectedSignal().Connect(&application, functor);
794 // Do an entire pan, only check finished value
795 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
796 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
798 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
799 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
800 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
802 // Rotate actor again and render a couple of times
803 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
804 application.SendNotification();
805 application.Render();
807 // Do an entire pan, only check finished value
808 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
809 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
811 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
812 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
813 DALI_TEST_EQUALS(Vector2(-5.0f, -8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
815 // Rotate actor again and render a couple of times
816 actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS);
817 application.SendNotification();
818 application.Render();
820 // Do an entire pan, only check finished value
821 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
822 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
824 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
825 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
826 DALI_TEST_EQUALS(Vector2(-8.0f, 5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
830 int UtcDaliPanGestureSignalReceptionChildHit(void)
832 TestApplication application;
834 Actor parent = Actor::New();
835 parent.SetSize(100.0f, 100.0f);
836 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
837 Stage::GetCurrent().Add(parent);
839 // Set child to completely cover parent.
840 // Change rotation of child to be different from parent so that we can check if our local coordinate
841 // conversion of the parent actor is correct.
842 Actor child = Actor::New();
843 child.SetSize(100.0f, 100.0f);
844 child.SetAnchorPoint(AnchorPoint::CENTER);
845 child.SetParentOrigin(ParentOrigin::CENTER);
846 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
849 TouchEventFunctor touchFunctor;
850 child.TouchedSignal().Connect(&application, touchFunctor);
853 application.SendNotification();
854 application.Render();
857 GestureReceivedFunctor functor(data);
859 PanGestureDetector detector = PanGestureDetector::New();
860 detector.Attach(parent);
861 detector.DetectedSignal().Connect(&application, functor);
863 // Do an entire pan, only check finished value - hits child area but parent should still receive it
864 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
865 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
867 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
868 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
869 DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION);
870 DALI_TEST_EQUALS(Vector2(5.0f, 8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
872 // Attach child and generate same touch points to yield a different displacement
873 // (Also proves that you can detach and then re-attach another actor)
874 detector.Attach(child);
875 detector.Detach(parent);
877 // Do an entire pan, only check finished value
878 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
879 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10));
881 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10));
882 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
883 DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION);
884 DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative
888 int UtcDaliPanGestureSignalReceptionAttachDetachMany(void)
890 TestApplication application;
892 Actor first = Actor::New();
893 first.SetSize(100.0f, 100.0f);
894 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
895 Stage::GetCurrent().Add(first);
897 Actor second = Actor::New();
898 second.SetSize(100.0f, 100.0f);
900 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
901 Stage::GetCurrent().Add(second);
904 application.SendNotification();
905 application.Render();
908 GestureReceivedFunctor functor(data);
910 PanGestureDetector detector = PanGestureDetector::New();
911 detector.Attach(first);
912 detector.Attach(second);
913 detector.DetectedSignal().Connect(&application, functor);
915 // Start pan within second actor's area
916 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
917 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10));
918 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
919 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
921 // Pan moves into first actor's area - second actor should receive the pan
923 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(120.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
924 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
925 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
927 // Detach the second actor during the pan, we should not receive the next event
928 detector.Detach(second);
930 // Gesture ends within actor's area
932 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
933 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
937 int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void)
939 TestApplication application;
941 Actor actor = Actor::New();
942 actor.SetSize(100.0f, 100.0f);
943 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
944 Stage::GetCurrent().Add(actor);
947 application.SendNotification();
948 application.Render();
951 GestureReceivedFunctor functor(data);
953 PanGestureDetector detector = PanGestureDetector::New();
954 detector.Attach(actor);
955 detector.DetectedSignal().Connect(&application, functor);
957 // Start pan in actor's area
958 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
959 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
960 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
962 // Pan continues within actor's area
964 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
965 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
967 // Actor become invisible - actor should not receive the next pan
968 actor.SetVisible(false);
971 application.SendNotification();
972 application.Render();
974 // Gesture ends within actor's area
976 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10));
977 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
981 int UtcDaliPanGestureSignalReceptionMultipleGestureDetectors(void)
983 TestApplication application;
984 Dali::TestGestureManager& gestureManager = application.GetGestureManager();
986 Actor first = Actor::New();
987 first.SetSize(100.0f, 100.0f);
988 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
989 Stage::GetCurrent().Add(first);
991 Actor second = Actor::New();
992 second.SetSize(100.0f, 100.0f);
993 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
997 application.SendNotification();
998 application.Render();
1001 GestureReceivedFunctor functor(data);
1003 PanGestureDetector firstDetector = PanGestureDetector::New();
1004 firstDetector.Attach(first);
1005 firstDetector.DetectedSignal().Connect(&application, functor);
1007 // secondDetector is scoped
1009 // Reset gestureManager statistics
1010 gestureManager.Initialize();
1012 PanGestureDetector secondDetector = PanGestureDetector::New();
1013 secondDetector.SetMinimumTouchesRequired(2);
1014 secondDetector.SetMaximumTouchesRequired(2);
1015 secondDetector.Attach(second);
1016 secondDetector.DetectedSignal().Connect(&application, functor);
1018 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1019 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1020 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1022 // Start pan within second actor's area
1023 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1024 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2));
1025 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1026 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1028 // Two touch pan changes to single touch - we should receive a finished state
1030 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10));
1031 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1032 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1033 DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1035 // Pan continues as single touch gesture - we should not receive any gesture
1037 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1038 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1040 // Pan ends - still no signal
1042 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1043 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1045 // Single touch pan starts - first actor should be panned
1047 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1048 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1049 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1050 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1052 // Pan changes to double-touch - we should receive a finished state
1054 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10, 2));
1055 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1056 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
1057 DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION);
1059 // Pan continues as double touch gesture - we should not receive any gesture
1061 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10));
1062 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1064 // Pan ends - still no signal
1066 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10));
1067 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1069 // Reset gesture manager statistics
1070 gestureManager.Initialize();
1073 // secondDetector has now been deleted. Gesture detection should have been updated only
1074 DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION);
1075 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION);
1076 DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
1080 int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void)
1082 TestApplication application;
1084 Actor actor = Actor::New();
1085 actor.SetSize(100.0f, 100.0f);
1086 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1087 Stage::GetCurrent().Add(actor);
1089 Actor actor2 = Actor::New();
1090 actor2.SetSize(100.0f, 100.0f);
1091 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1092 Stage::GetCurrent().Add(actor2);
1094 // Render and notify
1095 application.SendNotification();
1096 application.Render();
1098 // Attach actor to one detector
1099 SignalData firstData;
1100 GestureReceivedFunctor firstFunctor(firstData);
1101 PanGestureDetector firstDetector = PanGestureDetector::New();
1102 firstDetector.Attach(actor);
1103 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
1105 // Attach actor to another detector
1106 SignalData secondData;
1107 GestureReceivedFunctor secondFunctor(secondData);
1108 PanGestureDetector secondDetector = PanGestureDetector::New();
1109 secondDetector.Attach(actor);
1110 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
1112 // Add second actor to second detector, when we remove the actor, this will make sure that this
1113 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
1114 // functor should still not be called (which is what we're also testing).
1115 secondDetector.Attach(actor2);
1117 // Pan in actor's area - both detector's functors should be called
1118 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1119 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1120 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1121 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1123 // Pan continues in actor's area - both detector's functors should be called
1126 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1127 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1128 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1130 // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called.
1131 firstDetector.Detach(actor);
1134 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1135 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1136 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1138 // New pan on actor, only secondDetector has actor attached
1141 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1142 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1143 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1144 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1146 // Detach actor from secondDetector
1147 secondDetector.Detach(actor);
1150 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10));
1151 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1152 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
1156 int UtcDaliPanGestureSignalReceptionMultipleStarted(void)
1158 // Should handle two started events gracefully.
1160 TestApplication application;
1162 Actor actor = Actor::New();
1163 actor.SetSize(100.0f, 100.0f);
1164 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1165 Stage::GetCurrent().Add(actor);
1168 GestureReceivedFunctor functor(data);
1170 PanGestureDetector detector = PanGestureDetector::New();
1171 detector.Attach(actor);
1172 detector.DetectedSignal().Connect(&application, functor);
1174 // Render and notify
1175 application.SendNotification();
1176 application.Render();
1178 // Start pan in actor's area
1179 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1180 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1181 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1183 // Send another start in actor's area
1185 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1186 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1188 // Add a child actor to overlap actor and send another start in actor's area
1189 Actor child = Actor::New();
1190 child.SetSize(100.0f, 100.0f);
1191 child.SetAnchorPoint(AnchorPoint::CENTER);
1192 child.SetParentOrigin(ParentOrigin::CENTER);
1195 TouchEventFunctor touchFunctor;
1196 child.TouchedSignal().Connect(&application, touchFunctor);
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Send another possible and start in actor's area
1204 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1205 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1206 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1208 // Send another start in actor's area
1210 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1211 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1212 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1216 int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void)
1218 TestApplication application;
1220 Actor actor1 = Actor::New();
1221 actor1.SetSize(100.0f, 100.0f);
1222 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1223 Stage::GetCurrent().Add(actor1);
1225 GestureReceivedFunctor functor1(data1);
1226 PanGestureDetector detector1 = PanGestureDetector::New();
1227 detector1.Attach(actor1);
1228 detector1.DetectedSignal().Connect(&application, functor1);
1230 Actor actor2 = Actor::New();
1231 actor2.SetSize(100.0f, 100.0f);
1232 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
1233 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
1234 Stage::GetCurrent().Add(actor2);
1236 GestureReceivedFunctor functor2(data2);
1237 PanGestureDetector detector2 = PanGestureDetector::New();
1238 detector2.Attach(actor2);
1239 detector2.DetectedSignal().Connect(&application, functor2);
1241 // Render and notify
1242 application.SendNotification();
1243 application.Render();
1245 // Start pan in actor1's area, only data1 should be set
1246 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1247 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1248 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
1249 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
1253 int UtcDaliPanGestureSignalReceptionDifferentPossible(void)
1255 TestApplication application;
1257 Actor actor = Actor::New();
1258 actor.SetSize(100.0f, 100.0f);
1259 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1260 Stage::GetCurrent().Add(actor);
1262 // Render and notify
1263 application.SendNotification();
1264 application.Render();
1266 // Attach actor to detector
1268 GestureReceivedFunctor functor( data );
1269 PanGestureDetector detector = PanGestureDetector::New();
1270 detector.Attach(actor);
1271 detector.DetectedSignal().Connect( &application, functor );
1273 // Gesture possible in actor's area.
1274 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1275 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1277 // Move actor somewhere else
1278 actor.SetPosition( 100.0f, 100.0f );
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Emit Started event, we should not receive the long press.
1285 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1286 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1287 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1289 // LongPress possible in empty area.
1290 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1291 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1293 // Move actor in to the long press position.
1294 actor.SetPosition( 0.0f, 0.0f );
1296 // Render and notify
1297 application.SendNotification();
1298 application.Render();
1300 // Emit Started event, we should not receive the long press.
1301 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1302 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1303 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1305 // Normal long press in actor's area for completeness.
1306 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1307 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1308 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1309 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1313 int UtcDaliPanGestureEmitIncorrectState(void)
1315 TestApplication application;
1317 Actor actor = Actor::New();
1318 actor.SetSize(100.0f, 100.0f);
1319 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1320 Stage::GetCurrent().Add(actor);
1322 // Render and notify
1323 application.SendNotification();
1324 application.Render();
1326 // Attach actor to detector
1328 GestureReceivedFunctor functor( data );
1329 PanGestureDetector detector = PanGestureDetector::New();
1330 detector.Attach(actor);
1331 detector.DetectedSignal().Connect( &application, functor );
1333 // Try a Clear state
1336 application.ProcessEvent(GeneratePan(Gesture::Clear, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1337 tet_result(TET_FAIL);
1339 catch ( Dali::DaliException& e )
1341 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1346 int UtcDaliPanGestureActorUnstaged(void)
1348 TestApplication application;
1350 Actor actor = Actor::New();
1351 actor.SetSize(100.0f, 100.0f);
1352 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1353 Stage::GetCurrent().Add(actor);
1355 // Render and notify
1356 application.SendNotification();
1357 application.Render();
1359 // State to remove actor in.
1360 Gesture::State stateToUnstage( Gesture::Started );
1362 // Attach actor to detector
1364 UnstageActorFunctor functor( data, stateToUnstage );
1365 PanGestureDetector detector = PanGestureDetector::New();
1366 detector.Attach(actor);
1367 detector.DetectedSignal().Connect( &application, functor );
1370 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1371 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1372 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1374 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1375 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1378 // Render and notify
1379 application.SendNotification();
1380 application.Render();
1382 // Re-add actor to stage
1383 Stage::GetCurrent().Add(actor);
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Change state to Gesture::Continuing to remove
1390 stateToUnstage = Gesture::Continuing;
1393 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1394 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1395 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1397 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1398 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1400 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1401 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Re-add actor to stage
1409 Stage::GetCurrent().Add(actor);
1411 // Render and notify
1412 application.SendNotification();
1413 application.Render();
1415 // Change state to Gesture::Finished to remove
1416 stateToUnstage = Gesture::Finished;
1419 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1420 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1421 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1423 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1424 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1426 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1427 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1428 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1432 int UtcDaliPanGestureActorStagedAndDestroyed(void)
1434 TestApplication application;
1436 Actor actor = Actor::New();
1437 actor.SetSize(100.0f, 100.0f);
1438 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1439 Stage::GetCurrent().Add(actor);
1441 // Create and add a second actor so that GestureDetector destruction does not come into play.
1442 Actor dummyActor( Actor::New() );
1443 dummyActor.SetSize( 100.0f, 100.0f );
1444 dummyActor.SetPosition( 100.0f, 100.0f );
1445 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1446 Stage::GetCurrent().Add(dummyActor);
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // State to remove actor in.
1453 Gesture::State stateToUnstage( Gesture::Started );
1455 // Attach actor to detector
1457 UnstageActorFunctor functor( data, stateToUnstage );
1458 PanGestureDetector detector = PanGestureDetector::New();
1459 detector.Attach(actor);
1460 detector.Attach(dummyActor);
1461 detector.DetectedSignal().Connect( &application, functor );
1463 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1464 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1465 // position, we should still not be signalled.
1468 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1469 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1470 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Re add to the stage, we should not be signalled
1478 Stage::GetCurrent().Add(actor);
1480 // Render and notify
1481 application.SendNotification();
1482 application.Render();
1484 // Continue signal emission
1485 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1486 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1488 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1489 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1492 // Here we delete an actor in started, we should not receive any subsequent signalling.
1495 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1496 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1497 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Delete actor as well
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 // Continue signal emission
1512 application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1513 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1515 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
1516 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1520 int UtcDaliPanGestureSystemOverlay(void)
1522 TestApplication application;
1523 Dali::Integration::Core& core = application.GetCore();
1524 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1525 systemOverlay.GetOverlayRenderTasks().CreateTask();
1527 Actor actor = Actor::New();
1528 actor.SetSize(100.0f, 100.0f);
1529 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1530 systemOverlay.Add(actor);
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1537 GestureReceivedFunctor functor(data);
1539 PanGestureDetector detector = PanGestureDetector::New();
1540 detector.Attach(actor);
1541 detector.DetectedSignal().Connect(&application, functor);
1543 Vector2 screenCoordsStart( 10.0f, 20.0f );
1544 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1546 // Start pan within the actor's area
1547 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1548 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1549 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1553 int UtcDaliPanGestureBehindTouchableSystemOverlay(void)
1555 TestApplication application;
1556 Dali::Integration::Core& core = application.GetCore();
1557 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1558 systemOverlay.GetOverlayRenderTasks().CreateTask();
1560 // SystemOverlay actor
1561 Actor systemOverlayActor = Actor::New();
1562 systemOverlayActor.SetSize(100.0f, 100.0f);
1563 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1564 systemOverlay.Add(systemOverlayActor);
1567 Actor stageActor = Actor::New();
1568 stageActor.SetSize(100.0f, 100.0f);
1569 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1570 Stage::GetCurrent().Add(stageActor);
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Set system-overlay actor to touchable
1577 TouchEventData touchData;
1578 TouchEventDataFunctor touchFunctor( touchData );
1579 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1581 // Set stage actor to receive the gesture
1583 GestureReceivedFunctor functor(data);
1585 PanGestureDetector detector = PanGestureDetector::New();
1586 detector.Attach(stageActor);
1587 detector.DetectedSignal().Connect(&application, functor);
1589 Vector2 screenCoordsStart( 10.0f, 20.0f );
1590 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1592 // Start pan within the two actors' area
1593 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1594 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1595 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1596 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1597 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1602 // Do touch in the same area
1603 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1604 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1605 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1610 int UtcDaliPanGestureTouchBehindGesturedSystemOverlay(void)
1612 TestApplication application;
1613 Dali::Integration::Core& core = application.GetCore();
1614 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1615 systemOverlay.GetOverlayRenderTasks().CreateTask();
1617 // SystemOverlay actor
1618 Actor systemOverlayActor = Actor::New();
1619 systemOverlayActor.SetSize(100.0f, 100.0f);
1620 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1621 systemOverlay.Add(systemOverlayActor);
1624 Actor stageActor = Actor::New();
1625 stageActor.SetSize(100.0f, 100.0f);
1626 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1627 Stage::GetCurrent().Add(stageActor);
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 // Set stage actor to touchable
1634 TouchEventData touchData;
1635 TouchEventDataFunctor touchFunctor( touchData );
1636 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1638 // Set system-overlay actor to have the gesture
1640 GestureReceivedFunctor functor(data);
1642 PanGestureDetector detector = PanGestureDetector::New();
1643 detector.Attach(systemOverlayActor);
1644 detector.DetectedSignal().Connect(&application, functor);
1646 Vector2 screenCoordsStart( 10.0f, 20.0f );
1647 Vector2 screenCoordsEnd( 20.0f, 20.0f );
1649 // Start pan within the two actors' area
1650 application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) );
1651 application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) );
1652 application.ProcessEvent( GeneratePan( Gesture::Finished, screenCoordsStart, screenCoordsEnd, 10 ) );
1653 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1654 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1659 // Do touch in the same area
1660 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoordsStart ) );
1661 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1662 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1667 int UtcDaliPanGestureAngleHandling(void)
1669 TestApplication application;
1671 PanGestureDetector detector = PanGestureDetector::New();
1672 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1673 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1675 detector.AddAngle( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1676 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1677 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1679 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1681 tet_result( TET_PASS );
1685 if ( iter == endIter )
1687 tet_printf("%s, angle not added\n", TEST_LOCATION );
1688 tet_result( TET_FAIL );
1692 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Radian( Math::PI * 0.25 ) );
1693 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1695 // Remove something not in the container.
1696 detector.RemoveAngle( PanGestureDetector::DIRECTION_UP );
1697 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1699 detector.RemoveAngle( PanGestureDetector::DIRECTION_RIGHT );
1700 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(1), TEST_LOCATION );
1701 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1703 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1705 tet_printf("%s, angle not removed\n", TEST_LOCATION );
1706 tet_result( TET_FAIL );
1711 detector.ClearAngles();
1712 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1716 inline float RadiansToDegrees( float radian )
1718 return radian * 180.0f / Math::PI;
1721 int UtcDaliPanGestureAngleOutOfRange(void)
1723 TestApplication application;
1725 PanGestureDetector detector = PanGestureDetector::New();
1726 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1727 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1733 detector.AddAngle( Degree(180.0f) );
1734 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION );
1735 detector.ClearAngles();
1737 detector.AddAngle( Degree(190.0f) );
1738 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION );
1739 detector.ClearAngles();
1741 detector.AddAngle( Degree(-190.0f) );
1742 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION );
1743 detector.ClearAngles();
1745 detector.AddAngle( Degree(350.0f) );
1746 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1747 detector.ClearAngles();
1749 detector.AddAngle( Degree(-350.0f) );
1750 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1751 detector.ClearAngles();
1753 detector.AddAngle( Degree(370.0f) );
1754 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1755 detector.ClearAngles();
1757 detector.AddAngle( Degree(-370.0f) );
1758 DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION );
1759 detector.ClearAngles();
1765 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 0.0f ) );
1766 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION );
1767 detector.ClearAngles();
1769 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -10.0f ) );
1770 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION );
1771 detector.ClearAngles();
1773 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -181.0f ) );
1774 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1775 detector.ClearAngles();
1777 detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 181.0f ) );
1778 DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION );
1779 detector.ClearAngles();
1783 int UtcDaliPanGestureAngleProcessing(void)
1785 TestApplication application;
1787 Actor parent = Actor::New();
1788 parent.SetSize(100.0f, 100.0f);
1789 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1790 Stage::GetCurrent().Add(parent);
1792 Actor child = Actor::New();
1793 child.SetSize(100.0f, 100.0f);
1794 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Parent detector only requires up pans
1802 PanGestureDetector parentDetector = PanGestureDetector::New();
1803 parentDetector.Attach( parent );
1804 parentDetector.AddAngle( PanGestureDetector::DIRECTION_UP, Degree( 30.0f ) );
1805 SignalData parentData;
1806 GestureReceivedFunctor parentFunctor(parentData);
1807 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1809 // Child detector only requires right pans
1810 PanGestureDetector childDetector = PanGestureDetector::New();
1811 childDetector.Attach( child );
1812 childDetector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 30.0f ) );
1813 SignalData childData;
1814 GestureReceivedFunctor childFunctor(childData);
1815 childDetector.DetectedSignal().Connect(&application, childFunctor);
1817 // Generate an Up pan gesture, only parent should receive it.
1818 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1819 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1820 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1821 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1822 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1826 // Generate a Right pan gesture, only child should receive it.
1827 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1828 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1829 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1830 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1831 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1835 // Generate a Down pan gesture, no one should receive it.
1836 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1837 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1838 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1839 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1840 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1844 // Generate a Left pan gesture, no one should receive it.
1845 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1846 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1847 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1848 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1849 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1855 int UtcDaliPanGestureDirectionHandling(void)
1857 TestApplication application;
1859 PanGestureDetector detector = PanGestureDetector::New();
1860 const PanGestureDetector::AngleContainer& angles( detector.GetAngles() );
1861 DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION );
1863 detector.AddDirection( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) );
1864 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1865 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1867 if ( iter->first == PanGestureDetector::DIRECTION_LEFT )
1869 tet_result( TET_PASS );
1873 if ( iter == endIter )
1875 tet_printf("%s, angle not added\n", TEST_LOCATION );
1876 tet_result( TET_FAIL );
1880 for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter )
1882 if ( iter->first == PanGestureDetector::DIRECTION_RIGHT )
1884 tet_result( TET_PASS );
1888 if ( iter == endIter )
1890 tet_printf("%s, angle not added\n", TEST_LOCATION );
1891 tet_result( TET_FAIL );
1895 // Remove something not in the container.
1896 detector.RemoveDirection( PanGestureDetector::DIRECTION_UP );
1897 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(2), TEST_LOCATION );
1899 detector.RemoveDirection( PanGestureDetector::DIRECTION_RIGHT );
1900 DALI_TEST_EQUALS( angles.size(), static_cast<AngleSizeType>(0), TEST_LOCATION );
1904 int UtcDaliPanGestureDirectionProcessing(void)
1906 TestApplication application;
1908 Actor parent = Actor::New();
1909 parent.SetSize(100.0f, 100.0f);
1910 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1911 Stage::GetCurrent().Add(parent);
1913 Actor child = Actor::New();
1914 child.SetSize(100.0f, 100.0f);
1915 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 // Parent detector only requires vertical panning
1923 PanGestureDetector parentDetector = PanGestureDetector::New();
1924 parentDetector.Attach( parent );
1925 parentDetector.AddDirection( PanGestureDetector::DIRECTION_VERTICAL, Degree( 30.0f ) );
1926 SignalData parentData;
1927 GestureReceivedFunctor parentFunctor(parentData);
1928 parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1930 // Child detector only requires horizontal panning
1931 PanGestureDetector childDetector = PanGestureDetector::New();
1932 childDetector.Attach( child );
1933 childDetector.AddDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 30.0f ) );
1934 SignalData childData;
1935 GestureReceivedFunctor childFunctor(childData);
1936 childDetector.DetectedSignal().Connect(&application, childFunctor);
1938 // Generate an Up pan gesture, only parent should receive it.
1939 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1940 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) );
1941 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1942 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1943 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1947 // Generate a Right pan gesture, only child should receive it.
1948 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1949 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) );
1950 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1951 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1952 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1956 // Generate a Down pan gesture, only parent should receive it.
1957 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1958 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) );
1959 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1960 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1961 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1965 // Generate a Left pan gesture, only child should receive it.
1966 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1967 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) );
1968 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1969 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1970 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1974 // Generate a pan at -45 degrees, no one should receive it.
1975 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1976 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1977 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1978 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1979 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1983 // Generate a pan at 45 degrees, no one should receive it.
1984 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1985 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 30.0f), 10 ) );
1986 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1987 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1988 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
1992 // Generate a pan at 135 degrees, no one should receive it.
1993 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
1994 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) );
1995 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1996 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1997 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
2001 // Generate a pan at -135 degrees, no one should receive it.
2002 application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) );
2003 application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 10.0f), 10 ) );
2004 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
2005 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
2006 application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) );
2012 int UtcDaliPanGestureSetProperties(void)
2014 TestApplication application;
2015 TestRenderController& renderController( application.GetRenderController() );
2016 Integration::SetPanGesturePredictionMode(0);
2017 Integration::SetPanGestureSmoothingMode(0);
2019 Actor actor = Actor::New();
2020 actor.SetSize(100.0f, 100.0f);
2021 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2022 Stage::GetCurrent().Add(actor);
2024 // Add a pan detector
2025 PanGestureDetector detector = PanGestureDetector::New();
2026 detector.Attach( actor );
2028 GestureReceivedFunctor functor( data );
2029 detector.DetectedSignal().Connect( &application, functor );
2031 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2033 ConstraintData constraintData;
2034 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2035 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2036 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2037 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2038 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2039 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2040 PanConstraint( constraintData ) ) );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 renderController.Initialize();
2047 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), false, TEST_LOCATION );
2049 Vector2 screenPosition( 20.0f, 20.0f );
2050 Vector2 screenDisplacement( 1.0f, 1.0f );
2051 Vector2 screenVelocity( 1.3f, 4.0f );
2052 Vector2 localPosition( 21.0f, 21.0f );
2053 Vector2 localDisplacement( 0.5f, 0.5f );
2054 Vector2 localVelocity( 1.5f, 2.5f );
2056 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity ) );
2057 DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION );
2059 // Render and notify
2060 application.SendNotification();
2061 application.Render();
2063 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2064 DALI_TEST_EQUALS( constraintData.screenPosition, screenPosition, TEST_LOCATION );
2065 DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION );
2066 DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION );
2067 DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION );
2068 DALI_TEST_EQUALS( constraintData.screenVelocity, screenVelocity, TEST_LOCATION );
2069 DALI_TEST_EQUALS( constraintData.localVelocity, localVelocity, TEST_LOCATION );
2070 constraintData.Reset();
2074 int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
2076 TestApplication application;
2077 Integration::SetPanGesturePredictionMode(0);
2079 Actor actor = Actor::New();
2080 actor.SetSize(100.0f, 100.0f);
2081 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2082 Stage::GetCurrent().Add(actor);
2084 // Add a pan detector
2085 PanGestureDetector detector = PanGestureDetector::New();
2086 detector.Attach( actor );
2088 GestureReceivedFunctor functor( data );
2089 detector.DetectedSignal().Connect( &application, functor );
2091 Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO );
2093 ConstraintData constraintData;
2094 actor.ApplyConstraint( Constraint::New<Vector3>( property, Source( detector, PanGestureDetector::SCREEN_POSITION ),
2095 Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ),
2096 Source( detector, PanGestureDetector::SCREEN_VELOCITY ),
2097 Source( detector, PanGestureDetector::LOCAL_POSITION ),
2098 Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
2099 Source( detector, PanGestureDetector::LOCAL_VELOCITY ),
2100 PanConstraint( constraintData ) ) );
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 Vector2 previousPosition( 20.0f, 20.0f );
2107 Vector2 currentPosition( 20.0f, 10.0f );
2108 application.ProcessEvent( GeneratePan( Gesture::Possible, previousPosition, previousPosition, 10 ) );
2109 application.ProcessEvent( GeneratePan( Gesture::Started, previousPosition, currentPosition, 10 ) );
2110 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2112 Vector2 screenPosition( 100.0f, 20.0f );
2113 Vector2 localPosition( 110.0f, 110.0f );
2115 PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition ) );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION );
2122 DALI_TEST_EQUALS( constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION );
2123 DALI_TEST_EQUALS( constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION );
2124 constraintData.Reset();
2128 int UtcDaliPanGesturePropertyIndices(void)
2130 TestApplication application;
2131 PanGestureDetector detector = PanGestureDetector::New();
2133 Property::IndexContainer indices;
2134 detector.GetPropertyIndices( indices );
2135 DALI_TEST_CHECK( ! indices.empty() );
2136 DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION );
2140 int UtcDaliPanGestureLayerConsumesTouch(void)
2142 TestApplication application;
2144 Actor actor = Actor::New();
2145 actor.SetSize(100.0f, 100.0f);
2146 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2147 Stage::GetCurrent().Add(actor);
2149 // Add a pan detector
2150 PanGestureDetector detector = PanGestureDetector::New();
2151 detector.Attach( actor );
2153 GestureReceivedFunctor functor( data );
2154 detector.DetectedSignal().Connect( &application, functor );
2156 // Add a layer to overlap the actor
2157 Layer layer = Layer::New();
2158 layer.SetSize(100.0f, 100.0f);
2159 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2160 Stage::GetCurrent().Add( layer );
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Emit signals, should receive
2168 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2169 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2170 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2171 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2174 // Set layer to consume all touch
2175 layer.SetTouchConsumed( true );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Emit the same signals again, should not receive
2182 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2183 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2184 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10));
2185 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2191 int UtcDaliPanGestureNoTimeDiff(void)
2193 TestApplication application;
2195 Actor actor = Actor::New();
2196 actor.SetSize(100.0f, 100.0f);
2197 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2198 Stage::GetCurrent().Add(actor);
2200 // Add a pan detector
2201 PanGestureDetector detector = PanGestureDetector::New();
2202 detector.Attach( actor );
2204 GestureReceivedFunctor functor( data );
2205 detector.DetectedSignal().Connect( &application, functor );
2207 // Render and notify
2208 application.SendNotification();
2209 application.Render();
2211 // Emit signals, should receive
2212 application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2213 application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2214 application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 0));
2215 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2216 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.x ) );
2217 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.velocity.y ) );
2218 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.x ) );
2219 DALI_TEST_CHECK( !std::isinf( data.receivedGesture.screenVelocity.y ) );