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