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/devel-api/events/gesture-devel.h>
25 #include <dali/devel-api/events/rotation-gesture.h>
26 #include <dali/devel-api/events/rotation-gesture-detector.h>
27 #include <dali-test-suite-utils.h>
28 #include <test-touch-data-utils.h>
32 void utc_dali_rotation_gesture_detector_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_rotation_gesture_detector_cleanup(void)
39 test_return_value = TET_PASS;
42 ///////////////////////////////////////////////////////////////////////////////
46 // Stores data that is populated in the callback and will be read by the TET cases
50 : functorCalled(false),
51 voidFunctorCalled(false),
52 receivedGesture(Gesture::Started)
57 functorCalled = false;
58 voidFunctorCalled = false;
60 receivedGesture.state = Gesture::Started;
61 receivedGesture.rotation = 0.0f;
62 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
63 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
69 bool voidFunctorCalled;
70 RotationGesture receivedGesture;
74 // Functor that sets the data when called
75 struct GestureReceivedFunctor
77 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
79 void operator()(Actor actor, const RotationGesture& rotation)
81 signalData.functorCalled = true;
82 signalData.receivedGesture = rotation;
83 signalData.rotatedActor = actor;
88 signalData.voidFunctorCalled = true;
91 SignalData& signalData;
94 // Functor that removes the gestured actor from stage
95 struct UnstageActorFunctor : public GestureReceivedFunctor
97 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage, Integration::Scene scene )
98 : GestureReceivedFunctor( data ),
99 stateToUnstage( stateToUnstage ),
104 void operator()( Actor actor, const RotationGesture& rotation )
106 GestureReceivedFunctor::operator()( actor, rotation );
108 if ( rotation.state == stateToUnstage )
110 scene.Remove( actor );
114 Gesture::State& stateToUnstage;
115 Integration::Scene scene;
120 ///////////////////////////////////////////////////////////////////////////////
122 int UtcDaliRotationGestureDetectorConstructor(void)
124 TestApplication application;
126 RotationGestureDetector detector;
127 DALI_TEST_CHECK(!detector);
131 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
133 TestApplication application;
135 RotationGestureDetector detector = RotationGestureDetector::New();;
137 RotationGestureDetector copy( detector );
138 DALI_TEST_CHECK( detector );
142 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
144 TestApplication application;
146 RotationGestureDetector detector = RotationGestureDetector::New();;
148 RotationGestureDetector assign;
150 DALI_TEST_CHECK( detector );
152 DALI_TEST_CHECK( detector == assign );
156 int UtcDaliRotationGestureDetectorNew(void)
158 TestApplication application;
160 RotationGestureDetector detector = RotationGestureDetector::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 UtcDaliRotationGestureDetectorDownCast(void)
195 TestApplication application;
196 tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
198 RotationGestureDetector detector = RotationGestureDetector::New();
200 BaseHandle object(detector);
202 RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
203 DALI_TEST_CHECK(detector2);
205 RotationGestureDetector detector3 = DownCast< RotationGestureDetector >(object);
206 DALI_TEST_CHECK(detector3);
208 BaseHandle unInitializedObject;
209 RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
210 DALI_TEST_CHECK(!detector4);
212 RotationGestureDetector detector5 = DownCast< RotationGestureDetector >(unInitializedObject);
213 DALI_TEST_CHECK(!detector5);
215 GestureDetector detector6 = RotationGestureDetector::New();
216 RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
217 DALI_TEST_CHECK(detector7);
221 // Negative test case for a method
222 int UtcDaliRotationGestureSignalReceptionNegative(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 RotationGestureDetector detector = RotationGestureDetector::New();
239 detector.Attach(actor);
240 detector.DetectedSignal().Connect(&application, functor);
242 // Do a rotation outside actor's area
243 TestStartRotation( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
244 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
246 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
248 // Continue rotation into actor's area - we should still not receive the signal
250 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
251 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
253 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
255 // Stop rotating - we should still not receive the signal
257 TestEndRotation( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
258 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
260 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
264 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void)
266 TestApplication application;
268 Actor actor = Actor::New();
269 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
270 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
271 application.GetScene().Add(actor);
274 application.SendNotification();
275 application.Render();
278 GestureReceivedFunctor functor(data);
280 RotationGestureDetector detector = RotationGestureDetector::New();
281 detector.Attach(actor);
282 detector.DetectedSignal().Connect(&application, functor);
284 // Start pan within the actor's area
285 TestStartRotation( application, Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ),
286 Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 );
287 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
288 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
289 DALI_TEST_EQUALS(0.244f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
290 DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
292 // Continue the pan within the actor's area - we should still receive the signal
294 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
295 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
296 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
297 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
298 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
299 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
301 // Pan Gesture leaves actor's area - we should still receive the signal
303 TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
304 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
305 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
306 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
307 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
308 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
310 // Gesture ends - we would receive a finished state
312 TestEndRotation( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
313 Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
314 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
315 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
316 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
317 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
321 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
323 TestApplication application;
325 Actor actor = Actor::New();
326 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
327 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
328 application.GetScene().Add(actor);
331 application.SendNotification();
332 application.Render();
335 GestureReceivedFunctor functor(data);
337 RotationGestureDetector detector = RotationGestureDetector::New();
338 detector.Attach(actor);
339 detector.DetectedSignal().Connect(&application, functor);
341 // Start rotation within the actor's area
342 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
343 Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 );
344 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
345 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
346 DALI_TEST_EQUALS(0.404892f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
347 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
349 // Continue the rotation within the actor's area - we should still receive the signal
351 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
352 Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 );
353 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
354 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
355 DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
356 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
358 // Gesture ends within actor's area - we would receive a finished state
360 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
361 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 1000);
362 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
363 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
364 DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
365 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
369 int UtcDaliRotationGestureSignalReceptionDetach(void)
371 TestApplication application;
373 Actor actor = Actor::New();
374 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
375 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
376 application.GetScene().Add(actor);
379 application.SendNotification();
380 application.Render();
383 GestureReceivedFunctor functor(data);
385 RotationGestureDetector detector = RotationGestureDetector::New();
386 detector.Attach(actor);
387 detector.DetectedSignal().Connect(&application, functor);
389 // Start rotation within the actor's area
390 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
391 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
392 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
393 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
396 // Continue the rotation within the actor's area - we should still receive the signal
398 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
399 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
400 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
401 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
403 // Gesture ends within actor's area
405 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
406 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
407 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
408 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
411 detector.DetachAll();
413 // Ensure we are no longer signalled
415 TestGenerateRotation( application );
416 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
420 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(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 RotationGestureDetector detector = RotationGestureDetector::New();
437 detector.Attach(actor);
438 detector.DetectedSignal().Connect(&application, functor);
440 // Start rotation within the actor's area
441 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
442 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
443 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
444 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
446 // Continue the rotation within the actor's area - we should still receive the signal
448 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
449 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
450 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
451 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
453 // Detach actor during the rotation, we should not receive the next event
454 detector.DetachAll();
456 // Gesture ends within actor's area
458 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
459 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
460 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
464 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
466 TestApplication application;
469 GestureReceivedFunctor functor(data);
471 RotationGestureDetector detector = RotationGestureDetector::New();
472 detector.DetectedSignal().Connect(&application, functor);
474 // Attach a temporary actor to stop detector being removed from RotationGestureProcessor when main actor
476 Actor tempActor = Actor::New();
477 tempActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
478 tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
479 application.GetScene().Add(tempActor);
480 detector.Attach(tempActor);
482 // Actor lifetime is scoped
484 Actor actor = Actor::New();
485 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
486 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
487 application.GetScene().Add(actor);
490 application.SendNotification();
491 application.Render();
493 detector.Attach(actor);
495 // Start rotation within the actor's area
496 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
497 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
498 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
499 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
501 // Continue the rotation within the actor's area - we should still receive the signal
503 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
504 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
505 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
506 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
508 // Remove the actor from stage and reset the data
509 application.GetScene().Remove(actor);
512 application.SendNotification();
513 application.Render();
516 // Actor should now have been destroyed
518 // Gesture ends within the area where the actor used to be
520 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
521 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
522 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
526 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
528 TestApplication application;
530 Actor actor = Actor::New();
531 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
532 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
533 application.GetScene().Add(actor);
535 // Render and notify a couple of times
536 application.SendNotification();
537 application.Render();
540 GestureReceivedFunctor functor(data);
542 RotationGestureDetector detector = RotationGestureDetector::New();
543 detector.Attach(actor);
544 detector.DetectedSignal().Connect(&application, functor);
546 // Do an entire rotation, only check finished value
547 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
548 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
550 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
551 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000);
552 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
553 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
554 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
556 // Rotate actor again and render and notify
557 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
558 application.SendNotification();
559 application.Render();
561 // Do an entire rotation, only check finished value
562 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
563 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
565 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
566 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 3000);
567 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
568 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
569 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
571 // Rotate actor again and render and notify
572 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) );
573 application.SendNotification();
574 application.Render();
576 // Do an entire rotation, only check finished value
577 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
578 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
580 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
581 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000);
582 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
583 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
584 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
588 int UtcDaliRotationGestureSignalReceptionChildHit(void)
590 TestApplication application;
592 Actor parent = Actor::New();
593 parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
594 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
595 application.GetScene().Add(parent);
597 // Set child to completely cover parent.
598 // Change rotation of child to be different from parent so that we can check if our local coordinate
599 // conversion of the parent actor is correct.
600 Actor child = Actor::New();
601 child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
602 child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
603 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
604 child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
608 application.SendNotification();
609 application.Render();
612 GestureReceivedFunctor functor(data);
614 RotationGestureDetector detector = RotationGestureDetector::New();
615 detector.Attach(parent);
616 detector.DetectedSignal().Connect(&application, functor);
618 // Do an entire pan, only check finished value - hits child area but parent should still receive it
619 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
620 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
622 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
623 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000);
624 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
625 DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
626 DALI_TEST_EQUALS(0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
627 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
629 // Attach child and generate same touch points to yield same results
630 // (Also proves that you can detach and then re-attach another actor)
631 detector.Attach(child);
632 detector.Detach(parent);
634 // Do an entire pan, only check finished value
635 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
636 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
638 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
639 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000);
640 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
641 DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
642 DALI_TEST_EQUALS(0.982794f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
643 DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
647 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
649 TestApplication application;
651 Actor first = Actor::New();
652 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
653 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
654 application.GetScene().Add(first);
656 Actor second = Actor::New();
657 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
658 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
659 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
660 application.GetScene().Add(second);
663 application.SendNotification();
664 application.Render();
667 GestureReceivedFunctor functor(data);
669 RotationGestureDetector detector = RotationGestureDetector::New();
670 detector.Attach(first);
671 detector.Attach(second);
672 detector.DetectedSignal().Connect(&application, functor);
674 // Start rotation within second actor's area
675 TestStartRotation( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
676 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
677 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
678 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
680 // Rotation moves into first actor's area - second actor should receive the rotation
682 TestContinueRotation( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
683 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
684 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
685 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
687 // Detach the second actor during the rotation, we should not receive the next event
688 detector.Detach(second);
690 // Gesture ends within actor's area
692 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
693 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
694 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
698 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
700 TestApplication application;
702 Actor actor = Actor::New();
703 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
704 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
705 application.GetScene().Add(actor);
708 application.SendNotification();
709 application.Render();
712 GestureReceivedFunctor functor(data);
714 RotationGestureDetector detector = RotationGestureDetector::New();
715 detector.Attach(actor);
716 detector.DetectedSignal().Connect(&application, functor);
718 // Start rotation in actor's area
719 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
720 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
721 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
723 // Pan continues within actor's area
725 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
726 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
727 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
729 // Actor become invisible - actor should not receive the next rotation
730 actor.SetProperty( Actor::Property::VISIBLE,false);
733 application.SendNotification();
734 application.Render();
736 // Gesture ends within actor's area
738 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
739 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
740 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
744 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
746 TestApplication application;
748 Actor actor = Actor::New();
749 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
750 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
751 application.GetScene().Add(actor);
753 Actor actor2 = Actor::New();
754 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
755 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
756 application.GetScene().Add(actor2);
759 application.SendNotification();
760 application.Render();
762 // Attach actor to one detector
763 SignalData firstData;
764 GestureReceivedFunctor firstFunctor(firstData);
765 RotationGestureDetector firstDetector = RotationGestureDetector::New();
766 firstDetector.Attach(actor);
767 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
769 // Attach actor to another detector
770 SignalData secondData;
771 GestureReceivedFunctor secondFunctor(secondData);
772 RotationGestureDetector secondDetector = RotationGestureDetector::New();
773 secondDetector.Attach(actor);
774 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
776 // Add second actor to second detector, when we remove the actor, this will make sure that this
777 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
778 // functor should still not be called (which is what we're also testing).
779 secondDetector.Attach(actor2);
781 // Rotation in actor's area - both detector's functors should be called
782 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
783 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
784 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
785 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
787 // Rotation continues in actor's area - both detector's functors should be called
790 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
791 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 ),
800 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
801 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
802 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
804 // New rotation on actor, only secondDetector has actor attached
807 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
808 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
809 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
810 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
812 // Detach actor from secondDetector
813 secondDetector.Detach(actor);
816 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
817 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
818 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
819 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
823 int UtcDaliRotationGestureSignalReceptionEnsureCorrectSignalling(void)
825 TestApplication application;
827 Actor actor1 = Actor::New();
828 actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
829 actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
830 application.GetScene().Add(actor1);
832 GestureReceivedFunctor functor1(data1);
833 RotationGestureDetector detector1 = RotationGestureDetector::New();
834 detector1.Attach(actor1);
835 detector1.DetectedSignal().Connect(&application, functor1);
837 Actor actor2 = Actor::New();
838 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
839 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
840 actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
841 application.GetScene().Add(actor2);
843 GestureReceivedFunctor functor2(data2);
844 RotationGestureDetector detector2 = RotationGestureDetector::New();
845 detector2.Attach(actor2);
846 detector2.DetectedSignal().Connect(&application, functor2);
849 application.SendNotification();
850 application.Render();
852 // Start pan in actor1's area, only data1 should be set
853 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
854 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
855 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
856 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
860 int UtcDaliRotationGestureActorUnstaged(void)
862 TestApplication application;
864 Actor actor = Actor::New();
865 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
866 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
867 application.GetScene().Add(actor);
870 application.SendNotification();
871 application.Render();
873 // State to remove actor in.
874 Gesture::State stateToUnstage( Gesture::Started );
876 // Attach actor to detector
878 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
879 RotationGestureDetector detector = RotationGestureDetector::New();
880 detector.Attach(actor);
881 detector.DetectedSignal().Connect( &application, functor );
884 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
885 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
886 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
888 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
889 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
890 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
894 application.SendNotification();
895 application.Render();
897 // Re-add actor to stage
898 application.GetScene().Add(actor);
901 application.SendNotification();
902 application.Render();
904 // Change state to Gesture::Continuing to remove
905 stateToUnstage = Gesture::Continuing;
908 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
909 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
910 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
912 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
913 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
914 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
916 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
917 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
918 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
922 application.SendNotification();
923 application.Render();
925 // Re-add actor to stage
926 application.GetScene().Add(actor);
929 application.SendNotification();
930 application.Render();
932 // Change state to Gesture::Continuing to remove
933 stateToUnstage = Gesture::Finished;
936 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
937 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
938 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
940 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
941 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
942 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
944 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
945 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
946 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
947 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
951 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
953 TestApplication application;
955 Actor actor = Actor::New();
956 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
957 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
958 application.GetScene().Add(actor);
960 // Create and add a second actor so that GestureDetector destruction does not come into play.
961 Actor dummyActor( Actor::New() );
962 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
963 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
964 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
965 application.GetScene().Add(dummyActor);
968 application.SendNotification();
969 application.Render();
971 // State to remove actor in.
972 Gesture::State stateToUnstage( Gesture::Started );
974 // Attach actor to detector
976 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
977 RotationGestureDetector detector = RotationGestureDetector::New();
978 detector.Attach(actor);
979 detector.Attach(dummyActor);
980 detector.DetectedSignal().Connect( &application, functor );
982 // Here we are testing a Started actor which is removed in the Started callback, but then added back
983 // before we get a continuing state. As we were removed from the stage, even if we're at the same
984 // position, we should still not be signalled.
987 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
988 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
989 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
993 application.SendNotification();
994 application.Render();
996 // Re add to the stage, we should not be signalled
997 application.GetScene().Add(actor);
1000 application.SendNotification();
1001 application.Render();
1003 // Continue signal emission
1004 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1005 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1006 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1008 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1009 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1010 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1013 // Here we delete an actor in started, we should not receive any subsequent signalling.
1016 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1017 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1018 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1021 // Render and notify
1022 application.SendNotification();
1023 application.Render();
1025 // Delete actor as well
1028 // Render and notify
1029 application.SendNotification();
1030 application.Render();
1032 // Continue signal emission
1033 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1034 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1035 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1037 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1038 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1039 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1043 int UtcDaliRotationGestureLayerConsumesTouch(void)
1045 TestApplication application;
1047 Actor actor = Actor::New();
1048 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1049 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1050 application.GetScene().Add(actor);
1054 GestureReceivedFunctor functor(data);
1055 RotationGestureDetector detector = RotationGestureDetector::New();
1056 detector.Attach(actor);
1057 detector.DetectedSignal().Connect( &application, functor );
1059 // Add a layer to overlap the actor
1060 Layer layer = Layer::New();
1061 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1062 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1063 application.GetScene().Add( layer );
1066 // Render and notify
1067 application.SendNotification();
1068 application.Render();
1070 // Emit signals, should receive
1071 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1072 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1073 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1074 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1075 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1078 // Set layer to consume all touch
1079 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Emit the same signals again, should not receive
1086 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1087 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1088 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1089 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1090 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1096 int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void)
1098 TestApplication application;
1100 Actor actor = Actor::New();
1101 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1102 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1103 application.GetScene().Add(actor);
1105 bool consume = false;
1106 TouchDataFunctorConsumeSetter touchFunctor(consume);
1107 actor.TouchSignal().Connect(&application,touchFunctor);
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1114 GestureReceivedFunctor functor(data);
1116 RotationGestureDetector detector = RotationGestureDetector::New();
1117 detector.Attach(actor);
1118 detector.DetectedSignal().Connect(&application, functor);
1120 // Start gesture within the actor's area, we should receive the rotation as the touch is NOT being consumed
1121 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1122 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1124 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1125 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
1128 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1131 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1132 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1133 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1134 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
1137 // Start another rotation, we should not even get the callback this time
1138 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1139 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1140 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1145 int UtcDaliRotationGestureDisableDetectionDuringRotationN(void)
1147 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1149 TestApplication application;
1151 Actor actor = Actor::New();
1152 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1153 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1154 application.GetScene().Add(actor);
1157 RotationGestureDetector detector = RotationGestureDetector::New();
1158 bool functorCalled = false;
1159 detector.Attach( actor );
1160 detector.DetectedSignal().Connect(
1162 [&detector, &functorCalled](Actor actor, const RotationGesture& gesture)
1164 if( gesture.state == Gesture::Finished )
1166 detector.Detach(actor);
1167 functorCalled = true;
1171 // Render and notify
1172 application.SendNotification();
1173 application.Render();
1175 // Try the gesture, should not crash
1178 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1179 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1180 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1181 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1182 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1183 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1185 DALI_TEST_CHECK( true ); // No crash, test has passed
1186 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1190 DALI_TEST_CHECK( false ); // If we crash, the test has failed