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