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),
54 functorCalled = false;
55 voidFunctorCalled = false;
57 receivedGesture.Reset();
63 bool voidFunctorCalled;
64 RotationGesture receivedGesture;
68 // Functor that sets the data when called
69 struct GestureReceivedFunctor
71 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
73 void operator()(Actor actor, const RotationGesture& rotation)
75 signalData.functorCalled = true;
76 signalData.receivedGesture = rotation;
77 signalData.rotatedActor = actor;
82 signalData.voidFunctorCalled = true;
85 SignalData& signalData;
88 // Functor that removes the gestured actor from stage
89 struct UnstageActorFunctor : public GestureReceivedFunctor
91 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage, Integration::Scene scene )
92 : GestureReceivedFunctor( data ),
93 stateToUnstage( stateToUnstage ),
98 void operator()( Actor actor, const RotationGesture& rotation )
100 GestureReceivedFunctor::operator()( actor, rotation );
102 if ( rotation.GetState() == stateToUnstage )
104 scene.Remove( actor );
108 Gesture::State& stateToUnstage;
109 Integration::Scene scene;
114 ///////////////////////////////////////////////////////////////////////////////
116 int UtcDaliRotationGestureDetectorConstructor(void)
118 TestApplication application;
120 RotationGestureDetector detector;
121 DALI_TEST_CHECK(!detector);
125 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
127 TestApplication application;
129 RotationGestureDetector detector = RotationGestureDetector::New();;
131 RotationGestureDetector copy( detector );
132 DALI_TEST_CHECK( detector );
136 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
138 TestApplication application;
140 RotationGestureDetector detector = RotationGestureDetector::New();;
142 RotationGestureDetector assign;
144 DALI_TEST_CHECK( detector );
146 DALI_TEST_CHECK( detector == assign );
150 int UtcDaliRotationGestureDetectorNew(void)
152 TestApplication application;
154 RotationGestureDetector detector = RotationGestureDetector::New();
156 DALI_TEST_CHECK(detector);
158 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
159 Actor actor = Actor::New();
160 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
161 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
162 application.GetScene().Add(actor);
165 application.SendNotification();
166 application.Render();
168 detector.Attach(actor);
170 Integration::TouchEvent touchEvent(1);
171 Integration::Point point;
172 point.SetDeviceId( 1 );
173 point.SetState( PointState::DOWN );
174 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
175 touchEvent.AddPoint(point);
176 application.ProcessEvent(touchEvent);
178 Integration::Point point2;
179 point.SetDeviceId( 1 );
180 point.SetState( PointState::DOWN );
181 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
182 touchEvent.AddPoint(point2);
183 application.ProcessEvent(touchEvent);
187 int UtcDaliRotationGestureDetectorDownCast(void)
189 TestApplication application;
190 tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
192 RotationGestureDetector detector = RotationGestureDetector::New();
194 BaseHandle object(detector);
196 RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
197 DALI_TEST_CHECK(detector2);
199 RotationGestureDetector detector3 = DownCast< RotationGestureDetector >(object);
200 DALI_TEST_CHECK(detector3);
202 BaseHandle unInitializedObject;
203 RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
204 DALI_TEST_CHECK(!detector4);
206 RotationGestureDetector detector5 = DownCast< RotationGestureDetector >(unInitializedObject);
207 DALI_TEST_CHECK(!detector5);
209 GestureDetector detector6 = RotationGestureDetector::New();
210 RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
211 DALI_TEST_CHECK(detector7);
215 // Negative test case for a method
216 int UtcDaliRotationGestureSignalReceptionNegative(void)
218 TestApplication application;
220 Actor actor = Actor::New();
221 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
222 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
223 application.GetScene().Add(actor);
226 application.SendNotification();
227 application.Render();
230 GestureReceivedFunctor functor(data);
232 RotationGestureDetector detector = RotationGestureDetector::New();
233 detector.Attach(actor);
234 detector.DetectedSignal().Connect(&application, functor);
236 // Do a rotation outside actor's area
237 TestStartRotation( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
238 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
240 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
242 // Continue rotation into actor's area - we should still not receive the signal
244 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
245 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
247 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
249 // Stop rotating - we should still not receive the signal
251 TestEndRotation( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
252 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
254 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
258 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void)
260 TestApplication application;
262 Actor actor = Actor::New();
263 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
264 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
265 application.GetScene().Add(actor);
268 application.SendNotification();
269 application.Render();
272 GestureReceivedFunctor functor(data);
274 RotationGestureDetector detector = RotationGestureDetector::New();
275 detector.Attach(actor);
276 detector.DetectedSignal().Connect(&application, functor);
278 // Start pan within the actor's area
279 TestStartRotation( application, Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ),
280 Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 );
281 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
282 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
283 DALI_TEST_EQUALS(0.244f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
284 DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
285 DALI_TEST_EQUALS(Vector2(12.48f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
287 // Continue the pan within the actor's area - we should still receive the signal
289 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
290 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
291 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
292 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
293 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
294 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
295 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
297 // Pan Gesture leaves actor's area - we should still receive the signal
299 TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
300 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
301 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
302 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
303 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
304 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
305 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 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.GetState(), TEST_LOCATION);
313 DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
314 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
315 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
319 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
321 TestApplication application;
323 Actor actor = Actor::New();
324 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
325 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
326 application.GetScene().Add(actor);
329 application.SendNotification();
330 application.Render();
333 GestureReceivedFunctor functor(data);
335 RotationGestureDetector detector = RotationGestureDetector::New();
336 detector.Attach(actor);
337 detector.DetectedSignal().Connect(&application, functor);
339 // Start rotation within the actor's area
340 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
341 Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 );
342 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
343 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
344 DALI_TEST_EQUALS(0.404892f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
345 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
346 DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
348 // Continue the rotation within the actor's area - we should still receive the signal
350 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
351 Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 );
352 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
353 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
354 DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
355 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
356 DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 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.GetState(), TEST_LOCATION);
364 DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
365 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
366 DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
370 int UtcDaliRotationGestureSignalReceptionDetach(void)
372 TestApplication application;
374 Actor actor = Actor::New();
375 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
376 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
377 application.GetScene().Add(actor);
380 application.SendNotification();
381 application.Render();
384 GestureReceivedFunctor functor(data);
386 RotationGestureDetector detector = RotationGestureDetector::New();
387 detector.Attach(actor);
388 detector.DetectedSignal().Connect(&application, functor);
390 // Start rotation within the actor's area
391 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
392 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
393 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
394 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
397 // Continue the rotation within the actor's area - we should still receive the signal
399 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
400 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
401 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
402 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
404 // Gesture ends within actor's area
406 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
407 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
408 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
409 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.GetState(), TEST_LOCATION);
412 detector.DetachAll();
414 // Ensure we are no longer signalled
416 TestGenerateRotation( application );
417 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
421 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void)
423 TestApplication application;
425 Actor actor = Actor::New();
426 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
427 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
428 application.GetScene().Add(actor);
431 application.SendNotification();
432 application.Render();
435 GestureReceivedFunctor functor(data);
437 RotationGestureDetector detector = RotationGestureDetector::New();
438 detector.Attach(actor);
439 detector.DetectedSignal().Connect(&application, functor);
441 // Start rotation within the actor's area
442 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
443 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
444 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
445 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
447 // Continue the rotation within the actor's area - we should still receive the signal
449 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
450 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
451 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
452 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
454 // Detach actor during the rotation, we should not receive the next event
455 detector.DetachAll();
457 // Gesture ends within actor's area
459 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
460 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
461 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
465 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
467 TestApplication application;
470 GestureReceivedFunctor functor(data);
472 RotationGestureDetector detector = RotationGestureDetector::New();
473 detector.DetectedSignal().Connect(&application, functor);
475 // Attach a temporary actor to stop detector being removed from RotationGestureProcessor when main actor
477 Actor tempActor = Actor::New();
478 tempActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
479 tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
480 application.GetScene().Add(tempActor);
481 detector.Attach(tempActor);
483 // Actor lifetime is scoped
485 Actor actor = Actor::New();
486 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
487 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
488 application.GetScene().Add(actor);
491 application.SendNotification();
492 application.Render();
494 detector.Attach(actor);
496 // Start rotation within the actor's area
497 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
498 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
499 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
500 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
502 // Continue the rotation within the actor's area - we should still receive the signal
504 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
505 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
506 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
507 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.GetState(), TEST_LOCATION);
509 // Remove the actor from stage and reset the data
510 application.GetScene().Remove(actor);
513 application.SendNotification();
514 application.Render();
517 // Actor should now have been destroyed
519 // Gesture ends within the area where the actor used to be
521 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
522 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
523 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
527 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
529 TestApplication application;
531 Actor actor = Actor::New();
532 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
533 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
534 application.GetScene().Add(actor);
536 // Render and notify a couple of times
537 application.SendNotification();
538 application.Render();
541 GestureReceivedFunctor functor(data);
543 RotationGestureDetector detector = RotationGestureDetector::New();
544 detector.Attach(actor);
545 detector.DetectedSignal().Connect(&application, functor);
547 // Do an entire rotation, only check finished value
548 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
549 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
551 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
552 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000);
553 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
554 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
555 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
556 DALI_TEST_EQUALS(Vector2(67.5f, 27.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
558 // Rotate actor again and render and notify
559 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
560 application.SendNotification();
561 application.Render();
563 // Do an entire rotation, only check finished value
564 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
565 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
567 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
568 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 3000);
569 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
570 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
571 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
572 DALI_TEST_EQUALS(Vector2(27.0f, 32.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
574 // Rotate actor again and render and notify
575 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) );
576 application.SendNotification();
577 application.Render();
579 // Do an entire rotation, only check finished value
580 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
581 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
583 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
584 Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000);
585 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
586 DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
587 DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
588 DALI_TEST_EQUALS(Vector2(32.5f, 73.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
592 int UtcDaliRotationGestureSignalReceptionChildHit(void)
594 TestApplication application;
596 Actor parent = Actor::New();
597 parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
598 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
599 application.GetScene().Add(parent);
601 // Set child to completely cover parent.
602 // Change rotation of child to be different from parent so that we can check if our local coordinate
603 // conversion of the parent actor is correct.
604 Actor child = Actor::New();
605 child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
606 child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
607 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
608 child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
612 application.SendNotification();
613 application.Render();
616 GestureReceivedFunctor functor(data);
618 RotationGestureDetector detector = RotationGestureDetector::New();
619 detector.Attach(parent);
620 detector.DetectedSignal().Connect(&application, functor);
622 // Do an entire pan, only check finished value - hits child area but parent should still receive it
623 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
624 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
626 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
627 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000);
628 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
629 DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
630 DALI_TEST_EQUALS(0.463648f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
631 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
632 DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
634 // Attach child and generate same touch points to yield same results
635 // (Also proves that you can detach and then re-attach another actor)
636 detector.Attach(child);
637 detector.Detach(parent);
639 // Do an entire pan, only check finished value
640 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
641 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
643 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
644 Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000);
645 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
646 DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
647 DALI_TEST_EQUALS(0.982794f, data.receivedGesture.GetRotation().radian, 0.01f, TEST_LOCATION);
648 DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION);
649 DALI_TEST_EQUALS(Vector2(27.5f, 76.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION);
653 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
655 TestApplication application;
657 Actor first = Actor::New();
658 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
659 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
660 application.GetScene().Add(first);
662 Actor second = Actor::New();
663 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
664 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
665 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
666 application.GetScene().Add(second);
669 application.SendNotification();
670 application.Render();
673 GestureReceivedFunctor functor(data);
675 RotationGestureDetector detector = RotationGestureDetector::New();
676 detector.Attach(first);
677 detector.Attach(second);
678 detector.DetectedSignal().Connect(&application, functor);
680 // Start rotation within second actor's area
681 TestStartRotation( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
682 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
683 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
684 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
686 // Rotation moves into first actor's area - second actor should receive the rotation
688 TestContinueRotation( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
689 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
690 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
691 DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
693 // Detach the second actor during the rotation, we should not receive the next event
694 detector.Detach(second);
696 // Gesture ends within actor's area
698 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
699 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
700 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
704 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
706 TestApplication application;
708 Actor actor = Actor::New();
709 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
710 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
711 application.GetScene().Add(actor);
714 application.SendNotification();
715 application.Render();
718 GestureReceivedFunctor functor(data);
720 RotationGestureDetector detector = RotationGestureDetector::New();
721 detector.Attach(actor);
722 detector.DetectedSignal().Connect(&application, functor);
724 // Start rotation in actor's area
725 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
726 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
727 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
729 // Pan continues within actor's area
731 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
732 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
733 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
735 // Actor become invisible - actor should not receive the next rotation
736 actor.SetProperty( Actor::Property::VISIBLE,false);
739 application.SendNotification();
740 application.Render();
742 // Gesture ends within actor's area
744 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
745 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
746 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
750 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
752 TestApplication application;
754 Actor actor = Actor::New();
755 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
756 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
757 application.GetScene().Add(actor);
759 Actor actor2 = Actor::New();
760 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
761 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
762 application.GetScene().Add(actor2);
765 application.SendNotification();
766 application.Render();
768 // Attach actor to one detector
769 SignalData firstData;
770 GestureReceivedFunctor firstFunctor(firstData);
771 RotationGestureDetector firstDetector = RotationGestureDetector::New();
772 firstDetector.Attach(actor);
773 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
775 // Attach actor to another detector
776 SignalData secondData;
777 GestureReceivedFunctor secondFunctor(secondData);
778 RotationGestureDetector secondDetector = RotationGestureDetector::New();
779 secondDetector.Attach(actor);
780 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
782 // Add second actor to second detector, when we remove the actor, this will make sure that this
783 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
784 // functor should still not be called (which is what we're also testing).
785 secondDetector.Attach(actor2);
787 // Rotation in actor's area - both detector's functors should be called
788 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
789 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
790 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
791 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
793 // Rotation continues in actor's area - both detector's functors should be called
796 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
797 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
798 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
799 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
801 // Detach actor from firstDetector and emit rotation on actor, only secondDetector's functor should be called.
802 firstDetector.Detach(actor);
805 TestEndRotation( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
806 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
807 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
808 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
810 // New rotation on actor, only secondDetector has actor attached
813 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
814 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
815 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
816 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
818 // Detach actor from secondDetector
819 secondDetector.Detach(actor);
822 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
823 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
824 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
825 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
829 int UtcDaliRotationGestureSignalReceptionEnsureCorrectSignalling(void)
831 TestApplication application;
833 Actor actor1 = Actor::New();
834 actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
835 actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
836 application.GetScene().Add(actor1);
838 GestureReceivedFunctor functor1(data1);
839 RotationGestureDetector detector1 = RotationGestureDetector::New();
840 detector1.Attach(actor1);
841 detector1.DetectedSignal().Connect(&application, functor1);
843 Actor actor2 = Actor::New();
844 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
845 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
846 actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
847 application.GetScene().Add(actor2);
849 GestureReceivedFunctor functor2(data2);
850 RotationGestureDetector detector2 = RotationGestureDetector::New();
851 detector2.Attach(actor2);
852 detector2.DetectedSignal().Connect(&application, functor2);
855 application.SendNotification();
856 application.Render();
858 // Start pan in actor1's area, only data1 should be set
859 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
860 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
861 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
862 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
866 int UtcDaliRotationGestureActorUnstaged(void)
868 TestApplication application;
870 Actor actor = Actor::New();
871 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
872 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
873 application.GetScene().Add(actor);
876 application.SendNotification();
877 application.Render();
879 // State to remove actor in.
880 Gesture::State stateToUnstage( Gesture::Started );
882 // Attach actor to detector
884 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
885 RotationGestureDetector detector = RotationGestureDetector::New();
886 detector.Attach(actor);
887 detector.DetectedSignal().Connect( &application, functor );
890 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
891 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
892 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
894 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
895 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
896 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
900 application.SendNotification();
901 application.Render();
903 // Re-add actor to stage
904 application.GetScene().Add(actor);
907 application.SendNotification();
908 application.Render();
910 // Change state to Gesture::Continuing to remove
911 stateToUnstage = Gesture::Continuing;
914 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
915 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
916 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
918 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
919 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
920 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
922 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
923 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
924 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
928 application.SendNotification();
929 application.Render();
931 // Re-add actor to stage
932 application.GetScene().Add(actor);
935 application.SendNotification();
936 application.Render();
938 // Change state to Gesture::Continuing to remove
939 stateToUnstage = Gesture::Finished;
942 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
943 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
944 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
946 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
947 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
948 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
950 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
951 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
952 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
953 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
957 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
959 TestApplication application;
961 Actor actor = Actor::New();
962 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
963 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
964 application.GetScene().Add(actor);
966 // Create and add a second actor so that GestureDetector destruction does not come into play.
967 Actor dummyActor( Actor::New() );
968 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
969 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
970 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
971 application.GetScene().Add(dummyActor);
974 application.SendNotification();
975 application.Render();
977 // State to remove actor in.
978 Gesture::State stateToUnstage( Gesture::Started );
980 // Attach actor to detector
982 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
983 RotationGestureDetector detector = RotationGestureDetector::New();
984 detector.Attach(actor);
985 detector.Attach(dummyActor);
986 detector.DetectedSignal().Connect( &application, functor );
988 // Here we are testing a Started actor which is removed in the Started callback, but then added back
989 // before we get a continuing state. As we were removed from the stage, even if we're at the same
990 // position, we should still not be signalled.
993 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
994 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
995 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
999 application.SendNotification();
1000 application.Render();
1002 // Re add to the stage, we should not be signalled
1003 application.GetScene().Add(actor);
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Continue signal emission
1010 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1011 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1012 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1014 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1015 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1016 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1019 // Here we delete an actor in started, we should not receive any subsequent signalling.
1022 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1023 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1024 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1027 // Render and notify
1028 application.SendNotification();
1029 application.Render();
1031 // Delete actor as well
1034 // Render and notify
1035 application.SendNotification();
1036 application.Render();
1038 // Continue signal emission
1039 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1040 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1041 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1043 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1044 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1045 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1049 int UtcDaliRotationGestureLayerConsumesTouch(void)
1051 TestApplication application;
1053 Actor actor = Actor::New();
1054 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1055 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1056 application.GetScene().Add(actor);
1060 GestureReceivedFunctor functor(data);
1061 RotationGestureDetector detector = RotationGestureDetector::New();
1062 detector.Attach(actor);
1063 detector.DetectedSignal().Connect( &application, functor );
1065 // Add a layer to overlap the actor
1066 Layer layer = Layer::New();
1067 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1068 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1069 application.GetScene().Add( layer );
1072 // Render and notify
1073 application.SendNotification();
1074 application.Render();
1076 // Emit signals, should receive
1077 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1078 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1079 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1080 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1081 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1084 // Set layer to consume all touch
1085 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1087 // Render and notify
1088 application.SendNotification();
1089 application.Render();
1091 // Emit the same signals again, should not receive
1092 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1093 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1094 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1095 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1096 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1102 int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void)
1104 TestApplication application;
1106 Actor actor = Actor::New();
1107 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1108 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1109 application.GetScene().Add(actor);
1111 bool consume = false;
1112 TouchEventFunctorConsumeSetter touchFunctor(consume);
1113 actor.TouchSignal().Connect(&application,touchFunctor);
1115 // Render and notify
1116 application.SendNotification();
1117 application.Render();
1120 GestureReceivedFunctor functor(data);
1122 RotationGestureDetector detector = RotationGestureDetector::New();
1123 detector.Attach(actor);
1124 detector.DetectedSignal().Connect(&application, functor);
1126 // Start gesture within the actor's area, we should receive the rotation as the touch is NOT being consumed
1127 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1128 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1130 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1131 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.GetState(), TEST_LOCATION);
1134 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1137 TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1138 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1139 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1140 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.GetState(), TEST_LOCATION);
1143 // Start another rotation, we should not even get the callback this time
1144 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1145 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1146 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1151 int UtcDaliRotationGestureDisableDetectionDuringRotationN(void)
1153 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1155 TestApplication application;
1157 Actor actor = Actor::New();
1158 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1159 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1160 application.GetScene().Add(actor);
1163 RotationGestureDetector detector = RotationGestureDetector::New();
1164 bool functorCalled = false;
1165 detector.Attach( actor );
1166 detector.DetectedSignal().Connect(
1168 [&detector, &functorCalled](Actor actor, const RotationGesture& gesture)
1170 if( gesture.GetState() == Gesture::Finished )
1172 detector.Detach(actor);
1173 functorCalled = true;
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Try the gesture, should not crash
1184 TestStartRotation( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1185 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1186 TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1187 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1188 TestEndRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1189 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1191 DALI_TEST_CHECK( true ); // No crash, test has passed
1192 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1196 DALI_TEST_CHECK( false ); // If we crash, the test has failed