[dali_2.3.33] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-GestureDetector.cpp
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/threading/thread.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali/integration-api/events/touch-integ.h>
22 #include <dali/integration-api/render-task-list-integ.h>
23 #include <dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h>
24 #include <dali/internal/event/events/touch-event-impl.h>
25 #include <dali/internal/event/render-tasks/render-task-impl.h>
26 #include <dali/public-api/dali-core.h>
27 #include <stdlib.h>
28
29 #include <algorithm>
30 #include <iostream>
31
32 using namespace Dali;
33
34 void utc_dali_gesture_detector_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_gesture_detector_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46 // Stores data that is populated in the callback and will be read by the TET cases
47 struct SignalData
48 {
49   SignalData()
50   : functorCalled(false),
51     voidFunctorCalled(false),
52     receivedGesture(),
53     pressedActor()
54   {
55   }
56
57   void Reset()
58   {
59     functorCalled     = false;
60     voidFunctorCalled = false;
61
62     receivedGesture.Reset();
63
64     pressedActor.Reset();
65   }
66
67   bool    functorCalled;
68   bool    voidFunctorCalled;
69   Gesture receivedGesture;
70   Actor   pressedActor;
71 };
72
73 // Functor that sets the data when called
74 struct GestureReceivedFunctor
75 {
76   GestureReceivedFunctor(SignalData& data)
77   : signalData(data)
78   {
79   }
80
81   void operator()(Actor actor, const Gesture& gesture)
82   {
83     signalData.functorCalled   = true;
84     signalData.receivedGesture = gesture;
85     signalData.pressedActor    = actor;
86   }
87
88   void operator()()
89   {
90     signalData.voidFunctorCalled = true;
91   }
92
93   SignalData& signalData;
94 };
95
96 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, int source, uint32_t time)
97 {
98   Integration::TouchEvent touchEvent;
99   Integration::Point      point;
100   point.SetState(state);
101   point.SetDeviceId(4);
102   point.SetScreenPosition(screenPosition);
103   point.SetDeviceClass(Device::Class::TOUCH);
104   point.SetDeviceSubclass(Device::Subclass::NONE);
105   point.SetMouseButton(static_cast<MouseButton::Type>(source));
106   touchEvent.points.push_back(point);
107   touchEvent.time = time;
108   return touchEvent;
109 }
110
111 Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time)
112 {
113   Integration::TouchEvent touchEvent;
114   Integration::Point      point;
115   point.SetState(stateA);
116   point.SetDeviceId(4);
117   point.SetScreenPosition(screenPositionA);
118   point.SetDeviceClass(Device::Class::TOUCH);
119   point.SetDeviceSubclass(Device::Subclass::NONE);
120   touchEvent.points.push_back(point);
121   point.SetScreenPosition(screenPositionB);
122   point.SetState(stateB);
123   point.SetDeviceId(7);
124   touchEvent.points.push_back(point);
125   touchEvent.time = time;
126   return touchEvent;
127 }
128
129 } // namespace
130
131 int UtcDaliGestureDetectorConstructorN(void)
132 {
133   TestApplication application;
134
135   GestureDetector detector;
136
137   Actor actor = Actor::New();
138
139   try
140   {
141     detector.Attach(actor);
142     tet_result(TET_FAIL);
143   }
144   catch(DaliException& e)
145   {
146     DALI_TEST_ASSERT(e, "detector", TEST_LOCATION);
147   }
148   END_TEST;
149 }
150
151 int UtcDaliGestureDetectorConstructorP(void)
152 {
153   TestApplication application;
154
155   // Use pan gesture as GestureDetector cannot be created.
156   GestureDetector detector = PanGestureDetector::New();
157
158   Actor actor = Actor::New();
159
160   try
161   {
162     detector.Attach(actor);
163     tet_result(TET_PASS);
164   }
165   catch(DaliException& e)
166   {
167     DALI_TEST_PRINT_ASSERT(e);
168     tet_result(TET_FAIL);
169   }
170
171   GestureDetector moved = std::move(detector);
172   DALI_TEST_CHECK(moved);
173   DALI_TEST_CHECK(!detector);
174
175   END_TEST;
176 }
177
178 int UtcDaliGestureDetectorAssignP(void)
179 {
180   TestApplication application;
181
182   // Use pan gesture as GestureDetector cannot be created.
183   GestureDetector detector = PanGestureDetector::New();
184   GestureDetector detector2;
185
186   detector2 = detector;
187
188   Actor actor = Actor::New();
189
190   try
191   {
192     detector2.Attach(actor);
193     tet_result(TET_PASS);
194   }
195   catch(DaliException& e)
196   {
197     DALI_TEST_PRINT_ASSERT(e);
198     tet_result(TET_FAIL);
199   }
200
201   GestureDetector moved;
202   moved = std::move(detector2);
203   DALI_TEST_CHECK(moved);
204   DALI_TEST_CHECK(detector);
205   DALI_TEST_CHECK(!detector2);
206   END_TEST;
207 }
208
209 int UtcDaliGestureDetectorDownCastP(void)
210 {
211   TestApplication application;
212   tet_infoline("Testing Dali::GestureDetector::DownCast()");
213
214   GestureDetector detector = PanGestureDetector::New();
215
216   BaseHandle object(detector);
217
218   GestureDetector detector2 = GestureDetector::DownCast(object);
219   DALI_TEST_CHECK(detector2);
220
221   GestureDetector detector3 = DownCast<GestureDetector>(object);
222   DALI_TEST_CHECK(detector3);
223
224   BaseHandle      unInitializedObject;
225   GestureDetector detector4 = GestureDetector::DownCast(unInitializedObject);
226   DALI_TEST_CHECK(!detector4);
227
228   GestureDetector detector5 = DownCast<GestureDetector>(unInitializedObject);
229   DALI_TEST_CHECK(!detector5);
230   END_TEST;
231 }
232
233 int UtcDaliGestureDetectorAttachP(void)
234 {
235   TestApplication application;
236
237   // Use pan gesture as GestureDetector cannot be created.
238   GestureDetector detector = PanGestureDetector::New();
239
240   Actor actor = Actor::New();
241
242   detector.Attach(actor);
243
244   bool found = false;
245   for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
246   {
247     if(detector.GetAttachedActor(i) == actor)
248     {
249       tet_result(TET_PASS);
250       found = true;
251     }
252   }
253
254   if(!found)
255   {
256     tet_result(TET_FAIL);
257   }
258
259   // Scoped gesture detector. GestureDetectors connect to a destroy signal of the actor. If the
260   // actor is still alive when the gesture detector is destroyed, then it should disconnect from
261   // this signal.  If it does not, then when this function ends, there will be a segmentation fault
262   // thus, a TET case failure.
263   {
264     GestureDetector detector2 = PanGestureDetector::New();
265     detector2.Attach(actor);
266   }
267   END_TEST;
268 }
269
270 int UtcDaliGestureDetectorAttachN(void)
271 {
272   TestApplication application;
273
274   // Use pan gesture as GestureDetector cannot be created.
275   GestureDetector detector = PanGestureDetector::New();
276
277   // Do not initialise actor
278   Actor actor;
279
280   try
281   {
282     detector.Attach(actor);
283     tet_result(TET_FAIL);
284   }
285   catch(DaliException& e)
286   {
287     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
288   }
289   END_TEST;
290 }
291
292 int UtcDaliGestureDetectorDetachP(void)
293 {
294   TestApplication application;
295
296   // Use pan gesture as GestureDetector cannot be created.
297   GestureDetector detector = PanGestureDetector::New();
298
299   Actor actor = Actor::New();
300   detector.Attach(actor);
301
302   bool found = false;
303   for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
304   {
305     if(detector.GetAttachedActor(i) == actor)
306     {
307       tet_result(TET_PASS);
308       found = true;
309     }
310   }
311
312   if(!found)
313   {
314     tet_result(TET_FAIL);
315   }
316
317   // Detach and retrieve attached actors again, the vector should be empty.
318   detector.Detach(actor);
319
320   found = false;
321   for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
322   {
323     if(detector.GetAttachedActor(i) == actor)
324     {
325       found = true;
326     }
327   }
328
329   if(found)
330   {
331     tet_result(TET_FAIL);
332   }
333   else
334   {
335     tet_result(TET_PASS);
336   }
337
338   END_TEST;
339 }
340
341 int UtcDaliGestureDetectorDetachN01(void)
342 {
343   TestApplication application;
344
345   // Use pan gesture as GestureDetector cannot be created.
346   GestureDetector detector = PanGestureDetector::New();
347
348   // Do not initialise actor
349   Actor actor;
350
351   try
352   {
353     detector.Detach(actor);
354     tet_result(TET_FAIL);
355   }
356   catch(DaliException& e)
357   {
358     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
359   }
360   END_TEST;
361 }
362
363 int UtcDaliGestureDetectorDetachN02(void)
364 {
365   TestApplication application;
366
367   // Use pan gesture as GestureDetector cannot be created.
368   GestureDetector detector = PanGestureDetector::New();
369
370   Actor actor = Actor::New();
371   detector.Attach(actor);
372
373   // Detach an actor that hasn't been attached.  This should not cause an exception, it's a no-op.
374   try
375   {
376     Actor actor2 = Actor::New();
377     detector.Detach(actor2);
378     tet_result(TET_PASS);
379   }
380   catch(DaliException& e)
381   {
382     DALI_TEST_PRINT_ASSERT(e);
383     tet_result(TET_FAIL);
384   }
385   END_TEST;
386 }
387
388 int UtcDaliGestureDetectorDetachN03(void)
389 {
390   TestApplication application;
391
392   // Use pan gesture as GestureDetector cannot be created.
393   GestureDetector detector = PanGestureDetector::New();
394
395   Actor actor = Actor::New();
396   detector.Attach(actor);
397
398   DALI_TEST_EQUALS(1, detector.GetAttachedActorCount(), TEST_LOCATION);
399
400   // Detach an actor twice - no exception should happen.
401   try
402   {
403     detector.Detach(actor);
404     detector.Detach(actor);
405   }
406   catch(DaliException& e)
407   {
408     DALI_TEST_PRINT_ASSERT(e);
409     tet_result(TET_FAIL);
410   }
411
412   DALI_TEST_EQUALS(0, detector.GetAttachedActorCount(), TEST_LOCATION);
413
414   END_TEST;
415 }
416
417 int UtcDaliGestureDetectorDetachAllP(void)
418 {
419   TestApplication application;
420
421   // Use pan gesture as GestureDetector cannot be created.
422   GestureDetector detector = PanGestureDetector::New();
423
424   const unsigned int actorsToAdd = 5;
425   std::vector<Actor> myActors;
426
427   for(unsigned int i = 0; i < actorsToAdd; ++i)
428   {
429     Actor actor = Actor::New();
430     myActors.push_back(actor);
431     detector.Attach(actor);
432   }
433
434   DALI_TEST_EQUALS(actorsToAdd, detector.GetAttachedActorCount(), TEST_LOCATION);
435
436   // Detach and retrieve attached actors again, the vector should be empty.
437   detector.DetachAll();
438
439   DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
440   END_TEST;
441 }
442
443 int UtcDaliGestureDetectorDetachAllN(void)
444 {
445   TestApplication application;
446
447   // Use pan gesture as GestureDetector cannot be created.
448   GestureDetector detector = PanGestureDetector::New();
449
450   const unsigned int actorsToAdd = 5;
451   std::vector<Actor> myActors;
452
453   for(unsigned int i = 0; i < actorsToAdd; ++i)
454   {
455     Actor actor = Actor::New();
456     myActors.push_back(actor);
457     detector.Attach(actor);
458   }
459
460   DALI_TEST_EQUALS(actorsToAdd, detector.GetAttachedActorCount(), TEST_LOCATION);
461
462   // Detach and retrieve attached actors again, the vector should be empty.
463   detector.DetachAll();
464
465   DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
466
467   // Call DetachAll again, there should not be any exception
468   try
469   {
470     detector.DetachAll();
471   }
472   catch(DaliException& e)
473   {
474     DALI_TEST_PRINT_ASSERT(e);
475     tet_result(TET_FAIL);
476   }
477   END_TEST;
478 }
479
480 int UtcDaliGestureDetectorGetAttachedActors(void)
481 {
482   TestApplication application;
483
484   // Use pan gesture as GestureDetector cannot be created.
485   GestureDetector detector = PanGestureDetector::New();
486
487   // Initially there should not be any actors.
488   DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
489
490   // Attach one actor
491   Actor actor1 = Actor::New();
492   detector.Attach(actor1);
493   DALI_TEST_EQUALS(1u, detector.GetAttachedActorCount(), TEST_LOCATION);
494
495   // Attach another actor
496   Actor actor2 = Actor::New();
497   detector.Attach(actor2);
498   DALI_TEST_EQUALS(2u, detector.GetAttachedActorCount(), TEST_LOCATION);
499
500   // Attach another five actors
501   std::vector<Actor> myActors;
502   for(unsigned int i = 0; i < 5; ++i)
503   {
504     Actor actor = Actor::New();
505     myActors.push_back(actor);
506     detector.Attach(actor);
507   }
508   DALI_TEST_EQUALS(7u, detector.GetAttachedActorCount(), TEST_LOCATION);
509
510   // Detach actor2
511   detector.Detach(actor2);
512   DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
513
514   // Attach actor1 again, count should not increase.
515   detector.Attach(actor1);
516   DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
517
518   // Detach actor2 again, count should not decrease.
519   detector.Detach(actor2);
520   DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
521
522   // Detach actor1.
523   detector.Detach(actor1);
524   DALI_TEST_EQUALS(5u, detector.GetAttachedActorCount(), TEST_LOCATION);
525
526   // Create scoped actor, actor should be automatically removed from the detector when it goes out
527   // of scope.
528   {
529     Actor scopedActor = Actor::New();
530     detector.Attach(scopedActor);
531     DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
532   }
533   DALI_TEST_EQUALS(5u, detector.GetAttachedActorCount(), TEST_LOCATION);
534
535   // Detach all so nothing remains.
536   detector.DetachAll();
537   DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
538   END_TEST;
539 }
540
541 int UtcDaliGestureDetectorProperties(void)
542 {
543   TestApplication application;
544
545   // Use pinch gesture as that doen't currently have any properties. Will need to change it if default properties are added.
546   GestureDetector detector = PinchGestureDetector::New();
547
548   DALI_TEST_EQUALS(detector.GetPropertyCount(), 0u, TEST_LOCATION);
549
550   Property::IndexContainer indices;
551   detector.GetPropertyIndices(indices);
552   DALI_TEST_EQUALS(indices.Size(), 0u, TEST_LOCATION);
553
554   DALI_TEST_EQUALS(detector.IsPropertyWritable(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX), false, TEST_LOCATION);
555   DALI_TEST_EQUALS(detector.IsPropertyAnimatable(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX), false, TEST_LOCATION);
556   DALI_TEST_EQUALS(detector.IsPropertyAConstraintInput(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX), false, TEST_LOCATION);
557   DALI_TEST_EQUALS(detector.GetPropertyType(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX), Property::NONE, TEST_LOCATION);
558   DALI_TEST_EQUALS(detector.GetPropertyIndex("InvalidIndex"), Property::INVALID_INDEX, TEST_LOCATION);
559
560   Property::Value propValue = detector.GetProperty(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX);
561   DALI_TEST_EQUALS(propValue.GetType(), Property::NONE, TEST_LOCATION);
562
563   DALI_TEST_CHECK(detector.GetPropertyName(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX).empty());
564
565   // For coverage only, not testable
566   detector.SetProperty(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, true);
567
568   END_TEST;
569 }
570
571 int UtcDaliGestureDetectorRegisterProperty(void)
572 {
573   TestApplication application;
574
575   GestureDetector detector = PinchGestureDetector::New();
576
577   Property::Index index = detector.RegisterProperty("sceneProperty", 0);
578   DALI_TEST_EQUALS(index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION);
579   DALI_TEST_EQUALS(detector.GetProperty<int32_t>(index), 0, TEST_LOCATION);
580
581   detector.SetProperty(index, -123);
582   DALI_TEST_EQUALS(detector.GetProperty<int32_t>(index), -123, TEST_LOCATION);
583
584   using Dali::Animation;
585   Animation animation = Animation::New(1.0f);
586   animation.AnimateTo(Property(detector, index), 99);
587
588   DALI_TEST_EQUALS(detector.GetProperty<int32_t>(index), -123, TEST_LOCATION);
589   // Start the animation
590   animation.Play();
591
592   application.SendNotification();
593   application.Render(1000 /* 100% progress */);
594   DALI_TEST_EQUALS(detector.GetProperty<int32_t>(index), 99, TEST_LOCATION);
595
596   END_TEST;
597 }
598
599 int UtcDaliGestureDetectorCancelProcessing(void)
600 {
601   TestApplication    application;
602   Integration::Scene scene    = application.GetScene();
603   RenderTaskList     taskList = scene.GetRenderTaskList();
604   Dali::RenderTask   task     = taskList.GetTask(0);
605
606   LongPressGestureDetector longDetector     = LongPressGestureDetector::New();
607   TapGestureDetector       tapDetector      = TapGestureDetector::New();
608   PanGestureDetector       panDetector      = PanGestureDetector::New();
609   PinchGestureDetector     pinchDetector    = PinchGestureDetector::New();
610   RotationGestureDetector  rotationDetector = RotationGestureDetector::New();
611
612   Actor actor = Actor::New();
613   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
614   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
615
616   application.GetScene().Add(actor);
617
618   // Render and notify
619   application.SendNotification();
620   application.Render();
621
622   SignalData             data;
623   GestureReceivedFunctor functor(data);
624
625   SignalData             tData;
626   GestureReceivedFunctor tFunctor(tData);
627
628   SignalData             pData;
629   GestureReceivedFunctor pFunctor(pData);
630
631   longDetector.DetectedSignal().Connect(&application, functor);
632   tapDetector.DetectedSignal().Connect(&application, tFunctor);
633   pinchDetector.DetectedSignal().Connect(&application, pFunctor);
634
635   Integration::TouchEvent tp = GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 1, 100);
636   Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(100));
637   touchEventImpl->AddPoint(tp.GetPoint(0));
638   touchEventImpl->SetRenderTask(task);
639   Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
640   longDetector.HandleEvent(actor, touchEventHandle);
641   tapDetector.HandleEvent(actor, touchEventHandle);
642   panDetector.HandleEvent(actor, touchEventHandle);
643   pinchDetector.HandleEvent(actor, touchEventHandle);
644   rotationDetector.HandleEvent(actor, touchEventHandle);
645
646   TestTriggerLongPress(application);
647   longDetector.CancelAllOtherGestureDetectors();
648
649   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
650   DALI_TEST_EQUALS(false, tData.functorCalled, TEST_LOCATION);
651   data.Reset();
652   tData.Reset();
653
654   tp             = GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 1, 650);
655   touchEventImpl = new Internal::TouchEvent(650);
656   touchEventImpl->AddPoint(tp.GetPoint(0));
657   touchEventImpl->SetRenderTask(task);
658   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
659   longDetector.HandleEvent(actor, touchEventHandle);
660   tapDetector.HandleEvent(actor, touchEventHandle);
661   panDetector.HandleEvent(actor, touchEventHandle);
662   pinchDetector.HandleEvent(actor, touchEventHandle);
663   rotationDetector.HandleEvent(actor, touchEventHandle);
664
665   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
666   DALI_TEST_EQUALS(false, tData.functorCalled, TEST_LOCATION);
667   data.Reset();
668   tData.Reset();
669
670   longDetector.SetTouchesRequired(2, 2);
671
672   tp             = GenerateDoubleTouch(PointState::DOWN, Vector2(2.0f, 20.0f), PointState::DOWN, Vector2(38.0f, 20.0f), 100);
673   touchEventImpl = new Internal::TouchEvent(100);
674   touchEventImpl->AddPoint(tp.GetPoint(0));
675   touchEventImpl->AddPoint(tp.GetPoint(1));
676   touchEventImpl->SetRenderTask(task);
677   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
678   longDetector.HandleEvent(actor, touchEventHandle);
679   tapDetector.HandleEvent(actor, touchEventHandle);
680   panDetector.HandleEvent(actor, touchEventHandle);
681   pinchDetector.HandleEvent(actor, touchEventHandle);
682   rotationDetector.HandleEvent(actor, touchEventHandle);
683
684   pinchDetector.CancelAllOtherGestureDetectors();
685
686   tp             = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 150);
687   touchEventImpl = new Internal::TouchEvent(150);
688   touchEventImpl->AddPoint(tp.GetPoint(0));
689   touchEventImpl->AddPoint(tp.GetPoint(1));
690   touchEventImpl->SetRenderTask(task);
691   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
692   longDetector.HandleEvent(actor, touchEventHandle);
693   tapDetector.HandleEvent(actor, touchEventHandle);
694   panDetector.HandleEvent(actor, touchEventHandle);
695   pinchDetector.HandleEvent(actor, touchEventHandle);
696   rotationDetector.HandleEvent(actor, touchEventHandle);
697
698   tp             = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 200);
699   touchEventImpl = new Internal::TouchEvent(200);
700   touchEventImpl->AddPoint(tp.GetPoint(0));
701   touchEventImpl->AddPoint(tp.GetPoint(1));
702   touchEventImpl->SetRenderTask(task);
703   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
704   longDetector.HandleEvent(actor, touchEventHandle);
705   tapDetector.HandleEvent(actor, touchEventHandle);
706   panDetector.HandleEvent(actor, touchEventHandle);
707   pinchDetector.HandleEvent(actor, touchEventHandle);
708   rotationDetector.HandleEvent(actor, touchEventHandle);
709
710   tp             = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 250);
711   touchEventImpl = new Internal::TouchEvent(250);
712   touchEventImpl->AddPoint(tp.GetPoint(0));
713   touchEventImpl->AddPoint(tp.GetPoint(1));
714   touchEventImpl->SetRenderTask(task);
715   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
716   longDetector.HandleEvent(actor, touchEventHandle);
717   tapDetector.HandleEvent(actor, touchEventHandle);
718   panDetector.HandleEvent(actor, touchEventHandle);
719   pinchDetector.HandleEvent(actor, touchEventHandle);
720   rotationDetector.HandleEvent(actor, touchEventHandle);
721
722   tp             = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 300);
723   touchEventImpl = new Internal::TouchEvent(300);
724   touchEventImpl->AddPoint(tp.GetPoint(0));
725   touchEventImpl->AddPoint(tp.GetPoint(1));
726   touchEventImpl->SetRenderTask(task);
727   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
728   longDetector.HandleEvent(actor, touchEventHandle);
729   tapDetector.HandleEvent(actor, touchEventHandle);
730   panDetector.HandleEvent(actor, touchEventHandle);
731   pinchDetector.HandleEvent(actor, touchEventHandle);
732   rotationDetector.HandleEvent(actor, touchEventHandle);
733
734   tp             = GenerateDoubleTouch(PointState::UP, Vector2(10.0f, 20.0f), PointState::UP, Vector2(30.0f, 20.0f), 350);
735   touchEventImpl = new Internal::TouchEvent(350);
736   touchEventImpl->AddPoint(tp.GetPoint(0));
737   touchEventImpl->AddPoint(tp.GetPoint(1));
738   touchEventImpl->SetRenderTask(task);
739   touchEventHandle = Dali::TouchEvent(touchEventImpl.Get());
740   longDetector.HandleEvent(actor, touchEventHandle);
741   tapDetector.HandleEvent(actor, touchEventHandle);
742   panDetector.HandleEvent(actor, touchEventHandle);
743   pinchDetector.HandleEvent(actor, touchEventHandle);
744   rotationDetector.HandleEvent(actor, touchEventHandle);
745
746   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
747   DALI_TEST_EQUALS(false, tData.functorCalled, TEST_LOCATION);
748   DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
749   data.Reset();
750   tData.Reset();
751   pData.Reset();
752
753   END_TEST;
754 }
755
756 int UtcDaliGestureDetectorDestructWorkerThreadN(void)
757 {
758   TestApplication application;
759   tet_infoline("UtcDaliGestureDetectorDestructWorkerThreadN Test, for line coverage");
760
761   try
762   {
763     class TestThread : public Thread
764     {
765     public:
766       virtual void Run()
767       {
768         tet_printf("Run TestThread\n");
769         // Destruct at worker thread.
770         mGestureDetector.Reset();
771       }
772
773       Dali::GestureDetector mGestureDetector;
774     };
775     TestThread thread;
776
777     GestureDetector detector = PanGestureDetector::New();
778     thread.mGestureDetector  = std::move(detector);
779     detector.Reset();
780
781     thread.Start();
782
783     thread.Join();
784   }
785   catch(...)
786   {
787   }
788
789   // Always success
790   DALI_TEST_CHECK(true);
791
792   END_TEST;
793 }