[dali_1.9.13] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RotationGestureDetector.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
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
30 using namespace Dali;
31
32 void utc_dali_rotation_gesture_detector_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_rotation_gesture_detector_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 ///////////////////////////////////////////////////////////////////////////////
43 namespace
44 {
45
46 // Stores data that is populated in the callback and will be read by the TET cases
47 struct SignalData
48 {
49   SignalData()
50   : functorCalled(false),
51     voidFunctorCalled(false),
52     receivedGesture(Gesture::Started)
53   {}
54
55   void Reset()
56   {
57     functorCalled = false;
58     voidFunctorCalled = false;
59
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);
64
65     rotatedActor.Reset();
66   }
67
68   bool functorCalled;
69   bool voidFunctorCalled;
70   RotationGesture receivedGesture;
71   Actor rotatedActor;
72 };
73
74 // Functor that sets the data when called
75 struct GestureReceivedFunctor
76 {
77   GestureReceivedFunctor(SignalData& data) : signalData(data) { }
78
79   void operator()(Actor actor, const RotationGesture& rotation)
80   {
81     signalData.functorCalled = true;
82     signalData.receivedGesture = rotation;
83     signalData.rotatedActor = actor;
84   }
85
86   void operator()()
87   {
88     signalData.voidFunctorCalled = true;
89   }
90
91   SignalData& signalData;
92 };
93
94 // Functor that removes the gestured actor from stage
95 struct UnstageActorFunctor : public GestureReceivedFunctor
96 {
97   UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
98   : GestureReceivedFunctor( data ),
99     stateToUnstage( stateToUnstage )
100   {
101   }
102
103   void operator()( Actor actor, const RotationGesture& rotation )
104   {
105     GestureReceivedFunctor::operator()( actor, rotation );
106
107     if ( rotation.state == stateToUnstage )
108     {
109       Stage::GetCurrent().Remove( actor );
110     }
111   }
112
113   Gesture::State& stateToUnstage;
114 };
115
116 // Functor for receiving a touch event
117 struct TouchEventFunctor
118 {
119   bool operator()(Actor actor, const TouchEvent& touch)
120   {
121     return false;
122   }
123 };
124
125 } // anon namespace
126
127 ///////////////////////////////////////////////////////////////////////////////
128
129 int UtcDaliRotationGestureDetectorConstructor(void)
130 {
131   TestApplication application;
132
133   RotationGestureDetector detector;
134   DALI_TEST_CHECK(!detector);
135   END_TEST;
136 }
137
138 int UtcDaliRotationGestureDetectorCopyConstructorP(void)
139 {
140   TestApplication application;
141
142   RotationGestureDetector detector = RotationGestureDetector::New();;
143
144   RotationGestureDetector copy( detector );
145   DALI_TEST_CHECK( detector );
146   END_TEST;
147 }
148
149 int UtcDaliRotationGestureDetectorAssignmentOperatorP(void)
150 {
151   TestApplication application;
152
153   RotationGestureDetector detector = RotationGestureDetector::New();;
154
155   RotationGestureDetector assign;
156   assign = detector;
157   DALI_TEST_CHECK( detector );
158
159   DALI_TEST_CHECK( detector == assign );
160   END_TEST;
161 }
162
163 int UtcDaliRotationGestureDetectorNew(void)
164 {
165   TestApplication application;
166
167   RotationGestureDetector detector = RotationGestureDetector::New();
168
169   DALI_TEST_CHECK(detector);
170
171   // Attach an actor and emit a touch event on the actor to ensure complete line coverage
172   Actor actor = Actor::New();
173   actor.SetSize(100.0f, 100.0f);
174   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
175   Stage::GetCurrent().Add(actor);
176
177   // Render and notify
178   application.SendNotification();
179   application.Render();
180
181   detector.Attach(actor);
182
183   Integration::TouchEvent touchEvent(1);
184   Integration::Point point;
185   point.SetDeviceId( 1 );
186   point.SetState( PointState::DOWN );
187   point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
188   touchEvent.AddPoint(point);
189   application.ProcessEvent(touchEvent);
190
191   Integration::Point point2;
192   point.SetDeviceId( 1 );
193   point.SetState( PointState::DOWN );
194   point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
195   touchEvent.AddPoint(point2);
196   application.ProcessEvent(touchEvent);
197   END_TEST;
198 }
199
200 int UtcDaliRotationGestureDetectorDownCast(void)
201 {
202   TestApplication application;
203   tet_infoline("Testing Dali::RotationGestureDetector::DownCast()");
204
205   RotationGestureDetector detector = RotationGestureDetector::New();
206
207   BaseHandle object(detector);
208
209   RotationGestureDetector detector2 = RotationGestureDetector::DownCast(object);
210   DALI_TEST_CHECK(detector2);
211
212   RotationGestureDetector detector3 = DownCast< RotationGestureDetector >(object);
213   DALI_TEST_CHECK(detector3);
214
215   BaseHandle unInitializedObject;
216   RotationGestureDetector detector4 = RotationGestureDetector::DownCast(unInitializedObject);
217   DALI_TEST_CHECK(!detector4);
218
219   RotationGestureDetector detector5 = DownCast< RotationGestureDetector >(unInitializedObject);
220   DALI_TEST_CHECK(!detector5);
221
222   GestureDetector detector6 = RotationGestureDetector::New();
223   RotationGestureDetector detector7 = RotationGestureDetector::DownCast(detector6);
224   DALI_TEST_CHECK(detector7);
225   END_TEST;
226 }
227
228 // Negative test case for a method
229 int UtcDaliRotationGestureSignalReceptionNegative(void)
230 {
231   TestApplication application;
232
233   Actor actor = Actor::New();
234   actor.SetSize(100.0f, 100.0f);
235   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
236   Stage::GetCurrent().Add(actor);
237
238   // Render and notify
239   application.SendNotification();
240   application.Render();
241
242   SignalData data;
243   GestureReceivedFunctor functor(data);
244
245   RotationGestureDetector detector = RotationGestureDetector::New();
246   detector.Attach(actor);
247   detector.DetectedSignal().Connect(&application, functor);
248
249   // Do a rotation outside actor's area
250   TestStartRotation( application,  Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
251                                    Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
252
253   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
254
255   // Continue rotation into actor's area - we should still not receive the signal
256   data.Reset();
257   TestContinueRotation( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
258                                      Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
259
260   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
261
262   // Stop rotating - we should still not receive the signal
263   data.Reset();
264   TestEndRotation( application,  Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
265                                  Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
266
267   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
268   END_TEST;
269 }
270
271 int UtcDaliRotationGestureSignalReceptionDownMotionLeave(void)
272 {
273   TestApplication application;
274
275   Actor actor = Actor::New();
276   actor.SetSize(100.0f, 100.0f);
277   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
278   Stage::GetCurrent().Add(actor);
279
280   // Render and notify
281   application.SendNotification();
282   application.Render();
283
284   SignalData data;
285   GestureReceivedFunctor functor(data);
286
287   RotationGestureDetector detector = RotationGestureDetector::New();
288   detector.Attach(actor);
289   detector.DetectedSignal().Connect(&application, functor);
290
291   // Start pan within the actor's area
292   TestStartRotation( application,  Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 20.0f ),
293                                    Vector2( 5.0f, 5.0f ), Vector2( 20.0f, 30.0f ), 100 );
294   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
295   DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
296   DALI_TEST_EQUALS(0.244f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
297   DALI_TEST_EQUALS(Vector2(12.5f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
298
299   // Continue the pan within the actor's area - we should still receive the signal
300   data.Reset();
301   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
302                                      Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
303   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
304   DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
305   DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
306   DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
307
308   // Pan Gesture leaves actor's area - we should still receive the signal
309   data.Reset();
310   TestContinueRotation( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
311                                      Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
312   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
313   DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
314   DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
315   DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
316
317   // Gesture ends - we would receive a finished state
318   data.Reset();
319   TestEndRotation( application,  Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
320                                  Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
321   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
322   DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
323   DALI_TEST_EQUALS(-0.785398f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
324   DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
325   END_TEST;
326 }
327
328 int UtcDaliRotationGestureSignalReceptionDownMotionUp(void)
329 {
330   TestApplication application;
331
332   Actor actor = Actor::New();
333   actor.SetSize(100.0f, 100.0f);
334   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
335   Stage::GetCurrent().Add(actor);
336
337   // Render and notify
338   application.SendNotification();
339   application.Render();
340
341   SignalData data;
342   GestureReceivedFunctor functor(data);
343
344   RotationGestureDetector detector = RotationGestureDetector::New();
345   detector.Attach(actor);
346   detector.DetectedSignal().Connect(&application, functor);
347
348   // Start rotation within the actor's area
349   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
350                                    Vector2( 10.0f, 20.0f ), Vector2( 31.0f, 29.0f ), 100 );
351   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
352   DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
353   DALI_TEST_EQUALS(0.404892f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
354   DALI_TEST_EQUALS(Vector2(20.5f, 24.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
355
356   // Continue the rotation within the actor's area - we should still receive the signal
357   data.Reset();
358   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
359                                      Vector2( 15.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 500 );
360   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
361   DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
362   DALI_TEST_EQUALS(-0.343024f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
363   DALI_TEST_EQUALS(Vector2(22.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
364
365   // Gesture ends within actor's area - we would receive a finished state
366   data.Reset();
367   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
368                                  Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 15.0f ), 1000);
369   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
370   DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
371   DALI_TEST_EQUALS(-0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
372   DALI_TEST_EQUALS(Vector2(24.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
373   END_TEST;
374 }
375
376 int UtcDaliRotationGestureSignalReceptionDetach(void)
377 {
378   TestApplication application;
379
380   Actor actor = Actor::New();
381   actor.SetSize(100.0f, 100.0f);
382   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
383   Stage::GetCurrent().Add(actor);
384
385   // Render and notify
386   application.SendNotification();
387   application.Render();
388
389   SignalData data;
390   GestureReceivedFunctor functor(data);
391
392   RotationGestureDetector detector = RotationGestureDetector::New();
393   detector.Attach(actor);
394   detector.DetectedSignal().Connect(&application, functor);
395
396   // Start rotation within the actor's area
397   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
398                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
399   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
400   DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
401
402
403   // Continue the rotation within the actor's area - we should still receive the signal
404   data.Reset();
405   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
406                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
407   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
408   DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
409
410   // Gesture ends within actor's area
411   data.Reset();
412   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
413                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
414   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
415   DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
416
417   // Detach actor
418   detector.DetachAll();
419
420   // Ensure we are no longer signalled
421   data.Reset();
422   TestGenerateRotation(  application );
423   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
424   END_TEST;
425 }
426
427 int UtcDaliRotationGestureSignalReceptionDetachWhileRotationing(void)
428 {
429   TestApplication application;
430
431   Actor actor = Actor::New();
432   actor.SetSize(100.0f, 100.0f);
433   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
434   Stage::GetCurrent().Add(actor);
435
436   // Render and notify
437   application.SendNotification();
438   application.Render();
439
440   SignalData data;
441   GestureReceivedFunctor functor(data);
442
443   RotationGestureDetector detector = RotationGestureDetector::New();
444   detector.Attach(actor);
445   detector.DetectedSignal().Connect(&application, functor);
446
447   // Start rotation within the actor's area
448   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
449                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
450   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
451   DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
452
453   // Continue the rotation within the actor's area - we should still receive the signal
454   data.Reset();
455   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
456                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
457   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
458   DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
459
460   // Detach actor during the rotation, we should not receive the next event
461   detector.DetachAll();
462
463   // Gesture ends within actor's area
464   data.Reset();
465   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
466                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
467   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
468   END_TEST;
469 }
470
471 int UtcDaliRotationGestureSignalReceptionActorDestroyedWhileRotationing(void)
472 {
473   TestApplication application;
474
475   SignalData data;
476   GestureReceivedFunctor functor(data);
477
478   RotationGestureDetector detector = RotationGestureDetector::New();
479   detector.DetectedSignal().Connect(&application, functor);
480
481   // Attach a temporary actor to stop detector being removed from RotationGestureProcessor when main actor
482   // is destroyed.
483   Actor tempActor = Actor::New();
484   tempActor.SetSize(100.0f, 100.0f);
485   tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
486   Stage::GetCurrent().Add(tempActor);
487   detector.Attach(tempActor);
488
489   // Actor lifetime is scoped
490   {
491     Actor actor = Actor::New();
492     actor.SetSize(100.0f, 100.0f);
493     actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
494     Stage::GetCurrent().Add(actor);
495
496     // Render and notify
497     application.SendNotification();
498     application.Render();
499
500     detector.Attach(actor);
501
502     // Start rotation within the actor's area
503     TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
504                                      Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
505     DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
506     DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
507
508     // Continue the rotation within the actor's area - we should still receive the signal
509     data.Reset();
510     TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
511                                        Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
512     DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
513     DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
514
515     // Remove the actor from stage and reset the data
516     Stage::GetCurrent().Remove(actor);
517
518     // Render and notify
519     application.SendNotification();
520     application.Render();
521   }
522
523   // Actor should now have been destroyed
524
525   // Gesture ends within the area where the actor used to be
526   data.Reset();
527   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
528                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
529   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
530   END_TEST;
531 }
532
533 int UtcDaliRotationGestureSignalReceptionRotatedActor(void)
534 {
535   TestApplication application;
536
537   Actor actor = Actor::New();
538   actor.SetSize(100.0f, 100.0f);
539   actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
540   Stage::GetCurrent().Add(actor);
541
542   // Render and notify a couple of times
543   application.SendNotification();
544   application.Render();
545
546   SignalData data;
547   GestureReceivedFunctor functor(data);
548
549   RotationGestureDetector detector = RotationGestureDetector::New();
550   detector.Attach(actor);
551   detector.DetectedSignal().Connect(&application, functor);
552
553   // Do an entire rotation, only check finished value
554   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
555                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
556   data.Reset();
557   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
558                                  Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 1000);
559   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
560   DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
561   DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
562
563   // Rotate actor again and render and notify
564   actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
565   application.SendNotification();
566   application.Render();
567
568   // Do an entire rotation, only check finished value
569   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
570                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
571   data.Reset();
572   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
573                                  Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 3000);
574   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
575   DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
576   DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
577
578   // Rotate actor again and render and notify
579   actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS);
580   application.SendNotification();
581   application.Render();
582
583   // Do an entire rotation, only check finished value
584   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
585                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
586   data.Reset();
587   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
588                                  Vector2( 19.0f, 20.0f ), Vector2( 27.0f, 15.0f ), 5000);
589   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
590   DALI_TEST_EQUALS(-0.558599f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
591   DALI_TEST_EQUALS(Vector2(23.0f, 17.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
592   END_TEST;
593 }
594
595 int UtcDaliRotationGestureSignalReceptionChildHit(void)
596 {
597   TestApplication application;
598
599   Actor parent = Actor::New();
600   parent.SetSize(100.0f, 100.0f);
601   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
602   Stage::GetCurrent().Add(parent);
603
604   // Set child to completely cover parent.
605   // Change rotation of child to be different from parent so that we can check if our local coordinate
606   // conversion of the parent actor is correct.
607   Actor child = Actor::New();
608   child.SetSize(100.0f, 100.0f);
609   child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
610   child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
611   child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
612   parent.Add(child);
613
614   TouchEventFunctor touchFunctor;
615   child.TouchedSignal().Connect(&application, touchFunctor);
616
617   // Render and notify
618   application.SendNotification();
619   application.Render();
620
621   SignalData data;
622   GestureReceivedFunctor functor(data);
623
624   RotationGestureDetector detector = RotationGestureDetector::New();
625   detector.Attach(parent);
626   detector.DetectedSignal().Connect(&application, functor);
627
628   // Do an entire pan, only check finished value - hits child area but parent should still receive it
629   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
630                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
631   data.Reset();
632   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
633                                  Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 25.0f ), 1000);
634   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
635   DALI_TEST_EQUALS(true, parent == data.rotatedActor, TEST_LOCATION);
636   DALI_TEST_EQUALS(0.463648f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
637   DALI_TEST_EQUALS(Vector2(24.0f, 22.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
638
639   // Attach child and generate same touch points to yield same results
640   // (Also proves that you can detach and then re-attach another actor)
641   detector.Attach(child);
642   detector.Detach(parent);
643
644   // Do an entire pan, only check finished value
645   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
646                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
647   data.Reset();
648   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
649                                  Vector2( 19.0f, 20.0f ), Vector2( 29.0f, 35.0f ), 3000);
650   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
651   DALI_TEST_EQUALS(true, child == data.rotatedActor, TEST_LOCATION);
652   DALI_TEST_EQUALS(0.982794f, data.receivedGesture.rotation.radian, 0.01f, TEST_LOCATION);
653   DALI_TEST_EQUALS(Vector2(24.0f, 27.5f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
654   END_TEST;
655 }
656
657 int UtcDaliRotationGestureSignalReceptionAttachDetachMany(void)
658 {
659   TestApplication application;
660
661   Actor first = Actor::New();
662   first.SetSize(100.0f, 100.0f);
663   first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
664   Stage::GetCurrent().Add(first);
665
666   Actor second = Actor::New();
667   second.SetSize(100.0f, 100.0f);
668   second.SetX(100.0f);
669   second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
670   Stage::GetCurrent().Add(second);
671
672   // Render and notify
673   application.SendNotification();
674   application.Render();
675
676   SignalData data;
677   GestureReceivedFunctor functor(data);
678
679   RotationGestureDetector detector = RotationGestureDetector::New();
680   detector.Attach(first);
681   detector.Attach(second);
682   detector.DetectedSignal().Connect(&application, functor);
683
684   // Start rotation within second actor's area
685   TestStartRotation( application,  Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
686                                    Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
687   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
688   DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
689
690   // Rotation moves into first actor's area - second actor should receive the rotation
691   data.Reset();
692   TestContinueRotation( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
693                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
694   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
695   DALI_TEST_EQUALS(true, second == data.rotatedActor, TEST_LOCATION);
696
697   // Detach the second actor during the rotation, we should not receive the next event
698   detector.Detach(second);
699
700   // Gesture ends within actor's area
701   data.Reset();
702   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
703                                  Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
704   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
705   END_TEST;
706 }
707
708 int UtcDaliRotationGestureSignalReceptionActorBecomesUntouchable(void)
709 {
710   TestApplication application;
711
712   Actor actor = Actor::New();
713   actor.SetSize(100.0f, 100.0f);
714   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
715   Stage::GetCurrent().Add(actor);
716
717   // Render and notify
718   application.SendNotification();
719   application.Render();
720
721   SignalData data;
722   GestureReceivedFunctor functor(data);
723
724   RotationGestureDetector detector = RotationGestureDetector::New();
725   detector.Attach(actor);
726   detector.DetectedSignal().Connect(&application, functor);
727
728   // Start rotation in actor's area
729   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
730                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
731   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
732
733   // Pan continues within actor's area
734   data.Reset();
735   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
736                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
737   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
738
739   // Actor become invisible - actor should not receive the next rotation
740   actor.SetProperty( Actor::Property::VISIBLE,false);
741
742   // Render and notify
743   application.SendNotification();
744   application.Render();
745
746   // Gesture ends within actor's area
747   data.Reset();
748   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
749                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
750   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
751   END_TEST;
752 }
753
754 int UtcDaliRotationGestureSignalReceptionMultipleDetectorsOnActor(void)
755 {
756   TestApplication application;
757
758   Actor actor = Actor::New();
759   actor.SetSize(100.0f, 100.0f);
760   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
761   Stage::GetCurrent().Add(actor);
762
763   Actor actor2 = Actor::New();
764   actor2.SetSize(100.0f, 100.0f);
765   actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
766   Stage::GetCurrent().Add(actor2);
767
768   // Render and notify
769   application.SendNotification();
770   application.Render();
771
772   // Attach actor to one detector
773   SignalData firstData;
774   GestureReceivedFunctor firstFunctor(firstData);
775   RotationGestureDetector firstDetector = RotationGestureDetector::New();
776   firstDetector.Attach(actor);
777   firstDetector.DetectedSignal().Connect(&application, firstFunctor);
778
779   // Attach actor to another detector
780   SignalData secondData;
781   GestureReceivedFunctor secondFunctor(secondData);
782   RotationGestureDetector secondDetector = RotationGestureDetector::New();
783   secondDetector.Attach(actor);
784   secondDetector.DetectedSignal().Connect(&application, secondFunctor);
785
786   // Add second actor to second detector, when we remove the actor, this will make sure that this
787   // gesture detector is not removed from the GestureDetectorProcessor.  In this scenario, the
788   // functor should still not be called (which is what we're also testing).
789   secondDetector.Attach(actor2);
790
791   // Rotation in actor's area - both detector's functors should be called
792   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
793                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
794   DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
795   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
796
797   // Rotation continues in actor's area - both detector's functors should be called
798   firstData.Reset();
799   secondData.Reset();
800   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
801                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
802   DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
803   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
804
805   // Detach actor from firstDetector and emit rotation on actor, only secondDetector's functor should be called.
806   firstDetector.Detach(actor);
807   firstData.Reset();
808   secondData.Reset();
809   TestEndRotation( application,  Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
810                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
811   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
812   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
813
814   // New rotation on actor, only secondDetector has actor attached
815   firstData.Reset();
816   secondData.Reset();
817   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
818                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
819   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
820   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
821
822   // Detach actor from secondDetector
823   secondDetector.Detach(actor);
824   firstData.Reset();
825   secondData.Reset();
826   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
827                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
828   DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
829   DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
830   END_TEST;
831 }
832
833 int UtcDaliRotationGestureSignalReceptionEnsureCorrectSignalling(void)
834 {
835   TestApplication application;
836
837   Actor actor1 = Actor::New();
838   actor1.SetSize(100.0f, 100.0f);
839   actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
840   Stage::GetCurrent().Add(actor1);
841   SignalData data1;
842   GestureReceivedFunctor functor1(data1);
843   RotationGestureDetector detector1 = RotationGestureDetector::New();
844   detector1.Attach(actor1);
845   detector1.DetectedSignal().Connect(&application, functor1);
846
847   Actor actor2 = Actor::New();
848   actor2.SetSize(100.0f, 100.0f);
849   actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
850   actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
851   Stage::GetCurrent().Add(actor2);
852   SignalData data2;
853   GestureReceivedFunctor functor2(data2);
854   RotationGestureDetector detector2 = RotationGestureDetector::New();
855   detector2.Attach(actor2);
856   detector2.DetectedSignal().Connect(&application, functor2);
857
858   // Render and notify
859   application.SendNotification();
860   application.Render();
861
862   // Start pan in actor1's area, only data1 should be set
863   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
864                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
865   DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
866   DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
867   END_TEST;
868 }
869
870 int UtcDaliRotationGestureActorUnstaged(void)
871 {
872   TestApplication application;
873
874   Actor actor = Actor::New();
875   actor.SetSize(100.0f, 100.0f);
876   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
877   Stage::GetCurrent().Add(actor);
878
879   // Render and notify
880   application.SendNotification();
881   application.Render();
882
883   // State to remove actor in.
884   Gesture::State stateToUnstage( Gesture::Started );
885
886   // Attach actor to detector
887   SignalData data;
888   UnstageActorFunctor functor( data, stateToUnstage );
889   RotationGestureDetector detector = RotationGestureDetector::New();
890   detector.Attach(actor);
891   detector.DetectedSignal().Connect( &application, functor );
892
893   // Emit signals
894   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
895                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
896   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
897   data.Reset();
898   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
899                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
900   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
901   data.Reset();
902
903   // Render and notify
904   application.SendNotification();
905   application.Render();
906
907   // Re-add actor to stage
908   Stage::GetCurrent().Add(actor);
909
910   // Render and notify
911   application.SendNotification();
912   application.Render();
913
914   // Change state to Gesture::Continuing to remove
915   stateToUnstage = Gesture::Continuing;
916
917   // Emit signals
918   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
919                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
920   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
921   data.Reset();
922   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
923                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
924   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
925   data.Reset();
926   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
927                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
928   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
929   data.Reset();
930
931   // Render and notify
932   application.SendNotification();
933   application.Render();
934
935   // Re-add actor to stage
936   Stage::GetCurrent().Add(actor);
937
938   // Render and notify
939   application.SendNotification();
940   application.Render();
941
942   // Change state to Gesture::Continuing to remove
943   stateToUnstage = Gesture::Finished;
944
945   // Emit signals
946   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
947                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
948   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
949   data.Reset();
950   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
951                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
952   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
953   data.Reset();
954   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
955                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
956   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
957   tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
958   END_TEST;
959 }
960
961 int UtcDaliRotationGestureActorStagedAndDestroyed(void)
962 {
963   TestApplication application;
964
965   Actor actor = Actor::New();
966   actor.SetSize(100.0f, 100.0f);
967   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
968   Stage::GetCurrent().Add(actor);
969
970   // Create and add a second actor so that GestureDetector destruction does not come into play.
971   Actor dummyActor( Actor::New() );
972   dummyActor.SetSize( 100.0f, 100.0f );
973   dummyActor.SetPosition( 100.0f, 100.0f );
974   dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
975   Stage::GetCurrent().Add(dummyActor);
976
977   // Render and notify
978   application.SendNotification();
979   application.Render();
980
981   // State to remove actor in.
982   Gesture::State stateToUnstage( Gesture::Started );
983
984   // Attach actor to detector
985   SignalData data;
986   UnstageActorFunctor functor( data, stateToUnstage );
987   RotationGestureDetector detector = RotationGestureDetector::New();
988   detector.Attach(actor);
989   detector.Attach(dummyActor);
990   detector.DetectedSignal().Connect( &application, functor );
991
992   // Here we are testing a Started actor which is removed in the Started callback, but then added back
993   // before we get a continuing state.  As we were removed from the stage, even if we're at the same
994   // position, we should still not be signalled.
995
996   // Emit signals
997   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
998                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
999   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1000   data.Reset();
1001
1002   // Render and notify
1003   application.SendNotification();
1004   application.Render();
1005
1006   // Re add to the stage, we should not be signalled
1007   Stage::GetCurrent().Add(actor);
1008
1009   // Render and notify
1010   application.SendNotification();
1011   application.Render();
1012
1013   // Continue signal emission
1014   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1015                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1016   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1017   data.Reset();
1018   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1019                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1020   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1021   data.Reset();
1022
1023   // Here we delete an actor in started, we should not receive any subsequent signalling.
1024
1025   // Emit signals
1026   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1027                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1028   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1029   data.Reset();
1030
1031   // Render and notify
1032   application.SendNotification();
1033   application.Render();
1034
1035   // Delete actor as well
1036   actor.Reset();
1037
1038   // Render and notify
1039   application.SendNotification();
1040   application.Render();
1041
1042   // Continue signal emission
1043   TestContinueRotation( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1044                                      Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1045   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1046   data.Reset();
1047   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1048                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1049   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1050   END_TEST;
1051 }
1052
1053 int UtcDaliRotationGestureLayerConsumesTouch(void)
1054 {
1055   TestApplication application;
1056
1057   Actor actor = Actor::New();
1058   actor.SetSize(100.0f, 100.0f);
1059   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1060   Stage::GetCurrent().Add(actor);
1061
1062   // Add a detector
1063   SignalData data;
1064   GestureReceivedFunctor functor(data);
1065   RotationGestureDetector detector = RotationGestureDetector::New();
1066   detector.Attach(actor);
1067   detector.DetectedSignal().Connect( &application, functor );
1068
1069   // Add a layer to overlap the actor
1070   Layer layer = Layer::New();
1071   layer.SetSize(100.0f, 100.0f);
1072   layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1073   Stage::GetCurrent().Add( layer );
1074   layer.RaiseToTop();
1075
1076   // Render and notify
1077   application.SendNotification();
1078   application.Render();
1079
1080   // Emit signals, should receive
1081   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1082                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1083   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1084                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1085   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1086   data.Reset();
1087
1088   // Set layer to consume all touch
1089   layer.SetTouchConsumed( true );
1090
1091   // Render and notify
1092   application.SendNotification();
1093   application.Render();
1094
1095   // Emit the same signals again, should not receive
1096   TestStartRotation( application,  Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1097                                    Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1098   TestEndRotation( application,  Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1099                                  Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1100   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1101   data.Reset();
1102
1103   END_TEST;
1104 }
1105