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