2 * Copyright (c) 2019 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.
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-test-suite-utils.h>
26 #include <test-touch-utils.h>
30 ///////////////////////////////////////////////////////////////////////////////
37 : functorCalled(false),
38 voidFunctorCalled(false),
39 receivedGesture(Gesture::Started)
44 functorCalled = false;
45 voidFunctorCalled = false;
47 receivedGesture.state = Gesture::Started;
53 bool voidFunctorCalled;
54 PinchGesture receivedGesture;
58 // Functor that sets the data when called
59 struct GestureReceivedFunctor
61 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
63 void operator()(Actor actor, const PinchGesture& pinch)
65 signalData.functorCalled = true;
66 signalData.receivedGesture = pinch;
67 signalData.pinchedActor = actor;
72 signalData.voidFunctorCalled = true;
75 SignalData& signalData;
79 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
81 Integration::TouchEvent touchEvent;
82 Integration::Point point;
83 point.SetState( state );
84 point.SetScreenPosition( screenPosition );
85 point.SetDeviceClass( Device::Class::TOUCH );
86 point.SetDeviceSubclass( Device::Subclass::NONE );
87 touchEvent.points.push_back( point );
88 touchEvent.time = time;
92 Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time )
94 Integration::TouchEvent touchEvent;
95 Integration::Point point;
96 point.SetState( stateA );
97 point.SetScreenPosition( screenPositionA );
98 point.SetDeviceClass( Device::Class::TOUCH );
99 point.SetDeviceSubclass( Device::Subclass::NONE );
100 touchEvent.points.push_back( point );
101 point.SetScreenPosition( screenPositionB );
102 point.SetState( stateB);
103 touchEvent.points.push_back( point );
104 touchEvent.time = time;
111 ///////////////////////////////////////////////////////////////////////////////
114 int UtcDaliPinchGestureRecognizerBasicNoAction(void)
116 TestApplication application;
118 PinchGestureDetector detector = PinchGestureDetector::New();
120 Actor actor = Actor::New();
121 actor.SetSize(100.0f, 100.0f);
122 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
123 Stage::GetCurrent().Add(actor);
126 application.SendNotification();
127 application.Render();
129 detector.Attach(actor);
132 GestureReceivedFunctor functor(data);
133 detector.DetectedSignal().Connect(&application, functor);
135 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 150 ) );
137 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 200 ) );
139 application.SendNotification();
141 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
146 int UtcDaliPinchGestureRecognizerBasic(void)
148 TestApplication application;
150 PinchGestureDetector detector = PinchGestureDetector::New();
152 Actor actor = Actor::New();
153 actor.SetSize(100.0f, 100.0f);
154 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
155 Stage::GetCurrent().Add(actor);
158 application.SendNotification();
159 application.Render();
161 detector.Attach(actor);
164 GestureReceivedFunctor functor(data);
165 detector.DetectedSignal().Connect(&application, functor);
167 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
168 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
169 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
170 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
171 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
173 application.SendNotification();
175 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
180 int UtcDaliPinchGestureRecognizerEndEarly01(void)
182 TestApplication application;
184 PinchGestureDetector detector = PinchGestureDetector::New();
186 Actor actor = Actor::New();
187 actor.SetSize(100.0f, 100.0f);
188 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
189 Stage::GetCurrent().Add(actor);
192 application.SendNotification();
193 application.Render();
195 detector.Attach(actor);
198 GestureReceivedFunctor functor(data);
199 detector.DetectedSignal().Connect(&application, functor);
201 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
202 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
203 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 29.0f ), 165 ) );
204 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
205 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
206 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
208 application.SendNotification();
210 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
215 int UtcDaliPinchGestureRecognizerEndEarly02(void)
217 TestApplication application;
219 PinchGestureDetector detector = PinchGestureDetector::New();
221 Actor actor = Actor::New();
222 actor.SetSize(100.0f, 100.0f);
223 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
224 Stage::GetCurrent().Add(actor);
227 application.SendNotification();
228 application.Render();
230 detector.Attach(actor);
233 GestureReceivedFunctor functor(data);
234 detector.DetectedSignal().Connect(&application, functor);
236 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
237 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
238 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) );
239 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::UP, Vector2( 20.0f, 74.0f ), 173 ) );
240 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::DOWN, Vector2( 20.0f, 74.0f ), 178 ) );
241 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) );
242 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) );
244 application.SendNotification();
246 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
251 int UtcDaliPinchGestureRecognizerRealistic01(void)
253 TestApplication application;
255 PinchGestureDetector detector = PinchGestureDetector::New();
257 Actor actor = Actor::New();
258 actor.SetSize(100.0f, 100.0f);
259 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
260 Stage::GetCurrent().Add(actor);
263 application.SendNotification();
264 application.Render();
266 detector.Attach(actor);
269 GestureReceivedFunctor functor(data);
270 detector.DetectedSignal().Connect(&application, functor);
272 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
273 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
274 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
275 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
276 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
277 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
278 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
279 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
280 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
281 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
282 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 56.0f ), PointState::UP, Vector2( 20.0f, 60.0f ), 150 ) );
283 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
285 application.SendNotification();
287 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
292 int UtcDaliPinchGestureRecognizerRealistic02(void)
294 TestApplication application;
296 PinchGestureDetector detector = PinchGestureDetector::New();
298 Actor actor = Actor::New();
299 actor.SetSize(100.0f, 100.0f);
300 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
301 Stage::GetCurrent().Add(actor);
304 application.SendNotification();
305 application.Render();
307 detector.Attach(actor);
310 GestureReceivedFunctor functor(data);
311 detector.DetectedSignal().Connect(&application, functor);
313 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
314 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
315 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
316 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
317 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
318 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
319 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
320 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
321 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
322 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
323 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
325 application.SendNotification();
327 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
332 int UtcDaliPinchGestureRecognizerRealistic03(void)
334 TestApplication application;
336 PinchGestureDetector detector = PinchGestureDetector::New();
338 Actor actor = Actor::New();
339 actor.SetSize(100.0f, 100.0f);
340 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
341 Stage::GetCurrent().Add(actor);
344 application.SendNotification();
345 application.Render();
347 detector.Attach(actor);
350 GestureReceivedFunctor functor(data);
351 detector.DetectedSignal().Connect(&application, functor);
353 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 100 ) );
354 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 20.0f ), 105 ) );
355 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 110 ) );
356 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 25.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 115 ) );
357 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 85.0f ), 120 ) );
358 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 35.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 125 ) );
359 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 77.0f ), 127 ) );
360 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 75.0f ), 130 ) );
361 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 47.0f ), PointState::MOTION, Vector2( 20.0f, 73.0f ), 133 ) );
362 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 45.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 135 ) );
363 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 47.0f ), PointState::MOTION, Vector2( 20.0f, 67.0f ), 137 ) );
364 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 50.0f ), PointState::MOTION, Vector2( 20.0f, 65.0f ), 140 ) );
365 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 53.0f ), PointState::MOTION, Vector2( 20.0f, 63.0f ), 143 ) );
366 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 60.0f ), 145 ) );
368 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 56.0f ), 155 ) );
370 application.SendNotification();
372 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
377 int UtcDaliPinchGestureRecognizerMultipleDetectors(void)
379 TestApplication application;
381 Actor actor = Actor::New();
382 actor.SetSize(100.0f, 100.0f);
383 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
384 Stage::GetCurrent().Add(actor);
386 Actor actor2 = Actor::New();
387 actor2.SetSize(100.0f, 100.0f);
388 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
390 Stage::GetCurrent().Add(actor2);
393 application.SendNotification();
394 application.Render();
396 PinchGestureDetector detector = PinchGestureDetector::New();
397 detector.Attach(actor);
399 PinchGestureDetector detector2 = PinchGestureDetector::New();
400 detector2.Attach(actor2);
403 GestureReceivedFunctor functor(data);
404 detector.DetectedSignal().Connect(&application, functor);
407 GestureReceivedFunctor functor2(data2);
408 detector2.DetectedSignal().Connect(&application, functor2);
410 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 120.0f, 20.0f ), PointState::DOWN, Vector2( 120.0f, 90.0f ), 150 ) );
411 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 28.0f ), PointState::MOTION, Vector2( 120.0f, 82.0f ), 160 ) );
412 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 37.0f ), PointState::MOTION, Vector2( 120.0f, 74.0f ), 170 ) );
413 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 46.0f ), PointState::MOTION, Vector2( 120.0f, 66.0f ), 180 ) );
414 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 120.0f, 55.0f ), PointState::MOTION, Vector2( 120.0f, 58.0f ), 190 ) );
415 application.ProcessEvent( GenerateDoubleTouch( PointState::UP, Vector2( 120.0f, 55.0f ), PointState::UP, Vector2( 120.0f, 58.0f ), 200 ) );
417 application.SendNotification();
419 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
420 DALI_TEST_EQUALS(true, data2.functorCalled, TEST_LOCATION);
421 DALI_TEST_EQUALS(true, actor2 == data2.pinchedActor, TEST_LOCATION);
424 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 250 ) );
425 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 260 ) );
426 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 270 ) );
427 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 280 ) );
428 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 290 ) );
430 application.SendNotification();
432 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
433 DALI_TEST_EQUALS(true, actor == data.pinchedActor, TEST_LOCATION);
434 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
440 int UtcDaliPinchGestureRecognizerShortDistance01(void)
442 TestApplication application;
444 Integration::SetPinchGestureMinimumDistance(7.0f);
446 PinchGestureDetector detector = PinchGestureDetector::New();
448 Actor actor = Actor::New();
449 actor.SetSize(100.0f, 100.0f);
450 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
451 Stage::GetCurrent().Add(actor);
454 application.SendNotification();
455 application.Render();
457 detector.Attach(actor);
460 GestureReceivedFunctor functor(data);
461 detector.DetectedSignal().Connect(&application, functor);
463 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
464 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
465 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
466 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
467 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
469 application.SendNotification();
471 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
476 int UtcDaliPinchGestureRecognizerShortDistance02(void)
478 TestApplication application;
480 PinchGestureDetector detector = PinchGestureDetector::New();
482 Actor actor = Actor::New();
483 actor.SetSize(100.0f, 100.0f);
484 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
485 Stage::GetCurrent().Add(actor);
488 application.SendNotification();
489 application.Render();
491 detector.Attach(actor);
494 GestureReceivedFunctor functor(data);
495 detector.DetectedSignal().Connect(&application, functor);
497 Integration::SetPinchGestureMinimumDistance(7.0f);
499 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
500 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
501 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
502 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
503 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
505 application.SendNotification();
507 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
512 int UtcDaliPinchGestureRecognizerLongDistance01(void)
514 TestApplication application;
516 Integration::SetPinchGestureMinimumDistance(14.0f);
518 PinchGestureDetector detector = PinchGestureDetector::New();
520 Actor actor = Actor::New();
521 actor.SetSize(100.0f, 100.0f);
522 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
523 Stage::GetCurrent().Add(actor);
526 application.SendNotification();
527 application.Render();
529 detector.Attach(actor);
532 GestureReceivedFunctor functor(data);
533 detector.DetectedSignal().Connect(&application, functor);
535 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
536 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
537 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
538 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
540 application.SendNotification();
542 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
547 int UtcDaliPinchGestureRecognizerLongDistance02(void)
549 TestApplication application;
551 Integration::SetPinchGestureMinimumDistance(14.0f);
553 PinchGestureDetector detector = PinchGestureDetector::New();
555 Actor actor = Actor::New();
556 actor.SetSize(100.0f, 100.0f);
557 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
558 Stage::GetCurrent().Add(actor);
561 application.SendNotification();
562 application.Render();
564 detector.Attach(actor);
567 GestureReceivedFunctor functor(data);
568 detector.DetectedSignal().Connect(&application, functor);
570 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
571 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
572 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
573 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
574 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
576 application.SendNotification();
578 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
583 int UtcDaliPinchGestureRecognizerLongDistance03(void)
585 TestApplication application;
587 PinchGestureDetector detector = PinchGestureDetector::New();
589 Actor actor = Actor::New();
590 actor.SetSize(100.0f, 100.0f);
591 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
592 Stage::GetCurrent().Add(actor);
595 application.SendNotification();
596 application.Render();
598 detector.Attach(actor);
601 GestureReceivedFunctor functor(data);
602 detector.DetectedSignal().Connect(&application, functor);
604 Integration::SetPinchGestureMinimumDistance(14.0f);
606 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
607 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
608 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
609 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
611 application.SendNotification();
613 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
618 int UtcDaliPinchGestureRecognizerLongDistance04(void)
620 TestApplication application;
622 PinchGestureDetector detector = PinchGestureDetector::New();
624 Actor actor = Actor::New();
625 actor.SetSize(100.0f, 100.0f);
626 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
627 Stage::GetCurrent().Add(actor);
630 application.SendNotification();
631 application.Render();
633 detector.Attach(actor);
636 GestureReceivedFunctor functor(data);
637 detector.DetectedSignal().Connect(&application, functor);
639 Integration::SetPinchGestureMinimumDistance(14.0f);
641 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
642 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
643 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
644 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
645 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
647 application.SendNotification();
649 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
654 int UtcDaliPinchGestureRecognizerMinimumTouchEvents(void)
656 TestApplication application;
658 PinchGestureDetector detector = PinchGestureDetector::New();
660 Actor actor = Actor::New();
661 actor.SetSize( 100.0f, 100.0f );
662 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
663 Stage::GetCurrent().Add( actor );
666 application.SendNotification();
667 application.Render();
669 detector.Attach( actor );
672 GestureReceivedFunctor functor( data );
673 detector.DetectedSignal().Connect( &application, functor );
676 // 2 touch events make a gesture begin
677 Integration::SetPinchGestureMinimumTouchEvents( 2 );
678 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
679 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
681 DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.state, TEST_LOCATION );
682 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
686 // 4 touch events make a gesture begin
687 Integration::SetPinchGestureMinimumTouchEvents( 4 );
688 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
689 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
691 // Check the gesture is not detected unlike previous case
692 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
697 int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void)
699 TestApplication application;
701 PinchGestureDetector detector = PinchGestureDetector::New();
703 Actor actor = Actor::New();
704 actor.SetSize( 100.0f, 100.0f );
705 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
706 Stage::GetCurrent().Add( actor );
709 application.SendNotification();
710 application.Render();
712 detector.Attach( actor );
715 GestureReceivedFunctor functor( data );
716 detector.DetectedSignal().Connect( &application, functor );
719 // > 2 touch events make a gesture begin
720 // > 4 touch events generate gestures after begin
721 Integration::SetPinchGestureMinimumTouchEvents(2);
722 Integration::SetPinchGestureMinimumTouchEventsAfterStart(6);
724 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
725 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
727 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
728 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
730 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) );
731 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 180 ) );
732 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) );
733 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) );
734 // > Test : not enough touch events to make the gesture state "Continuing"
735 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
737 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) );
738 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) );
739 // > Test : 6 touch events after start make the gesture state "Continuing"
740 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);