2 * Copyright (c) 2022 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_rotation_gesture_detector_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_rotation_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 RotationGesture receivedGesture;
69 // Functor that sets the data when called
70 struct GestureReceivedFunctor
72 GestureReceivedFunctor(SignalData& data)
77 void operator()(Actor actor, const RotationGesture& rotation)
79 signalData.functorCalled = true;
80 signalData.receivedGesture = rotation;
81 signalData.rotatedActor = 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 RotationGesture& rotation)
104 GestureReceivedFunctor::operator()(actor, rotation);
106 if(rotation.GetState() == stateToUnstage)
112 GestureState& stateToUnstage;
113 Integration::Scene scene;
118 ///////////////////////////////////////////////////////////////////////////////
120 int UtcDaliRotationGestureDetectorConstructor(void)
122 TestApplication application;
124 RotationGestureDetector detector;
125 DALI_TEST_CHECK(!detector);
129 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
131 TestApplication application;
133 RotationGestureDetector detector = RotationGestureDetector::New();
135 RotationGestureDetector copy(detector);
136 DALI_TEST_CHECK(detector);
140 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
142 TestApplication application;
144 RotationGestureDetector detector = RotationGestureDetector::New();
146 RotationGestureDetector assign;
148 DALI_TEST_CHECK(detector);
150 DALI_TEST_CHECK(detector == assign);
154 int UtcDaliRotationGestureDetectorMoveConstructorP(void)
156 TestApplication application;
158 RotationGestureDetector detector = RotationGestureDetector::New();
159 DALI_TEST_CHECK(detector);
161 RotationGestureDetector moved = std::move(detector);
162 DALI_TEST_CHECK(moved);
163 DALI_TEST_CHECK(!detector);
167 int UtcDaliRotationGestureDetectorMoveAssignmentOperatorP(void)
169 TestApplication application;
171 RotationGestureDetector detector;
172 detector = RotationGestureDetector::New();
173 DALI_TEST_CHECK(detector);
175 RotationGestureDetector moved;
176 moved = std::move(detector);
177 DALI_TEST_CHECK(moved);
178 DALI_TEST_CHECK(!detector);
182 int UtcDaliRotationGestureDetectorNew(void)
184 TestApplication application;
186 RotationGestureDetector detector = RotationGestureDetector::New();
188 DALI_TEST_CHECK(detector);
190 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
191 Actor actor = Actor::New();
192 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
193 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
194 application.GetScene().Add(actor);
197 application.SendNotification();
198 application.Render();
200 detector.Attach(actor);
202 Integration::TouchEvent touchEvent(1);
203 Integration::Point point;
204 point.SetDeviceId(1);
205 point.SetState(PointState::DOWN);
206 point.SetScreenPosition(Vector2(20.0f, 20.0f));
207 touchEvent.AddPoint(point);
208 application.ProcessEvent(touchEvent);
210 Integration::Point point2;
211 point.SetDeviceId(1);
212 point.SetState(PointState::DOWN);
213 point.SetScreenPosition(Vector2(20.0f, 20.0f));
214 touchEvent.AddPoint(point2);
215 application.ProcessEvent(touchEvent);
219 int UtcDaliRotationGestureDetectorDownCast(void)
221 TestApplication application;
222 tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
224 RotationGestureDetector detector = RotationGestureDetector::New();
226 BaseHandle object(detector);
228 RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
229 DALI_TEST_CHECK(detector2);
231 RotationGestureDetector detector3 = DownCast<RotationGestureDetector>(object);
232 DALI_TEST_CHECK(detector3);
234 BaseHandle unInitializedObject;
235 RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
236 DALI_TEST_CHECK(!detector4);
238 RotationGestureDetector detector5 = DownCast<RotationGestureDetector>(unInitializedObject);
239 DALI_TEST_CHECK(!detector5);
241 GestureDetector detector6 = RotationGestureDetector::New();
242 RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
243 DALI_TEST_CHECK(detector7);
247 // Negative test case for a method
248 int UtcDaliRotationGestureSignalReceptionNegative(void)
250 TestApplication application;
252 Actor actor = Actor::New();
253 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
254 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
255 application.GetScene().Add(actor);
258 application.SendNotification();
259 application.Render();
262 GestureReceivedFunctor functor(data);
264 RotationGestureDetector detector = RotationGestureDetector::New();
265 detector.Attach(actor);
266 detector.DetectedSignal().Connect(&application, functor);
268 // Do a rotation outside actor's area
269 TestStartRotation(application, Vector2(112.0f, 62.0f), Vector2(112.0f, 162.0f), Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), 100);
271 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
273 // Continue rotation into actor's area - we should still not receive the signal
275 TestContinueRotation(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
277 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
279 // Stop rotating - we should still not receive the signal
281 TestEndRotation(application, Vector2(6.0f, 6.0f), Vector2(18.0f, 18.0f), Vector2(10.0f, 8.0f), Vector2(14.0f, 16.0f), 300);
283 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
287 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void)
289 TestApplication application;
291 Actor actor = Actor::New();
292 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
293 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
294 application.GetScene().Add(actor);
297 application.SendNotification();
298 application.Render();
301 GestureReceivedFunctor functor(data);
303 RotationGestureDetector detector = RotationGestureDetector::New();
304 detector.Attach(actor);
305 detector.DetectedSignal().Connect(&application, functor);
307 // Start rotation within the actor's area
308 TestStartRotation(application, Vector2(5.0f, 5.0f), Vector2(20.0f, 20.0f), Vector2(5.0f, 5.0f), Vector2(20.0f, 30.0f), 100);
309 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
310 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
311 DALI_TEST_EQUALS(0.244f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
312 DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
313 DALI_TEST_EQUALS(Vector2(12.48f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
315 // Continue the rotation within the actor's area - we should still receive the signal
317 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), 400);
318 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
319 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
320 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
321 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
322 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
324 // Rotation Gesture leaves actor's area - we should still receive the signal
326 TestContinueRotation(application, Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), 1000);
327 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
328 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
329 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
330 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
331 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
333 // Gesture ends - we would receive a finished state
335 TestEndRotation(application, Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), Vector2(305.0f, 10.0f), Vector2(315.0f, 10.0f), 1500);
336 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
337 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
338 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
339 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
340 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
344 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
346 TestApplication application;
348 Actor actor = Actor::New();
349 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
350 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
351 application.GetScene().Add(actor);
354 application.SendNotification();
355 application.Render();
358 GestureReceivedFunctor functor(data);
360 RotationGestureDetector detector = RotationGestureDetector::New();
361 detector.Attach(actor);
362 detector.DetectedSignal().Connect(&application, functor);
364 // Start rotation within the actor's area
365 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(31.0f, 29.0f), 100);
366 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
367 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
368 DALI_TEST_EQUALS(0.404892f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
369 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
370 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
372 // Continue the rotation within the actor's area - we should still receive the signal
374 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(29.0f, 15.0f), 500);
375 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
376 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
377 DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
378 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
379 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
381 // Gesture ends within actor's area - we would receive a finished state
383 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(29.0f, 15.0f), 1000);
384 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
385 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
386 DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
387 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
388 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
392 int UtcDaliRotationGestureSignalReceptionDetach(void)
394 TestApplication application;
396 Actor actor = Actor::New();
397 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
398 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
399 application.GetScene().Add(actor);
402 application.SendNotification();
403 application.Render();
406 GestureReceivedFunctor functor(data);
408 RotationGestureDetector detector = RotationGestureDetector::New();
409 detector.Attach(actor);
410 detector.DetectedSignal().Connect(&application, functor);
412 // Start rotation within the actor's area
413 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
414 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
415 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
417 // Continue the rotation within the actor's area - we should still receive the signal
419 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
420 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
421 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
423 // Gesture ends within actor's area
425 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
426 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
427 DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION);
430 detector.DetachAll();
432 // Ensure we are no longer signalled
434 TestGenerateRotation(application);
435 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
439 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void)
441 TestApplication application;
443 Actor actor = Actor::New();
444 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
445 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
446 application.GetScene().Add(actor);
449 application.SendNotification();
450 application.Render();
453 GestureReceivedFunctor functor(data);
455 RotationGestureDetector detector = RotationGestureDetector::New();
456 detector.Attach(actor);
457 detector.DetectedSignal().Connect(&application, functor);
459 // Start rotation within the actor's area
460 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
461 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
462 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
464 // Continue the rotation within the actor's area - we should still receive the signal
466 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
467 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
468 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
470 // Detach actor during the rotation, we should not receive the next event
471 detector.DetachAll();
473 // Gesture ends within actor's area
475 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
476 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
480 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
482 TestApplication application;
485 GestureReceivedFunctor functor(data);
487 RotationGestureDetector detector = RotationGestureDetector::New();
488 detector.DetectedSignal().Connect(&application, functor);
490 // Attach a temporary actor to stop detector being removed from RotationGestureProcessor when main actor
492 Actor tempActor = Actor::New();
493 tempActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
494 tempActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
495 application.GetScene().Add(tempActor);
496 detector.Attach(tempActor);
498 // Actor lifetime is scoped
500 Actor actor = Actor::New();
501 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
502 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
503 application.GetScene().Add(actor);
506 application.SendNotification();
507 application.Render();
509 detector.Attach(actor);
511 // Start rotation within the actor's area
512 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
513 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
514 DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
516 // Continue the rotation within the actor's area - we should still receive the signal
518 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
519 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
520 DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION);
522 // Remove the actor from stage and reset the data
523 application.GetScene().Remove(actor);
526 application.SendNotification();
527 application.Render();
530 // Actor should now have been destroyed
532 // Gesture ends within the area where the actor used to be
534 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
535 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
539 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
541 TestApplication application;
543 Actor actor = Actor::New();
544 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
545 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
546 application.GetScene().Add(actor);
548 // Render and notify a couple of times
549 application.SendNotification();
550 application.Render();
553 GestureReceivedFunctor functor(data);
555 RotationGestureDetector detector = RotationGestureDetector::New();
556 detector.Attach(actor);
557 detector.DetectedSignal().Connect(&application, functor);
559 // Do an entire rotation, only check finished value
560 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
562 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(27.0f, 15.0f), 1000);
563 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
564 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
565 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
566 DALI_TEST_EQUALS(Vector2(67.5f, 27.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
568 // Rotate actor again and render and notify
569 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS));
570 application.SendNotification();
571 application.Render();
573 // Do an entire rotation, only check finished value
574 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100);
576 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(27.0f, 15.0f), 3000);
577 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
578 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
579 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
580 DALI_TEST_EQUALS(Vector2(27.0f, 32.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
582 // Rotate actor again and render and notify
583 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS));
584 application.SendNotification();
585 application.Render();
587 // Do an entire rotation, only check finished value
588 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 4100);
590 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(27.0f, 15.0f), 5000);
591 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
592 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
593 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
594 DALI_TEST_EQUALS(Vector2(32.5f, 73.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
598 int UtcDaliRotationGestureSignalReceptionChildHit(void)
600 TestApplication application;
602 Actor parent = Actor::New();
603 parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
604 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
605 application.GetScene().Add(parent);
607 // Set child to completely cover parent.
608 // Change rotation of child to be different from parent so that we can check if our local coordinate
609 // conversion of the parent actor is correct.
610 Actor child = Actor::New();
611 child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
612 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
613 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
614 child.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS));
618 application.SendNotification();
619 application.Render();
622 GestureReceivedFunctor functor(data);
624 RotationGestureDetector detector = RotationGestureDetector::New();
625 detector.Attach(parent);
626 detector.DetectedSignal().Connect(&application, functor);
628 // Do an entire pan, only check finished value - hits child area but parent should still receive it
629 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
631 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(29.0f, 25.0f), 1000);
632 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
633 DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
634 DALI_TEST_EQUALS(0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
635 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
636 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
638 // Attach child and generate same touch points to yield same results
639 // (Also proves that you can detach and then re-attach another actor)
640 detector.Attach(child);
641 detector.Detach(parent);
643 // Do an entire pan, only check finished value
644 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100);
646 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(29.0f, 35.0f), 3000);
647 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
648 DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
649 DALI_TEST_EQUALS(0.982794f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
650 DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
651 DALI_TEST_EQUALS(Vector2(27.5f, 76.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
655 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
657 TestApplication application;
659 Actor first = Actor::New();
660 first.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
661 first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
662 application.GetScene().Add(first);
664 Actor second = Actor::New();
665 second.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
666 second.SetProperty(Actor::Property::POSITION_X, 100.0f);
667 second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
668 application.GetScene().Add(second);
671 application.SendNotification();
672 application.Render();
675 GestureReceivedFunctor functor(data);
677 RotationGestureDetector detector = RotationGestureDetector::New();
678 detector.Attach(first);
679 detector.Attach(second);
680 detector.DetectedSignal().Connect(&application, functor);
682 // Start rotation within second actor's area
683 TestStartRotation(application, Vector2(102.0f, 20.0f), Vector2(138.0f, 20.0f), Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), 100);
684 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
685 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
687 // Rotation moves into first actor's area - second actor should receive the rotation
689 TestContinueRotation(application, Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
690 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
691 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
693 // Detach the second actor during the rotation, we should not receive the next event
694 detector.Detach(second);
696 // Gesture ends within actor's area
698 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(119.0f, 20.0f), Vector2(121.0f, 20.0f), 3000);
699 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
703 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
705 TestApplication application;
707 Actor actor = Actor::New();
708 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
709 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
710 application.GetScene().Add(actor);
713 application.SendNotification();
714 application.Render();
717 GestureReceivedFunctor functor(data);
719 RotationGestureDetector detector = RotationGestureDetector::New();
720 detector.Attach(actor);
721 detector.DetectedSignal().Connect(&application, functor);
723 // Start rotation in actor's area
724 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
725 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
727 // Rotation continues within actor's area
729 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
730 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
732 // Actor become invisible - actor should not receive the next rotation
733 actor.SetProperty(Actor::Property::VISIBLE, false);
736 application.SendNotification();
737 application.Render();
739 // Gesture ends within actor's area
741 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
742 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
746 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
748 TestApplication application;
750 Actor actor = Actor::New();
751 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
752 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
753 application.GetScene().Add(actor);
755 Actor actor2 = Actor::New();
756 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
757 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
758 application.GetScene().Add(actor2);
761 application.SendNotification();
762 application.Render();
764 // Attach actor to one detector
765 SignalData firstData;
766 GestureReceivedFunctor firstFunctor(firstData);
767 RotationGestureDetector firstDetector = RotationGestureDetector::New();
768 firstDetector.Attach(actor);
769 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
771 // Attach actor to another detector
772 SignalData secondData;
773 GestureReceivedFunctor secondFunctor(secondData);
774 RotationGestureDetector secondDetector = RotationGestureDetector::New();
775 secondDetector.Attach(actor);
776 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
778 // Add second actor to second detector, when we remove the actor, this will make sure that this
779 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
780 // functor should still not be called (which is what we're also testing).
781 secondDetector.Attach(actor2);
783 // Rotation in actor's area - both detector's functors should be called
784 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
785 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
786 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
788 // Rotation continues in actor's area - both detector's functors should be called
791 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
792 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
793 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
795 // Detach actor from firstDetector and emit rotation on actor, only secondDetector's functor should be called.
796 firstDetector.Detach(actor);
799 TestEndRotation(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
800 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
801 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
803 // New rotation on actor, only secondDetector has actor attached
806 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
807 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
808 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
810 // Detach actor from secondDetector
811 secondDetector.Detach(actor);
814 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000);
815 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
816 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
820 int UtcDaliRotationGestureSignalReceptionEnsureCorrectSignalling(void)
822 TestApplication application;
824 Actor actor1 = Actor::New();
825 actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
826 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
827 application.GetScene().Add(actor1);
829 GestureReceivedFunctor functor1(data1);
830 RotationGestureDetector detector1 = RotationGestureDetector::New();
831 detector1.Attach(actor1);
832 detector1.DetectedSignal().Connect(&application, functor1);
834 Actor actor2 = Actor::New();
835 actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
836 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
837 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT);
838 application.GetScene().Add(actor2);
840 GestureReceivedFunctor functor2(data2);
841 RotationGestureDetector detector2 = RotationGestureDetector::New();
842 detector2.Attach(actor2);
843 detector2.DetectedSignal().Connect(&application, functor2);
846 application.SendNotification();
847 application.Render();
849 // Start pan in actor1's area, only data1 should be set
850 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
851 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
852 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
856 int UtcDaliRotationGestureActorUnstaged(void)
858 TestApplication application;
860 Actor actor = Actor::New();
861 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
862 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
863 application.GetScene().Add(actor);
866 application.SendNotification();
867 application.Render();
869 // State to remove actor in.
870 GestureState stateToUnstage(GestureState::STARTED);
872 // Attach actor to detector
874 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
875 RotationGestureDetector detector = RotationGestureDetector::New();
876 detector.Attach(actor);
877 detector.DetectedSignal().Connect(&application, functor);
880 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
881 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
883 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
884 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
888 application.SendNotification();
889 application.Render();
891 // Re-add actor to stage
892 application.GetScene().Add(actor);
895 application.SendNotification();
896 application.Render();
898 // Change state to GestureState::CONTINUING to remove
899 stateToUnstage = GestureState::CONTINUING;
902 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
903 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
905 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
906 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
908 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
909 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
913 application.SendNotification();
914 application.Render();
916 // Re-add actor to stage
917 application.GetScene().Add(actor);
920 application.SendNotification();
921 application.Render();
923 // Change state to GestureState::CONTINUING to remove
924 stateToUnstage = GestureState::FINISHED;
927 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
928 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
930 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
931 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
933 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
934 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
935 tet_result(TET_PASS); // If we get here then we have handled actor stage removal gracefully.
939 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
941 TestApplication application;
943 Actor actor = Actor::New();
944 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
945 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
946 application.GetScene().Add(actor);
948 // Create and add a second actor so that GestureDetector destruction does not come into play.
949 Actor dummyActor(Actor::New());
950 dummyActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
951 dummyActor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
952 dummyActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
953 application.GetScene().Add(dummyActor);
956 application.SendNotification();
957 application.Render();
959 // State to remove actor in.
960 GestureState stateToUnstage(GestureState::STARTED);
962 // Attach actor to detector
964 UnstageActorFunctor functor(data, stateToUnstage, application.GetScene());
965 RotationGestureDetector detector = RotationGestureDetector::New();
966 detector.Attach(actor);
967 detector.Attach(dummyActor);
968 detector.DetectedSignal().Connect(&application, functor);
970 // Here we are testing a STARTED actor which is removed in the STARTED callback, but then added back
971 // before we get a continuing state. As we were removed from the stage, even if we're at the same
972 // position, we should still not be signalled.
975 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
976 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
980 application.SendNotification();
981 application.Render();
983 // Re add to the stage, we should not be signalled
984 application.GetScene().Add(actor);
987 application.SendNotification();
988 application.Render();
990 // Continue signal emission
991 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
992 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
994 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
995 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
998 // Here we delete an actor in started, we should not receive any subsequent signalling.
1001 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
1002 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Delete actor as well
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Continue signal emission
1017 TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000);
1018 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1020 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000);
1021 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1025 int UtcDaliRotationGestureLayerConsumesTouch(void)
1027 TestApplication application;
1029 Actor actor = Actor::New();
1030 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1031 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1032 application.GetScene().Add(actor);
1036 GestureReceivedFunctor functor(data);
1037 RotationGestureDetector detector = RotationGestureDetector::New();
1038 detector.Attach(actor);
1039 detector.DetectedSignal().Connect(&application, functor);
1041 // Add a layer to overlap the actor
1042 Layer layer = Layer::New();
1043 layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1044 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1045 application.GetScene().Add(layer);
1048 // Render and notify
1049 application.SendNotification();
1050 application.Render();
1052 // Emit signals, should receive
1053 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1054 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
1055 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1058 // Set layer to consume all touch
1059 layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 // Emit the same signals again, should not receive
1066 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500);
1067 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 2000);
1068 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1074 int UtcDaliRotationGestureDisableDetectionDuringRotationN(void)
1076 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1078 TestApplication application;
1080 Actor actor = Actor::New();
1081 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1082 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1083 application.GetScene().Add(actor);
1086 RotationGestureDetector detector = RotationGestureDetector::New();
1087 bool functorCalled = false;
1088 detector.Attach(actor);
1089 detector.DetectedSignal().Connect(
1091 [&detector, &functorCalled](Actor actor, const RotationGesture& gesture) {
1092 if(gesture.GetState() == GestureState::FINISHED)
1094 detector.Detach(actor);
1095 functorCalled = true;
1099 // Render and notify
1100 application.SendNotification();
1101 application.Render();
1103 // Try the gesture, should not crash
1106 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1107 TestContinueRotation(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
1108 TestEndRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000);
1110 DALI_TEST_CHECK(true); // No crash, test has passed
1111 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1115 DALI_TEST_CHECK(false); // If we crash, the test has failed
1121 int UtcDaliRotationGestureWhenGesturePropargation(void)
1123 TestApplication application;
1125 Actor parentActor = Actor::New();
1126 parentActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1127 parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1129 Actor childActor = Actor::New();
1130 childActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1131 childActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1133 parentActor.Add(childActor);
1134 application.GetScene().Add(parentActor);
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1141 GestureReceivedFunctor pFunctor(pData);
1143 RotationGestureDetector parentDetector = RotationGestureDetector::New();
1144 parentDetector.Attach(parentActor);
1145 parentDetector.DetectedSignal().Connect(&application, pFunctor);
1148 GestureReceivedFunctor cFunctor(cData);
1150 RotationGestureDetector childDetector = RotationGestureDetector::New();
1151 childDetector.Attach(childActor);
1152 childDetector.DetectedSignal().Connect(&application, cFunctor);
1154 // Start gesture within the actor's area, we receive the gesture not parent actor but child actor.
1155 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
1156 TestEndRotation(application, Vector2(6.0f, 6.0f), Vector2(18.0f, 18.0f), Vector2(10.0f, 8.0f), Vector2(14.0f, 16.0f), 300);
1157 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1158 DALI_TEST_EQUALS(false, pData.functorCalled, TEST_LOCATION);
1162 // If GesturePropargation is set, a gesture event is to pass over to the parent.
1163 Dali::DevelActor::SetNeedGesturePropagation(childActor, true);
1165 // So now the parent got the gesture event.
1166 TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 700);
1167 TestEndRotation(application, Vector2(6.0f, 6.0f), Vector2(18.0f, 18.0f), Vector2(10.0f, 8.0f), Vector2(14.0f, 16.0f), 900);
1168 DALI_TEST_EQUALS(true, cData.functorCalled, TEST_LOCATION);
1169 DALI_TEST_EQUALS(true, pData.functorCalled, TEST_LOCATION);