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-utils.h>
29 #include <test-touch-data-utils.h>
33 void utc_dali_rotation_gesture_detector_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_rotation_gesture_detector_cleanup(void)
40 test_return_value = TET_PASS;
43 ///////////////////////////////////////////////////////////////////////////////
47 // Stores data that is populated in the callback and will be read by the TET cases
51 : functorCalled(false),
52 voidFunctorCalled(false),
53 receivedGesture(Gesture::Started)
58 functorCalled = false;
59 voidFunctorCalled = false;
61 receivedGesture.state = Gesture::Started;
62 receivedGesture.rotation = 0.0f;
63 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
64 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
70 bool voidFunctorCalled;
71 RotationGesture receivedGesture;
75 // Functor that sets the data when called
76 struct GestureReceivedFunctor
78 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
80 void operator()(Actor actor, const RotationGesture& rotation)
82 signalData.functorCalled = true;
83 signalData.receivedGesture = rotation;
84 signalData.rotatedActor = actor;
89 signalData.voidFunctorCalled = true;
92 SignalData& signalData;
95 // Functor that removes the gestured actor from stage
96 struct UnstageActorFunctor : public GestureReceivedFunctor
98 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage, Integration::Scene scene )
99 : GestureReceivedFunctor( data ),
100 stateToUnstage( stateToUnstage ),
105 void operator()( Actor actor, const RotationGesture& rotation )
107 GestureReceivedFunctor::operator()( actor, rotation );
109 if ( rotation.state == stateToUnstage )
111 scene.Remove( actor );
115 Gesture::State& stateToUnstage;
116 Integration::Scene scene;
119 // Functor for receiving a touch event
120 struct TouchEventFunctor
122 bool operator()(Actor actor, const TouchEvent& touch)
130 ///////////////////////////////////////////////////////////////////////////////
132 int UtcDaliRotationGestureDetectorConstructor(void)
134 TestApplication application;
136 RotationGestureDetector detector;
137 DALI_TEST_CHECK(!detector);
141 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
143 TestApplication application;
145 RotationGestureDetector detector = RotationGestureDetector::New();;
147 RotationGestureDetector copy( detector );
148 DALI_TEST_CHECK( detector );
152 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
154 TestApplication application;
156 RotationGestureDetector detector = RotationGestureDetector::New();;
158 RotationGestureDetector assign;
160 DALI_TEST_CHECK( detector );
162 DALI_TEST_CHECK( detector == assign );
166 int UtcDaliRotationGestureDetectorNew(void)
168 TestApplication application;
170 RotationGestureDetector detector = RotationGestureDetector::New();
172 DALI_TEST_CHECK(detector);
174 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
175 Actor actor = Actor::New();
176 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
177 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
178 application.GetScene().Add(actor);
181 application.SendNotification();
182 application.Render();
184 detector.Attach(actor);
186 Integration::TouchEvent touchEvent(1);
187 Integration::Point point;
188 point.SetDeviceId( 1 );
189 point.SetState( PointState::DOWN );
190 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
191 touchEvent.AddPoint(point);
192 application.ProcessEvent(touchEvent);
194 Integration::Point point2;
195 point.SetDeviceId( 1 );
196 point.SetState( PointState::DOWN );
197 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
198 touchEvent.AddPoint(point2);
199 application.ProcessEvent(touchEvent);
203 int UtcDaliRotationGestureDetectorDownCast(void)
205 TestApplication application;
206 tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
208 RotationGestureDetector detector = RotationGestureDetector::New();
210 BaseHandle object(detector);
212 RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
213 DALI_TEST_CHECK(detector2);
215 RotationGestureDetector detector3 = DownCast< RotationGestureDetector >(object);
216 DALI_TEST_CHECK(detector3);
218 BaseHandle unInitializedObject;
219 RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
220 DALI_TEST_CHECK(!detector4);
222 RotationGestureDetector detector5 = DownCast< RotationGestureDetector >(unInitializedObject);
223 DALI_TEST_CHECK(!detector5);
225 GestureDetector detector6 = RotationGestureDetector::New();
226 RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
227 DALI_TEST_CHECK(detector7);
231 // Negative test case for a method
232 int UtcDaliRotationGestureSignalReceptionNegative(void)
234 TestApplication application;
236 Actor actor = Actor::New();
237 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
238 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
239 application.GetScene().Add(actor);
242 application.SendNotification();
243 application.Render();
246 GestureReceivedFunctor functor(data);
248 RotationGestureDetector detector = RotationGestureDetector::New();
249 detector.Attach(actor);
250 detector.DetectedSignal().Connect(&application, functor);
252 // Do a rotation outside actor's area
253 TestStartRotation( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
254 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
256 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
258 // Continue rotation into actor's area - we should still not receive the signal
260 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
261 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
263 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
265 // Stop rotating - we should still not receive the signal
267 TestEndRotation( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
268 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
270 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
274 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void)
276 TestApplication application;
278 Actor actor = Actor::New();
279 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
280 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
281 application.GetScene().Add(actor);
284 application.SendNotification();
285 application.Render();
288 GestureReceivedFunctor functor(data);
290 RotationGestureDetector detector = RotationGestureDetector::New();
291 detector.Attach(actor);
292 detector.DetectedSignal().Connect(&application, functor);
294 // Start pan within the actor's area
295 TestStartRotation( application, Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ),
296 Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 );
297 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
298 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
299 DALI_TEST_EQUALS(0.244f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
300 DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
302 // Continue the pan within the actor's area - we should still receive the signal
304 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
305 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
306 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
307 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
308 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
309 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
311 // Pan Gesture leaves actor's area - we should still receive the signal
313 TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
314 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
315 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
316 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
317 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
318 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
320 // Gesture ends - we would receive a finished state
322 TestEndRotation( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
323 Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
324 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
325 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
326 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
327 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
331 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
333 TestApplication application;
335 Actor actor = Actor::New();
336 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
337 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
338 application.GetScene().Add(actor);
341 application.SendNotification();
342 application.Render();
345 GestureReceivedFunctor functor(data);
347 RotationGestureDetector detector = RotationGestureDetector::New();
348 detector.Attach(actor);
349 detector.DetectedSignal().Connect(&application, functor);
351 // Start rotation within the actor's area
352 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
353 Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 );
354 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
355 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
356 DALI_TEST_EQUALS(0.404892f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
357 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
359 // Continue the rotation within the actor's area - we should still receive the signal
361 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
362 Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 );
363 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
364 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
365 DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
366 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
368 // Gesture ends within actor's area - we would receive a finished state
370 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
371 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 1000);
372 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
373 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
374 DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
375 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
379 int UtcDaliRotationGestureSignalReceptionDetach(void)
381 TestApplication application;
383 Actor actor = Actor::New();
384 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
385 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
386 application.GetScene().Add(actor);
389 application.SendNotification();
390 application.Render();
393 GestureReceivedFunctor functor(data);
395 RotationGestureDetector detector = RotationGestureDetector::New();
396 detector.Attach(actor);
397 detector.DetectedSignal().Connect(&application, functor);
399 // Start rotation within the actor's area
400 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
401 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
402 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
403 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
406 // Continue the rotation within the actor's area - we should still receive the signal
408 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
409 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
410 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
411 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
413 // Gesture ends within actor's area
415 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
416 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
417 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
418 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
421 detector.DetachAll();
423 // Ensure we are no longer signalled
425 TestGenerateRotation( application );
426 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
430 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void)
432 TestApplication application;
434 Actor actor = Actor::New();
435 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
436 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
437 application.GetScene().Add(actor);
440 application.SendNotification();
441 application.Render();
444 GestureReceivedFunctor functor(data);
446 RotationGestureDetector detector = RotationGestureDetector::New();
447 detector.Attach(actor);
448 detector.DetectedSignal().Connect(&application, functor);
450 // Start rotation within the actor's area
451 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
452 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
453 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
454 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
456 // Continue the rotation within the actor's area - we should still receive the signal
458 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
459 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
460 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
461 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
463 // Detach actor during the rotation, we should not receive the next event
464 detector.DetachAll();
466 // Gesture ends within actor's area
468 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
469 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
470 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
474 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
476 TestApplication application;
479 GestureReceivedFunctor functor(data);
481 RotationGestureDetector detector = RotationGestureDetector::New();
482 detector.DetectedSignal().Connect(&application, functor);
484 // Attach a temporary actor to stop detector being removed from RotationGestureProcessor when main actor
486 Actor tempActor = Actor::New();
487 tempActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
488 tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
489 application.GetScene().Add(tempActor);
490 detector.Attach(tempActor);
492 // Actor lifetime is scoped
494 Actor actor = Actor::New();
495 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
496 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
497 application.GetScene().Add(actor);
500 application.SendNotification();
501 application.Render();
503 detector.Attach(actor);
505 // Start rotation within the actor's area
506 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
507 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
508 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
509 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
511 // Continue the rotation within the actor's area - we should still receive the signal
513 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
514 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
515 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
516 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
518 // Remove the actor from stage and reset the data
519 application.GetScene().Remove(actor);
522 application.SendNotification();
523 application.Render();
526 // Actor should now have been destroyed
528 // Gesture ends within the area where the actor used to be
530 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
531 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
532 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
536 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
538 TestApplication application;
540 Actor actor = Actor::New();
541 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
542 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
543 application.GetScene().Add(actor);
545 // Render and notify a couple of times
546 application.SendNotification();
547 application.Render();
550 GestureReceivedFunctor functor(data);
552 RotationGestureDetector detector = RotationGestureDetector::New();
553 detector.Attach(actor);
554 detector.DetectedSignal().Connect(&application, functor);
556 // Do an entire rotation, only check finished value
557 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
558 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
560 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
561 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000);
562 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
563 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
564 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
566 // Rotate actor again and render and notify
567 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
568 application.SendNotification();
569 application.Render();
571 // Do an entire rotation, only check finished value
572 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
573 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
575 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
576 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.rotation.radian, 0.01f, TEST_LOCATION);
579 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
581 // Rotate actor again and render and notify
582 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) );
583 application.SendNotification();
584 application.Render();
586 // Do an entire rotation, only check finished value
587 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
588 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
590 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
591 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000);
592 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
593 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
594 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 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) );
617 TouchEventFunctor touchFunctor;
618 child.TouchedSignal().Connect(&application, touchFunctor);
621 application.SendNotification();
622 application.Render();
625 GestureReceivedFunctor functor(data);
627 RotationGestureDetector detector = RotationGestureDetector::New();
628 detector.Attach(parent);
629 detector.DetectedSignal().Connect(&application, functor);
631 // Do an entire pan, only check finished value - hits child area but parent should still receive it
632 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
633 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
635 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
636 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000);
637 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
638 DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
639 DALI_TEST_EQUALS(0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
640 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
642 // Attach child and generate same touch points to yield same results
643 // (Also proves that you can detach and then re-attach another actor)
644 detector.Attach(child);
645 detector.Detach(parent);
647 // Do an entire pan, only check finished value
648 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
649 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
651 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
652 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000);
653 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
654 DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
655 DALI_TEST_EQUALS(0.982794f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
656 DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
660 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
662 TestApplication application;
664 Actor first = Actor::New();
665 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
666 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
667 application.GetScene().Add(first);
669 Actor second = Actor::New();
670 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
671 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
672 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
673 application.GetScene().Add(second);
676 application.SendNotification();
677 application.Render();
680 GestureReceivedFunctor functor(data);
682 RotationGestureDetector detector = RotationGestureDetector::New();
683 detector.Attach(first);
684 detector.Attach(second);
685 detector.DetectedSignal().Connect(&application, functor);
687 // Start rotation within second actor's area
688 TestStartRotation( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
689 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
690 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
691 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
693 // Rotation moves into first actor's area - second actor should receive the rotation
695 TestContinueRotation( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
696 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
697 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
698 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
700 // Detach the second actor during the rotation, we should not receive the next event
701 detector.Detach(second);
703 // Gesture ends within actor's area
705 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
706 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
707 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
711 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
713 TestApplication application;
715 Actor actor = Actor::New();
716 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
717 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
718 application.GetScene().Add(actor);
721 application.SendNotification();
722 application.Render();
725 GestureReceivedFunctor functor(data);
727 RotationGestureDetector detector = RotationGestureDetector::New();
728 detector.Attach(actor);
729 detector.DetectedSignal().Connect(&application, functor);
731 // Start rotation in actor's area
732 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
733 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
734 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
736 // Pan continues within actor's area
738 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
739 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
740 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
742 // Actor become invisible - actor should not receive the next rotation
743 actor.SetProperty( Actor::Property::VISIBLE,false);
746 application.SendNotification();
747 application.Render();
749 // Gesture ends within actor's area
751 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
752 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
753 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
757 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
759 TestApplication application;
761 Actor actor = Actor::New();
762 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
763 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
764 application.GetScene().Add(actor);
766 Actor actor2 = Actor::New();
767 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
768 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
769 application.GetScene().Add(actor2);
772 application.SendNotification();
773 application.Render();
775 // Attach actor to one detector
776 SignalData firstData;
777 GestureReceivedFunctor firstFunctor(firstData);
778 RotationGestureDetector firstDetector = RotationGestureDetector::New();
779 firstDetector.Attach(actor);
780 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
782 // Attach actor to another detector
783 SignalData secondData;
784 GestureReceivedFunctor secondFunctor(secondData);
785 RotationGestureDetector secondDetector = RotationGestureDetector::New();
786 secondDetector.Attach(actor);
787 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
789 // Add second actor to second detector, when we remove the actor, this will make sure that this
790 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
791 // functor should still not be called (which is what we're also testing).
792 secondDetector.Attach(actor2);
794 // Rotation in actor's area - both detector's functors should be called
795 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
796 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
797 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
798 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
800 // Rotation continues in actor's area - both detector's functors should be called
803 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
804 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
805 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
806 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
808 // Detach actor from firstDetector and emit rotation on actor, only secondDetector's functor should be called.
809 firstDetector.Detach(actor);
812 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
813 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
814 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
815 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
817 // New rotation on actor, only secondDetector has actor attached
820 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
821 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
822 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
823 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
825 // Detach actor from secondDetector
826 secondDetector.Detach(actor);
829 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
830 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
831 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
832 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
836 int UtcDaliRotationGestureSignalReceptionEnsureCorrectSignalling(void)
838 TestApplication application;
840 Actor actor1 = Actor::New();
841 actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
842 actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
843 application.GetScene().Add(actor1);
845 GestureReceivedFunctor functor1(data1);
846 RotationGestureDetector detector1 = RotationGestureDetector::New();
847 detector1.Attach(actor1);
848 detector1.DetectedSignal().Connect(&application, functor1);
850 Actor actor2 = Actor::New();
851 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
852 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
853 actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
854 application.GetScene().Add(actor2);
856 GestureReceivedFunctor functor2(data2);
857 RotationGestureDetector detector2 = RotationGestureDetector::New();
858 detector2.Attach(actor2);
859 detector2.DetectedSignal().Connect(&application, functor2);
862 application.SendNotification();
863 application.Render();
865 // Start pan in actor1's area, only data1 should be set
866 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
867 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
868 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
869 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
873 int UtcDaliRotationGestureActorUnstaged(void)
875 TestApplication application;
877 Actor actor = Actor::New();
878 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
879 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
880 application.GetScene().Add(actor);
883 application.SendNotification();
884 application.Render();
886 // State to remove actor in.
887 Gesture::State stateToUnstage( Gesture::Started );
889 // Attach actor to detector
891 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
892 RotationGestureDetector detector = RotationGestureDetector::New();
893 detector.Attach(actor);
894 detector.DetectedSignal().Connect( &application, functor );
897 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
898 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
899 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
901 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
902 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
903 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
907 application.SendNotification();
908 application.Render();
910 // Re-add actor to stage
911 application.GetScene().Add(actor);
914 application.SendNotification();
915 application.Render();
917 // Change state to Gesture::Continuing to remove
918 stateToUnstage = Gesture::Continuing;
921 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
922 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
923 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
925 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
926 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
927 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
929 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
930 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
931 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
935 application.SendNotification();
936 application.Render();
938 // Re-add actor to stage
939 application.GetScene().Add(actor);
942 application.SendNotification();
943 application.Render();
945 // Change state to Gesture::Continuing to remove
946 stateToUnstage = Gesture::Finished;
949 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
950 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
951 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
953 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
954 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
955 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
957 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
958 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
959 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
960 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
964 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
966 TestApplication application;
968 Actor actor = Actor::New();
969 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
970 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
971 application.GetScene().Add(actor);
973 // Create and add a second actor so that GestureDetector destruction does not come into play.
974 Actor dummyActor( Actor::New() );
975 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
976 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
977 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
978 application.GetScene().Add(dummyActor);
981 application.SendNotification();
982 application.Render();
984 // State to remove actor in.
985 Gesture::State stateToUnstage( Gesture::Started );
987 // Attach actor to detector
989 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
990 RotationGestureDetector detector = RotationGestureDetector::New();
991 detector.Attach(actor);
992 detector.Attach(dummyActor);
993 detector.DetectedSignal().Connect( &application, functor );
995 // Here we are testing a Started actor which is removed in the Started callback, but then added back
996 // before we get a continuing state. As we were removed from the stage, even if we're at the same
997 // position, we should still not be signalled.
1000 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1001 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1002 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Re add to the stage, we should not be signalled
1010 application.GetScene().Add(actor);
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 ),
1018 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1019 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1021 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1022 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1023 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1026 // Here we delete an actor in started, we should not receive any subsequent signalling.
1029 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1030 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1031 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1034 // Render and notify
1035 application.SendNotification();
1036 application.Render();
1038 // Delete actor as well
1041 // Render and notify
1042 application.SendNotification();
1043 application.Render();
1045 // Continue signal emission
1046 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1047 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1048 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1050 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1051 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1052 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1056 int UtcDaliRotationGestureLayerConsumesTouch(void)
1058 TestApplication application;
1060 Actor actor = Actor::New();
1061 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1062 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1063 application.GetScene().Add(actor);
1067 GestureReceivedFunctor functor(data);
1068 RotationGestureDetector detector = RotationGestureDetector::New();
1069 detector.Attach(actor);
1070 detector.DetectedSignal().Connect( &application, functor );
1072 // Add a layer to overlap the actor
1073 Layer layer = Layer::New();
1074 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1075 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1076 application.GetScene().Add( layer );
1079 // Render and notify
1080 application.SendNotification();
1081 application.Render();
1083 // Emit signals, should receive
1084 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1085 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1086 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1087 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1088 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1091 // Set layer to consume all touch
1092 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1094 // Render and notify
1095 application.SendNotification();
1096 application.Render();
1098 // Emit the same signals again, should not receive
1099 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1100 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1101 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1102 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1103 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1109 int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void)
1111 TestApplication application;
1113 Actor actor = Actor::New();
1114 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1115 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1116 application.GetScene().Add(actor);
1118 bool consume = false;
1119 TouchDataFunctorConsumeSetter touchFunctor(consume);
1120 actor.TouchSignal().Connect(&application,touchFunctor);
1122 // Render and notify
1123 application.SendNotification();
1124 application.Render();
1127 GestureReceivedFunctor functor(data);
1129 RotationGestureDetector detector = RotationGestureDetector::New();
1130 detector.Attach(actor);
1131 detector.DetectedSignal().Connect(&application, functor);
1133 // Start gesture within the actor's area, we should receive the pinch as the touch is NOT being consumed
1134 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1135 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1137 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1138 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
1141 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1144 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1145 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1146 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1147 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
1150 // Start another pinch, we should not even get the callback this time
1151 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1152 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1153 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);