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.
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>
29 ///////////////////////////////////////////////////////////////////////////////
36 : functorCalled(false),
37 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) : signalData(data) { }
62 void operator()(Actor actor, const PinchGesture& pinch)
64 signalData.functorCalled = true;
65 signalData.receivedGesture = pinch;
66 signalData.pinchedActor = actor;
71 signalData.voidFunctorCalled = true;
74 SignalData& signalData;
78 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
80 Integration::TouchEvent touchEvent;
81 Integration::Point point;
82 point.SetState( state );
83 point.SetScreenPosition( screenPosition );
84 point.SetDeviceClass( Device::Class::TOUCH );
85 point.SetDeviceSubclass( Device::Subclass::NONE );
86 touchEvent.points.push_back( point );
87 touchEvent.time = time;
91 Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time )
93 Integration::TouchEvent touchEvent;
94 Integration::Point point;
95 point.SetState( stateA );
96 point.SetScreenPosition( screenPositionA );
97 point.SetDeviceClass( Device::Class::TOUCH );
98 point.SetDeviceSubclass( Device::Subclass::NONE );
99 touchEvent.points.push_back( point );
100 point.SetScreenPosition( screenPositionB );
101 point.SetState( stateB);
102 touchEvent.points.push_back( point );
103 touchEvent.time = time;
110 ///////////////////////////////////////////////////////////////////////////////
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);
439 int UtcDaliPinchGestureRecognizerShortDistance01(void)
441 TestApplication application;
443 Integration::SetPinchGestureMinimumDistance(7.0f);
445 PinchGestureDetector detector = PinchGestureDetector::New();
447 Actor actor = Actor::New();
448 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
449 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
450 application.GetScene().Add(actor);
453 application.SendNotification();
454 application.Render();
456 detector.Attach(actor);
459 GestureReceivedFunctor functor(data);
460 detector.DetectedSignal().Connect(&application, functor);
462 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
463 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
464 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
465 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
466 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
468 application.SendNotification();
470 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
475 int UtcDaliPinchGestureRecognizerShortDistance02(void)
477 TestApplication application;
479 PinchGestureDetector detector = PinchGestureDetector::New();
481 Actor actor = Actor::New();
482 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
483 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
484 application.GetScene().Add(actor);
487 application.SendNotification();
488 application.Render();
490 detector.Attach(actor);
493 GestureReceivedFunctor functor(data);
494 detector.DetectedSignal().Connect(&application, functor);
496 Integration::SetPinchGestureMinimumDistance(7.0f);
498 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
499 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) );
500 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 30.0f ), PointState::MOTION, Vector2( 20.0f, 80.0f ), 170 ) );
501 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 32.0f ), PointState::MOTION, Vector2( 20.0f, 78.0f ), 180 ) );
502 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 34.0f ), PointState::MOTION, Vector2( 20.0f, 76.0f ), 190 ) );
504 application.SendNotification();
506 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
511 int UtcDaliPinchGestureRecognizerLongDistance01(void)
513 TestApplication application;
515 Integration::SetPinchGestureMinimumDistance(14.0f);
517 PinchGestureDetector detector = PinchGestureDetector::New();
519 Actor actor = Actor::New();
520 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
521 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
522 application.GetScene().Add(actor);
525 application.SendNotification();
526 application.Render();
528 detector.Attach(actor);
531 GestureReceivedFunctor functor(data);
532 detector.DetectedSignal().Connect(&application, functor);
534 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
535 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
536 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
537 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
539 application.SendNotification();
541 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
546 int UtcDaliPinchGestureRecognizerLongDistance02(void)
548 TestApplication application;
550 Integration::SetPinchGestureMinimumDistance(14.0f);
552 PinchGestureDetector detector = PinchGestureDetector::New();
554 Actor actor = Actor::New();
555 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
556 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
557 application.GetScene().Add(actor);
560 application.SendNotification();
561 application.Render();
563 detector.Attach(actor);
566 GestureReceivedFunctor functor(data);
567 detector.DetectedSignal().Connect(&application, functor);
569 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
570 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
571 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
572 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
573 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
575 application.SendNotification();
577 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
582 int UtcDaliPinchGestureRecognizerLongDistance03(void)
584 TestApplication application;
586 PinchGestureDetector detector = PinchGestureDetector::New();
588 Actor actor = Actor::New();
589 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
590 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
591 application.GetScene().Add(actor);
594 application.SendNotification();
595 application.Render();
597 detector.Attach(actor);
600 GestureReceivedFunctor functor(data);
601 detector.DetectedSignal().Connect(&application, functor);
603 Integration::SetPinchGestureMinimumDistance(14.0f);
605 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
606 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 22.0f ), PointState::MOTION, Vector2( 20.0f, 88.0f ), 160 ) );
607 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 24.0f ), PointState::MOTION, Vector2( 20.0f, 86.0f ), 170 ) );
608 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 26.0f ), PointState::MOTION, Vector2( 20.0f, 84.0f ), 180 ) );
610 application.SendNotification();
612 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
617 int UtcDaliPinchGestureRecognizerLongDistance04(void)
619 TestApplication application;
621 PinchGestureDetector detector = PinchGestureDetector::New();
623 Actor actor = Actor::New();
624 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
625 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
626 application.GetScene().Add(actor);
629 application.SendNotification();
630 application.Render();
632 detector.Attach(actor);
635 GestureReceivedFunctor functor(data);
636 detector.DetectedSignal().Connect(&application, functor);
638 Integration::SetPinchGestureMinimumDistance(14.0f);
640 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
641 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 38.0f ), PointState::MOTION, Vector2( 20.0f, 72.0f ), 160 ) );
642 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), PointState::MOTION, Vector2( 20.0f, 70.0f ), 170 ) );
643 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 42.0f ), PointState::MOTION, Vector2( 20.0f, 68.0f ), 180 ) );
644 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 44.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 190 ) );
646 application.SendNotification();
648 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
653 int UtcDaliPinchGestureRecognizerMinimumTouchEvents(void)
655 TestApplication application;
657 PinchGestureDetector detector = PinchGestureDetector::New();
659 Actor actor = Actor::New();
660 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
661 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
662 application.GetScene().Add( actor );
665 application.SendNotification();
666 application.Render();
668 detector.Attach( actor );
671 GestureReceivedFunctor functor( data );
672 detector.DetectedSignal().Connect( &application, functor );
675 // 2 touch events make a gesture begin
676 Integration::SetPinchGestureMinimumTouchEvents( 2 );
677 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
678 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
680 DALI_TEST_EQUALS( GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION );
681 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
685 // 4 touch events make a gesture begin
686 Integration::SetPinchGestureMinimumTouchEvents( 4 );
687 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
688 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
690 // Check the gesture is not detected unlike previous case
691 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
696 int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void)
698 TestApplication application;
700 PinchGestureDetector detector = PinchGestureDetector::New();
702 Actor actor = Actor::New();
703 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
704 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
705 application.GetScene().Add( actor );
708 application.SendNotification();
709 application.Render();
711 detector.Attach( actor );
714 GestureReceivedFunctor functor( data );
715 detector.DetectedSignal().Connect( &application, functor );
718 // > 2 touch events make a gesture begin
719 // > 4 touch events generate gestures after begin
720 Integration::SetPinchGestureMinimumTouchEvents(2);
721 Integration::SetPinchGestureMinimumTouchEventsAfterStart(6);
723 application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
724 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
726 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
727 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
729 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) );
730 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 180 ) );
731 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) );
732 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) );
733 // > Test : not enough touch events to make the gesture state "CONTINUING"
734 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
736 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) );
737 application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) );
738 // > Test : 6 touch events after start make the gesture state "CONTINUING"
739 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);