2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
29 ///////////////////////////////////////////////////////////////////////////////
35 : functorCalled(false),
36 voidFunctorCalled(false),
43 functorCalled = false;
44 voidFunctorCalled = false;
46 receivedGesture.Reset();
52 bool voidFunctorCalled;
53 PinchGesture receivedGesture;
57 // Functor that sets the data when called
58 struct GestureReceivedFunctor
60 GestureReceivedFunctor(SignalData& data)
65 void operator()(Actor actor, const PinchGesture& pinch)
67 signalData.functorCalled = true;
68 signalData.receivedGesture = pinch;
69 signalData.pinchedActor = actor;
74 signalData.voidFunctorCalled = true;
77 SignalData& signalData;
80 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time)
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;
93 Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time)
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;
111 ///////////////////////////////////////////////////////////////////////////////
113 int UtcDaliPinchGestureRecognizerBasicNoAction(void)
115 TestApplication application;
117 PinchGestureDetector detector = PinchGestureDetector::New();
119 Actor actor = Actor::New();
120 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
121 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
122 application.GetScene().Add(actor);
125 application.SendNotification();
126 application.Render();
128 detector.Attach(actor);
131 GestureReceivedFunctor functor(data);
132 detector.DetectedSignal().Connect(&application, functor);
134 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
136 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 200));
138 application.SendNotification();
140 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
145 int UtcDaliPinchGestureRecognizerBasic(void)
147 TestApplication application;
149 PinchGestureDetector detector = PinchGestureDetector::New();
151 Actor actor = Actor::New();
152 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
153 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
154 application.GetScene().Add(actor);
157 application.SendNotification();
158 application.Render();
160 detector.Attach(actor);
163 GestureReceivedFunctor functor(data);
164 detector.DetectedSignal().Connect(&application, functor);
166 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
167 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160));
168 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 74.0f), 170));
169 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 46.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 180));
170 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 58.0f), 190));
172 application.SendNotification();
174 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
179 int UtcDaliPinchGestureRecognizerEndEarly01(void)
181 TestApplication application;
183 PinchGestureDetector detector = PinchGestureDetector::New();
185 Actor actor = Actor::New();
186 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
187 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
188 application.GetScene().Add(actor);
191 application.SendNotification();
192 application.Render();
194 detector.Attach(actor);
197 GestureReceivedFunctor functor(data);
198 detector.DetectedSignal().Connect(&application, functor);
200 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
201 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160));
202 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 29.0f), 165));
203 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 74.0f), 170));
204 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 46.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 180));
205 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 58.0f), 190));
207 application.SendNotification();
209 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
214 int UtcDaliPinchGestureRecognizerEndEarly02(void)
216 TestApplication application;
218 PinchGestureDetector detector = PinchGestureDetector::New();
220 Actor actor = Actor::New();
221 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
222 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
223 application.GetScene().Add(actor);
226 application.SendNotification();
227 application.Render();
229 detector.Attach(actor);
232 GestureReceivedFunctor functor(data);
233 detector.DetectedSignal().Connect(&application, functor);
235 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
236 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160));
237 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 74.0f), 170));
238 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::UP, Vector2(20.0f, 74.0f), 173));
239 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::DOWN, Vector2(20.0f, 74.0f), 178));
240 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 46.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 180));
241 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 58.0f), 190));
243 application.SendNotification();
245 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
250 int UtcDaliPinchGestureRecognizerRealistic01(void)
252 TestApplication application;
254 PinchGestureDetector detector = PinchGestureDetector::New();
256 Actor actor = Actor::New();
257 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
258 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
259 application.GetScene().Add(actor);
262 application.SendNotification();
263 application.Render();
265 detector.Attach(actor);
268 GestureReceivedFunctor functor(data);
269 detector.DetectedSignal().Connect(&application, functor);
271 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 100));
272 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 105));
273 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 110));
274 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 25.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 115));
275 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 30.0f), PointState::MOTION, Vector2(20.0f, 85.0f), 120));
276 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 35.0f), PointState::MOTION, Vector2(20.0f, 80.0f), 125));
277 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), PointState::MOTION, Vector2(20.0f, 75.0f), 130));
278 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 45.0f), PointState::MOTION, Vector2(20.0f, 70.0f), 135));
279 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), PointState::MOTION, Vector2(20.0f, 65.0f), 140));
280 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 60.0f), 145));
281 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 56.0f), PointState::UP, Vector2(20.0f, 60.0f), 150));
282 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 56.0f), 155));
284 application.SendNotification();
286 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
291 int UtcDaliPinchGestureRecognizerRealistic02(void)
293 TestApplication application;
295 PinchGestureDetector detector = PinchGestureDetector::New();
297 Actor actor = Actor::New();
298 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
299 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
300 application.GetScene().Add(actor);
303 application.SendNotification();
304 application.Render();
306 detector.Attach(actor);
309 GestureReceivedFunctor functor(data);
310 detector.DetectedSignal().Connect(&application, functor);
312 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 100));
313 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 105));
314 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 110));
315 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 25.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 115));
316 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 30.0f), PointState::MOTION, Vector2(20.0f, 85.0f), 120));
317 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 35.0f), PointState::MOTION, Vector2(20.0f, 80.0f), 125));
318 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), PointState::MOTION, Vector2(20.0f, 75.0f), 130));
319 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 45.0f), PointState::MOTION, Vector2(20.0f, 70.0f), 135));
320 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), PointState::MOTION, Vector2(20.0f, 65.0f), 140));
321 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 60.0f), 145));
322 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 56.0f), 155));
324 application.SendNotification();
326 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
331 int UtcDaliPinchGestureRecognizerRealistic03(void)
333 TestApplication application;
335 PinchGestureDetector detector = PinchGestureDetector::New();
337 Actor actor = Actor::New();
338 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
339 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
340 application.GetScene().Add(actor);
343 application.SendNotification();
344 application.Render();
346 detector.Attach(actor);
349 GestureReceivedFunctor functor(data);
350 detector.DetectedSignal().Connect(&application, functor);
352 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 100));
353 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 105));
354 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 110));
355 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 25.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 115));
356 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 30.0f), PointState::MOTION, Vector2(20.0f, 85.0f), 120));
357 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 35.0f), PointState::MOTION, Vector2(20.0f, 80.0f), 125));
358 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 77.0f), 127));
359 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), PointState::MOTION, Vector2(20.0f, 75.0f), 130));
360 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 47.0f), PointState::MOTION, Vector2(20.0f, 73.0f), 133));
361 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 45.0f), PointState::MOTION, Vector2(20.0f, 70.0f), 135));
362 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 47.0f), PointState::MOTION, Vector2(20.0f, 67.0f), 137));
363 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 50.0f), PointState::MOTION, Vector2(20.0f, 65.0f), 140));
364 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 53.0f), PointState::MOTION, Vector2(20.0f, 63.0f), 143));
365 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 60.0f), 145));
367 application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 56.0f), 155));
369 application.SendNotification();
371 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
376 int UtcDaliPinchGestureRecognizerMultipleDetectors(void)
378 TestApplication application;
380 Actor actor = Actor::New();
381 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
382 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
383 application.GetScene().Add(actor);
385 Actor actor2 = Actor::New();
386 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
387 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
388 actor2.SetProperty(Actor::Property::POSITION_X, 100.0f);
389 application.GetScene().Add(actor2);
392 application.SendNotification();
393 application.Render();
395 PinchGestureDetector detector = PinchGestureDetector::New();
396 detector.Attach(actor);
398 PinchGestureDetector detector2 = PinchGestureDetector::New();
399 detector2.Attach(actor2);
402 GestureReceivedFunctor functor(data);
403 detector.DetectedSignal().Connect(&application, functor);
406 GestureReceivedFunctor functor2(data2);
407 detector2.DetectedSignal().Connect(&application, functor2);
409 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(120.0f, 20.0f), PointState::DOWN, Vector2(120.0f, 90.0f), 150));
410 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(120.0f, 28.0f), PointState::MOTION, Vector2(120.0f, 82.0f), 160));
411 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(120.0f, 37.0f), PointState::MOTION, Vector2(120.0f, 74.0f), 170));
412 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(120.0f, 46.0f), PointState::MOTION, Vector2(120.0f, 66.0f), 180));
413 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(120.0f, 55.0f), PointState::MOTION, Vector2(120.0f, 58.0f), 190));
414 application.ProcessEvent(GenerateDoubleTouch(PointState::UP, Vector2(120.0f, 55.0f), PointState::UP, Vector2(120.0f, 58.0f), 200));
416 application.SendNotification();
418 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
419 DALI_TEST_EQUALS(true, data2.functorCalled, TEST_LOCATION);
420 DALI_TEST_EQUALS(true, actor2 == data2.pinchedActor, TEST_LOCATION);
423 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 250));
424 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 260));
425 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 74.0f), 270));
426 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 46.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 280));
427 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 58.0f), 290));
429 application.SendNotification();
431 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
432 DALI_TEST_EQUALS(true, actor == data.pinchedActor, TEST_LOCATION);
433 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
438 int UtcDaliPinchGestureRecognizerShortDistance01(void)
440 TestApplication application;
442 Integration::SetPinchGestureMinimumDistance(7.0f);
444 PinchGestureDetector detector = PinchGestureDetector::New();
446 Actor actor = Actor::New();
447 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
448 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
449 application.GetScene().Add(actor);
452 application.SendNotification();
453 application.Render();
455 detector.Attach(actor);
458 GestureReceivedFunctor functor(data);
459 detector.DetectedSignal().Connect(&application, functor);
461 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
462 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160));
463 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 30.0f), PointState::MOTION, Vector2(20.0f, 80.0f), 170));
464 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 32.0f), PointState::MOTION, Vector2(20.0f, 78.0f), 180));
465 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 34.0f), PointState::MOTION, Vector2(20.0f, 76.0f), 190));
467 application.SendNotification();
469 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
474 int UtcDaliPinchGestureRecognizerShortDistance02(void)
476 TestApplication application;
478 PinchGestureDetector detector = PinchGestureDetector::New();
480 Actor actor = Actor::New();
481 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
482 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
483 application.GetScene().Add(actor);
486 application.SendNotification();
487 application.Render();
489 detector.Attach(actor);
492 GestureReceivedFunctor functor(data);
493 detector.DetectedSignal().Connect(&application, functor);
495 Integration::SetPinchGestureMinimumDistance(7.0f);
497 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
498 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160));
499 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 30.0f), PointState::MOTION, Vector2(20.0f, 80.0f), 170));
500 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 32.0f), PointState::MOTION, Vector2(20.0f, 78.0f), 180));
501 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 34.0f), PointState::MOTION, Vector2(20.0f, 76.0f), 190));
503 application.SendNotification();
505 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
510 int UtcDaliPinchGestureRecognizerLongDistance01(void)
512 TestApplication application;
514 Integration::SetPinchGestureMinimumDistance(14.0f);
516 PinchGestureDetector detector = PinchGestureDetector::New();
518 Actor actor = Actor::New();
519 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
520 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
521 application.GetScene().Add(actor);
524 application.SendNotification();
525 application.Render();
527 detector.Attach(actor);
530 GestureReceivedFunctor functor(data);
531 detector.DetectedSignal().Connect(&application, functor);
533 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
534 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 22.0f), PointState::MOTION, Vector2(20.0f, 88.0f), 160));
535 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 24.0f), PointState::MOTION, Vector2(20.0f, 86.0f), 170));
536 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 26.0f), PointState::MOTION, Vector2(20.0f, 84.0f), 180));
538 application.SendNotification();
540 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
545 int UtcDaliPinchGestureRecognizerLongDistance02(void)
547 TestApplication application;
549 Integration::SetPinchGestureMinimumDistance(14.0f);
551 PinchGestureDetector detector = PinchGestureDetector::New();
553 Actor actor = Actor::New();
554 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
555 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
556 application.GetScene().Add(actor);
559 application.SendNotification();
560 application.Render();
562 detector.Attach(actor);
565 GestureReceivedFunctor functor(data);
566 detector.DetectedSignal().Connect(&application, functor);
568 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
569 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 38.0f), PointState::MOTION, Vector2(20.0f, 72.0f), 160));
570 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), PointState::MOTION, Vector2(20.0f, 70.0f), 170));
571 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 42.0f), PointState::MOTION, Vector2(20.0f, 68.0f), 180));
572 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 44.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 190));
574 application.SendNotification();
576 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
581 int UtcDaliPinchGestureRecognizerLongDistance03(void)
583 TestApplication application;
585 PinchGestureDetector detector = PinchGestureDetector::New();
587 Actor actor = Actor::New();
588 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
589 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
590 application.GetScene().Add(actor);
593 application.SendNotification();
594 application.Render();
596 detector.Attach(actor);
599 GestureReceivedFunctor functor(data);
600 detector.DetectedSignal().Connect(&application, functor);
602 Integration::SetPinchGestureMinimumDistance(14.0f);
604 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
605 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 22.0f), PointState::MOTION, Vector2(20.0f, 88.0f), 160));
606 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 24.0f), PointState::MOTION, Vector2(20.0f, 86.0f), 170));
607 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 26.0f), PointState::MOTION, Vector2(20.0f, 84.0f), 180));
609 application.SendNotification();
611 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
616 int UtcDaliPinchGestureRecognizerLongDistance04(void)
618 TestApplication application;
620 PinchGestureDetector detector = PinchGestureDetector::New();
622 Actor actor = Actor::New();
623 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
624 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
625 application.GetScene().Add(actor);
628 application.SendNotification();
629 application.Render();
631 detector.Attach(actor);
634 GestureReceivedFunctor functor(data);
635 detector.DetectedSignal().Connect(&application, functor);
637 Integration::SetPinchGestureMinimumDistance(14.0f);
639 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
640 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 38.0f), PointState::MOTION, Vector2(20.0f, 72.0f), 160));
641 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), PointState::MOTION, Vector2(20.0f, 70.0f), 170));
642 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 42.0f), PointState::MOTION, Vector2(20.0f, 68.0f), 180));
643 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 44.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 190));
645 application.SendNotification();
647 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
652 int UtcDaliPinchGestureRecognizerMinimumTouchEvents(void)
654 TestApplication application;
656 PinchGestureDetector detector = PinchGestureDetector::New();
658 Actor actor = Actor::New();
659 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
660 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
661 application.GetScene().Add(actor);
664 application.SendNotification();
665 application.Render();
667 detector.Attach(actor);
670 GestureReceivedFunctor functor(data);
671 detector.DetectedSignal().Connect(&application, functor);
674 // 2 touch events make a gesture begin
675 Integration::SetPinchGestureMinimumTouchEvents(2);
676 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
677 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(90.0f, 90.0f), 160));
679 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
680 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
684 // 4 touch events make a gesture begin
685 Integration::SetPinchGestureMinimumTouchEvents(4);
686 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
687 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(90.0f, 90.0f), 160));
689 // Check the gesture is not detected unlike previous case
690 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
695 int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void)
697 TestApplication application;
699 PinchGestureDetector detector = PinchGestureDetector::New();
701 Actor actor = Actor::New();
702 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
703 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
704 application.GetScene().Add(actor);
707 application.SendNotification();
708 application.Render();
710 detector.Attach(actor);
713 GestureReceivedFunctor functor(data);
714 detector.DetectedSignal().Connect(&application, functor);
717 // > 2 touch events make a gesture begin
718 // > 4 touch events generate gestures after begin
719 Integration::SetPinchGestureMinimumTouchEvents(2);
720 Integration::SetPinchGestureMinimumTouchEventsAfterStart(6);
722 application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150));
723 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(90.0f, 90.0f), 160));
725 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
726 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
728 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 170));
729 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 180));
730 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 190));
731 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 200));
732 // > Test : not enough touch events to make the gesture state "CONTINUING"
733 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
735 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 210));
736 application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(20.0f, 90.0f), 220));
737 // > Test : 6 touch events after start make the gesture state "CONTINUING"
738 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);