[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-PanGestureRecognizer.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/integration-api/events/touch-event-integ.h>
20 #include <dali/integration-api/input-options.h>
21 #include <dali/integration-api/render-task-list-integ.h>
22 #include <dali/public-api/dali-core.h>
23 #include <stdlib.h>
24
25 #include <chrono>
26 #include <iostream>
27
28 using namespace Dali;
29
30 ///////////////////////////////////////////////////////////////////////////////
31 namespace
32 {
33 struct SignalData
34 {
35   SignalData()
36   : functorCalled(false),
37     voidFunctorCalled(false),
38     receivedGesture()
39   {
40   }
41
42   void Reset()
43   {
44     functorCalled     = false;
45     voidFunctorCalled = false;
46
47     receivedGesture.Reset();
48
49     pannedActor.Reset();
50   }
51
52   bool       functorCalled;
53   bool       voidFunctorCalled;
54   PanGesture receivedGesture;
55   Actor      pannedActor;
56 };
57
58 // Functor that sets the data when called
59 struct GestureReceivedFunctor
60 {
61   GestureReceivedFunctor(SignalData& data)
62   : signalData(data)
63   {
64   }
65
66   void operator()(Actor actor, const PanGesture& pan)
67   {
68     signalData.functorCalled   = true;
69     signalData.receivedGesture = pan;
70     signalData.pannedActor     = actor;
71   }
72
73   void operator()()
74   {
75     signalData.voidFunctorCalled = true;
76   }
77
78   SignalData& signalData;
79 };
80
81 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time)
82 {
83   Integration::TouchEvent touchEvent;
84   Integration::Point      point;
85   point.SetState(state);
86   point.SetScreenPosition(screenPosition);
87   point.SetDeviceClass(Device::Class::TOUCH);
88   point.SetDeviceSubclass(Device::Subclass::NONE);
89   touchEvent.points.push_back(point);
90   touchEvent.time = time;
91   return touchEvent;
92 }
93
94 Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time)
95 {
96   Integration::TouchEvent touchEvent;
97   Integration::Point      point;
98   point.SetState(stateA);
99   point.SetScreenPosition(screenPositionA);
100   point.SetDeviceClass(Device::Class::TOUCH);
101   point.SetDeviceSubclass(Device::Subclass::NONE);
102   touchEvent.points.push_back(point);
103   point.SetScreenPosition(screenPositionB);
104   point.SetState(stateB);
105   touchEvent.points.push_back(point);
106   touchEvent.time = time;
107   return touchEvent;
108 }
109
110 uint32_t GetMilliSeconds()
111 {
112   // Get the time of a monotonic clock since its epoch.
113   auto epoch = std::chrono::steady_clock::now().time_since_epoch();
114
115   auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(epoch);
116
117   return static_cast<uint32_t>(duration.count());
118 }
119 } // namespace
120
121 ///////////////////////////////////////////////////////////////////////////////
122
123 int UtcDaliPanGestureRecognizerBasicNoAction(void)
124 {
125   TestApplication application;
126
127   PanGestureDetector detector = PanGestureDetector::New();
128
129   Actor actor = Actor::New();
130   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
131   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
132   application.GetScene().Add(actor);
133
134   // Render and notify
135   application.SendNotification();
136   application.Render();
137
138   detector.Attach(actor);
139
140   SignalData             data;
141   GestureReceivedFunctor functor(data);
142   detector.DetectedSignal().Connect(&application, functor);
143
144   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
145
146   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 200));
147
148   application.SendNotification();
149
150   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
151
152   END_TEST;
153 }
154
155 int UtcDaliPanGestureRecognizerBasic(void)
156 {
157   TestApplication application;
158
159   PanGestureDetector detector = PanGestureDetector::New();
160
161   Actor actor = Actor::New();
162   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
163   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
164   application.GetScene().Add(actor);
165
166   // Render and notify
167   application.SendNotification();
168   application.Render();
169
170   detector.Attach(actor);
171
172   SignalData             data;
173   GestureReceivedFunctor functor(data);
174   detector.DetectedSignal().Connect(&application, functor);
175
176   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
177   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
178   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 152));
179
180   application.SendNotification();
181
182   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
183
184   END_TEST;
185 }
186
187 int UtcDaliPanGestureRecognizerBasicInterrupted(void)
188 {
189   TestApplication application;
190
191   PanGestureDetector detector = PanGestureDetector::New();
192
193   Actor actor = Actor::New();
194   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
195   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
196   application.GetScene().Add(actor);
197
198   // Render and notify
199   application.SendNotification();
200   application.Render();
201
202   detector.Attach(actor);
203
204   SignalData             data;
205   GestureReceivedFunctor functor(data);
206   detector.DetectedSignal().Connect(&application, functor);
207
208   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
209   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 25.0f), 151));
210   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(20.0f, 30.0f), 152));
211
212   application.SendNotification();
213
214   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
215
216   END_TEST;
217 }
218
219 int UtcDaliPanGestureRecognizerBasicShortest(void)
220 {
221   TestApplication application;
222
223   PanGestureDetector detector = PanGestureDetector::New();
224
225   Actor actor = Actor::New();
226   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
227   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
228   application.GetScene().Add(actor);
229
230   // Render and notify
231   application.SendNotification();
232   application.Render();
233
234   detector.Attach(actor);
235
236   SignalData             data;
237   GestureReceivedFunctor functor(data);
238   detector.DetectedSignal().Connect(&application, functor);
239
240   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
241   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
242   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 40.0f), 155));
243
244   application.SendNotification();
245
246   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
247
248   END_TEST;
249 }
250
251 int UtcDaliPanGestureRecognizerBasicFailToStart(void)
252 {
253   TestApplication application;
254
255   PanGestureDetector detector = PanGestureDetector::New();
256
257   Actor actor = Actor::New();
258   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
259   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
260   application.GetScene().Add(actor);
261
262   // Render and notify
263   application.SendNotification();
264   application.Render();
265
266   detector.Attach(actor);
267
268   SignalData             data;
269   GestureReceivedFunctor functor(data);
270   detector.DetectedSignal().Connect(&application, functor);
271
272   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
273   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
274   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(40.0f, 40.0f), 153));
275
276   application.SendNotification();
277
278   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
279
280   END_TEST;
281 }
282
283 int UtcDaliPanGestureRecognizerBasicStationary(void)
284 {
285   TestApplication application;
286
287   PanGestureDetector detector = PanGestureDetector::New();
288
289   Actor actor = Actor::New();
290   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
291   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
292   application.GetScene().Add(actor);
293
294   // Render and notify
295   application.SendNotification();
296   application.Render();
297
298   detector.Attach(actor);
299
300   SignalData             data;
301   GestureReceivedFunctor functor(data);
302   detector.DetectedSignal().Connect(&application, functor);
303
304   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
305   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
306   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), 152));
307   application.ProcessEvent(GenerateSingleTouch(PointState::STATIONARY, Vector2(20.0f, 50.0f), 153));
308   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), 154));
309
310   application.SendNotification();
311
312   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
313
314   END_TEST;
315 }
316
317 int UtcDaliPanGestureRecognizerNewParametersFail(void)
318 {
319   TestApplication application;
320
321   PanGestureDetector detector = PanGestureDetector::New();
322
323   detector.SetMaximumTouchesRequired(2);
324   detector.SetMinimumTouchesRequired(2);
325
326   Actor actor = Actor::New();
327   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
328   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
329   application.GetScene().Add(actor);
330
331   // Render and notify
332   application.SendNotification();
333   application.Render();
334
335   detector.Attach(actor);
336
337   SignalData             data;
338   GestureReceivedFunctor functor(data);
339   detector.DetectedSignal().Connect(&application, functor);
340
341   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
342   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
343   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 152));
344
345   application.SendNotification();
346
347   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
348
349   END_TEST;
350 }
351
352 int UtcDaliPanGestureRecognizerNewParametersSuccess(void)
353 {
354   TestApplication application;
355
356   PanGestureDetector detector = PanGestureDetector::New();
357
358   detector.SetMaximumTouchesRequired(2);
359   detector.SetMinimumTouchesRequired(2);
360
361   Actor actor = Actor::New();
362   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
363   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
364   application.GetScene().Add(actor);
365
366   // Render and notify
367   application.SendNotification();
368   application.Render();
369
370   detector.Attach(actor);
371
372   SignalData             data;
373   GestureReceivedFunctor functor(data);
374   detector.DetectedSignal().Connect(&application, functor);
375
376   application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(20.0f, 40.0f), 150));
377   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(40.0f, 50.0f), PointState::MOTION, Vector2(40.0f, 40.0f), 151));
378   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(50.0f, 50.0f), PointState::MOTION, Vector2(50.0f, 40.0f), 152));
379
380   application.SendNotification();
381
382   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
383
384   END_TEST;
385 }
386
387 int UtcDaliPanGestureRecognizerNewParametersEndFewerTouches01(void)
388 {
389   TestApplication application;
390
391   PanGestureDetector detector = PanGestureDetector::New();
392
393   detector.SetMaximumTouchesRequired(2);
394   detector.SetMinimumTouchesRequired(2);
395
396   Actor actor = Actor::New();
397   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
398   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
399   application.GetScene().Add(actor);
400
401   // Render and notify
402   application.SendNotification();
403   application.Render();
404
405   detector.Attach(actor);
406
407   SignalData             data;
408   GestureReceivedFunctor functor(data);
409   detector.DetectedSignal().Connect(&application, functor);
410
411   application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(20.0f, 40.0f), 150));
412   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(40.0f, 50.0f), PointState::MOTION, Vector2(40.0f, 40.0f), 151));
413   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(50.0f, 50.0f), PointState::MOTION, Vector2(50.0f, 40.0f), 152));
414   application.ProcessEvent(GenerateSingleTouch(PointState::STATIONARY, Vector2(50.0f, 50.0f), 153));
415
416   application.SendNotification();
417
418   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
419
420   END_TEST;
421 }
422
423 int UtcDaliPanGestureRecognizerNewParametersEndFewerTouches02(void)
424 {
425   TestApplication application;
426
427   PanGestureDetector detector = PanGestureDetector::New();
428
429   detector.SetMaximumTouchesRequired(2);
430   detector.SetMinimumTouchesRequired(2);
431
432   Actor actor = Actor::New();
433   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
434   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
435   application.GetScene().Add(actor);
436
437   // Render and notify
438   application.SendNotification();
439   application.Render();
440
441   detector.Attach(actor);
442
443   SignalData             data;
444   GestureReceivedFunctor functor(data);
445   detector.DetectedSignal().Connect(&application, functor);
446
447   application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(20.0f, 40.0f), 150));
448   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(40.0f, 50.0f), PointState::MOTION, Vector2(40.0f, 40.0f), 151));
449   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(50.0f, 50.0f), PointState::MOTION, Vector2(50.0f, 40.0f), 152));
450   application.ProcessEvent(GenerateDoubleTouch(PointState::STATIONARY, Vector2(50.0f, 50.0f), PointState::UP, Vector2(50.0f, 40.0f), 153));
451
452   application.SendNotification();
453
454   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
455
456   END_TEST;
457 }
458
459 int UtcDaliPanGestureRecognizerNewParametersNoStart(void)
460 {
461   TestApplication application;
462
463   PanGestureDetector detector = PanGestureDetector::New();
464
465   detector.SetMaximumTouchesRequired(2);
466   detector.SetMinimumTouchesRequired(2);
467
468   Actor actor = Actor::New();
469   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
470   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
471   application.GetScene().Add(actor);
472
473   // Render and notify
474   application.SendNotification();
475   application.Render();
476
477   detector.Attach(actor);
478
479   SignalData             data;
480   GestureReceivedFunctor functor(data);
481   detector.DetectedSignal().Connect(&application, functor);
482
483   application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(20.0f, 40.0f), 150));
484   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(40.0f, 50.0f), PointState::MOTION, Vector2(40.0f, 40.0f), 151));
485   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 153));
486
487   application.SendNotification();
488
489   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
490
491   END_TEST;
492 }
493
494 int UtcDaliPanGestureRecognizerNewParametersSlowRelease(void)
495 {
496   TestApplication application;
497
498   PanGestureDetector detector = PanGestureDetector::New();
499
500   detector.SetMaximumTouchesRequired(2);
501   detector.SetMinimumTouchesRequired(2);
502
503   Actor actor = Actor::New();
504   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
505   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
506   application.GetScene().Add(actor);
507
508   // Render and notify
509   application.SendNotification();
510   application.Render();
511
512   detector.Attach(actor);
513
514   SignalData             data;
515   GestureReceivedFunctor functor(data);
516   detector.DetectedSignal().Connect(&application, functor);
517
518   application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 50.0f), PointState::DOWN, Vector2(20.0f, 40.0f), 150));
519   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(40.0f, 50.0f), PointState::MOTION, Vector2(40.0f, 40.0f), 151));
520   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(50.0f, 50.0f), PointState::MOTION, Vector2(50.0f, 40.0f), 152));
521   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(60.0f, 50.0f), PointState::MOTION, Vector2(60.0f, 40.0f), 153));
522   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(70.0f, 50.0f), PointState::MOTION, Vector2(70.0f, 40.0f), 154));
523   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(70.0f, 50.0f), 155));
524
525   application.SendNotification();
526
527   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
528
529   END_TEST;
530 }
531
532 int UtcDaliPanGestureRecognizerNewParamsMaxMotionEventAge(void)
533 {
534   TestApplication application;
535
536   PanGestureDetector detector = PanGestureDetector::New();
537
538   detector.SetMaximumMotionEventAge(1000);
539
540   Actor actor = Actor::New();
541   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
542   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
543   application.GetScene().Add(actor);
544
545   // Render and notify
546   application.SendNotification();
547   application.Render();
548
549   detector.Attach(actor);
550
551   SignalData             data;
552   GestureReceivedFunctor functor(data);
553   detector.DetectedSignal().Connect(&application, functor);
554
555   uint32_t currentTime = GetMilliSeconds();
556   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), currentTime));
557   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), currentTime));
558   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), currentTime));
559   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), currentTime));
560   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), currentTime));
561   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), currentTime));
562
563   application.SendNotification();
564
565   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
566
567   data.Reset();
568
569   // Update current time
570   currentTime = GetMilliSeconds();
571
572   tet_infoline("Test fast enough motion\n");
573   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), currentTime - 100));
574
575   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
576
577   data.Reset();
578
579   // Update current time
580   currentTime = GetMilliSeconds();
581
582   tet_infoline("Test super heavy motion\n");
583   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), currentTime - 10000));
584   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), currentTime - 9000));
585   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), currentTime - 8000));
586   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), currentTime - 7000));
587
588   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
589
590   END_TEST;
591 }
592
593 int UtcDaliPanGestureRecognizerOtherEvent(void)
594 {
595   TestApplication application;
596
597   PanGestureDetector detector = PanGestureDetector::New();
598
599   Actor actor = Actor::New();
600   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
601   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
602   application.GetScene().Add(actor);
603
604   // Render and notify
605   application.SendNotification();
606   application.Render();
607
608   detector.Attach(actor);
609
610   SignalData             data;
611   GestureReceivedFunctor functor(data);
612   detector.DetectedSignal().Connect(&application, functor);
613
614   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
615   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 151));
616   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 152));
617   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 60.0f), 153)); // Exercise default case in STARTED case. Not sure if realistic
618   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 65.0f), 154));
619
620   application.SendNotification();
621
622   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
623
624   END_TEST;
625 }
626
627 int UtcDaliPanGestureRecognizerSlowMoving(void)
628 {
629   TestApplication application;
630
631   PanGestureDetector detector = PanGestureDetector::New();
632
633   Actor actor = Actor::New();
634   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
635   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
636   application.GetScene().Add(actor);
637
638   // Render and notify
639   application.SendNotification();
640   application.Render();
641
642   detector.Attach(actor);
643
644   SignalData             data;
645   GestureReceivedFunctor functor(data);
646   detector.DetectedSignal().Connect(&application, functor);
647
648   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
649   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
650   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
651   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
652   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
653   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
654
655   application.SendNotification();
656
657   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
658
659   END_TEST;
660 }
661
662 int UtcDaliPanGestureRecognizerNewParamsMinNum(void)
663 {
664   TestApplication application;
665
666   Integration::SetPanGestureMinimumPanEvents(8);
667
668   PanGestureDetector detector = PanGestureDetector::New();
669
670   Actor actor = Actor::New();
671   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
672   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
673   application.GetScene().Add(actor);
674
675   // Render and notify
676   application.SendNotification();
677   application.Render();
678
679   detector.Attach(actor);
680
681   SignalData             data;
682   GestureReceivedFunctor functor(data);
683   detector.DetectedSignal().Connect(&application, functor);
684
685   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
686   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
687   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
688   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
689   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
690   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
691
692   application.SendNotification();
693
694   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
695
696   END_TEST;
697 }
698
699 int UtcDaliPanGestureRecognizerUpdateParamsMinNum(void)
700 {
701   TestApplication application;
702
703   Integration::SetPanGestureMinimumPanEvents(8);
704
705   PanGestureDetector detector = PanGestureDetector::New();
706
707   Actor actor = Actor::New();
708   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
709   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
710   application.GetScene().Add(actor);
711
712   // Render and notify
713   application.SendNotification();
714   application.Render();
715
716   detector.Attach(actor);
717
718   SignalData             data;
719   GestureReceivedFunctor functor(data);
720   detector.DetectedSignal().Connect(&application, functor);
721
722   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
723   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
724   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
725   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
726   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
727   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
728
729   application.SendNotification();
730
731   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
732   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 90.0f), 756));
733   application.SendNotification();
734   data.Reset();
735
736   Integration::SetPanGestureMinimumPanEvents(10);
737
738   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
739   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
740   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
741   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
742   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
743   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
744   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 100.0f), 756));
745   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 110.0f), 857));
746
747   application.SendNotification();
748
749   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
750
751   END_TEST;
752 }
753
754
755 int UtcDaliPanGestureRecognizerNewParamsMinDistance(void)
756 {
757   TestApplication application;
758
759   Integration::SetPanGestureMinimumDistance(100);
760
761   PanGestureDetector detector = PanGestureDetector::New();
762
763   Actor actor = Actor::New();
764   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
765   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
766   application.GetScene().Add(actor);
767
768   // Render and notify
769   application.SendNotification();
770   application.Render();
771
772   detector.Attach(actor);
773
774   SignalData             data;
775   GestureReceivedFunctor functor(data);
776   detector.DetectedSignal().Connect(&application, functor);
777
778   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
779   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
780   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
781   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
782   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
783   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
784
785   application.SendNotification();
786
787   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
788
789   END_TEST;
790 }
791
792 int UtcDaliPanGestureRecognizerUpdateParamsMinDistance(void)
793 {
794   TestApplication application;
795
796   Integration::SetPanGestureMinimumDistance(100);
797
798   PanGestureDetector detector = PanGestureDetector::New();
799
800   Actor actor = Actor::New();
801   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
802   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
803   application.GetScene().Add(actor);
804
805   // Render and notify
806   application.SendNotification();
807   application.Render();
808
809   detector.Attach(actor);
810
811   SignalData             data;
812   GestureReceivedFunctor functor(data);
813   detector.DetectedSignal().Connect(&application, functor);
814
815   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
816   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
817   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
818   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
819   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
820   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
821
822   application.SendNotification();
823
824   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
825   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 90.0f), 756));
826   application.SendNotification();
827   data.Reset();
828
829   Integration::SetPanGestureMinimumDistance(130);
830
831   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
832   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251));
833   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352));
834   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453));
835   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554));
836   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655));
837   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 100.0f),756));
838   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 110.0f),857));
839   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 120.0f),858));
840
841   application.SendNotification();
842
843   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
844
845   END_TEST;
846 }