[dali_2.3.30] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-PanGestureDetector.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/actors/actor-devel.h>
20 #include <dali/devel-api/events/pan-gesture-devel.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/touch-integ.h>
23 #include <dali/integration-api/input-options.h>
24 #include <dali/integration-api/profiling.h>
25 #include <dali/integration-api/render-task-list-integ.h>
26 #include <dali/internal/event/events/touch-event-impl.h>
27 #include <dali/internal/event/render-tasks/render-task-impl.h>
28 #include <dali/public-api/dali-core.h>
29 #include <stdlib.h>
30 #include <test-touch-event-utils.h>
31
32 #include <cmath>
33 #include <iostream>
34
35 using namespace Dali;
36
37 void utc_dali_pan_gesture_detector_startup(void)
38 {
39   test_return_value = TET_UNDEF;
40 }
41
42 void utc_dali_pan_gesture_detector_cleanup(void)
43 {
44   test_return_value = TET_PASS;
45 }
46
47 ///////////////////////////////////////////////////////////////////////////////
48 namespace
49 {
50 const int PAN_EVENT_TIME_DELTA     = 8;
51 const int PAN_GESTURE_UPDATE_COUNT = 50;
52
53 // Stores data that is populated in the callback and will be read by the test cases
54 struct SignalData
55 {
56   SignalData()
57   : functorCalled(false),
58     voidFunctorCalled(false),
59     receivedGesture()
60   {
61   }
62
63   void Reset()
64   {
65     functorCalled     = false;
66     voidFunctorCalled = false;
67
68     receivedGesture.Reset();
69
70     pannedActor.Reset();
71   }
72
73   bool       functorCalled;
74   bool       voidFunctorCalled;
75   PanGesture receivedGesture;
76   Actor      pannedActor;
77 };
78
79 // Functor that sets the data when called
80 struct GestureReceivedFunctor
81 {
82   GestureReceivedFunctor(SignalData& data)
83   : signalData(data)
84   {
85   }
86
87   void operator()(Actor actor, const PanGesture& pan)
88   {
89     signalData.functorCalled   = true;
90     signalData.receivedGesture = pan;
91     signalData.pannedActor     = actor;
92   }
93
94   void operator()()
95   {
96     signalData.voidFunctorCalled = true;
97   }
98
99   SignalData& signalData;
100 };
101
102 // Functor that removes the gestured actor from stage
103 struct UnstageActorFunctor : public GestureReceivedFunctor
104 {
105   UnstageActorFunctor(SignalData& data, GestureState& stateToUnstage, Integration::Scene scene)
106   : GestureReceivedFunctor(data),
107     stateToUnstage(stateToUnstage),
108     scene(scene)
109   {
110   }
111
112   void operator()(Actor actor, const PanGesture& pan)
113   {
114     GestureReceivedFunctor::operator()(actor, pan);
115
116     if(pan.GetState() == stateToUnstage)
117     {
118       scene.Remove(actor);
119     }
120   }
121
122   GestureState&      stateToUnstage;
123   Integration::Scene scene;
124 };
125
126 // Functor that removes the gestured actor from stage
127 struct PropagationActorFunctor : public GestureReceivedFunctor
128 {
129   PropagationActorFunctor(SignalData& data, bool propagation)
130   : GestureReceivedFunctor(data),
131     propagation(propagation)
132   {
133   }
134
135   void operator()(Actor actor, const PanGesture& pan)
136   {
137     GestureReceivedFunctor::operator()(actor, pan);
138     Dali::DevelActor::SetNeedGesturePropagation(actor, propagation);
139   }
140
141   bool propagation;
142 };
143
144
145 // Data for constraints
146 struct ConstraintData
147 {
148   ConstraintData()
149   : panning(false),
150     called(false)
151   {
152   }
153
154   Vector2 screenPosition;
155   Vector2 screenDisplacement;
156   Vector2 screenVelocity;
157   Vector2 localPosition;
158   Vector2 localDisplacement;
159   Vector2 localVelocity;
160   bool    panning;
161   bool    called;
162
163   void Reset()
164   {
165     screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO;
166     panning                                                                                                  = false;
167     called                                                                                                   = false;
168   }
169 };
170
171 // Constraint used with panning properties
172 struct PanConstraint
173 {
174   PanConstraint(ConstraintData& data)
175   : constraintData(data)
176   {
177   }
178
179   void operator()(Vector3& current, const PropertyInputContainer& inputs)
180   {
181     constraintData.screenPosition     = inputs[0]->GetVector2();
182     constraintData.screenDisplacement = inputs[1]->GetVector2();
183     constraintData.screenVelocity     = inputs[2]->GetVector2();
184     constraintData.localPosition      = inputs[3]->GetVector2();
185     constraintData.localDisplacement  = inputs[4]->GetVector2();
186     constraintData.localVelocity      = inputs[5]->GetVector2();
187     constraintData.panning            = inputs[6]->GetBoolean();
188     constraintData.called             = true;
189     current                           = Vector3::ZERO;
190   }
191
192   ConstraintData& constraintData;
193 };
194
195 // Generate a PanGesture
196 PanGesture GeneratePan(unsigned int time,
197                        GestureState state,
198                        Vector2      screenPosition,
199                        Vector2      localPosition,
200                        Vector2      screenDisplacement = Vector2::ONE,
201                        Vector2      localDisplacement  = Vector2::ONE,
202                        Vector2      screenVelocity     = Vector2::ONE,
203                        Vector2      localVelocity      = Vector2::ONE,
204                        unsigned int numberOfTouches    = 1)
205 {
206   Dali::PanGesture pan = DevelPanGesture::New(state);
207
208   DevelPanGesture::SetTime(pan, time);
209
210   DevelPanGesture::SetScreenPosition(pan, screenPosition);
211   DevelPanGesture::SetPosition(pan, localPosition);
212
213   DevelPanGesture::SetScreenDisplacement(pan, screenDisplacement);
214   DevelPanGesture::SetDisplacement(pan, localDisplacement);
215
216   DevelPanGesture::SetScreenVelocity(pan, screenVelocity);
217   DevelPanGesture::SetVelocity(pan, localVelocity);
218
219   DevelPanGesture::SetNumberOfTouches(pan, numberOfTouches);
220
221   return pan;
222 }
223
224 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time)
225 {
226   Integration::TouchEvent touchEvent;
227   Integration::Point      point;
228   point.SetState(state);
229   point.SetDeviceId(4);
230   point.SetScreenPosition(screenPosition);
231   point.SetDeviceClass(Device::Class::TOUCH);
232   point.SetDeviceSubclass(Device::Subclass::NONE);
233   touchEvent.points.push_back(point);
234   touchEvent.time = time;
235   return touchEvent;
236 }
237 } // namespace
238
239 ///////////////////////////////////////////////////////////////////////////////
240
241 // Positive test case for a method
242 int UtcDaliPanGestureDetectorConstructor(void)
243 {
244   TestApplication application;
245
246   PanGestureDetector detector;
247   DALI_TEST_CHECK(!detector);
248   END_TEST;
249 }
250
251 int UtcDaliPanGestureDetectorCopyConstructorP(void)
252 {
253   TestApplication application;
254
255   PanGestureDetector detector = PanGestureDetector::New();
256
257   PanGestureDetector copy(detector);
258   DALI_TEST_CHECK(detector);
259   END_TEST;
260 }
261
262 int UtcDaliPanGestureDetectorAssignmentOperatorP(void)
263 {
264   TestApplication application;
265
266   PanGestureDetector detector = PanGestureDetector::New();
267
268   PanGestureDetector assign;
269   assign = detector;
270   DALI_TEST_CHECK(detector);
271
272   DALI_TEST_CHECK(detector == assign);
273   END_TEST;
274 }
275
276 int UtcDaliPanGestureDetectorMoveConstructorP(void)
277 {
278   TestApplication application;
279
280   PanGestureDetector detector = PanGestureDetector::New();
281   DALI_TEST_CHECK(detector);
282
283   PanGestureDetector moved = std::move(detector);
284   DALI_TEST_CHECK(moved);
285   DALI_TEST_CHECK(!detector);
286   END_TEST;
287 }
288
289 int UtcDaliPanGestureDetectorMoveAssignmentOperatorP(void)
290 {
291   TestApplication application;
292
293   PanGestureDetector detector;
294   detector = PanGestureDetector::New();
295   DALI_TEST_CHECK(detector);
296
297   PanGestureDetector moved;
298   moved = std::move(detector);
299   DALI_TEST_CHECK(moved);
300   DALI_TEST_CHECK(!detector);
301   END_TEST;
302 }
303
304 // Negative test case for a method
305 int UtcDaliPanGestureDetectorNew(void)
306 {
307   TestApplication application;
308
309   PanGestureDetector detector = PanGestureDetector::New();
310
311   DALI_TEST_CHECK(detector);
312
313   DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
314   DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
315   DALI_TEST_EQUALS(std::numeric_limits<uint32_t>::max(), detector.GetMaximumMotionEventAge(), TEST_LOCATION);
316
317   // Attach an actor and emit a touch event on the actor to ensure complete line coverage
318   Actor actor = Actor::New();
319   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
320   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
321   detector.Attach(actor);
322
323   application.GetScene().Add(actor);
324
325   // Render and notify
326   application.SendNotification();
327   application.Render();
328
329   // Use long press function for touch event
330   TestStartLongPress(application);
331
332   END_TEST;
333 }
334
335 int UtcDaliPanGestureDetectorDownCast(void)
336 {
337   TestApplication application;
338   tet_infoline("Testing Dali::GestureDetector::DownCast()");
339
340   PanGestureDetector detector = PanGestureDetector::New();
341
342   BaseHandle object(detector);
343
344   PanGestureDetector detector2 = PanGestureDetector::DownCast(object);
345   DALI_TEST_CHECK(detector2);
346
347   PanGestureDetector detector3 = DownCast<PanGestureDetector>(object);
348   DALI_TEST_CHECK(detector3);
349
350   BaseHandle         unInitializedObject;
351   PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject);
352   DALI_TEST_CHECK(!detector4);
353
354   PanGestureDetector detector5 = DownCast<PanGestureDetector>(unInitializedObject);
355   DALI_TEST_CHECK(!detector5);
356
357   GestureDetector    detector6 = PanGestureDetector::New();
358   PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6);
359   DALI_TEST_CHECK(detector7);
360   END_TEST;
361 }
362
363 int UtcDaliPanGestureSetMinimumTouchesRequired(void)
364 {
365   TestApplication application;
366
367   PanGestureDetector detector = PanGestureDetector::New();
368
369   unsigned int min = 2;
370
371   DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired());
372
373   detector.SetMinimumTouchesRequired(min);
374
375   DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
376
377   // Attach an actor and change the minimum touches
378
379   Actor actor = Actor::New();
380   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
381   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
382   application.GetScene().Add(actor);
383
384   // Render and notify
385   application.SendNotification();
386   application.Render();
387
388   SignalData             data;
389   GestureReceivedFunctor functor(data);
390
391   detector.Attach(actor);
392   detector.DetectedSignal().Connect(&application, functor);
393
394   detector.SetMinimumTouchesRequired(3);
395
396   // Create a second gesture detector that requires even less minimum touches
397   PanGestureDetector secondDetector = PanGestureDetector::New();
398   secondDetector.Attach(actor);
399
400   DALI_TEST_EQUALS(3, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
401
402   END_TEST;
403 }
404
405 int UtcDaliPanGestureSetMaximumTouchesRequired(void)
406 {
407   TestApplication application;
408
409   PanGestureDetector detector = PanGestureDetector::New();
410
411   unsigned int max = 3;
412
413   DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired());
414
415   detector.SetMaximumTouchesRequired(max);
416
417   DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
418
419   // Attach an actor and change the maximum touches
420
421   Actor actor = Actor::New();
422   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
423   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
424   application.GetScene().Add(actor);
425
426   // Render and notify
427   application.SendNotification();
428   application.Render();
429
430   SignalData             data;
431   GestureReceivedFunctor functor(data);
432
433   detector.Attach(actor);
434   detector.DetectedSignal().Connect(&application, functor);
435
436   detector.SetMaximumTouchesRequired(4);
437
438   DALI_TEST_EQUALS(4, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
439
440   END_TEST;
441 }
442
443 int UtcDaliPanGestureSetMaximumMotionEventAge(void)
444 {
445   TestApplication application;
446
447   PanGestureDetector detector = PanGestureDetector::New();
448
449   uint32_t minTime = 20;
450
451   DALI_TEST_CHECK(minTime != detector.GetMaximumMotionEventAge());
452
453   detector.SetMaximumMotionEventAge(minTime);
454
455   DALI_TEST_EQUALS(minTime, detector.GetMaximumMotionEventAge(), TEST_LOCATION);
456
457   // Attach an actor and change the maximum touches
458
459   Actor actor = Actor::New();
460   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
461   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
462   application.GetScene().Add(actor);
463
464   // Render and notify
465   application.SendNotification();
466   application.Render();
467
468   SignalData             data;
469   GestureReceivedFunctor functor(data);
470
471   detector.Attach(actor);
472   detector.DetectedSignal().Connect(&application, functor);
473
474   detector.SetMaximumMotionEventAge(minTime * 2);
475
476   DALI_TEST_EQUALS(minTime * 2, detector.GetMaximumMotionEventAge(), TEST_LOCATION);
477
478   END_TEST;
479 }
480
481 int UtcDaliPanGestureGetMinimumTouchesRequired(void)
482 {
483   TestApplication application;
484
485   PanGestureDetector detector = PanGestureDetector::New();
486   DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION);
487   END_TEST;
488 }
489
490 int UtcDaliPanGestureGetMaximumTouchesRequired(void)
491 {
492   TestApplication application;
493
494   PanGestureDetector detector = PanGestureDetector::New();
495   DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION);
496   END_TEST;
497 }
498
499 int UtcDaliPanGestureGetMaximumMotionEventAge(void)
500 {
501   TestApplication application;
502
503   PanGestureDetector detector = PanGestureDetector::New();
504   DALI_TEST_EQUALS(std::numeric_limits<uint32_t>::max(), detector.GetMaximumMotionEventAge(), TEST_LOCATION);
505   END_TEST;
506 }
507
508 int UtcDaliPanGestureSignalReceptionNegative(void)
509 {
510   TestApplication application;
511
512   Actor actor = Actor::New();
513   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
514   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
515   application.GetScene().Add(actor);
516
517   // Render and notify
518   application.SendNotification();
519   application.Render();
520
521   SignalData             data;
522   GestureReceivedFunctor functor(data);
523
524   PanGestureDetector detector = PanGestureDetector::New();
525   detector.Attach(actor);
526   detector.DetectedSignal().Connect(&application, functor);
527
528   // Do a pan outside actor's area
529   uint32_t time = 100;
530   TestStartPan(application, Vector2(110.0f, 110.0f), Vector2(121.0f, 121.0f), time);
531
532   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
533
534   // Continue pan into actor's area - we should still not receive the signal
535   data.Reset();
536   TestMovePan(application, Vector2(20.0f, 20.0f), time);
537
538   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
539
540   // Stop panning - we should still not receive the signal
541   data.Reset();
542   TestEndPan(application, Vector2(12.0f, 12.0f), time);
543
544   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
545   END_TEST;
546 }
547
548 int UtcDaliPanGestureSignalReceptionDownMotionLeave(void)
549 {
550   TestApplication application;
551
552   Actor actor = Actor::New();
553   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
554   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
555   application.GetScene().Add(actor);
556
557   // Render and notify
558   application.SendNotification();
559   application.Render();
560
561   SignalData             data;
562   GestureReceivedFunctor functor(data);
563
564   PanGestureDetector detector = PanGestureDetector::New();
565   detector.Attach(actor);
566   detector.DetectedSignal().Connect(&application, functor);
567
568   // Start pan within the actor's area
569   uint32_t time = 100;
570   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
571
572   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
573   DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
574   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
575   DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
576   DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
577   DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
578   DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
579
580   // Continue the pan within the actor's area - we should still receive the signal
581   data.Reset();
582
583   TestMovePan(application, Vector2(26.0f, 4.0f), time);
584   time += TestGetFrameInterval();
585
586   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
587   DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
588   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
589   DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
590   DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
591   DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
592   DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
593
594   // Pan Gesture leaves actor's area - we should still receive the signal
595   data.Reset();
596
597   TestMovePan(application, Vector2(346.0f, 4.0f), time);
598   time += TestGetFrameInterval();
599
600   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
601   DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
602   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
603   DALI_TEST_EQUALS(Vector2(320.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
604   DALI_TEST_EQUALS(Vector2(20.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
605   DALI_TEST_EQUALS(320.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
606   DALI_TEST_EQUALS(20.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
607
608   // Gesture ends - we would receive a finished state
609   data.Reset();
610
611   TestEndPan(application, Vector2(314.0f, 4.0f), time);
612
613   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
614   DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
615   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
616   DALI_TEST_EQUALS(Vector2(-32.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
617   DALI_TEST_EQUALS(Vector2(-2.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
618   DALI_TEST_EQUALS(32.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
619   DALI_TEST_EQUALS(2.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
620   END_TEST;
621 }
622
623 int UtcDaliPanGestureSignalReceptionDownMotionUp(void)
624 {
625   TestApplication application;
626
627   Actor actor = Actor::New();
628   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
629   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
630   application.GetScene().Add(actor);
631
632   // Render and notify
633   application.SendNotification();
634   application.Render();
635
636   SignalData             data;
637   GestureReceivedFunctor functor(data);
638
639   PanGestureDetector detector = PanGestureDetector::New();
640   detector.Attach(actor);
641   detector.DetectedSignal().Connect(&application, functor);
642
643   // Start pan within the actor's area
644   uint32_t time = 100;
645   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
646
647   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
648   DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
649   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
650   DALI_TEST_EQUALS(Vector2(16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
651   DALI_TEST_EQUALS(Vector2(0.5f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
652   DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
653   DALI_TEST_EQUALS(0.5f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
654
655   // Continue the pan within the actor's area - we should still receive the signal
656   data.Reset();
657
658   TestMovePan(application, Vector2(26.0f, 4.0f), time);
659   time += TestGetFrameInterval();
660
661   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
662   DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
663   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
664   DALI_TEST_EQUALS(Vector2(0.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
665   DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
666   DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
667   DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
668
669   // Gesture ends within actor's area - we would receive a finished state
670   data.Reset();
671
672   TestEndPan(application, Vector2(10.0f, 4.0f), time);
673
674   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
675   DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
676   DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
677   DALI_TEST_EQUALS(Vector2(-16.0f, 0.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION);
678   DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.GetVelocity(), 0.01f, TEST_LOCATION);
679   DALI_TEST_EQUALS(16.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION);
680   DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
681   END_TEST;
682 }
683
684 int UtcDaliPanGestureSignalReceptionDetach(void)
685 {
686   TestApplication application;
687
688   Actor actor = Actor::New();
689   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
690   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
691   application.GetScene().Add(actor);
692
693   // Render and notify
694   application.SendNotification();
695   application.Render();
696
697   SignalData             data;
698   GestureReceivedFunctor functor(data);
699
700   PanGestureDetector detector = PanGestureDetector::New();
701   detector.Attach(actor);
702   detector.DetectedSignal().Connect(&application, functor);
703
704   // Start pan within the actor's area
705   uint32_t time = 100;
706   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
707   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
708
709   // Continue the pan within the actor's area - we should still receive the signal
710   data.Reset();
711
712   TestMovePan(application, Vector2(26.0f, 4.0f), time);
713   time += TestGetFrameInterval();
714
715   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
716
717   // Gesture ends within actor's area
718   data.Reset();
719
720   TestEndPan(application, Vector2(10.0f, 4.0f), time);
721   time += TestGetFrameInterval();
722
723   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
724
725   // Detach actor
726   detector.DetachAll();
727
728   // Ensure we are no longer signalled
729   data.Reset();
730
731   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
732   TestMovePan(application, Vector2(26.0f, 4.0f), time);
733   time += TestGetFrameInterval();
734   TestEndPan(application, Vector2(10.0f, 4.0f), time);
735
736   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
737   END_TEST;
738 }
739
740 int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void)
741 {
742   TestApplication application;
743
744   Actor actor = Actor::New();
745   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
746   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
747   application.GetScene().Add(actor);
748
749   // Render and notify
750   application.SendNotification();
751   application.Render();
752
753   SignalData             data;
754   GestureReceivedFunctor functor(data);
755
756   PanGestureDetector detector = PanGestureDetector::New();
757   detector.Attach(actor);
758   detector.DetectedSignal().Connect(&application, functor);
759
760   // Start pan within the actor's area
761   uint32_t time = 100;
762   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
763   application.SendNotification();
764
765   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
766
767   // Continue the pan within the actor's area - we should still receive the signal
768   data.Reset();
769
770   TestMovePan(application, Vector2(26.0f, 4.0f), time);
771   time += TestGetFrameInterval();
772
773   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
774
775   // Detach actor during the pan, we should not receive the next event
776   detector.DetachAll();
777
778   // Gesture ends within actor's area
779   data.Reset();
780
781   TestEndPan(application, Vector2(10.0f, 4.0f), time);
782
783   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
784   END_TEST;
785 }
786
787 int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void)
788 {
789   TestApplication application;
790
791   SignalData             data;
792   GestureReceivedFunctor functor(data);
793
794   PanGestureDetector detector = PanGestureDetector::New();
795   detector.DetectedSignal().Connect(&application, functor);
796
797   // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor
798   // is destroyed.
799   Actor tempActor = Actor::New();
800   tempActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
801   tempActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
802   application.GetScene().Add(tempActor);
803   detector.Attach(tempActor);
804
805   uint32_t time = 100;
806
807   // Actor lifetime is scoped
808   {
809     Actor actor = Actor::New();
810     actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
811     actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
812     application.GetScene().Add(actor);
813
814     // Render and notify
815     application.SendNotification();
816     application.Render();
817
818     detector.Attach(actor);
819
820     // Start pan within the actor's area
821     TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
822
823     DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
824
825     // Continue the pan within the actor's area - we should still receive the signal
826     data.Reset();
827
828     TestMovePan(application, Vector2(26.0f, 4.0f), time);
829     time += TestGetFrameInterval();
830
831     DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
832
833     // Remove the actor from stage and reset the data
834     application.GetScene().Remove(actor);
835
836     // Render and notify
837     application.SendNotification();
838     application.Render();
839   }
840
841   // Actor should now have been destroyed
842
843   // Gesture ends within the area where the actor used to be
844   data.Reset();
845
846   TestEndPan(application, Vector2(10.0f, 4.0f), time);
847
848   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
849   END_TEST;
850 }
851
852 int UtcDaliPanGestureSignalReceptionRotatedActor(void)
853 {
854   TestApplication application;
855
856   Actor actor = Actor::New();
857   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
858   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
859   application.GetScene().Add(actor);
860
861   // Render and notify
862   application.SendNotification();
863   application.Render();
864
865   SignalData             data;
866   GestureReceivedFunctor functor(data);
867
868   PanGestureDetector detector = PanGestureDetector::New();
869   detector.Attach(actor);
870   detector.DetectedSignal().Connect(&application, functor);
871
872   // Do an entire pan, only check finished value
873   uint32_t time = 100;
874   TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
875
876   data.Reset();
877
878   TestEndPan(application, Vector2(25.0f, 28.0f), time);
879
880   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
881   DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
882
883   // Rotate actor again and render a couple of times
884   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS));
885   application.SendNotification();
886   application.Render();
887
888   // Do an entire pan, only check finished value
889   TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
890
891   data.Reset();
892
893   TestEndPan(application, Vector2(25.0f, 28.0f), time);
894
895   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
896   DALI_TEST_EQUALS(Vector2(2.0f, -16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
897
898   // Rotate actor again and render a couple of times
899   actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS));
900   application.SendNotification();
901   application.Render();
902
903   // Do an entire pan, only check finished value
904   TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
905
906   data.Reset();
907
908   TestEndPan(application, Vector2(25.0f, 28.0f), time);
909
910   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
911   DALI_TEST_EQUALS(Vector2(-16.0f, -2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
912   END_TEST;
913 }
914
915 int UtcDaliPanGestureSignalReceptionChildHit(void)
916 {
917   TestApplication application;
918
919   Actor parent = Actor::New();
920   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
921   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
922   application.GetScene().Add(parent);
923
924   // Set child to completely cover parent.
925   // Change rotation of child to be different from parent so that we can check if our local coordinate
926   // conversion of the parent actor is correct.
927   Actor child = Actor::New();
928   child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
929   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
930   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
931   child.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
932   parent.Add(child);
933
934   // Render and notify
935   application.SendNotification();
936   application.Render();
937
938   SignalData             data;
939   GestureReceivedFunctor functor(data);
940
941   PanGestureDetector detector = PanGestureDetector::New();
942   detector.Attach(parent);
943   detector.DetectedSignal().Connect(&application, functor);
944
945   // Do an entire pan, only check finished value - hits child area but parent should still receive it
946   uint32_t time = 100;
947   TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
948
949   data.Reset();
950
951   TestEndPan(application, Vector2(25.0f, 28.0f), time);
952
953   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
954   DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION);
955   DALI_TEST_EQUALS(Vector2(-2.0f, 16.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
956
957   // Attach child and generate same touch points to yield a different displacement
958   // (Also proves that you can detach and then re-attach another actor)
959   detector.Attach(child);
960   detector.Detach(parent);
961
962   // Do an entire pan, only check finished value
963   TestStartPan(application, Vector2(11.0f, 12.0f), Vector2(27.0f, 12.0f), time);
964
965   data.Reset();
966
967   TestEndPan(application, Vector2(25.0f, 28.0f), time);
968
969   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
970   DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION);
971   DALI_TEST_EQUALS(Vector2(16.0f, 2.0f), data.receivedGesture.GetDisplacement(), 0.01f, TEST_LOCATION); // Actor relative
972   END_TEST;
973 }
974
975 int UtcDaliPanGestureSignalReceptionAttachDetachMany(void)
976 {
977   TestApplication application;
978
979   Actor first = Actor::New();
980   first.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
981   first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
982   application.GetScene().Add(first);
983
984   Actor second = Actor::New();
985   second.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
986   second.SetProperty(Actor::Property::POSITION_X, 100.0f);
987   second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
988   application.GetScene().Add(second);
989
990   // Render and notify
991   application.SendNotification();
992   application.Render();
993
994   SignalData             data;
995   GestureReceivedFunctor functor(data);
996
997   PanGestureDetector detector = PanGestureDetector::New();
998   detector.Attach(first);
999   detector.Attach(second);
1000   detector.DetectedSignal().Connect(&application, functor);
1001
1002   DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), first.GetParent(), TEST_LOCATION);
1003   DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), second.GetParent(), TEST_LOCATION);
1004
1005   // Start pan within second actor's area
1006   uint32_t time = 100;
1007   TestStartPan(application, Vector2(110.0f, 20.0f), Vector2(126.0f, 20.0f), time);
1008
1009   DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), first.GetParent(), TEST_LOCATION);
1010   DALI_TEST_EQUALS(application.GetScene().GetRootLayer(), second.GetParent(), TEST_LOCATION);
1011
1012   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1013   DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1014
1015   // Pan moves into first actor's area - second actor should receive the pan
1016   data.Reset();
1017
1018   TestMovePan(application, Vector2(126.0f, 20.0f), time);
1019   time += TestGetFrameInterval();
1020
1021   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1022   DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION);
1023
1024   // Detach the second actor during the pan, we should not receive the next event
1025   detector.Detach(second);
1026
1027   // Gesture ends within actor's area
1028   data.Reset();
1029
1030   TestMovePan(application, Vector2(26.0f, 20.0f), time);
1031   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1032
1033   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1034
1035   END_TEST;
1036 }
1037
1038 int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void)
1039 {
1040   TestApplication application;
1041
1042   Actor actor = Actor::New();
1043   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1044   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1045   application.GetScene().Add(actor);
1046
1047   // Render and notify
1048   application.SendNotification();
1049   application.Render();
1050
1051   SignalData             data;
1052   GestureReceivedFunctor functor(data);
1053
1054   PanGestureDetector detector = PanGestureDetector::New();
1055   detector.Attach(actor);
1056   detector.DetectedSignal().Connect(&application, functor);
1057
1058   // Start pan in actor's area
1059   uint32_t time = 100;
1060   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1061
1062   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1063
1064   // Pan continues within actor's area
1065   data.Reset();
1066
1067   TestMovePan(application, Vector2(26.0f, 4.0f), time);
1068   time += TestGetFrameInterval();
1069
1070   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1071
1072   // Actor become invisible - actor should not receive the next pan
1073   actor.SetProperty(Actor::Property::VISIBLE, false);
1074
1075   // Render and notify
1076   application.SendNotification();
1077   application.Render();
1078
1079   // Gesture ends within actor's area
1080   data.Reset();
1081
1082   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1083
1084   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1085   END_TEST;
1086 }
1087
1088 int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void)
1089 {
1090   TestApplication application;
1091
1092   Actor actor = Actor::New();
1093   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1094   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1095   application.GetScene().Add(actor);
1096
1097   Actor actor2 = Actor::New();
1098   actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1099   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
1100   application.GetScene().Add(actor2);
1101
1102   // Render and notify
1103   application.SendNotification();
1104   application.Render();
1105
1106   // Attach actor to one detector
1107   SignalData             firstData;
1108   GestureReceivedFunctor firstFunctor(firstData);
1109   PanGestureDetector     firstDetector = PanGestureDetector::New();
1110   firstDetector.Attach(actor);
1111   firstDetector.DetectedSignal().Connect(&application, firstFunctor);
1112
1113   // Attach actor to another detector
1114   SignalData             secondData;
1115   GestureReceivedFunctor secondFunctor(secondData);
1116   PanGestureDetector     secondDetector = PanGestureDetector::New();
1117   secondDetector.Attach(actor);
1118   secondDetector.DetectedSignal().Connect(&application, secondFunctor);
1119
1120   // Add second actor to second detector, when we remove the actor, this will make sure that this
1121   // gesture detector is not removed from the GestureDetectorProcessor.  In this scenario, the
1122   // functor should still not be called (which is what we're also testing).
1123   secondDetector.Attach(actor2);
1124
1125   // Pan in actor's area - both detector's functors should be called
1126   uint32_t time = 100;
1127   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1128
1129   DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1130   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1131
1132   // Pan continues in actor's area - both detector's functors should be called
1133   firstData.Reset();
1134   secondData.Reset();
1135
1136   TestMovePan(application, Vector2(10.0f, 20.0f), time);
1137   time += TestGetFrameInterval();
1138
1139   DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
1140   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1141
1142   // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called.
1143   firstDetector.Detach(actor);
1144   firstData.Reset();
1145   secondData.Reset();
1146
1147   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1148
1149   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1150   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1151
1152   // New pan on actor, only secondDetector has actor attached
1153   firstData.Reset();
1154   secondData.Reset();
1155
1156   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1157
1158   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1159   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1160
1161   // Detach actor from secondDetector
1162   secondDetector.Detach(actor);
1163   firstData.Reset();
1164   secondData.Reset();
1165
1166   TestMovePan(application, Vector2(10.0f, 20.0f), time);
1167
1168   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
1169   DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
1170
1171   END_TEST;
1172 }
1173
1174 int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void)
1175 {
1176   TestApplication application;
1177
1178   Actor actor1 = Actor::New();
1179   actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1180   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1181   application.GetScene().Add(actor1);
1182   SignalData             data1;
1183   GestureReceivedFunctor functor1(data1);
1184   PanGestureDetector     detector1 = PanGestureDetector::New();
1185   detector1.Attach(actor1);
1186   detector1.DetectedSignal().Connect(&application, functor1);
1187
1188   Actor actor2 = Actor::New();
1189   actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1190   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
1191   actor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT);
1192   application.GetScene().Add(actor2);
1193   SignalData             data2;
1194   GestureReceivedFunctor functor2(data2);
1195   PanGestureDetector     detector2 = PanGestureDetector::New();
1196   detector2.Attach(actor2);
1197   detector2.DetectedSignal().Connect(&application, functor2);
1198
1199   // Render and notify
1200   application.SendNotification();
1201   application.Render();
1202
1203   // Start pan in actor1's area, only data1 should be set
1204   uint32_t time = 100;
1205   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1206
1207   DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
1208   DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
1209   END_TEST;
1210 }
1211
1212 int UtcDaliPanGestureSignalReceptionAttachActorAfterDown(void)
1213 {
1214   // This test checks to ensure a pan is possible after attaching an actor after a down (possible) event
1215
1216   TestApplication application;
1217
1218   Actor actor = Actor::New();
1219   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1220   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1221   application.GetScene().Add(actor);
1222
1223   // Render and notify
1224   application.SendNotification();
1225   application.Render();
1226
1227   // Gesture possible in actor's area (using long-press)
1228   uint32_t time = 100;
1229   TestStartLongPress(application, 10.0f, 20.0f, time);
1230   time += TestGetFrameInterval();
1231
1232   // Attach actor to detector
1233   SignalData             data;
1234   GestureReceivedFunctor functor(data);
1235   PanGestureDetector     detector = PanGestureDetector::New();
1236   detector.DetectedSignal().Connect(&application, functor);
1237   detector.Attach(actor);
1238
1239   // Start a pan, initially it'll only be possible, we shouldn't receive it
1240   TestMovePan(application, Vector2(10.0f, 20.0f), time);
1241   time += TestGetFrameInterval();
1242   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1243
1244   // Now the pan truly starts, we should receive a signal
1245   TestMovePan(application, Vector2(26.0f, 20.0f), time);
1246   time += TestGetFrameInterval();
1247   TestMovePan(application, Vector2(32.0f, 32.0f), time);
1248   time += TestGetFrameInterval();
1249   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1250
1251   // Finish the pan, we should still receive a signal
1252   data.Reset();
1253   TestEndPan(application, Vector2(32.0f, 32.0f), time);
1254   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1255
1256   END_TEST;
1257 }
1258
1259 int UtcDaliPanGestureSignalReceptionAttachActorAfterDownAfterInitialPanToAnotherActor(void)
1260 {
1261   // This test checks to ensure a pan is possible after attaching an actor after a down (possible) event even if another
1262   // pan actor was there before (parent)
1263
1264   TestApplication application;
1265
1266   Actor parent = Actor::New();
1267   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1268   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1269   application.GetScene().Add(parent);
1270
1271   Actor child = Actor::New();
1272   child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1273   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1274   child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1275   parent.Add(child);
1276
1277   // Create detector for parent and attach
1278   SignalData             parentData;
1279   GestureReceivedFunctor parentFunctor(parentData);
1280   PanGestureDetector     parentDetector = PanGestureDetector::New();
1281   parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1282   parentDetector.Attach(parent);
1283
1284   // Create detector for child but do not attach
1285   SignalData             childData;
1286   GestureReceivedFunctor childFunctor(childData);
1287   PanGestureDetector     childDetector = PanGestureDetector::New();
1288   childDetector.DetectedSignal().Connect(&application, childFunctor);
1289
1290   // Render and notify
1291   application.SendNotification();
1292   application.Render();
1293
1294   // Do a full pan in both actors' area, only the parent's functor should be called
1295   uint32_t time = 100;
1296   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1297   DALI_TEST_EQUALS(parentData.functorCalled, true, TEST_LOCATION);
1298   DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1299   parentData.Reset();
1300   childData.Reset();
1301   TestEndPan(application, Vector2(26.0f, 20.0f), time);
1302   DALI_TEST_EQUALS(parentData.functorCalled, true, TEST_LOCATION);
1303   DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1304   parentData.Reset();
1305   childData.Reset();
1306
1307   // Gesture possible in both actors' area (using long-press), no functors called
1308   TestStartLongPress(application, 10.0f, 20.0f, time);
1309   time += TestGetFrameInterval();
1310   DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1311   DALI_TEST_EQUALS(childData.functorCalled, false, TEST_LOCATION);
1312
1313   // Attach the child as well now
1314   childDetector.Attach(child);
1315
1316   // Now the pan truly starts, we should receive a signal for the child only
1317   TestMovePan(application, Vector2(26.0f, 20.0f), time);
1318   time += TestGetFrameInterval();
1319   TestMovePan(application, Vector2(32.0f, 32.0f), time);
1320   time += TestGetFrameInterval();
1321   DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1322   DALI_TEST_EQUALS(childData.functorCalled, true, TEST_LOCATION);
1323   parentData.Reset();
1324   childData.Reset();
1325
1326   // Finish the pan, again only the child should still receive a signal
1327   TestEndPan(application, Vector2(32.0f, 32.0f), time);
1328   DALI_TEST_EQUALS(parentData.functorCalled, false, TEST_LOCATION);
1329   DALI_TEST_EQUALS(childData.functorCalled, true, TEST_LOCATION);
1330
1331   END_TEST;
1332 }
1333
1334 int UtcDaliPanGestureSignalReceptionDifferentPossible(void)
1335 {
1336   TestApplication application;
1337
1338   Actor actor = Actor::New();
1339   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1340   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1341   application.GetScene().Add(actor);
1342
1343   // Render and notify
1344   application.SendNotification();
1345   application.Render();
1346
1347   // Attach actor to detector
1348   SignalData             data;
1349   GestureReceivedFunctor functor(data);
1350   PanGestureDetector     detector = PanGestureDetector::New();
1351   detector.Attach(actor);
1352   detector.DetectedSignal().Connect(&application, functor);
1353
1354   // Gesture possible in actor's area.
1355   uint32_t time = 100;
1356   TestStartLongPress(application, 10.0f, 20.0f, time);
1357   time += TestGetFrameInterval();
1358
1359   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1360
1361   // Move actor somewhere else
1362   actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
1363
1364   // Render and notify
1365   application.SendNotification();
1366   application.Render();
1367
1368   // Emit STARTED event, we should not receive the pan.
1369   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1370   TestEndPan(application, Vector2(26.0f, 20.0f), time);
1371   time += TestGetFrameInterval();
1372
1373   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1374
1375   // LONG_PRESS possible in empty area.
1376   TestStartLongPress(application, 10.0f, 20.0f, time);
1377   time += TestGetFrameInterval();
1378
1379   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1380
1381   // Move actor in to the long press position.
1382   actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
1383
1384   // Render and notify
1385   application.SendNotification();
1386   application.Render();
1387
1388   // Emit STARTED event, we should be receiving the pan now.
1389   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1390   TestEndPan(application, Vector2(26.0f, 20.0f), time);
1391   time += TestGetFrameInterval();
1392
1393   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1394
1395   // Normal pan in actor's area for completeness.
1396   data.Reset();
1397   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1398   TestEndPan(application, Vector2(26.0f, 20.0f), time);
1399   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1400   END_TEST;
1401 }
1402
1403 int UtcDaliPanGestureActorUnstaged(void)
1404 {
1405   TestApplication application;
1406
1407   Actor actor = Actor::New();
1408   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1409   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1410   application.GetScene().Add(actor);
1411
1412   // Render and notify
1413   application.SendNotification();
1414   application.Render();
1415
1416   // State to remove actor in.
1417   GestureState stateToUnstage(GestureState::STARTED);
1418
1419   // Attach actor to detector
1420   SignalData          data;
1421   UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
1422   PanGestureDetector  detector = PanGestureDetector::New();
1423   detector.Attach(actor);
1424   detector.DetectedSignal().Connect(&application, functor);
1425
1426   // Emit signals
1427   uint32_t time = 100;
1428   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1429
1430   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1431   data.Reset();
1432
1433   TestEndPan(application, Vector2(26.0f, 20.0f), time);
1434
1435   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1436   data.Reset();
1437
1438   // Render and notify
1439   application.SendNotification();
1440   application.Render();
1441
1442   // Re-add actor to stage
1443   application.GetScene().Add(actor);
1444
1445   // Render and notify
1446   application.SendNotification();
1447   application.Render();
1448
1449   // Change state to GestureState::CONTINUING to remove
1450   stateToUnstage = GestureState::CONTINUING;
1451
1452   // Emit signals
1453   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1454
1455   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1456   data.Reset();
1457
1458   TestMovePan(application, Vector2(26.0f, 4.0f), time);
1459   time += TestGetFrameInterval();
1460
1461   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1462
1463   data.Reset();
1464
1465   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1466
1467   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1468   data.Reset();
1469
1470   // Render and notify
1471   application.SendNotification();
1472   application.Render();
1473
1474   // Re-add actor to stage
1475   application.GetScene().Add(actor);
1476
1477   // Render and notify
1478   application.SendNotification();
1479   application.Render();
1480
1481   // Change state to GestureState::FINISHED to remove
1482   stateToUnstage = GestureState::FINISHED;
1483
1484   // Emit signals
1485   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1486
1487   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1488   data.Reset();
1489
1490   TestMovePan(application, Vector2(26.0f, 4.0f), time);
1491   time += TestGetFrameInterval();
1492
1493   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1494   data.Reset();
1495
1496   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1497
1498   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1499   tet_result(TET_PASS); // If we get here then we have handled actor stage removal gracefully.
1500   END_TEST;
1501 }
1502
1503 int UtcDaliPanGestureActorStagedAndDestroyed(void)
1504 {
1505   TestApplication application;
1506
1507   Actor actor = Actor::New();
1508   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1509   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1510   application.GetScene().Add(actor);
1511
1512   // Create and add a second actor so that GestureDetector destruction does not come into play.
1513   Actor dummyActor(Actor::New());
1514   dummyActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1515   dummyActor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
1516   dummyActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1517   application.GetScene().Add(dummyActor);
1518
1519   // Render and notify
1520   application.SendNotification();
1521   application.Render();
1522
1523   // State to remove actor in.
1524   GestureState stateToUnstage(GestureState::STARTED);
1525
1526   // Attach actor to detector
1527   SignalData          data;
1528   UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
1529   PanGestureDetector  detector = PanGestureDetector::New();
1530   detector.Attach(actor);
1531   detector.Attach(dummyActor);
1532   detector.DetectedSignal().Connect(&application, functor);
1533
1534   // Here we are testing a STARTED actor which is removed in the STARTED callback, but then added back
1535   // before we get a continuing state.  As we were removed from the stage, even if we're at the same
1536   // position, we should still not be signalled.
1537
1538   // Emit signals
1539   uint32_t time = 100;
1540   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1541
1542   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1543   data.Reset();
1544
1545   // Render and notify
1546   application.SendNotification();
1547   application.Render();
1548
1549   // Re add to the stage, we should not be signalled
1550   application.GetScene().Add(actor);
1551
1552   // Render and notify
1553   application.SendNotification();
1554   application.Render();
1555
1556   // Continue signal emission
1557   TestMovePan(application, Vector2(26.0f, 4.0f), time);
1558   time += TestGetFrameInterval();
1559
1560   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1561   data.Reset();
1562
1563   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1564   time += TestGetFrameInterval();
1565
1566   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1567   data.Reset();
1568
1569   // Here we delete an actor in started, we should not receive any subsequent signalling.
1570
1571   // Emit signals
1572   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
1573
1574   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1575   data.Reset();
1576
1577   // Render and notify
1578   application.SendNotification();
1579   application.Render();
1580
1581   // Delete actor as well
1582   actor.Reset();
1583
1584   // Render and notify
1585   application.SendNotification();
1586   application.Render();
1587
1588   // Continue signal emission
1589   TestMovePan(application, Vector2(26.0f, 4.0f), time);
1590   time += TestGetFrameInterval();
1591
1592   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1593   data.Reset();
1594
1595   TestEndPan(application, Vector2(10.0f, 4.0f), time);
1596
1597   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1598   END_TEST;
1599 }
1600
1601 int UtcDaliPanGestureAngleHandling(void)
1602 {
1603   TestApplication application;
1604
1605   PanGestureDetector detector = PanGestureDetector::New();
1606   DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1607
1608   detector.AddAngle(PanGestureDetector::DIRECTION_LEFT, Radian(Math::PI * 0.25));
1609   DALI_TEST_EQUALS(detector.GetAngleCount(), 1u, TEST_LOCATION);
1610   bool found = false;
1611   for(size_t i = 0; i < detector.GetAngleCount(); i++)
1612   {
1613     if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT)
1614     {
1615       tet_result(TET_PASS);
1616       found = true;
1617       break;
1618     }
1619   }
1620
1621   if(!found)
1622   {
1623     tet_printf("%s, angle not added\n", TEST_LOCATION);
1624     tet_result(TET_FAIL);
1625   }
1626
1627   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Radian(Math::PI * 0.25));
1628   DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1629
1630   // Remove something not in the container.
1631   detector.RemoveAngle(PanGestureDetector::DIRECTION_UP);
1632   DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1633
1634   detector.RemoveAngle(PanGestureDetector::DIRECTION_RIGHT);
1635   DALI_TEST_EQUALS(detector.GetAngleCount(), 1u, TEST_LOCATION);
1636   for(size_t i = 0; i < detector.GetAngleCount(); i++)
1637   {
1638     if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT)
1639     {
1640       tet_printf("%s, angle not removed\n", TEST_LOCATION);
1641       tet_result(TET_FAIL);
1642       break;
1643     }
1644   }
1645
1646   detector.ClearAngles();
1647   DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1648   END_TEST;
1649 }
1650
1651 int UtcDaliPanGestureGetAngle(void)
1652 {
1653   TestApplication application;
1654
1655   PanGestureDetector detector = PanGestureDetector::New();
1656   DALI_TEST_EQUALS(detector.GetAngleCount(), 0, TEST_LOCATION);
1657
1658   detector.AddAngle(PanGestureDetector::DIRECTION_LEFT);
1659   DALI_TEST_EQUALS(detector.GetAngleCount(), 1, TEST_LOCATION);
1660
1661   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT);
1662   DALI_TEST_EQUALS(detector.GetAngleCount(), 2, TEST_LOCATION);
1663
1664   detector.AddAngle(PanGestureDetector::DIRECTION_UP);
1665   DALI_TEST_EQUALS(detector.GetAngleCount(), 3, TEST_LOCATION);
1666
1667   detector.AddAngle(PanGestureDetector::DIRECTION_DOWN);
1668   DALI_TEST_EQUALS(detector.GetAngleCount(), 4, TEST_LOCATION);
1669
1670   DALI_TEST_EQUALS(detector.GetAngle(0).first, PanGestureDetector::DIRECTION_LEFT, TEST_LOCATION);
1671   DALI_TEST_EQUALS(detector.GetAngle(1).first, PanGestureDetector::DIRECTION_RIGHT, TEST_LOCATION);
1672   DALI_TEST_EQUALS(detector.GetAngle(2).first, PanGestureDetector::DIRECTION_UP, TEST_LOCATION);
1673   DALI_TEST_EQUALS(detector.GetAngle(3).first, PanGestureDetector::DIRECTION_DOWN, TEST_LOCATION);
1674
1675   END_TEST;
1676 }
1677
1678 inline float RadiansToDegrees(float radian)
1679 {
1680   return radian * 180.0f / Math::PI;
1681 }
1682
1683 int UtcDaliPanGestureAngleOutOfRange(void)
1684 {
1685   TestApplication application;
1686
1687   PanGestureDetector detector = PanGestureDetector::New();
1688   DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1689
1690   //
1691   // Angle
1692   //
1693
1694   detector.AddAngle(Degree(180.0f));
1695   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-180.0f)), 0.000001, TEST_LOCATION);
1696   detector.ClearAngles();
1697
1698   detector.AddAngle(Degree(190.0f));
1699   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-170.0f)), 0.000001, TEST_LOCATION);
1700   detector.ClearAngles();
1701
1702   detector.AddAngle(Degree(-190.0f));
1703   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(170.0f)), 0.000001, TEST_LOCATION);
1704   detector.ClearAngles();
1705
1706   detector.AddAngle(Degree(350.0f));
1707   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-10.0f)), 0.000001, TEST_LOCATION);
1708   detector.ClearAngles();
1709
1710   detector.AddAngle(Degree(-350.0f));
1711   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1712   detector.ClearAngles();
1713
1714   detector.AddAngle(Degree(370.0f));
1715   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1716   detector.ClearAngles();
1717
1718   detector.AddAngle(Degree(-370.0f));
1719   DALI_TEST_EQUALS(detector.GetAngle(0).first, Radian(Degree(-10.0f)), 0.000001, TEST_LOCATION);
1720   detector.ClearAngles();
1721
1722   //
1723   // Threshold
1724   //
1725
1726   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(0.0f));
1727   DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(0.0f)), 0.000001, TEST_LOCATION);
1728   detector.ClearAngles();
1729
1730   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(-10.0f));
1731   DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(10.0f)), 0.000001, TEST_LOCATION);
1732   detector.ClearAngles();
1733
1734   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(-181.0f));
1735   DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(180.0f)), 0.000001, TEST_LOCATION);
1736   detector.ClearAngles();
1737
1738   detector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(181.0f));
1739   DALI_TEST_EQUALS(detector.GetAngle(0).second, Radian(Degree(180.0f)), 0.000001, TEST_LOCATION);
1740   detector.ClearAngles();
1741   END_TEST;
1742 }
1743
1744 int UtcDaliPanGestureAngleProcessing(void)
1745 {
1746   TestApplication application;
1747
1748   Actor parent = Actor::New();
1749   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1750   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1751   application.GetScene().Add(parent);
1752
1753   Actor child = Actor::New();
1754   child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1755   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1756   parent.Add(child);
1757
1758   // Render and notify
1759   application.SendNotification();
1760   application.Render();
1761
1762   // Parent detector only requires up pans
1763   PanGestureDetector parentDetector = PanGestureDetector::New();
1764   parentDetector.Attach(parent);
1765   parentDetector.AddAngle(PanGestureDetector::DIRECTION_UP, Degree(30.0f));
1766   SignalData             parentData;
1767   GestureReceivedFunctor parentFunctor(parentData);
1768   parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1769
1770   // Child detector only requires right pans
1771   PanGestureDetector childDetector = PanGestureDetector::New();
1772   childDetector.Attach(child);
1773   childDetector.AddAngle(PanGestureDetector::DIRECTION_RIGHT, Degree(30.0f));
1774   SignalData             childData;
1775   GestureReceivedFunctor childFunctor(childData);
1776   childDetector.DetectedSignal().Connect(&application, childFunctor);
1777
1778   // Generate an Up pan gesture, only parent should receive it.
1779   uint32_t time = 100;
1780   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 4.0f), time);
1781
1782   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1783   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1784
1785   TestEndPan(application, Vector2(20.0f, 4.0f), time);
1786   time += TestGetFrameInterval();
1787   parentData.Reset();
1788   childData.Reset();
1789
1790   // Generate a Right pan gesture, only child should receive it.
1791   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(36.0f, 20.0f), time);
1792
1793   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1794   DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1795
1796   TestEndPan(application, Vector2(4.0f, 20.0f), time);
1797   time += TestGetFrameInterval();
1798   parentData.Reset();
1799   childData.Reset();
1800
1801   // Generate a Down pan gesture, no one should receive it.
1802   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 36.0f), time);
1803
1804   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1805   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1806
1807   TestEndPan(application, Vector2(20.0f, 36.0f), time);
1808   time += TestGetFrameInterval();
1809   parentData.Reset();
1810   childData.Reset();
1811
1812   // Generate a Left pan gesture, no one should receive it.
1813   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 20.0f), time);
1814
1815   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1816   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1817
1818   TestEndPan(application, Vector2(4.0f, 20.0f), time);
1819   parentData.Reset();
1820   childData.Reset();
1821   END_TEST;
1822 }
1823
1824 int UtcDaliPanGestureDirectionHandling(void)
1825 {
1826   TestApplication application;
1827
1828   PanGestureDetector detector = PanGestureDetector::New();
1829   DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1830
1831   detector.AddDirection(PanGestureDetector::DIRECTION_LEFT, Radian(Math::PI * 0.25));
1832   DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1833   bool found = false;
1834   for(size_t i = 0; detector.GetAngleCount(); i++)
1835   {
1836     if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_LEFT)
1837     {
1838       tet_result(TET_PASS);
1839       found = true;
1840       break;
1841     }
1842   }
1843
1844   if(!found)
1845   {
1846     tet_printf("%s, angle not added\n", TEST_LOCATION);
1847     tet_result(TET_FAIL);
1848   }
1849
1850   found = false;
1851   for(size_t i = 0; i < detector.GetAngleCount(); i++)
1852   {
1853     if(detector.GetAngle(i).first == PanGestureDetector::DIRECTION_RIGHT)
1854     {
1855       tet_result(TET_PASS);
1856       found = true;
1857       break;
1858     }
1859   }
1860
1861   if(!found)
1862   {
1863     tet_printf("%s, angle not added\n", TEST_LOCATION);
1864     tet_result(TET_FAIL);
1865   }
1866
1867   // Remove something not in the container.
1868   detector.RemoveDirection(PanGestureDetector::DIRECTION_UP);
1869   DALI_TEST_EQUALS(detector.GetAngleCount(), 2u, TEST_LOCATION);
1870
1871   detector.RemoveDirection(PanGestureDetector::DIRECTION_RIGHT);
1872   DALI_TEST_EQUALS(detector.GetAngleCount(), 0u, TEST_LOCATION);
1873   END_TEST;
1874 }
1875
1876 int UtcDaliPanGestureDirectionProcessing(void)
1877 {
1878   TestApplication application;
1879
1880   Actor parent = Actor::New();
1881   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1882   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1883   application.GetScene().Add(parent);
1884
1885   Actor child = Actor::New();
1886   child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1887   child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1888   parent.Add(child);
1889
1890   // Render and notify
1891   application.SendNotification();
1892   application.Render();
1893
1894   // Parent detector only requires vertical panning
1895   PanGestureDetector parentDetector = PanGestureDetector::New();
1896   parentDetector.Attach(parent);
1897   parentDetector.AddDirection(PanGestureDetector::DIRECTION_VERTICAL, Degree(30.0f));
1898   SignalData             parentData;
1899   GestureReceivedFunctor parentFunctor(parentData);
1900   parentDetector.DetectedSignal().Connect(&application, parentFunctor);
1901
1902   // Child detector only requires horizontal panning
1903   PanGestureDetector childDetector = PanGestureDetector::New();
1904   childDetector.Attach(child);
1905   childDetector.AddDirection(PanGestureDetector::DIRECTION_HORIZONTAL, Degree(30.0f));
1906   SignalData             childData;
1907   GestureReceivedFunctor childFunctor(childData);
1908   childDetector.DetectedSignal().Connect(&application, childFunctor);
1909
1910   // Generate an Up pan gesture, only parent should receive it.
1911   uint32_t time = 100;
1912   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 4.0f), time);
1913
1914   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1915   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1916
1917   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1918   time += TestGetFrameInterval();
1919   parentData.Reset();
1920   childData.Reset();
1921
1922   // Generate a Right pan gesture, only child should receive it.
1923   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(36.0f, 20.0f), time);
1924
1925   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1926   DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1927
1928   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1929   time += TestGetFrameInterval();
1930   parentData.Reset();
1931   childData.Reset();
1932
1933   // Generate a Down pan gesture, only parent should receive it.
1934   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(20.0f, 36.0f), time);
1935
1936   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1937   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1938
1939   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1940   time += TestGetFrameInterval();
1941   parentData.Reset();
1942   childData.Reset();
1943
1944   // Generate a Left pan gesture, only child should receive it.
1945   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 20.0f), time);
1946
1947   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1948   DALI_TEST_EQUALS(true, childData.functorCalled, TEST_LOCATION);
1949
1950   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1951   time += TestGetFrameInterval();
1952   parentData.Reset();
1953   childData.Reset();
1954
1955   // Generate a pan at -45 degrees, no one should receive it.
1956   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(9.0f, 31.0f), time);
1957
1958   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1959   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1960
1961   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1962   time += TestGetFrameInterval();
1963   parentData.Reset();
1964   childData.Reset();
1965
1966   // Generate a pan at 45 degrees, no one should receive it.
1967   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(31.0f, 31.0f), time);
1968
1969   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1970   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1971
1972   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1973   time += TestGetFrameInterval();
1974   parentData.Reset();
1975   childData.Reset();
1976
1977   // Generate a pan at -135 degrees, no one should receive it.
1978   TestStartPan(application, Vector2(20.0f, 20.0f), Vector2(4.0f, 4.0f), time);
1979
1980   DALI_TEST_EQUALS(false, parentData.functorCalled, TEST_LOCATION);
1981   DALI_TEST_EQUALS(false, childData.functorCalled, TEST_LOCATION);
1982
1983   TestEndPan(application, Vector2(20.0f, 20.0f), time);
1984   parentData.Reset();
1985   childData.Reset();
1986   END_TEST;
1987 }
1988
1989 int UtcDaliPanGestureNoPredictionNoSmoothing(void)
1990 {
1991   TestApplication application;
1992   Integration::SetPanGesturePredictionMode(0);
1993   Integration::SetPanGestureSmoothingMode(0);
1994
1995   Actor actor = Actor::New();
1996   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1997   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1998   application.GetScene().Add(actor);
1999
2000   // Add a pan detector
2001   PanGestureDetector detector = PanGestureDetector::New();
2002   detector.Attach(actor);
2003   SignalData             data;
2004   GestureReceivedFunctor functor(data);
2005   detector.DetectedSignal().Connect(&application, functor);
2006
2007   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2008
2009   ConstraintData constraintData;
2010   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2011   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2012   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2013   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2014   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2015   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2016   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2017   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2018   constraint.Apply();
2019
2020   // Render and notify
2021   application.SendNotification();
2022   application.Render();
2023
2024   Vector2  startPosition(1.0f, 1.0f);
2025   Vector2  position(-14.0f, 1.0f);
2026   Vector2  direction(Vector2::XAXIS * -5.0f);
2027   uint32_t time = 100;
2028
2029   TestStartPan(application, startPosition, position, time);
2030
2031   for(int i = 0; i < 47; i++)
2032   {
2033     position += direction;
2034     TestMovePan(application, position, time);
2035     time += TestGetFrameInterval();
2036     application.SendNotification();
2037     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2038   }
2039
2040   TestEndPan(application, position, time);
2041   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2042
2043   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2044   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2045   DALI_TEST_EQUALS(constraintData.screenPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION);
2046   DALI_TEST_EQUALS(constraintData.localPosition, startPosition + (direction * PAN_GESTURE_UPDATE_COUNT), 0.1f, TEST_LOCATION);
2047
2048   constraintData.Reset();
2049   END_TEST;
2050 }
2051
2052 int UtcDaliPanGestureNoPredictionSmoothing(void)
2053 {
2054   TestApplication application;
2055   Integration::SetPanGesturePredictionMode(0);
2056   Integration::SetPanGestureSmoothingMode(1);
2057
2058   Actor actor = Actor::New();
2059   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2060   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2061   application.GetScene().Add(actor);
2062
2063   // Add a pan detector
2064   PanGestureDetector detector = PanGestureDetector::New();
2065   detector.Attach(actor);
2066   SignalData             data;
2067   GestureReceivedFunctor functor(data);
2068   detector.DetectedSignal().Connect(&application, functor);
2069
2070   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2071
2072   ConstraintData constraintData;
2073   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2074   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2075   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2076   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2077   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2078   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2079   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2080   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2081   constraint.Apply();
2082
2083   // Render and notify
2084   application.SendNotification();
2085   application.Render();
2086
2087   Vector2  startPosition(1.0f, 1.0f);
2088   Vector2  position(-14.0f, 1.0f);
2089   Vector2  direction(Vector2::XAXIS * -5.0f);
2090   uint32_t time = 100;
2091
2092   TestStartPan(application, startPosition, position, time);
2093
2094   for(int i = 0; i < 47; i++)
2095   {
2096     position += direction;
2097     TestMovePan(application, position, time);
2098     time += TestGetFrameInterval();
2099     application.SendNotification();
2100     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2101   }
2102
2103   TestEndPan(application, position, time);
2104   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2105
2106   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2107   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2108   // Take into account resampling done when prediction is off.
2109   DALI_TEST_EQUALS(constraintData.screenPosition, startPosition + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION);
2110   DALI_TEST_EQUALS(constraintData.localPosition, startPosition + (direction * (PAN_GESTURE_UPDATE_COUNT - 0.25f)), 0.15f, TEST_LOCATION);
2111
2112   constraintData.Reset();
2113   END_TEST;
2114 }
2115
2116 int UtcDaliPanGesturePredictionNoSmoothing(void)
2117 {
2118   TestApplication application;
2119   Integration::SetPanGesturePredictionMode(1);
2120   Integration::SetPanGestureSmoothingMode(0);
2121
2122   Actor actor = Actor::New();
2123   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2124   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2125   application.GetScene().Add(actor);
2126
2127   // Add a pan detector
2128   PanGestureDetector detector = PanGestureDetector::New();
2129   detector.Attach(actor);
2130   SignalData             data;
2131   GestureReceivedFunctor functor(data);
2132   detector.DetectedSignal().Connect(&application, functor);
2133
2134   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2135
2136   ConstraintData constraintData;
2137   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2138   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2139   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2140   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2141   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2142   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2143   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2144   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2145   constraint.Apply();
2146
2147   // Render and notify
2148   application.SendNotification();
2149   application.Render();
2150
2151   Vector2  startPosition(1.0f, 1.0f);
2152   Vector2  position(-1.0f, 1.0f);
2153   Vector2  direction(Vector2::XAXIS * -1.0f);
2154   uint32_t time = 100;
2155
2156   TestStartPan(application, startPosition, position, time);
2157
2158   for(int i = 0; i < 47; i++)
2159   {
2160     position += direction;
2161     TestMovePan(application, position, time);
2162     time += TestGetFrameInterval();
2163     application.SendNotification();
2164     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2165   }
2166
2167   TestEndPan(application, position, time);
2168   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2169
2170   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2171   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2172   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2173   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2174
2175   constraintData.Reset();
2176   END_TEST;
2177 }
2178
2179 int UtcDaliPanGesturePredictionSmoothing01(void)
2180 {
2181   TestApplication application;
2182   Integration::SetPanGesturePredictionMode(1);
2183   Integration::SetPanGestureSmoothingMode(1);
2184
2185   Actor actor = Actor::New();
2186   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2187   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2188   application.GetScene().Add(actor);
2189
2190   // Add a pan detector
2191   PanGestureDetector detector = PanGestureDetector::New();
2192   detector.Attach(actor);
2193   SignalData             data;
2194   GestureReceivedFunctor functor(data);
2195   detector.DetectedSignal().Connect(&application, functor);
2196
2197   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2198
2199   ConstraintData constraintData;
2200   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2201   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2202   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2203   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2204   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2205   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2206   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2207   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2208   constraint.Apply();
2209
2210   // Render and notify
2211   application.SendNotification();
2212   application.Render();
2213
2214   Vector2  startPosition(1.0f, 1.0f);
2215   Vector2  position(-1.0f, 1.0f);
2216   Vector2  direction(Vector2::XAXIS * -1.0f);
2217   uint32_t time = 100;
2218
2219   TestStartPan(application, startPosition, position, time);
2220
2221   for(int i = 0; i < 47; i++)
2222   {
2223     position += direction;
2224     TestMovePan(application, position, time);
2225     time += TestGetFrameInterval();
2226     application.SendNotification();
2227     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2228   }
2229
2230   TestEndPan(application, position, time);
2231   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2232
2233   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2234   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2235   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2236   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(1.0f, 1.0f) + (direction * PAN_GESTURE_UPDATE_COUNT), 10.0f, TEST_LOCATION);
2237
2238   constraintData.Reset();
2239   END_TEST;
2240 }
2241
2242 int UtcDaliPanGesturePredictionSmoothing02(void)
2243 {
2244   TestApplication application;
2245   Integration::SetPanGesturePredictionMode(1);
2246   Integration::SetPanGestureMaximumPredictionAmount(1);
2247   Integration::SetPanGesturePredictionAmountAdjustment(2);
2248   Integration::SetPanGestureSmoothingMode(1);
2249   Integration::SetPanGestureSmoothingAmount(0.25f);
2250
2251   Actor actor = Actor::New();
2252   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2253   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2254   application.GetScene().Add(actor);
2255
2256   // Add a pan detector
2257   PanGestureDetector detector = PanGestureDetector::New();
2258   detector.Attach(actor);
2259   SignalData             data;
2260   GestureReceivedFunctor functor(data);
2261   detector.DetectedSignal().Connect(&application, functor);
2262
2263   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2264
2265   ConstraintData constraintData;
2266   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2267   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2268   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2269   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2270   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2271   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2272   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2273   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2274   constraint.Apply();
2275
2276   // Render and notify
2277   application.SendNotification();
2278   application.Render();
2279
2280   Vector2  startPosition(2.0f, 2.0f);
2281   Vector2  position(4.0f, 2.0f);
2282   Vector2  directionX(Vector2::XAXIS);
2283   Vector2  directionY(Vector2::YAXIS);
2284   uint32_t time = 100;
2285
2286   TestStartPan(application, startPosition, position, time);
2287
2288   for(int i = 0; i < 7; i++)
2289   {
2290     position += directionX;
2291     TestMovePan(application, position, time);
2292     time += TestGetFrameInterval();
2293     application.SendNotification();
2294     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2295   }
2296
2297   position += directionX * 10.0f;
2298   TestMovePan(application, position, time);
2299   time += TestGetFrameInterval();
2300   application.SendNotification();
2301   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2302
2303   for(int i = 0; i < 2; i++)
2304   {
2305     position += (directionX * -1.0f);
2306     TestMovePan(application, position, time);
2307     time += TestGetFrameInterval();
2308     application.SendNotification();
2309     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2310   }
2311
2312   for(int i = 0; i < 10; i++)
2313   {
2314     position += directionX;
2315     TestMovePan(application, position, time);
2316     time += TestGetFrameInterval();
2317     application.SendNotification();
2318     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2319   }
2320
2321   for(int i = 0; i < 10; i++)
2322   {
2323     position += directionY;
2324     TestMovePan(application, position, time);
2325     time += TestGetFrameInterval();
2326     application.SendNotification();
2327     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2328   }
2329
2330   TestEndPan(application, position, time);
2331   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2332
2333   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2334   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2335   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2336   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2337
2338   constraintData.Reset();
2339   END_TEST;
2340 }
2341
2342 int UtcDaliPanGesturePrediction2SmoothingMultiTap01(void)
2343 {
2344   TestApplication application;
2345
2346   Integration::SetPanGesturePredictionMode(2);
2347   Integration::SetPanGesturePredictionAmount(57);
2348   Integration::SetPanGestureSmoothingMode(2);
2349   Integration::SetPanGestureUseActualTimes(false);
2350   Integration::SetPanGestureInterpolationTimeRange(10);
2351   Integration::SetPanGestureScalarOnlyPredictionEnabled(false);
2352   Integration::SetPanGestureTwoPointPredictionEnabled(true);
2353   Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2354   Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2355   Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2356   Integration::SetPanGestureMultitapSmoothingRange(34);
2357
2358   Actor actor = Actor::New();
2359   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2360   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2361   application.GetScene().Add(actor);
2362
2363   // Add a pan detector
2364   PanGestureDetector detector = PanGestureDetector::New();
2365   detector.Attach(actor);
2366   SignalData             data;
2367   GestureReceivedFunctor functor(data);
2368   detector.DetectedSignal().Connect(&application, functor);
2369
2370   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2371
2372   ConstraintData constraintData;
2373   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2374   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2375   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2376   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2377   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2378   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2379   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2380   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2381   constraint.Apply();
2382
2383   // Render and notify
2384   application.SendNotification();
2385   application.Render();
2386
2387   Vector2  startPosition(2.0f, 2.0f);
2388   Vector2  position(-1.0f, 2.0f);
2389   Vector2  direction(Vector2::XAXIS * -1.0f);
2390   uint32_t time = 100;
2391
2392   TestStartPan(application, startPosition, position, time);
2393
2394   for(int i = 0; i < 27; i++)
2395   {
2396     position += direction;
2397     TestMovePan(application, position, time);
2398     time += TestGetFrameInterval();
2399     application.SendNotification();
2400     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2401   }
2402
2403   TestEndPan(application, position, time);
2404   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2405
2406   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2407   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2408   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2409   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2410
2411   constraintData.Reset();
2412   END_TEST;
2413 }
2414
2415 int UtcDaliPanGesturePrediction2SmoothingMultiTap02(void)
2416 {
2417   TestApplication application;
2418
2419   Integration::SetPanGesturePredictionMode(2);
2420   Integration::SetPanGestureSmoothingMode(2);
2421   Integration::SetPanGestureUseActualTimes(true);
2422   Integration::SetPanGestureInterpolationTimeRange(10);
2423   Integration::SetPanGestureScalarOnlyPredictionEnabled(true);
2424   Integration::SetPanGestureTwoPointPredictionEnabled(true);
2425   Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2426   Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2427   Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2428   Integration::SetPanGestureMultitapSmoothingRange(34);
2429
2430   Integration::EnableProfiling(Integration::PROFILING_TYPE_PAN_GESTURE);
2431
2432   Actor actor = Actor::New();
2433   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2434   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2435   application.GetScene().Add(actor);
2436
2437   // Add a pan detector
2438   PanGestureDetector detector = PanGestureDetector::New();
2439   detector.Attach(actor);
2440   SignalData             data;
2441   GestureReceivedFunctor functor(data);
2442   detector.DetectedSignal().Connect(&application, functor);
2443
2444   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2445
2446   ConstraintData constraintData;
2447   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2448   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2449   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2450   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2451   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2452   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2453   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2454   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2455   constraint.Apply();
2456
2457   // Render and notify
2458   application.SendNotification();
2459   application.Render();
2460
2461   Vector2  startPosition(2.0f, 2.0f);
2462   Vector2  position(17.0f, 2.0f);
2463   Vector2  direction(Vector2::XAXIS * -1.0f);
2464   uint32_t time = 100;
2465
2466   TestStartPan(application, startPosition, position, time);
2467
2468   for(int i = 0; i < 10; i++)
2469   {
2470     position += direction;
2471     TestMovePan(application, position, time);
2472     time += TestGetFrameInterval();
2473
2474     position += direction;
2475     TestMovePan(application, position, time);
2476     time += TestGetFrameInterval();
2477
2478     position += direction;
2479     TestMovePan(application, position, time);
2480     time += TestGetFrameInterval();
2481
2482     application.SendNotification();
2483     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2484   }
2485
2486   for(int i = 0; i < 10; i++)
2487   {
2488     application.SendNotification();
2489     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2490   }
2491
2492   for(int i = 0; i < 10; i++)
2493   {
2494     position += direction;
2495     TestMovePan(application, position, time);
2496     application.SendNotification();
2497     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2498   }
2499
2500   for(int i = 0; i < 10; i++)
2501   {
2502     position += direction;
2503     TestMovePan(application, position, time);
2504     time += TestGetFrameInterval();
2505     application.SendNotification();
2506     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2507   }
2508
2509   TestEndPan(application, position, time);
2510   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2511
2512   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2513   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2514   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2515   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2516
2517   constraintData.Reset();
2518   END_TEST;
2519 }
2520
2521 int UtcDaliPanGesturePrediction2Smoothing(void)
2522 {
2523   TestApplication application;
2524
2525   Integration::SetPanGesturePredictionMode(2);
2526   Integration::SetPanGesturePredictionAmount(57);
2527   Integration::SetPanGestureSmoothingMode(1);
2528   Integration::SetPanGestureUseActualTimes(false);
2529   Integration::SetPanGestureInterpolationTimeRange(10);
2530   Integration::SetPanGestureScalarOnlyPredictionEnabled(true);
2531   Integration::SetPanGestureTwoPointPredictionEnabled(true);
2532   Integration::SetPanGestureTwoPointInterpolatePastTime(42);
2533   Integration::SetPanGestureTwoPointVelocityBias(0.35f);
2534   Integration::SetPanGestureTwoPointAccelerationBias(0.10f);
2535   Integration::SetPanGestureMultitapSmoothingRange(34);
2536
2537   Actor actor = Actor::New();
2538   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2539   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2540   application.GetScene().Add(actor);
2541
2542   // Add a pan detector
2543   PanGestureDetector detector = PanGestureDetector::New();
2544   detector.Attach(actor);
2545   SignalData             data;
2546   GestureReceivedFunctor functor(data);
2547   detector.DetectedSignal().Connect(&application, functor);
2548
2549   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2550
2551   ConstraintData constraintData;
2552   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2553   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2554   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2555   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2556   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2557   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2558   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2559   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2560   constraint.Apply();
2561
2562   // Render and notify
2563   application.SendNotification();
2564   application.Render();
2565
2566   Vector2  startPosition(2.0f, 2.0f);
2567   Vector2  position(17.0f, 2.0f);
2568   Vector2  direction(Vector2::XAXIS * -1.0f);
2569   uint32_t time = 100;
2570
2571   TestStartPan(application, startPosition, position, time);
2572
2573   for(int i = 0; i < 10; i++)
2574   {
2575     position += direction;
2576     TestMovePan(application, position, time);
2577     time += TestGetFrameInterval();
2578     application.SendNotification();
2579     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2580   }
2581
2582   position += direction;
2583   TestMovePan(application, position, time);
2584   time += TestGetFrameInterval();
2585
2586   position += direction;
2587   TestMovePan(application, position, time);
2588   time += TestGetFrameInterval();
2589
2590   position += direction;
2591   TestMovePan(application, position, time);
2592   time += TestGetFrameInterval();
2593
2594   application.SendNotification();
2595   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2596
2597   for(int i = 0; i < 5; i++)
2598   {
2599     application.SendNotification();
2600     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2601   }
2602
2603   for(int i = 0; i < 10; i++)
2604   {
2605     position += direction;
2606     TestMovePan(application, position, time);
2607     time += TestGetFrameInterval();
2608     application.SendNotification();
2609     application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2610   }
2611
2612   TestEndPan(application, position, time);
2613   application.Render(TestApplication::DEFAULT_RENDER_INTERVAL);
2614
2615   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2616   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2617   DALI_TEST_EQUALS(constraintData.screenPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2618   DALI_TEST_EQUALS(constraintData.localPosition, Vector2(2.0f, 2.0f) + position, 10.0f, TEST_LOCATION);
2619
2620   constraintData.Reset();
2621   END_TEST;
2622 }
2623
2624 int UtcDaliPanGestureSetProperties(void)
2625 {
2626   TestApplication       application;
2627   TestRenderController& renderController(application.GetRenderController());
2628   Integration::SetPanGesturePredictionMode(0);
2629   Integration::SetPanGestureSmoothingMode(0);
2630
2631   Actor actor = Actor::New();
2632   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2633   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2634   application.GetScene().Add(actor);
2635
2636   // Add a pan detector
2637   PanGestureDetector detector = PanGestureDetector::New();
2638   detector.Attach(actor);
2639   SignalData             data;
2640   GestureReceivedFunctor functor(data);
2641   detector.DetectedSignal().Connect(&application, functor);
2642
2643   Property::Index property                  = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2644   Property::Index animatableGestureProperty = detector.RegisterProperty("Dummy Property", Vector3::ZERO); // For code coverage
2645
2646   ConstraintData constraintData;
2647   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2648   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2649   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2650   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2651   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2652   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2653   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2654   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2655   constraint.AddSource(Source(detector, animatableGestureProperty));
2656   constraint.Apply();
2657
2658   // Render and notify
2659   application.SendNotification();
2660   application.Render();
2661
2662   renderController.Initialize();
2663   DALI_TEST_EQUALS(renderController.WasCalled(TestRenderController::RequestUpdateFunc), false, TEST_LOCATION);
2664
2665   Vector2 screenPosition(20.0f, 20.0f);
2666   Vector2 screenDisplacement(1.0f, 1.0f);
2667   Vector2 screenVelocity(1.3f, 4.0f);
2668   Vector2 localPosition(21.0f, 21.0f);
2669   Vector2 localDisplacement(0.5f, 0.5f);
2670   Vector2 localVelocity(1.5f, 2.5f);
2671
2672   PanGestureDetector::SetPanGestureProperties(GeneratePan(1u, GestureState::STARTED, screenPosition, localPosition, screenDisplacement, localDisplacement, screenVelocity, localVelocity));
2673   DALI_TEST_EQUALS(renderController.WasCalled(TestRenderController::RequestUpdateFunc), true, TEST_LOCATION);
2674
2675   // Render and notify
2676   application.SendNotification();
2677   application.Render();
2678
2679   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2680   DALI_TEST_EQUALS(constraintData.screenPosition, screenPosition, TEST_LOCATION);
2681   DALI_TEST_EQUALS(constraintData.localPosition, localPosition, TEST_LOCATION);
2682   DALI_TEST_EQUALS(constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION);
2683   DALI_TEST_EQUALS(constraintData.localDisplacement, localDisplacement, TEST_LOCATION);
2684   DALI_TEST_EQUALS(constraintData.screenVelocity, screenVelocity, TEST_LOCATION);
2685   DALI_TEST_EQUALS(constraintData.localVelocity, localVelocity, TEST_LOCATION);
2686   constraintData.Reset();
2687   END_TEST;
2688 }
2689
2690 int UtcDaliPanGestureSetPropertiesAlreadyPanning(void)
2691 {
2692   TestApplication application;
2693   Integration::SetPanGesturePredictionMode(0);
2694
2695   Actor actor = Actor::New();
2696   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2697   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2698   application.GetScene().Add(actor);
2699
2700   // Add a pan detector
2701   PanGestureDetector detector = PanGestureDetector::New();
2702   detector.Attach(actor);
2703   SignalData             data;
2704   GestureReceivedFunctor functor(data);
2705   detector.DetectedSignal().Connect(&application, functor);
2706
2707   Property::Index property = actor.RegisterProperty("Dummy Property", Vector3::ZERO);
2708
2709   ConstraintData constraintData;
2710   Constraint     constraint = Constraint::New<Vector3>(actor, property, PanConstraint(constraintData));
2711   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_POSITION));
2712   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_DISPLACEMENT));
2713   constraint.AddSource(Source(detector, PanGestureDetector::Property::SCREEN_VELOCITY));
2714   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_POSITION));
2715   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT));
2716   constraint.AddSource(Source(detector, PanGestureDetector::Property::LOCAL_VELOCITY));
2717   constraint.AddSource(Source(detector, PanGestureDetector::Property::PANNING));
2718   constraint.Apply();
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   Vector2  currentPosition(20.0f, 4.0f);
2725   uint32_t time = 100;
2726   TestStartPan(application, Vector2(20.0f, 20.0f), currentPosition, time);
2727   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2728
2729   Vector2 screenPosition(100.0f, 20.0f);
2730   Vector2 localPosition(110.0f, 110.0f);
2731
2732   PanGestureDetector::SetPanGestureProperties(GeneratePan(1u, GestureState::STARTED, screenPosition, localPosition));
2733
2734   // Render and notify
2735   application.SendNotification();
2736   application.Render();
2737
2738   DALI_TEST_EQUALS(constraintData.called, true, TEST_LOCATION);
2739   DALI_TEST_EQUALS(constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION);
2740   DALI_TEST_EQUALS(constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION);
2741   constraintData.Reset();
2742   END_TEST;
2743 }
2744
2745 int UtcDaliPanGesturePropertyIndices(void)
2746 {
2747   TestApplication    application;
2748   PanGestureDetector detector = PanGestureDetector::New();
2749
2750   Property::IndexContainer indices;
2751   detector.GetPropertyIndices(indices);
2752   DALI_TEST_CHECK(indices.Size());
2753   DALI_TEST_EQUALS(indices.Size(), detector.GetPropertyCount(), TEST_LOCATION);
2754   END_TEST;
2755 }
2756
2757 namespace
2758 {
2759 struct PropertyStringIndex
2760 {
2761   const char* const     name;
2762   const Property::Index index;
2763   const Property::Type  type;
2764   const Property::Value value;
2765 };
2766
2767 const PropertyStringIndex PROPERTY_TABLE[] =
2768   {
2769     {"screenPosition", PanGestureDetector::Property::SCREEN_POSITION, Property::VECTOR2, Vector2::ZERO},
2770     {"screenDisplacement", PanGestureDetector::Property::SCREEN_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO},
2771     {"screenVelocity", PanGestureDetector::Property::SCREEN_VELOCITY, Property::VECTOR2, Vector2::ZERO},
2772     {"localPosition", PanGestureDetector::Property::LOCAL_POSITION, Property::VECTOR2, Vector2::ZERO},
2773     {"localDisplacement", PanGestureDetector::Property::LOCAL_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO},
2774     {"localVelocity", PanGestureDetector::Property::LOCAL_VELOCITY, Property::VECTOR2, Vector2::ZERO},
2775     {"panning", PanGestureDetector::Property::PANNING, Property::BOOLEAN, false},
2776 };
2777 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
2778 } // unnamed namespace
2779
2780 int UtcDaliPanGestureProperties(void)
2781 {
2782   TestApplication    application;
2783   PanGestureDetector detector = PanGestureDetector::New();
2784
2785   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2786   {
2787     DALI_TEST_EQUALS(detector.GetPropertyName(PROPERTY_TABLE[i].index), std::string(PROPERTY_TABLE[i].name), TEST_LOCATION);
2788     DALI_TEST_EQUALS(detector.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
2789     DALI_TEST_EQUALS(detector.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
2790     DALI_TEST_EQUALS(detector.IsPropertyWritable(PROPERTY_TABLE[i].index), false, TEST_LOCATION);
2791     DALI_TEST_EQUALS(detector.IsPropertyAnimatable(PROPERTY_TABLE[i].index), false, TEST_LOCATION);
2792     DALI_TEST_EQUALS(detector.IsPropertyAConstraintInput(PROPERTY_TABLE[i].index), true, TEST_LOCATION);
2793     detector.SetProperty(PROPERTY_TABLE[i].index, Property::Value()); // Just for Coverage
2794   }
2795
2796   END_TEST;
2797 }
2798
2799 int UtcDaliPanGestureGetProperty(void)
2800 {
2801   TestApplication    application;
2802   PanGestureDetector detector = PanGestureDetector::New();
2803
2804   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2805   {
2806     if(PROPERTY_TABLE[i].type == Property::VECTOR2)
2807     {
2808       bool value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<bool>();
2809       DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<bool>(), value, TEST_LOCATION);
2810     }
2811     else if(PROPERTY_TABLE[i].type == Property::BOOLEAN)
2812     {
2813       Vector2 value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<Vector2>();
2814       DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<Vector2>(), value, TEST_LOCATION);
2815     }
2816   }
2817
2818   END_TEST;
2819 }
2820
2821 int UtcDaliPanGestureGetPropertyWithSceneObject(void)
2822 {
2823   TestApplication application;
2824
2825   Actor actor = Actor::New();
2826   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2827   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2828   application.GetScene().Add(actor);
2829
2830   // Add a pan detector
2831   PanGestureDetector detector = PanGestureDetector::New();
2832   detector.Attach(actor);
2833
2834   // Render and notify
2835   application.SendNotification();
2836   application.Render();
2837
2838   for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
2839   {
2840     detector.SetProperty(PROPERTY_TABLE[i].index, Property::Value()); // Just for Coverage
2841
2842     if(PROPERTY_TABLE[i].type == Property::VECTOR2)
2843     {
2844       bool value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<bool>();
2845       DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<bool>(), value, TEST_LOCATION);
2846     }
2847     else if(PROPERTY_TABLE[i].type == Property::BOOLEAN)
2848     {
2849       Vector2 value = detector.GetProperty(PROPERTY_TABLE[i].index).Get<Vector2>();
2850       DALI_TEST_EQUALS(PROPERTY_TABLE[i].value.Get<Vector2>(), value, TEST_LOCATION);
2851     }
2852   }
2853
2854   END_TEST;
2855 }
2856
2857 int UtcDaliPanGestureLayerConsumesTouch(void)
2858 {
2859   TestApplication application;
2860
2861   Actor actor = Actor::New();
2862   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2863   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2864   application.GetScene().Add(actor);
2865
2866   // Add a pan detector
2867   PanGestureDetector detector = PanGestureDetector::New();
2868   detector.Attach(actor);
2869   SignalData             data;
2870   GestureReceivedFunctor functor(data);
2871   detector.DetectedSignal().Connect(&application, functor);
2872
2873   // Add a layer to overlap the actor
2874   Layer layer = Layer::New();
2875   layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2876   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2877   application.GetScene().Add(layer);
2878   layer.RaiseToTop();
2879
2880   // Render and notify
2881   application.SendNotification();
2882   application.Render();
2883
2884   // Emit signals, should receive
2885   uint32_t time = 100;
2886   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2887   TestEndPan(application, Vector2(26.0f, 20.0f), time);
2888   time += TestGetFrameInterval();
2889
2890   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2891   data.Reset();
2892
2893   // Set layer to consume all touch
2894   layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
2895
2896   // Render and notify
2897   application.SendNotification();
2898   application.Render();
2899
2900   // Emit the same signals again, should not receive
2901   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2902   TestEndPan(application, Vector2(26.0f, 20.0f), time);
2903
2904   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2905   data.Reset();
2906
2907   END_TEST;
2908 }
2909
2910 int UtcDaliPanGestureNoTimeDiff(void)
2911 {
2912   TestApplication application;
2913
2914   Actor actor = Actor::New();
2915   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2916   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2917   application.GetScene().Add(actor);
2918
2919   // Add a pan detector
2920   PanGestureDetector detector = PanGestureDetector::New();
2921   detector.Attach(actor);
2922   SignalData             data;
2923   GestureReceivedFunctor functor(data);
2924   detector.DetectedSignal().Connect(&application, functor);
2925
2926   // Render and notify
2927   application.SendNotification();
2928   application.Render();
2929
2930   // As normal helper function adds intervals between presses we must generate the sequence
2931   // using other helper functions
2932   TestStartLongPress(application, 10.0f, 20.0f, 100); // Used to send a down press event
2933   TestMovePan(application, Vector2(26.0f, 20.0f), 100);
2934   TestMovePan(application, Vector2(26.0f, 20.0f), 100); // 2 motions required to trigger
2935   TestEndPan(application, Vector2(26.0f, 20.0f), 100);
2936
2937   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2938   DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetVelocity().x));
2939   DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetVelocity().y));
2940   DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetScreenVelocity().x));
2941   DALI_TEST_CHECK(!std::isinf(data.receivedGesture.GetScreenVelocity().y));
2942   data.Reset();
2943
2944   data.Reset();
2945
2946   END_TEST;
2947 }
2948
2949 int UtcDaliPanGestureDisableDetectionDuringPanN(void)
2950 {
2951   // Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
2952
2953   TestApplication application;
2954
2955   Actor actor = Actor::New();
2956   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2957   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2958   application.GetScene().Add(actor);
2959
2960   // Add a pan detector
2961   PanGestureDetector detector      = PanGestureDetector::New();
2962   bool               functorCalled = false;
2963   detector.Attach(actor);
2964   detector.DetectedSignal().Connect(
2965     &application,
2966     [&detector, &functorCalled](Actor actor, const PanGesture& pan) {
2967       if(pan.GetState() == GestureState::FINISHED)
2968       {
2969         detector.Detach(actor);
2970         functorCalled = true;
2971       }
2972     });
2973
2974   // Render and notify
2975   application.SendNotification();
2976   application.Render();
2977
2978   // Try the gesture, should not crash
2979   try
2980   {
2981     uint32_t time = 100;
2982     TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
2983     TestEndPan(application, Vector2(26.0f, 20.0f));
2984
2985     DALI_TEST_CHECK(true); // No crash, test has passed
2986     DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
2987   }
2988   catch(...)
2989   {
2990     DALI_TEST_CHECK(false); // If we crash, the test has failed
2991   }
2992
2993   END_TEST;
2994 }
2995
2996 int UtcDaliPanGestureWhenGesturePropargation(void)
2997 {
2998   TestApplication application;
2999
3000   Actor parentActor = Actor::New();
3001   parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3002   parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3003
3004   Actor childActor = Actor::New();
3005   childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3006   childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3007
3008   parentActor.Add(childActor);
3009   application.GetScene().Add(parentActor);
3010
3011   // Render and notify
3012   application.SendNotification();
3013   application.Render();
3014
3015   SignalData             pData;
3016   GestureReceivedFunctor pFunctor(pData);
3017
3018   PanGestureDetector parentDetector = PanGestureDetector::New();
3019   parentDetector.Attach(parentActor);
3020   parentDetector.DetectedSignal().Connect(&application, pFunctor);
3021
3022   SignalData             cData;
3023   GestureReceivedFunctor cFunctor(cData);
3024
3025   PanGestureDetector childDetector = PanGestureDetector::New();
3026   childDetector.Attach(childActor);
3027   childDetector.DetectedSignal().Connect(&application, cFunctor);
3028
3029   // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
3030   uint32_t time = 100;
3031   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3032
3033   DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3034   DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3035   cData.Reset();
3036   pData.Reset();
3037
3038   TestMovePan(application, Vector2(26.0f, 4.0f), time);
3039   time += TestGetFrameInterval();
3040
3041   DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3042   DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3043   cData.Reset();
3044   pData.Reset();
3045
3046   TestEndPan(application, Vector2(26.0f, 20.0f), time);
3047
3048   DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3049   DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3050   cData.Reset();
3051   pData.Reset();
3052
3053   // If GesturePropargation is set, a gesture event is to pass over to the parent.
3054   Dali::DevelActor::SetNeedGesturePropagation(childActor, true);
3055
3056   // So now the parent got the gesture event.
3057   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3058   DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3059   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3060   cData.Reset();
3061   pData.Reset();
3062
3063   TestMovePan(application, Vector2(26.0f, 4.0f), time);
3064   time += TestGetFrameInterval();
3065
3066   // child does not receive gestures. This is because we have passed the permission of the gesture to the parent.
3067   DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
3068   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3069   cData.Reset();
3070   pData.Reset();
3071
3072   TestEndPan(application, Vector2(26.0f, 20.0f), time);
3073   DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
3074   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3075   cData.Reset();
3076   pData.Reset();
3077
3078   END_TEST;
3079 }
3080
3081 int UtcDaliPanGestureHandleEvent(void)
3082 {
3083   TestApplication application;
3084   Integration::Scene scene     = application.GetScene();
3085   RenderTaskList   taskList  = scene.GetRenderTaskList();
3086   Dali::RenderTask task      = taskList.GetTask(0);
3087
3088   Actor parentActor = Actor::New();
3089   parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3090   parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3091
3092   Actor childActor = Actor::New();
3093   childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3094   childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3095
3096   parentActor.Add(childActor);
3097   application.GetScene().Add(parentActor);
3098
3099   // Render and notify
3100   application.SendNotification();
3101   application.Render();
3102
3103   SignalData             pData;
3104   GestureReceivedFunctor pFunctor(pData);
3105
3106   PanGestureDetector parentDetector = PanGestureDetector::New();
3107   parentDetector.DetectedSignal().Connect(&application, pFunctor);
3108
3109
3110   Integration::TouchEvent tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3111   Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(100));
3112   touchEventImpl->AddPoint(tp.GetPoint(0));
3113   touchEventImpl->SetRenderTask(task);
3114   Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
3115   parentDetector.HandleEvent(parentActor, touchEventHandle);
3116
3117
3118   tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 150);
3119   touchEventImpl = new Internal::TouchEvent(150);
3120   touchEventImpl->AddPoint(tp.GetPoint(0));
3121   touchEventImpl->SetRenderTask(task);
3122   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3123   parentDetector.HandleEvent(parentActor, touchEventHandle);
3124
3125
3126   tp = GenerateSingleTouch(PointState::MOTION, Vector2(90.0f, 90.0f), 200);
3127   touchEventImpl = new Internal::TouchEvent(200);
3128   touchEventImpl->AddPoint(tp.GetPoint(0));
3129   touchEventImpl->SetRenderTask(task);
3130   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3131   parentDetector.HandleEvent(parentActor, touchEventHandle);
3132
3133   tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 250);
3134   touchEventImpl = new Internal::TouchEvent(250);
3135   touchEventImpl->AddPoint(tp.GetPoint(0));
3136   touchEventImpl->SetRenderTask(task);
3137   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3138   parentDetector.HandleEvent(parentActor, touchEventHandle);
3139
3140
3141   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3142   pData.Reset();
3143
3144   END_TEST;
3145 }
3146
3147 int UtcDaliPanGestureSignalReceptionWithGeometryHittest(void)
3148 {
3149   TestApplication application;
3150   application.GetScene().SetGeometryHittestEnabled(true);
3151
3152   Actor actor = Actor::New();
3153   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3154   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3155   application.GetScene().Add(actor);
3156
3157   // Render and notify
3158   application.SendNotification();
3159   application.Render();
3160
3161   SignalData             data;
3162   GestureReceivedFunctor functor(data);
3163
3164   PanGestureDetector detector = PanGestureDetector::New();
3165   detector.Attach(actor);
3166   detector.DetectedSignal().Connect(&application, functor);
3167
3168   // Start pan within the actor's area
3169   uint32_t time = 100;
3170   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3171   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3172
3173   // Continue the pan within the actor's area - we should still receive the signal
3174   data.Reset();
3175
3176   TestMovePan(application, Vector2(26.0f, 4.0f), time);
3177   time += TestGetFrameInterval();
3178
3179   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3180
3181   // Gesture ends within actor's area
3182   data.Reset();
3183
3184   TestEndPan(application, Vector2(10.0f, 4.0f), time);
3185   time += TestGetFrameInterval();
3186
3187   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
3188
3189   // Detach actor
3190   detector.DetachAll();
3191
3192   // Ensure we are no longer signalled
3193   data.Reset();
3194
3195   TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
3196   TestMovePan(application, Vector2(26.0f, 4.0f), time);
3197   time += TestGetFrameInterval();
3198   TestEndPan(application, Vector2(10.0f, 4.0f), time);
3199
3200   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
3201   END_TEST;
3202 }
3203
3204 int UtcDaliPanGestureFeedTouchWhenGesturePropagation(void)
3205 {
3206   TestApplication application;
3207   Integration::Scene scene     = application.GetScene();
3208   RenderTaskList   taskList  = scene.GetRenderTaskList();
3209   Dali::RenderTask task      = taskList.GetTask(0);
3210
3211   Actor parentActor = Actor::New();
3212   parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3213   parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3214
3215   Actor childActor = Actor::New();
3216   childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3217   childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3218
3219   parentActor.Add(childActor);
3220   application.GetScene().Add(parentActor);
3221
3222   // Render and notify
3223   application.SendNotification();
3224   application.Render();
3225
3226   SignalData             pData;
3227   GestureReceivedFunctor pFunctor(pData);
3228
3229   PanGestureDetector parentDetector = PanGestureDetector::New();
3230   parentDetector.DetectedSignal().Connect(&application, pFunctor);
3231
3232   SignalData             cData;
3233   GestureReceivedFunctor cFunctor(cData);
3234
3235   PanGestureDetector childDetector = PanGestureDetector::New();
3236   childDetector.DetectedSignal().Connect(&application, cFunctor);
3237
3238   // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
3239   Integration::TouchEvent tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3240   Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(100));
3241   touchEventImpl->AddPoint(tp.GetPoint(0));
3242   touchEventImpl->SetRenderTask(task);
3243   Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
3244   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3245   {
3246     parentDetector.HandleEvent(parentActor, touchEventHandle);
3247   }
3248
3249   tp = GenerateSingleTouch(PointState::MOTION, Vector2(60.0f, 60.0f), 150);
3250   touchEventImpl = new Internal::TouchEvent(150);
3251   touchEventImpl->AddPoint(tp.GetPoint(0));
3252   touchEventImpl->SetRenderTask(task);
3253   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3254   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3255   {
3256     parentDetector.HandleEvent(parentActor, touchEventHandle);
3257   }
3258
3259   tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 200);
3260   touchEventImpl = new Internal::TouchEvent(200);
3261   touchEventImpl->AddPoint(tp.GetPoint(0));
3262   touchEventImpl->SetRenderTask(task);
3263   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3264   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3265   {
3266     parentDetector.HandleEvent(parentActor, touchEventHandle);
3267   }
3268
3269   tp = GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f), 250);
3270   touchEventImpl = new Internal::TouchEvent(200);
3271   touchEventImpl->AddPoint(tp.GetPoint(0));
3272   touchEventImpl->SetRenderTask(task);
3273   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3274   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3275   {
3276     parentDetector.HandleEvent(parentActor, touchEventHandle);
3277   }
3278
3279   tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 300);
3280   touchEventImpl = new Internal::TouchEvent(250);
3281   touchEventImpl->AddPoint(tp.GetPoint(0));
3282   touchEventImpl->SetRenderTask(task);
3283   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3284   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3285   {
3286     parentDetector.HandleEvent(parentActor, touchEventHandle);
3287   }
3288
3289   DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
3290   DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
3291   cData.Reset();
3292   pData.Reset();
3293
3294
3295   // If GesturePropargation is set, a gesture event is to pass over to the parent.
3296   SignalData              cPData;
3297   PropagationActorFunctor cPFunctor(cPData, true);
3298   childDetector.DetectedSignal().Connect(&application, cPFunctor);
3299
3300   // So now the parent got the gesture event.
3301   tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 100);
3302   touchEventImpl = new Internal::TouchEvent(100);
3303   touchEventImpl->AddPoint(tp.GetPoint(0));
3304   touchEventImpl->SetRenderTask(task);
3305   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3306   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3307   {
3308     parentDetector.HandleEvent(parentActor, touchEventHandle);
3309   }
3310
3311   tp = GenerateSingleTouch(PointState::MOTION, Vector2(60.0f, 60.0f), 150);
3312   touchEventImpl = new Internal::TouchEvent(150);
3313   touchEventImpl->AddPoint(tp.GetPoint(0));
3314   touchEventImpl->SetRenderTask(task);
3315   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3316   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3317   {
3318     parentDetector.HandleEvent(parentActor, touchEventHandle);
3319   }
3320
3321   tp = GenerateSingleTouch(PointState::MOTION, Vector2(70.0f, 70.0f), 200);
3322   touchEventImpl = new Internal::TouchEvent(200);
3323   touchEventImpl->AddPoint(tp.GetPoint(0));
3324   touchEventImpl->SetRenderTask(task);
3325   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3326   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3327   {
3328     parentDetector.HandleEvent(parentActor, touchEventHandle);
3329   }
3330
3331   tp = GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f), 250);
3332   touchEventImpl = new Internal::TouchEvent(250);
3333   touchEventImpl->AddPoint(tp.GetPoint(0));
3334   touchEventImpl->SetRenderTask(task);
3335   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3336   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3337   {
3338     parentDetector.HandleEvent(parentActor, touchEventHandle);
3339   }
3340
3341   tp = GenerateSingleTouch(PointState::UP, Vector2(100.0f, 100.0f), 300);
3342   touchEventImpl = new Internal::TouchEvent(300);
3343   touchEventImpl->AddPoint(tp.GetPoint(0));
3344   touchEventImpl->SetRenderTask(task);
3345   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
3346   if(!childDetector.HandleEvent(childActor, touchEventHandle))
3347   {
3348     parentDetector.HandleEvent(parentActor, touchEventHandle);
3349   }
3350
3351   DALI_TEST_EQUALS(true, cPData.functorCalled, TEST_LOCATION);
3352   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
3353   cPData.Reset();
3354   pData.Reset();
3355
3356   END_TEST;
3357 }