Gesture event refactor
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-PinchGestureRecognizer.cpp
1 /*
2  * Copyright (c) 2019 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 <dali/public-api/dali-core.h>
22 #include <dali/integration-api/input-options.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/render-task-list-integ.h>
25 #include <dali/internal/event/events/pinch-gesture-event.h>
26 #include <dali-test-suite-utils.h>
27 #include <test-touch-utils.h>
28
29 using namespace Dali;
30
31 ///////////////////////////////////////////////////////////////////////////////
32 namespace
33 {
34
35 struct SignalData
36 {
37   SignalData()
38   : functorCalled(false),
39     voidFunctorCalled(false),
40     receivedGesture(Gesture::Started)
41   {}
42
43   void Reset()
44   {
45     functorCalled = false;
46     voidFunctorCalled = false;
47
48     receivedGesture.state = Gesture::Started;
49
50     pinchedActor.Reset();
51   }
52
53   bool functorCalled;
54   bool voidFunctorCalled;
55   PinchGesture receivedGesture;
56   Actor pinchedActor;
57 };
58
59 // Functor that sets the data when called
60 struct GestureReceivedFunctor
61 {
62   GestureReceivedFunctor(SignalData& data) : signalData(data) { }
63
64   void operator()(Actor actor, const PinchGesture& pinch)
65   {
66     signalData.functorCalled = true;
67     signalData.receivedGesture = pinch;
68     signalData.pinchedActor = actor;
69   }
70
71   void operator()()
72   {
73     signalData.voidFunctorCalled = true;
74   }
75
76   SignalData& signalData;
77 };
78
79
80 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
81 {
82   Integration::TouchEvent touchEvent;
83   Integration::Point point;
84   point.SetState( state );
85   point.SetScreenPosition( screenPosition );
86   point.SetDeviceClass( Device::Class::TOUCH );
87   point.SetDeviceSubclass( Device::Subclass::NONE );
88   touchEvent.points.push_back( point );
89   touchEvent.time = time;
90   return touchEvent;
91 }
92
93 Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time )
94 {
95   Integration::TouchEvent touchEvent;
96   Integration::Point point;
97   point.SetState( stateA );
98   point.SetScreenPosition( screenPositionA );
99   point.SetDeviceClass( Device::Class::TOUCH );
100   point.SetDeviceSubclass( Device::Subclass::NONE );
101   touchEvent.points.push_back( point );
102   point.SetScreenPosition( screenPositionB );
103   point.SetState( stateB);
104   touchEvent.points.push_back( point );
105   touchEvent.time = time;
106   return touchEvent;
107 }
108
109
110 } // anon namespace
111
112 ///////////////////////////////////////////////////////////////////////////////
113
114
115 int UtcDaliPinchGestureRecognizerBasicNoAction(void)
116 {
117   TestApplication application;
118
119   PinchGestureDetector detector = PinchGestureDetector::New();
120
121   Actor actor = Actor::New();
122   actor.SetSize(100.0f, 100.0f);
123   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
124   Stage::GetCurrent().Add(actor);
125
126   // Render and notify
127   application.SendNotification();
128   application.Render();
129
130   detector.Attach(actor);
131
132   SignalData data;
133   GestureReceivedFunctor functor(data);
134   detector.DetectedSignal().Connect(&application, functor);
135
136   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 150 ) );
137
138   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 200 ) );
139
140   application.SendNotification();
141
142   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
143
144   END_TEST;
145 }
146
147 int UtcDaliPinchGestureRecognizerBasic(void)
148 {
149   TestApplication application;
150
151   PinchGestureDetector detector = PinchGestureDetector::New();
152
153   Actor actor = Actor::New();
154   actor.SetSize(100.0f, 100.0f);
155   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
156   Stage::GetCurrent().Add(actor);
157
158   // Render and notify
159   application.SendNotification();
160   application.Render();
161
162   detector.Attach(actor);
163
164   SignalData data;
165   GestureReceivedFunctor functor(data);
166   detector.DetectedSignal().Connect(&application, functor);
167
168   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
169   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
170   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
171   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
172   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
173
174   application.SendNotification();
175
176   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
177
178   END_TEST;
179 }
180
181 int UtcDaliPinchGestureRecognizerEndEarly01(void)
182 {
183   TestApplication application;
184
185   PinchGestureDetector detector = PinchGestureDetector::New();
186
187   Actor actor = Actor::New();
188   actor.SetSize(100.0f, 100.0f);
189   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
190   Stage::GetCurrent().Add(actor);
191
192   // Render and notify
193   application.SendNotification();
194   application.Render();
195
196   detector.Attach(actor);
197
198   SignalData data;
199   GestureReceivedFunctor functor(data);
200   detector.DetectedSignal().Connect(&application, functor);
201
202   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
203   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
204   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 29.0f ), 165 ) );
205   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
206   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
207   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
208
209   application.SendNotification();
210
211   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
212
213   END_TEST;
214 }
215
216 int UtcDaliPinchGestureRecognizerEndEarly02(void)
217 {
218   TestApplication application;
219
220   PinchGestureDetector detector = PinchGestureDetector::New();
221
222   Actor actor = Actor::New();
223   actor.SetSize(100.0f, 100.0f);
224   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
225   Stage::GetCurrent().Add(actor);
226
227   // Render and notify
228   application.SendNotification();
229   application.Render();
230
231   detector.Attach(actor);
232
233   SignalData data;
234   GestureReceivedFunctor functor(data);
235   detector.DetectedSignal().Connect(&application, functor);
236
237   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
238   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
239   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
240   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::UP, Vector2( 20.0f, 74.0f ), 173 ) );
241   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::DOWN, Vector2( 20.0f, 74.0f ), 178 ) );
242   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
243   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
244
245   application.SendNotification();
246
247   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
248
249   END_TEST;
250 }
251
252 int UtcDaliPinchGestureRecognizerRealistic01(void)
253 {
254   TestApplication application;
255
256   PinchGestureDetector detector = PinchGestureDetector::New();
257
258   Actor actor = Actor::New();
259   actor.SetSize(100.0f, 100.0f);
260   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
261   Stage::GetCurrent().Add(actor);
262
263   // Render and notify
264   application.SendNotification();
265   application.Render();
266
267   detector.Attach(actor);
268
269   SignalData data;
270   GestureReceivedFunctor functor(data);
271   detector.DetectedSignal().Connect(&application, functor);
272
273   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
274   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
275   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
276   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
277   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
278   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
279   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
280   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
281   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
282   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
283   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 56.0f ), PointState::UP, Vector2( 20.0f, 60.0f ), 150 ) );
284   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
285
286   application.SendNotification();
287
288   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
289
290   END_TEST;
291 }
292
293 int UtcDaliPinchGestureRecognizerRealistic02(void)
294 {
295   TestApplication application;
296
297   PinchGestureDetector detector = PinchGestureDetector::New();
298
299   Actor actor = Actor::New();
300   actor.SetSize(100.0f, 100.0f);
301   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
302   Stage::GetCurrent().Add(actor);
303
304   // Render and notify
305   application.SendNotification();
306   application.Render();
307
308   detector.Attach(actor);
309
310   SignalData data;
311   GestureReceivedFunctor functor(data);
312   detector.DetectedSignal().Connect(&application, functor);
313
314   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
315   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
316   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
317   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
318   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
319   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
320   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
321   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
322   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
323   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
324   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
325
326   application.SendNotification();
327
328   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
329
330   END_TEST;
331 }
332
333 int UtcDaliPinchGestureRecognizerRealistic03(void)
334 {
335   TestApplication application;
336
337   PinchGestureDetector detector = PinchGestureDetector::New();
338
339   Actor actor = Actor::New();
340   actor.SetSize(100.0f, 100.0f);
341   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
342   Stage::GetCurrent().Add(actor);
343
344   // Render and notify
345   application.SendNotification();
346   application.Render();
347
348   detector.Attach(actor);
349
350   SignalData data;
351   GestureReceivedFunctor functor(data);
352   detector.DetectedSignal().Connect(&application, functor);
353
354   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
355   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
356   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
357   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
358   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
359   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
360   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 77.0f ), 127 ) );
361   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
362   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 47.0f ), PointState::MOTION, Vector2( 20.0f, 73.0f ), 133 ) );
363   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
364   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 47.0f ), PointState::MOTION, Vector2( 20.0f, 67.0f ), 137 ) );
365   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
366   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 53.0f ), PointState::MOTION, Vector2( 20.0f, 63.0f ), 143 ) );
367   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
368
369   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
370
371   application.SendNotification();
372
373   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
374
375   END_TEST;
376 }
377
378 int UtcDaliPinchGestureRecognizerMultipleDetectors(void)
379 {
380   TestApplication application;
381
382   Actor actor = Actor::New();
383   actor.SetSize(100.0f, 100.0f);
384   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
385   Stage::GetCurrent().Add(actor);
386
387   Actor actor2 = Actor::New();
388   actor2.SetSize(100.0f, 100.0f);
389   actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
390   actor2.SetX(100.0f);
391   Stage::GetCurrent().Add(actor2);
392
393   // Render and notify
394   application.SendNotification();
395   application.Render();
396
397   PinchGestureDetector detector = PinchGestureDetector::New();
398   detector.Attach(actor);
399
400   PinchGestureDetector detector2 = PinchGestureDetector::New();
401   detector2.Attach(actor2);
402
403   SignalData data;
404   GestureReceivedFunctor functor(data);
405   detector.DetectedSignal().Connect(&application, functor);
406
407   SignalData data2;
408   GestureReceivedFunctor functor2(data2);
409   detector2.DetectedSignal().Connect(&application, functor2);
410
411   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 120.0f, 20.0f ), PointState::DOWN, Vector2( 120.0f, 90.0f ), 150 ) );
412   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 28.0f ), PointState::MOTION, Vector2( 120.0f, 82.0f ), 160 ) );
413   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 37.0f ), PointState::MOTION, Vector2( 120.0f, 74.0f ), 170 ) );
414   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 46.0f ), PointState::MOTION, Vector2( 120.0f, 66.0f ), 180 ) );
415   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 55.0f ), PointState::MOTION, Vector2( 120.0f, 58.0f ), 190 ) );
416   application.ProcessEvent( GenerateDoubleTouch( PointState::UP, Vector2( 120.0f, 55.0f ), PointState::UP, Vector2( 120.0f, 58.0f ), 200 ) );
417
418   application.SendNotification();
419
420   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
421   DALI_TEST_EQUALS(true, data2.functorCalled, TEST_LOCATION);
422   DALI_TEST_EQUALS(true, actor2 == data2.pinchedActor, TEST_LOCATION);
423   data2.Reset();
424
425   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 250 ) );
426   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 260 ) );
427   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 270 ) );
428   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 280 ) );
429   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 290 ) );
430
431   application.SendNotification();
432
433   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
434   DALI_TEST_EQUALS(true, actor == data.pinchedActor, TEST_LOCATION);
435   DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
436
437   END_TEST;
438 }
439
440
441 int UtcDaliPinchGestureRecognizerShortDistance01(void)
442 {
443   TestApplication application;
444
445   Integration::SetPinchGestureMinimumDistance(7.0f);
446
447   PinchGestureDetector detector = PinchGestureDetector::New();
448
449   Actor actor = Actor::New();
450   actor.SetSize(100.0f, 100.0f);
451   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
452   Stage::GetCurrent().Add(actor);
453
454   // Render and notify
455   application.SendNotification();
456   application.Render();
457
458   detector.Attach(actor);
459
460   SignalData data;
461   GestureReceivedFunctor functor(data);
462   detector.DetectedSignal().Connect(&application, functor);
463
464   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
465   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
466   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
467   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
468   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
469
470   application.SendNotification();
471
472   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
473
474   END_TEST;
475 }
476
477 int UtcDaliPinchGestureRecognizerShortDistance02(void)
478 {
479   TestApplication application;
480
481   PinchGestureDetector detector = PinchGestureDetector::New();
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   detector.Attach(actor);
493
494   SignalData data;
495   GestureReceivedFunctor functor(data);
496   detector.DetectedSignal().Connect(&application, functor);
497
498   Integration::SetPinchGestureMinimumDistance(7.0f);
499
500   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
501   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
502   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
503   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
504   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
505
506   application.SendNotification();
507
508   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
509
510   END_TEST;
511 }
512
513 int UtcDaliPinchGestureRecognizerLongDistance01(void)
514 {
515   TestApplication application;
516
517   Integration::SetPinchGestureMinimumDistance(14.0f);
518
519   PinchGestureDetector detector = PinchGestureDetector::New();
520
521   Actor actor = Actor::New();
522   actor.SetSize(100.0f, 100.0f);
523   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
524   Stage::GetCurrent().Add(actor);
525
526   // Render and notify
527   application.SendNotification();
528   application.Render();
529
530   detector.Attach(actor);
531
532   SignalData data;
533   GestureReceivedFunctor functor(data);
534   detector.DetectedSignal().Connect(&application, functor);
535
536   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
537   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
538   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
539   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
540
541   application.SendNotification();
542
543   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
544
545   END_TEST;
546 }
547
548 int UtcDaliPinchGestureRecognizerLongDistance02(void)
549 {
550   TestApplication application;
551
552   Integration::SetPinchGestureMinimumDistance(14.0f);
553
554   PinchGestureDetector detector = PinchGestureDetector::New();
555
556   Actor actor = Actor::New();
557   actor.SetSize(100.0f, 100.0f);
558   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
559   Stage::GetCurrent().Add(actor);
560
561   // Render and notify
562   application.SendNotification();
563   application.Render();
564
565   detector.Attach(actor);
566
567   SignalData data;
568   GestureReceivedFunctor functor(data);
569   detector.DetectedSignal().Connect(&application, functor);
570
571   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
572   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
573   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
574   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
575   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
576
577   application.SendNotification();
578
579   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
580
581   END_TEST;
582 }
583
584 int UtcDaliPinchGestureRecognizerLongDistance03(void)
585 {
586   TestApplication application;
587
588   PinchGestureDetector detector = PinchGestureDetector::New();
589
590   Actor actor = Actor::New();
591   actor.SetSize(100.0f, 100.0f);
592   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
593   Stage::GetCurrent().Add(actor);
594
595   // Render and notify
596   application.SendNotification();
597   application.Render();
598
599   detector.Attach(actor);
600
601   SignalData data;
602   GestureReceivedFunctor functor(data);
603   detector.DetectedSignal().Connect(&application, functor);
604
605   Integration::SetPinchGestureMinimumDistance(14.0f);
606
607   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
608   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
609   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
610   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
611
612   application.SendNotification();
613
614   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
615
616   END_TEST;
617 }
618
619 int UtcDaliPinchGestureRecognizerLongDistance04(void)
620 {
621   TestApplication application;
622
623   PinchGestureDetector detector = PinchGestureDetector::New();
624
625   Actor actor = Actor::New();
626   actor.SetSize(100.0f, 100.0f);
627   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
628   Stage::GetCurrent().Add(actor);
629
630   // Render and notify
631   application.SendNotification();
632   application.Render();
633
634   detector.Attach(actor);
635
636   SignalData data;
637   GestureReceivedFunctor functor(data);
638   detector.DetectedSignal().Connect(&application, functor);
639
640   Integration::SetPinchGestureMinimumDistance(14.0f);
641
642   application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
643   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
644   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
645   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
646   application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
647
648   application.SendNotification();
649
650   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
651
652   END_TEST;
653 }