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/events/touch-event-integ.h>
23 #include <dali/integration-api/render-task-list-integ.h>
24 #include <dali-test-suite-utils.h>
25 #include <test-touch-event-utils.h>
29 void utc_dali_rotation_gesture_detector_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_rotation_gesture_detector_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled(false),
48 voidFunctorCalled(false),
49 receivedGesture(Gesture::Started)
54 functorCalled = false;
55 voidFunctorCalled = false;
57 receivedGesture.state = Gesture::Started;
58 receivedGesture.rotation = 0.0f;
59 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
60 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
66 bool voidFunctorCalled;
67 RotationGesture receivedGesture;
71 // Functor that sets the data when called
72 struct GestureReceivedFunctor
74 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
76 void operator()(Actor actor, const RotationGesture& rotation)
78 signalData.functorCalled = true;
79 signalData.receivedGesture = rotation;
80 signalData.rotatedActor = actor;
85 signalData.voidFunctorCalled = true;
88 SignalData& signalData;
91 // Functor that removes the gestured actor from stage
92 struct UnstageActorFunctor : public GestureReceivedFunctor
94 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage, Integration::Scene scene )
95 : GestureReceivedFunctor( data ),
96 stateToUnstage( stateToUnstage ),
101 void operator()( Actor actor, const RotationGesture& rotation )
103 GestureReceivedFunctor::operator()( actor, rotation );
105 if ( rotation.state == stateToUnstage )
107 scene.Remove( actor );
111 Gesture::State& stateToUnstage;
112 Integration::Scene scene;
117 ///////////////////////////////////////////////////////////////////////////////
119 int UtcDaliRotationGestureDetectorConstructor(void)
121 TestApplication application;
123 RotationGestureDetector detector;
124 DALI_TEST_CHECK(!detector);
128 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
130 TestApplication application;
132 RotationGestureDetector detector = RotationGestureDetector::New();;
134 RotationGestureDetector copy( detector );
135 DALI_TEST_CHECK( detector );
139 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
141 TestApplication application;
143 RotationGestureDetector detector = RotationGestureDetector::New();;
145 RotationGestureDetector assign;
147 DALI_TEST_CHECK( detector );
149 DALI_TEST_CHECK( detector == assign );
153 int UtcDaliRotationGestureDetectorNew(void)
155 TestApplication application;
157 RotationGestureDetector detector = RotationGestureDetector::New();
159 DALI_TEST_CHECK(detector);
161 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
162 Actor actor = Actor::New();
163 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
164 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
165 application.GetScene().Add(actor);
168 application.SendNotification();
169 application.Render();
171 detector.Attach(actor);
173 Integration::TouchEvent touchEvent(1);
174 Integration::Point point;
175 point.SetDeviceId( 1 );
176 point.SetState( PointState::DOWN );
177 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
178 touchEvent.AddPoint(point);
179 application.ProcessEvent(touchEvent);
181 Integration::Point point2;
182 point.SetDeviceId( 1 );
183 point.SetState( PointState::DOWN );
184 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
185 touchEvent.AddPoint(point2);
186 application.ProcessEvent(touchEvent);
190 int UtcDaliRotationGestureDetectorDownCast(void)
192 TestApplication application;
193 tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
195 RotationGestureDetector detector = RotationGestureDetector::New();
197 BaseHandle object(detector);
199 RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
200 DALI_TEST_CHECK(detector2);
202 RotationGestureDetector detector3 = DownCast< RotationGestureDetector >(object);
203 DALI_TEST_CHECK(detector3);
205 BaseHandle unInitializedObject;
206 RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
207 DALI_TEST_CHECK(!detector4);
209 RotationGestureDetector detector5 = DownCast< RotationGestureDetector >(unInitializedObject);
210 DALI_TEST_CHECK(!detector5);
212 GestureDetector detector6 = RotationGestureDetector::New();
213 RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
214 DALI_TEST_CHECK(detector7);
218 // Negative test case for a method
219 int UtcDaliRotationGestureSignalReceptionNegative(void)
221 TestApplication application;
223 Actor actor = Actor::New();
224 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
225 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
226 application.GetScene().Add(actor);
229 application.SendNotification();
230 application.Render();
233 GestureReceivedFunctor functor(data);
235 RotationGestureDetector detector = RotationGestureDetector::New();
236 detector.Attach(actor);
237 detector.DetectedSignal().Connect(&application, functor);
239 // Do a rotation outside actor's area
240 TestStartRotation( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
241 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
243 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
245 // Continue rotation into actor's area - we should still not receive the signal
247 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
248 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
250 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
252 // Stop rotating - we should still not receive the signal
254 TestEndRotation( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
255 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
257 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
261 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(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 RotationGestureDetector detector = RotationGestureDetector::New();
278 detector.Attach(actor);
279 detector.DetectedSignal().Connect(&application, functor);
281 // Start pan within the actor's area
282 TestStartRotation( application, Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ),
283 Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 );
284 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
285 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
286 DALI_TEST_EQUALS(0.244f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
287 DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
289 // Continue the pan within the actor's area - we should still receive the signal
291 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
292 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
293 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
294 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
295 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
296 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
298 // Pan Gesture leaves actor's area - we should still receive the signal
300 TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
301 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
302 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
303 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
304 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
305 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
307 // Gesture ends - we would receive a finished state
309 TestEndRotation( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
310 Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
311 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
312 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
313 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
314 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
318 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
320 TestApplication application;
322 Actor actor = Actor::New();
323 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
324 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
325 application.GetScene().Add(actor);
328 application.SendNotification();
329 application.Render();
332 GestureReceivedFunctor functor(data);
334 RotationGestureDetector detector = RotationGestureDetector::New();
335 detector.Attach(actor);
336 detector.DetectedSignal().Connect(&application, functor);
338 // Start rotation within the actor's area
339 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
340 Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 );
341 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
342 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
343 DALI_TEST_EQUALS(0.404892f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
344 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
346 // Continue the rotation within the actor's area - we should still receive the signal
348 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
349 Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 );
350 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
351 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
352 DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
353 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
355 // Gesture ends within actor's area - we would receive a finished state
357 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
358 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 1000);
359 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
360 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
361 DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
362 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
366 int UtcDaliRotationGestureSignalReceptionDetach(void)
368 TestApplication application;
370 Actor actor = Actor::New();
371 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
372 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
373 application.GetScene().Add(actor);
376 application.SendNotification();
377 application.Render();
380 GestureReceivedFunctor functor(data);
382 RotationGestureDetector detector = RotationGestureDetector::New();
383 detector.Attach(actor);
384 detector.DetectedSignal().Connect(&application, functor);
386 // Start rotation within the actor's area
387 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
388 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
389 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
390 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
393 // Continue the rotation within the actor's area - we should still receive the signal
395 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
396 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
397 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
398 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
400 // Gesture ends within actor's area
402 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
403 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
404 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
405 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
408 detector.DetachAll();
410 // Ensure we are no longer signalled
412 TestGenerateRotation( application );
413 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
417 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void)
419 TestApplication application;
421 Actor actor = Actor::New();
422 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
423 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
424 application.GetScene().Add(actor);
427 application.SendNotification();
428 application.Render();
431 GestureReceivedFunctor functor(data);
433 RotationGestureDetector detector = RotationGestureDetector::New();
434 detector.Attach(actor);
435 detector.DetectedSignal().Connect(&application, functor);
437 // Start rotation within the actor's area
438 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
439 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
440 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
441 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
443 // Continue the rotation within the actor's area - we should still receive the signal
445 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
446 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
447 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
448 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
450 // Detach actor during the rotation, we should not receive the next event
451 detector.DetachAll();
453 // Gesture ends within actor's area
455 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
456 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
457 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
461 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
463 TestApplication application;
466 GestureReceivedFunctor functor(data);
468 RotationGestureDetector detector = RotationGestureDetector::New();
469 detector.DetectedSignal().Connect(&application, functor);
471 // Attach a temporary actor to stop detector being removed from RotationGestureProcessor 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 rotation within the actor's area
493 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
494 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
495 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
496 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
498 // Continue the rotation within the actor's area - we should still receive the signal
500 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
501 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
502 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
503 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
505 // Remove the actor from stage and reset the data
506 application.GetScene().Remove(actor);
509 application.SendNotification();
510 application.Render();
513 // Actor should now have been destroyed
515 // Gesture ends within the area where the actor used to be
517 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
518 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
519 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
523 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
525 TestApplication application;
527 Actor actor = Actor::New();
528 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
529 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
530 application.GetScene().Add(actor);
532 // Render and notify a couple of times
533 application.SendNotification();
534 application.Render();
537 GestureReceivedFunctor functor(data);
539 RotationGestureDetector detector = RotationGestureDetector::New();
540 detector.Attach(actor);
541 detector.DetectedSignal().Connect(&application, functor);
543 // Do an entire rotation, only check finished value
544 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
545 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
547 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
548 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000);
549 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
550 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
551 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
553 // Rotate actor again and render and notify
554 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
555 application.SendNotification();
556 application.Render();
558 // Do an entire rotation, only check finished value
559 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
560 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
562 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
563 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 3000);
564 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
565 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
566 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
568 // Rotate actor again and render and notify
569 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.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 ),
575 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
577 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
578 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000);
579 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
580 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
581 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
585 int UtcDaliRotationGestureSignalReceptionChildHit(void)
587 TestApplication application;
589 Actor parent = Actor::New();
590 parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
591 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
592 application.GetScene().Add(parent);
594 // Set child to completely cover parent.
595 // Change rotation of child to be different from parent so that we can check if our local coordinate
596 // conversion of the parent actor is correct.
597 Actor child = Actor::New();
598 child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
599 child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
600 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
601 child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
605 application.SendNotification();
606 application.Render();
609 GestureReceivedFunctor functor(data);
611 RotationGestureDetector detector = RotationGestureDetector::New();
612 detector.Attach(parent);
613 detector.DetectedSignal().Connect(&application, functor);
615 // Do an entire pan, only check finished value - hits child area but parent should still receive it
616 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
617 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
619 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
620 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000);
621 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
622 DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
623 DALI_TEST_EQUALS(0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
624 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
626 // Attach child and generate same touch points to yield same results
627 // (Also proves that you can detach and then re-attach another actor)
628 detector.Attach(child);
629 detector.Detach(parent);
631 // Do an entire pan, only check finished value
632 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
633 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
635 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
636 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000);
637 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
638 DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
639 DALI_TEST_EQUALS(0.982794f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
640 DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
644 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
646 TestApplication application;
648 Actor first = Actor::New();
649 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
650 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
651 application.GetScene().Add(first);
653 Actor second = Actor::New();
654 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
655 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
656 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
657 application.GetScene().Add(second);
660 application.SendNotification();
661 application.Render();
664 GestureReceivedFunctor functor(data);
666 RotationGestureDetector detector = RotationGestureDetector::New();
667 detector.Attach(first);
668 detector.Attach(second);
669 detector.DetectedSignal().Connect(&application, functor);
671 // Start rotation within second actor's area
672 TestStartRotation( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
673 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
674 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
675 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
677 // Rotation moves into first actor's area - second actor should receive the rotation
679 TestContinueRotation( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
680 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
681 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
682 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
684 // Detach the second actor during the rotation, we should not receive the next event
685 detector.Detach(second);
687 // Gesture ends within actor's area
689 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
690 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
691 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
695 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
697 TestApplication application;
699 Actor actor = Actor::New();
700 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
701 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
702 application.GetScene().Add(actor);
705 application.SendNotification();
706 application.Render();
709 GestureReceivedFunctor functor(data);
711 RotationGestureDetector detector = RotationGestureDetector::New();
712 detector.Attach(actor);
713 detector.DetectedSignal().Connect(&application, functor);
715 // Start rotation in actor's area
716 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
717 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
718 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
720 // Pan continues within actor's area
722 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
723 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
724 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
726 // Actor become invisible - actor should not receive the next rotation
727 actor.SetProperty( Actor::Property::VISIBLE,false);
730 application.SendNotification();
731 application.Render();
733 // Gesture ends within actor's area
735 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
736 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
737 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
741 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
743 TestApplication application;
745 Actor actor = Actor::New();
746 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
747 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
748 application.GetScene().Add(actor);
750 Actor actor2 = Actor::New();
751 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
752 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
753 application.GetScene().Add(actor2);
756 application.SendNotification();
757 application.Render();
759 // Attach actor to one detector
760 SignalData firstData;
761 GestureReceivedFunctor firstFunctor(firstData);
762 RotationGestureDetector firstDetector = RotationGestureDetector::New();
763 firstDetector.Attach(actor);
764 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
766 // Attach actor to another detector
767 SignalData secondData;
768 GestureReceivedFunctor secondFunctor(secondData);
769 RotationGestureDetector secondDetector = RotationGestureDetector::New();
770 secondDetector.Attach(actor);
771 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
773 // Add second actor to second detector, when we remove the actor, this will make sure that this
774 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
775 // functor should still not be called (which is what we're also testing).
776 secondDetector.Attach(actor2);
778 // Rotation in actor's area - both detector's functors should be called
779 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
780 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
781 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
782 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
784 // Rotation continues in actor's area - both detector's functors should be called
787 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
788 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
789 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
790 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
792 // Detach actor from firstDetector and emit rotation on actor, only secondDetector's functor should be called.
793 firstDetector.Detach(actor);
796 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
797 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
798 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
799 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
801 // New rotation on actor, only secondDetector has actor attached
804 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
805 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
806 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
807 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
809 // Detach actor from secondDetector
810 secondDetector.Detach(actor);
813 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
814 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 ),
851 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
852 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
853 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
857 int UtcDaliRotationGestureActorUnstaged(void)
859 TestApplication application;
861 Actor actor = Actor::New();
862 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
863 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
864 application.GetScene().Add(actor);
867 application.SendNotification();
868 application.Render();
870 // State to remove actor in.
871 Gesture::State stateToUnstage( Gesture::Started );
873 // Attach actor to detector
875 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
876 RotationGestureDetector detector = RotationGestureDetector::New();
877 detector.Attach(actor);
878 detector.DetectedSignal().Connect( &application, functor );
881 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
882 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
883 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
885 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
886 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
887 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
891 application.SendNotification();
892 application.Render();
894 // Re-add actor to stage
895 application.GetScene().Add(actor);
898 application.SendNotification();
899 application.Render();
901 // Change state to Gesture::Continuing to remove
902 stateToUnstage = Gesture::Continuing;
905 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
906 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
907 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
909 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
910 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
911 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
913 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
914 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
915 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
919 application.SendNotification();
920 application.Render();
922 // Re-add actor to stage
923 application.GetScene().Add(actor);
926 application.SendNotification();
927 application.Render();
929 // Change state to Gesture::Continuing to remove
930 stateToUnstage = Gesture::Finished;
933 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
934 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
935 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
937 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
938 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
939 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
941 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
942 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
943 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
944 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
948 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
950 TestApplication application;
952 Actor actor = Actor::New();
953 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
954 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
955 application.GetScene().Add(actor);
957 // Create and add a second actor so that GestureDetector destruction does not come into play.
958 Actor dummyActor( Actor::New() );
959 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
960 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
961 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
962 application.GetScene().Add(dummyActor);
965 application.SendNotification();
966 application.Render();
968 // State to remove actor in.
969 Gesture::State stateToUnstage( Gesture::Started );
971 // Attach actor to detector
973 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
974 RotationGestureDetector detector = RotationGestureDetector::New();
975 detector.Attach(actor);
976 detector.Attach(dummyActor);
977 detector.DetectedSignal().Connect( &application, functor );
979 // Here we are testing a Started actor which is removed in the Started callback, but then added back
980 // before we get a continuing state. As we were removed from the stage, even if we're at the same
981 // position, we should still not be signalled.
984 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
985 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
986 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
990 application.SendNotification();
991 application.Render();
993 // Re add to the stage, we should not be signalled
994 application.GetScene().Add(actor);
997 application.SendNotification();
998 application.Render();
1000 // Continue signal emission
1001 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1002 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1003 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1005 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1006 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1007 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1010 // Here we delete an actor in started, we should not receive any subsequent signalling.
1013 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1014 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1015 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1018 // Render and notify
1019 application.SendNotification();
1020 application.Render();
1022 // Delete actor as well
1025 // Render and notify
1026 application.SendNotification();
1027 application.Render();
1029 // Continue signal emission
1030 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1031 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1032 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1034 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1035 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1036 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1040 int UtcDaliRotationGestureLayerConsumesTouch(void)
1042 TestApplication application;
1044 Actor actor = Actor::New();
1045 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1046 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1047 application.GetScene().Add(actor);
1051 GestureReceivedFunctor functor(data);
1052 RotationGestureDetector detector = RotationGestureDetector::New();
1053 detector.Attach(actor);
1054 detector.DetectedSignal().Connect( &application, functor );
1056 // Add a layer to overlap the actor
1057 Layer layer = Layer::New();
1058 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1059 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1060 application.GetScene().Add( layer );
1063 // Render and notify
1064 application.SendNotification();
1065 application.Render();
1067 // Emit signals, should receive
1068 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1069 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1070 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1071 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1072 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1075 // Set layer to consume all touch
1076 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Emit the same signals again, should not receive
1083 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1084 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1085 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1086 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1087 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1093 int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void)
1095 TestApplication application;
1097 Actor actor = Actor::New();
1098 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1099 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1100 application.GetScene().Add(actor);
1102 bool consume = false;
1103 TouchEventFunctorConsumeSetter touchFunctor(consume);
1104 actor.TouchSignal().Connect(&application,touchFunctor);
1106 // Render and notify
1107 application.SendNotification();
1108 application.Render();
1111 GestureReceivedFunctor functor(data);
1113 RotationGestureDetector detector = RotationGestureDetector::New();
1114 detector.Attach(actor);
1115 detector.DetectedSignal().Connect(&application, functor);
1117 // Start gesture within the actor's area, we should receive the rotation as the touch is NOT being consumed
1118 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1119 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1121 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1122 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
1125 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1128 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1129 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1130 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1131 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
1134 // Start another rotation, we should not even get the callback this time
1135 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1136 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1137 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1142 int UtcDaliRotationGestureDisableDetectionDuringRotationN(void)
1144 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1146 TestApplication application;
1148 Actor actor = Actor::New();
1149 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1150 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1151 application.GetScene().Add(actor);
1154 RotationGestureDetector detector = RotationGestureDetector::New();
1155 bool functorCalled = false;
1156 detector.Attach( actor );
1157 detector.DetectedSignal().Connect(
1159 [&detector, &functorCalled](Actor actor, const RotationGesture& gesture)
1161 if( gesture.state == Gesture::Finished )
1163 detector.Detach(actor);
1164 functorCalled = true;
1168 // Render and notify
1169 application.SendNotification();
1170 application.Render();
1172 // Try the gesture, should not crash
1175 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1176 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1177 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1178 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1179 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1180 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1182 DALI_TEST_CHECK( true ); // No crash, test has passed
1183 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1187 DALI_TEST_CHECK( false ); // If we crash, the test has failed