2 * Copyright (c) 2021 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/devel-api/actors/actor-devel.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali/integration-api/render-task-list-integ.h>
22 #include <dali/public-api/dali-core.h>
24 #include <test-touch-event-utils.h>
30 void utc_dali_pinch_gesture_detector_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_pinch_gesture_detector_cleanup(void)
37 test_return_value = TET_PASS;
40 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled(false),
48 voidFunctorCalled(false),
55 functorCalled = false;
56 voidFunctorCalled = false;
58 receivedGesture.Reset();
64 bool voidFunctorCalled;
65 PinchGesture receivedGesture;
69 // Functor that sets the data when called
70 struct GestureReceivedFunctor
72 GestureReceivedFunctor(SignalData& data)
77 void operator()(Actor actor, const PinchGesture& pinch)
79 signalData.functorCalled = true;
80 signalData.receivedGesture = pinch;
81 signalData.pinchedActor = actor;
86 signalData.voidFunctorCalled = true;
89 SignalData& signalData;
92 // Functor that removes the gestured actor from stage
93 struct UnstageActorFunctor : public GestureReceivedFunctor
95 UnstageActorFunctor(SignalData& data, GestureState& stateToUnstage, Integration::Scene scene)
96 : GestureReceivedFunctor(data),
97 stateToUnstage(stateToUnstage),
102 void operator()(Actor actor, const PinchGesture& pinch)
104 GestureReceivedFunctor::operator()(actor, pinch);
106 if(pinch.GetState() == stateToUnstage)
112 GestureState& stateToUnstage;
113 Integration::Scene scene;
118 ///////////////////////////////////////////////////////////////////////////////
120 int UtcDaliPinchGestureDetectorConstructor(void)
122 TestApplication application;
124 PinchGestureDetector detector;
125 DALI_TEST_CHECK(!detector);
129 int UtcDaliPinchGestureDetectorCopyConstructorP(void)
131 TestApplication application;
133 PinchGestureDetector detector = PinchGestureDetector::New();
136 PinchGestureDetector copy(detector);
137 DALI_TEST_CHECK(detector);
141 int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
143 TestApplication application;
145 PinchGestureDetector detector = PinchGestureDetector::New();
148 PinchGestureDetector assign;
150 DALI_TEST_CHECK(detector);
152 DALI_TEST_CHECK(detector == assign);
156 int UtcDaliPinchGestureDetectorNew(void)
158 TestApplication application;
160 PinchGestureDetector detector = PinchGestureDetector::New();
162 DALI_TEST_CHECK(detector);
164 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
165 Actor actor = Actor::New();
166 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
167 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
168 application.GetScene().Add(actor);
171 application.SendNotification();
172 application.Render();
174 detector.Attach(actor);
176 Integration::TouchEvent touchEvent(1);
177 Integration::Point point;
178 point.SetDeviceId(1);
179 point.SetState(PointState::DOWN);
180 point.SetScreenPosition(Vector2(20.0f, 20.0f));
181 touchEvent.AddPoint(point);
182 application.ProcessEvent(touchEvent);
184 Integration::Point point2;
185 point.SetDeviceId(1);
186 point.SetState(PointState::DOWN);
187 point.SetScreenPosition(Vector2(20.0f, 20.0f));
188 touchEvent.AddPoint(point2);
189 application.ProcessEvent(touchEvent);
193 int UtcDaliPinchGestureDetectorDownCast(void)
195 TestApplication application;
196 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
198 PinchGestureDetector detector = PinchGestureDetector::New();
200 BaseHandle object(detector);
202 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
203 DALI_TEST_CHECK(detector2);
205 PinchGestureDetector detector3 = DownCast<PinchGestureDetector>(object);
206 DALI_TEST_CHECK(detector3);
208 BaseHandle unInitializedObject;
209 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
210 DALI_TEST_CHECK(!detector4);
212 PinchGestureDetector detector5 = DownCast<PinchGestureDetector>(unInitializedObject);
213 DALI_TEST_CHECK(!detector5);
215 GestureDetector detector6 = PinchGestureDetector::New();
216 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
217 DALI_TEST_CHECK(detector7);
221 // Negative test case for a method
222 int UtcDaliPinchGestureSignalReceptionNegative(void)
224 TestApplication application;
226 Actor actor = Actor::New();
227 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
228 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
229 application.GetScene().Add(actor);
232 application.SendNotification();
233 application.Render();
236 GestureReceivedFunctor functor(data);
238 PinchGestureDetector detector = PinchGestureDetector::New();
239 detector.Attach(actor);
240 detector.DetectedSignal().Connect(&application, functor);
242 // Do a pinch outside actor's area
243 TestStartPinch(application, Vector2(112.0f, 62.0f), Vector2(112.0f, 162.0f), Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), 100);
245 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
247 // Continue pinch into actor's area - we should still not receive the signal
249 TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
251 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
253 // Stop pinching - we should still not receive the signal
255 TestEndPinch(application, Vector2(6.0f, 6.0f), Vector2(18.0f, 18.0f), Vector2(10.0f, 8.0f), Vector2(14.0f, 16.0f), 300);
257 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
261 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
263 TestApplication application;
265 Actor actor = Actor::New();
266 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
267 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
268 application.GetScene().Add(actor);
271 application.SendNotification();
272 application.Render();
275 GestureReceivedFunctor functor(data);
277 PinchGestureDetector detector = PinchGestureDetector::New();
278 detector.Attach(actor);
279 detector.DetectedSignal().Connect(&application, functor);
281 // Start pan within the actor's area
282 TestStartPinch(application, Vector2(5.0f, 20.0f), Vector2(35.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
283 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
284 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
285 DALI_TEST_EQUALS(0.666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
286 DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
287 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
288 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
290 // Continue the pan within the actor's area - we should still receive the signal
292 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), 400);
293 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
294 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
295 DALI_TEST_EQUALS(0.2666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
296 DALI_TEST_EQUALS(80.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
297 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
298 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
300 // Pinch Gesture leaves actor's area - we should still receive the signal
302 TestContinuePinch(application, Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), 1000);
303 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
304 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
305 DALI_TEST_EQUALS(1.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
306 DALI_TEST_EQUALS(213.333f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
307 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
308 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
310 // Gesture ends - we would receive a finished state
312 TestEndPinch(application, Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), Vector2(305.0f, 10.0f), Vector2(315.0f, 10.0f), 1500);
313 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
314 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
315 DALI_TEST_EQUALS(0.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
316 DALI_TEST_EQUALS(600.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
317 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
318 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
322 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
324 TestApplication application;
326 Actor actor = Actor::New();
327 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
328 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
329 application.GetScene().Add(actor);
332 application.SendNotification();
333 application.Render();
336 GestureReceivedFunctor functor(data);
338 PinchGestureDetector detector = PinchGestureDetector::New();
339 detector.Attach(actor);
340 detector.DetectedSignal().Connect(&application, functor);
342 // Start pinch within the actor's area
343 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
344 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
345 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
346 DALI_TEST_EQUALS(0.555f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
347 DALI_TEST_EQUALS(106.667f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
348 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
349 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
351 // Continue the pinch within the actor's area - we should still receive the signal
353 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
354 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
355 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
356 DALI_TEST_EQUALS(0.277f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
357 DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
358 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
359 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
361 // Gesture ends within actor's area - we would receive a finished state
363 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
364 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
365 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
366 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
367 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
368 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
369 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
373 int UtcDaliPinchGestureSignalReceptionDetach(void)
375 TestApplication application;
377 Actor actor = Actor::New();
378 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
379 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
380 application.GetScene().Add(actor);
383 application.SendNotification();
384 application.Render();
387 GestureReceivedFunctor functor(data);
389 PinchGestureDetector detector = PinchGestureDetector::New();
390 detector.Attach(actor);
391 detector.DetectedSignal().Connect(&application, functor);
393 // Start pinch within the actor's area
394 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
395 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
396 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
398 // Continue the pinch within the actor's area - we should still receive the signal
400 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
401 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
402 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
404 // Gesture ends within actor's area
406 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
407 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
408 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
411 detector.DetachAll();
413 // Ensure we are no longer signalled
415 TestGeneratePinch(application);
416 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
420 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
422 TestApplication application;
424 Actor actor = Actor::New();
425 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
426 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
427 application.GetScene().Add(actor);
430 application.SendNotification();
431 application.Render();
434 GestureReceivedFunctor functor(data);
436 PinchGestureDetector detector = PinchGestureDetector::New();
437 detector.Attach(actor);
438 detector.DetectedSignal().Connect(&application, functor);
440 // Start pinch within the actor's area
441 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
442 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
443 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
445 // Continue the pinch within the actor's area - we should still receive the signal
447 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
448 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
449 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
451 // Detach actor during the pinch, we should not receive the next event
452 detector.DetachAll();
454 // Gesture ends within actor's area
456 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
457 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
461 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
463 TestApplication application;
466 GestureReceivedFunctor functor(data);
468 PinchGestureDetector detector = PinchGestureDetector::New();
469 detector.DetectedSignal().Connect(&application, functor);
471 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
473 Actor tempActor = Actor::New();
474 tempActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
475 tempActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
476 application.GetScene().Add(tempActor);
477 detector.Attach(tempActor);
479 // Actor lifetime is scoped
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);
492 // Start pinch within the actor's area
493 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
494 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
495 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
497 // Continue the pinch within the actor's area - we should still receive the signal
499 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
500 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
501 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
503 // Remove the actor from stage and reset the data
504 application.GetScene().Remove(actor);
507 application.SendNotification();
508 application.Render();
511 // Actor should now have been destroyed
513 // Gesture ends within the area where the actor used to be
515 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
516 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
520 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
522 TestApplication application;
524 Actor actor = Actor::New();
525 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
526 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
527 application.GetScene().Add(actor);
529 // Render and notify a couple of times
530 application.SendNotification();
531 application.Render();
534 GestureReceivedFunctor functor(data);
536 PinchGestureDetector detector = PinchGestureDetector::New();
537 detector.Attach(actor);
538 detector.DetectedSignal().Connect(&application, functor);
540 // Do an entire pinch, only check finished value
541 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
543 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
544 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
545 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
546 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
547 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
548 DALI_TEST_EQUALS(Vector2(70.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
550 // Rotate actor again and render and notify
551 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS));
552 application.SendNotification();
553 application.Render();
555 // Do an entire pinch, only check finished value
556 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100);
558 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
559 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
560 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
561 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
562 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
563 DALI_TEST_EQUALS(Vector2(30.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
565 // Rotate actor again and render and notify
566 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS));
567 application.SendNotification();
568 application.Render();
570 // Do an entire pinch, only check finished value
571 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 4100);
573 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 5000);
574 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
575 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
576 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
577 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
578 DALI_TEST_EQUALS(Vector2(30.0f, 70.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
582 int UtcDaliPinchGestureSignalReceptionChildHit(void)
584 TestApplication application;
586 Actor parent = Actor::New();
587 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
588 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
589 application.GetScene().Add(parent);
591 // Set child to completely cover parent.
592 // Change rotation of child to be different from parent so that we can check if our local coordinate
593 // conversion of the parent actor is correct.
594 Actor child = Actor::New();
595 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
596 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
597 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
598 child.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
602 application.SendNotification();
603 application.Render();
606 GestureReceivedFunctor functor(data);
608 PinchGestureDetector detector = PinchGestureDetector::New();
609 detector.Attach(parent);
610 detector.DetectedSignal().Connect(&application, functor);
612 // Do an entire pan, only check finished value - hits child area but parent should still receive it
613 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
615 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
616 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
617 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
618 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
619 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
620 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
622 // Attach child and generate same touch points to yield same results
623 // (Also proves that you can detach and then re-attach another actor)
624 detector.Attach(child);
625 detector.Detach(parent);
627 // Do an entire pan, only check finished value
628 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100);
630 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
631 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
632 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
633 DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION);
634 DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION);
635 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
636 DALI_TEST_EQUALS(Vector2(20.0f, 80.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
640 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
642 TestApplication application;
644 Actor first = Actor::New();
645 first.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
646 first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
647 application.GetScene().Add(first);
649 Actor second = Actor::New();
650 second.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
651 second.SetProperty(Actor::Property::POSITION_X, 100.0f);
652 second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
653 application.GetScene().Add(second);
656 application.SendNotification();
657 application.Render();
660 GestureReceivedFunctor functor(data);
662 PinchGestureDetector detector = PinchGestureDetector::New();
663 detector.Attach(first);
664 detector.Attach(second);
665 detector.DetectedSignal().Connect(&application, functor);
667 // Start pinch within second actor's area
668 TestStartPinch(application, Vector2(102.0f, 20.0f), Vector2(138.0f, 20.0f), Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), 100);
669 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
670 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
672 // Pinch moves into first actor's area - second actor should receive the pinch
674 TestContinuePinch(application, Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
675 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
676 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
678 // Detach the second actor during the pinch, we should not receive the next event
679 detector.Detach(second);
681 // Gesture ends within actor's area
683 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(119.0f, 20.0f), Vector2(121.0f, 20.0f), 3000);
684 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
688 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
690 TestApplication application;
692 Actor actor = Actor::New();
693 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
694 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
695 application.GetScene().Add(actor);
698 application.SendNotification();
699 application.Render();
702 GestureReceivedFunctor functor(data);
704 PinchGestureDetector detector = PinchGestureDetector::New();
705 detector.Attach(actor);
706 detector.DetectedSignal().Connect(&application, functor);
708 // Start pinch in actor's area
709 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
710 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
712 // Pan continues within actor's area
714 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
715 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
717 // Actor become invisible - actor should not receive the next pinch
718 actor.SetProperty(Actor::Property::VISIBLE, false);
721 application.SendNotification();
722 application.Render();
724 // Gesture ends within actor's area
726 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
727 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
731 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
733 TestApplication application;
735 Actor actor = Actor::New();
736 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
737 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
738 application.GetScene().Add(actor);
740 Actor actor2 = Actor::New();
741 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
742 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
743 application.GetScene().Add(actor2);
746 application.SendNotification();
747 application.Render();
749 // Attach actor to one detector
750 SignalData firstData;
751 GestureReceivedFunctor firstFunctor(firstData);
752 PinchGestureDetector firstDetector = PinchGestureDetector::New();
753 firstDetector.Attach(actor);
754 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
756 // Attach actor to another detector
757 SignalData secondData;
758 GestureReceivedFunctor secondFunctor(secondData);
759 PinchGestureDetector secondDetector = PinchGestureDetector::New();
760 secondDetector.Attach(actor);
761 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
763 // Add second actor to second detector, when we remove the actor, this will make sure that this
764 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
765 // functor should still not be called (which is what we're also testing).
766 secondDetector.Attach(actor2);
768 // Pinch in actor's area - both detector's functors should be called
769 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
770 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
771 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
773 // Pinch continues in actor's area - both detector's functors should be called
776 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
777 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
778 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
780 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
781 firstDetector.Detach(actor);
784 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
785 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
786 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
788 // New pinch on actor, only secondDetector has actor attached
791 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
792 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
793 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
795 // Detach actor from secondDetector
796 secondDetector.Detach(actor);
799 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000);
800 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
801 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
805 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
807 TestApplication application;
809 Actor actor1 = Actor::New();
810 actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
811 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
812 application.GetScene().Add(actor1);
814 GestureReceivedFunctor functor1(data1);
815 PinchGestureDetector detector1 = PinchGestureDetector::New();
816 detector1.Attach(actor1);
817 detector1.DetectedSignal().Connect(&application, functor1);
819 Actor actor2 = Actor::New();
820 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
821 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
822 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT);
823 application.GetScene().Add(actor2);
825 GestureReceivedFunctor functor2(data2);
826 PinchGestureDetector detector2 = PinchGestureDetector::New();
827 detector2.Attach(actor2);
828 detector2.DetectedSignal().Connect(&application, functor2);
831 application.SendNotification();
832 application.Render();
834 // Start pan in actor1's area, only data1 should be set
835 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
836 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
837 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
841 int UtcDaliPinchGestureActorUnstaged(void)
843 TestApplication application;
845 Actor actor = Actor::New();
846 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
847 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
848 application.GetScene().Add(actor);
851 application.SendNotification();
852 application.Render();
854 // State to remove actor in.
855 GestureState stateToUnstage(GestureState::STARTED);
857 // Attach actor to detector
859 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
860 PinchGestureDetector detector = PinchGestureDetector::New();
861 detector.Attach(actor);
862 detector.DetectedSignal().Connect(&application, functor);
865 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
866 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
868 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
869 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
873 application.SendNotification();
874 application.Render();
876 // Re-add actor to stage
877 application.GetScene().Add(actor);
880 application.SendNotification();
881 application.Render();
883 // Change state to GestureState::CONTINUING to remove
884 stateToUnstage = GestureState::CONTINUING;
887 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
888 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
890 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
891 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
893 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
894 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
898 application.SendNotification();
899 application.Render();
901 // Re-add actor to stage
902 application.GetScene().Add(actor);
905 application.SendNotification();
906 application.Render();
908 // Change state to GestureState::CONTINUING to remove
909 stateToUnstage = GestureState::FINISHED;
912 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
913 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
915 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
916 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
918 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
919 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
920 tet_result(TET_PASS); // If we get here then we have handled actor stage removal gracefully.
924 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
926 TestApplication application;
928 Actor actor = Actor::New();
929 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
930 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
931 application.GetScene().Add(actor);
933 // Create and add a second actor so that GestureDetector destruction does not come into play.
934 Actor dummyActor(Actor::New());
935 dummyActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
936 dummyActor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
937 dummyActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
938 application.GetScene().Add(dummyActor);
941 application.SendNotification();
942 application.Render();
944 // State to remove actor in.
945 GestureState stateToUnstage(GestureState::STARTED);
947 // Attach actor to detector
949 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
950 PinchGestureDetector detector = PinchGestureDetector::New();
951 detector.Attach(actor);
952 detector.Attach(dummyActor);
953 detector.DetectedSignal().Connect(&application, functor);
955 // Here we are testing a STARTED actor which is removed in the STARTED callback, but then added back
956 // before we get a continuing state. As we were removed from the stage, even if we're at the same
957 // position, we should still not be signalled.
960 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
961 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
965 application.SendNotification();
966 application.Render();
968 // Re add to the stage, we should not be signalled
969 application.GetScene().Add(actor);
972 application.SendNotification();
973 application.Render();
975 // Continue signal emission
976 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
977 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
979 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
980 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
983 // Here we delete an actor in started, we should not receive any subsequent signalling.
986 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
987 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
991 application.SendNotification();
992 application.Render();
994 // Delete actor as well
998 application.SendNotification();
999 application.Render();
1001 // Continue signal emission
1002 TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000);
1003 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1005 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
1006 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1010 int UtcDaliPinchGestureLayerConsumesTouch(void)
1012 TestApplication application;
1014 Actor actor = Actor::New();
1015 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1016 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1017 application.GetScene().Add(actor);
1021 GestureReceivedFunctor functor(data);
1022 PinchGestureDetector detector = PinchGestureDetector::New();
1023 detector.Attach(actor);
1024 detector.DetectedSignal().Connect(&application, functor);
1026 // Add a layer to overlap the actor
1027 Layer layer = Layer::New();
1028 layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1029 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1030 application.GetScene().Add(layer);
1033 // Render and notify
1034 application.SendNotification();
1035 application.Render();
1037 // Emit signals, should receive
1038 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1039 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
1040 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1043 // Set layer to consume all touch
1044 layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
1046 // Render and notify
1047 application.SendNotification();
1048 application.Render();
1050 // Emit the same signals again, should not receive
1051 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
1052 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 2000);
1053 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1059 int UtcDaliPinchGestureDisableDetectionDuringPinchN(void)
1061 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1063 TestApplication application;
1065 Actor actor = Actor::New();
1066 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1067 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1068 application.GetScene().Add(actor);
1071 PinchGestureDetector detector = PinchGestureDetector::New();
1072 bool functorCalled = false;
1073 detector.Attach(actor);
1074 detector.DetectedSignal().Connect(
1076 [&detector, &functorCalled](Actor actor, const PinchGesture& gesture) {
1077 if(gesture.GetState() == GestureState::FINISHED)
1079 detector.Detach(actor);
1080 functorCalled = true;
1084 // Render and notify
1085 application.SendNotification();
1086 application.Render();
1088 // Try the gesture, should not crash
1091 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1092 TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
1093 TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
1095 DALI_TEST_CHECK(true); // No crash, test has passed
1096 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1100 DALI_TEST_CHECK(false); // If we crash, the test has failed
1106 int UtcDaliPinchGestureWhenGesturePropargation(void)
1108 TestApplication application;
1110 Actor parentActor = Actor::New();
1111 parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1112 parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1114 Actor childActor = Actor::New();
1115 childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1116 childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1118 parentActor.Add(childActor);
1119 application.GetScene().Add(parentActor);
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1126 GestureReceivedFunctor pFunctor(pData);
1128 PinchGestureDetector parentDetector = PinchGestureDetector::New();
1129 parentDetector.Attach(parentActor);
1130 parentDetector.DetectedSignal().Connect(&application, pFunctor);
1133 GestureReceivedFunctor cFunctor(cData);
1135 PinchGestureDetector childDetector = PinchGestureDetector::New();
1136 childDetector.Attach(childActor);
1137 childDetector.DetectedSignal().Connect(&application, cFunctor);
1139 // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
1140 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1141 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1142 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
1146 TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
1147 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1148 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
1152 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 300);
1153 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1154 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
1158 // If GesturePropargation is set, a gesture event is to pass over to the parent.
1159 Dali::DevelActor::SetNeedGesturePropagation(childActor, true);
1161 // So now the parent got the gesture event.
1162 TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 700);
1163 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1164 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
1168 // child does not receive gestures. This is because we have passed the permission of the gesture to the parent.
1169 TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 800);
1170 DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
1171 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);
1175 TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 900);
1176 DALI_TEST_EQUALS(false, cData.functorCalled, TEST_LOCATION);
1177 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);