Revert "Revert "HoverEvent class pimpling""
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TouchDataProcessing.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-test-suite-utils.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26
27 using namespace Dali;
28
29 void utc_dali_touch_data_processing_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_touch_data_processing_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 ///////////////////////////////////////////////////////////////////////////////
40
41 namespace
42 {
43 struct TestPoint
44 {
45   int32_t deviceId;
46   PointState::Type state;
47   Actor hitActor;
48   Vector2 local;
49   Vector2 screen;
50   float radius;
51   Vector2 ellipseRadius;
52   float pressure;
53   Degree angle;
54   Device::Class::Type deviceClass;
55   Device::Subclass::Type deviceSubclass;
56
57   TestPoint()
58   : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
59   {
60   }
61   static const TestPoint ZERO;
62 };
63
64 const TestPoint TestPoint::ZERO;
65
66
67 // Stores data that is populated in the callback and will be read by the TET cases
68 struct SignalData
69 {
70   SignalData()
71   : functorCalled( false ),
72     touchData(),
73     touchedActor()
74   {
75   }
76
77   struct TestTouchData
78   {
79     unsigned long time;
80     std::vector<TestPoint> points;
81
82     const TestPoint& GetPoint(size_t i)
83     {
84       if( i < points.size() )
85       {
86         return points[i];
87       }
88       return TestPoint::ZERO;
89     }
90     size_t GetPointCount()
91     {
92       return points.size();
93     }
94   };
95
96   void Reset()
97   {
98     functorCalled = false;
99
100     touchData.time = 0u;
101     touchData.points.clear();
102
103     touchedActor.Reset();
104   }
105
106   bool functorCalled;
107   TestTouchData touchData;
108   Actor touchedActor;
109 };
110
111 // Functor that sets the data when called
112 struct TouchDataFunctor
113 {
114   /**
115    * Constructor.
116    * @param[in]  data         Reference to the data to store callback information.
117    * @param[in]  returnValue  What the functor should return.
118    */
119   TouchDataFunctor( SignalData& data, bool returnValue = true )
120   : signalData( data ),
121     returnValue( returnValue )
122   {
123   }
124
125   bool operator()( Actor actor, const TouchData& touchData )
126   {
127     signalData.functorCalled = true;
128     signalData.touchedActor = actor;
129
130     signalData.touchData.time = touchData.GetTime();
131     signalData.touchData.points.clear();
132
133     for( size_t i=0; i<touchData.GetPointCount(); ++i )
134     {
135       TestPoint p;
136       p.deviceId = touchData.GetDeviceId(i);
137       p.state = touchData.GetState(i);
138       p.hitActor = touchData.GetHitActor(i);
139       p.local = touchData.GetLocalPosition(i);
140       p.screen = touchData.GetScreenPosition(i);
141       p.radius = touchData.GetRadius(i);
142       p.ellipseRadius = touchData.GetEllipseRadius(i);
143       p.pressure = touchData.GetPressure(i);
144       p.angle = touchData.GetAngle(i);
145       p.deviceClass = touchData.GetDeviceClass(i);
146       p.deviceSubclass = touchData.GetDeviceSubclass(i);
147       signalData.touchData.points.push_back(p);
148     }
149
150     return returnValue;
151   }
152
153   SignalData& signalData;
154   bool returnValue;
155 };
156
157 struct HandleData
158 {
159   bool signalReceived;
160   TouchData touchData;
161
162   HandleData()
163   : signalReceived(false)
164   {
165   }
166 };
167
168 struct TouchDataHandleFunctor
169 {
170   /**
171    * Constructor.
172    * @param[in]  data         Reference to the data to store callback information.
173    * @param[in]  returnValue  What the functor should return.
174    */
175   TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
176   : handleData(handleData),
177     returnValue( returnValue )
178   {
179   }
180
181   bool operator()( Actor actor, const TouchData& someTouchData )
182   {
183     handleData.signalReceived = true;
184     TouchData handle(someTouchData);
185     handleData.touchData = handle;
186     return returnValue;
187   }
188
189   HandleData& handleData;
190   bool returnValue;
191 };
192
193
194 // Functor that removes the actor when called.
195 struct RemoveActorFunctor : public TouchDataFunctor
196 {
197   /**
198    * Constructor.
199    * @param[in]  data         Reference to the data to store callback information.
200    * @param[in]  returnValue  What the functor should return.
201    */
202   RemoveActorFunctor( SignalData& data, bool returnValue = true )
203   : TouchDataFunctor( data, returnValue )
204   {
205   }
206
207   bool operator()( Actor actor, const TouchData& touchData )
208   {
209     Actor parent( actor.GetParent() );
210     if ( parent )
211     {
212       parent.Remove( actor );
213     }
214
215     return TouchDataFunctor::operator()( actor, touchData );
216   }
217 };
218
219 struct OutOfBoundsData
220 {
221   TestPoint point;
222   bool functorCalled;
223
224   OutOfBoundsData()
225   :functorCalled(false)
226   {
227   }
228 };
229
230 // Functor that reads out of bounds data when called
231 struct OutOfBoundsFunctor
232 {
233   /**
234    * Constructor.
235    * @param[in]  data         Reference to the data to store callback information.
236    * @param[in]  returnValue  What the functor should return.
237    */
238   OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
239   : outOfBoundsData ( data ),
240     returnValue( returnValue )
241   {
242   }
243
244   bool operator()( Actor actor, const TouchData& touchData )
245   {
246     outOfBoundsData.functorCalled = true;
247     size_t count = touchData.GetPointCount();
248
249     // Read out of bounds data
250     outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
251     outOfBoundsData.point.state = touchData.GetState(count+1);
252     outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
253     outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
254     outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
255
256     return returnValue;
257   }
258
259   OutOfBoundsData& outOfBoundsData;
260   bool returnValue;
261 };
262
263 struct TouchEventFunctor
264 {
265   /**
266    * Constructor.
267    * @param[in]  functorCalled  Reference to a boolean which is set to true if the touch event functor is called.
268    */
269   TouchEventFunctor( bool& functorCalled )
270   : functorCalled( functorCalled )
271   {
272   }
273
274   bool operator()( Actor actor, const TouchEvent& touch )
275   {
276     functorCalled = true;
277     return true;
278   }
279
280   bool& functorCalled;
281 };
282
283 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
284 {
285   Integration::TouchEvent touchEvent;
286   Integration::Point point;
287   point.SetState( state );
288   point.SetScreenPosition( screenPosition );
289   point.SetDeviceClass( Device::Class::TOUCH );
290   point.SetDeviceSubclass( Device::Subclass::NONE );
291   touchEvent.points.push_back( point );
292   return touchEvent;
293 }
294
295 } // anon namespace
296
297 ///////////////////////////////////////////////////////////////////////////////
298
299 int UtcDaliTouchDataNormalProcessing01(void)
300 {
301   TestApplication application;
302
303   Actor actor = Actor::New();
304   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
305   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
306   application.GetScene().Add(actor);
307
308   // Render and notify
309   application.SendNotification();
310   application.Render();
311
312   // Connect to actor's touched signal
313   SignalData data;
314   TouchDataFunctor functor( data );
315   actor.TouchSignal().Connect( &application, functor );
316
317   Vector2 screenCoordinates( 10.0f, 10.0f );
318   Vector2 localCoordinates;
319   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
320
321   // Emit a down signal
322   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
323   const TestPoint *point1 = &data.touchData.GetPoint(0);
324   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
325   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
326   DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
327   DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
328   DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
329   data.Reset();
330
331   // Emit a motion signal
332   screenCoordinates.x = screenCoordinates.y = 11.0f;
333   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
334   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
335   const TestPoint *point2 = &data.touchData.GetPoint(0);
336   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
337   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
338   DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
339   DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
340   DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
341   data.Reset();
342
343   // Emit an up signal
344   screenCoordinates.x = screenCoordinates.y = 12.0f;
345   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
346   application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
347   const TestPoint *point3 = &data.touchData.GetPoint(0);
348   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
349   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
350   DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
351   DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
352   DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
353   data.Reset();
354
355   // Emit a down signal where the actor is not present
356   screenCoordinates.x = screenCoordinates.y = 200.0f;
357   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
358   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
359   END_TEST;
360 }
361
362
363 int UtcDaliTouchDataNormalProcessing02(void)
364 {
365   TestApplication application;
366
367   Actor actor = Actor::New();
368   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
369   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
370   application.GetScene().Add(actor);
371
372   // Render and notify
373   application.SendNotification();
374   application.Render();
375
376   // Connect to actor's touched signal
377   HandleData handleData;
378   TouchDataHandleFunctor functor( handleData );
379   actor.TouchSignal().Connect( &application, functor );
380
381   Vector2 screenCoordinates( 10.0f, 10.0f );
382   Vector2 localCoordinates;
383   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
384
385   // Emit a down signal
386   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
387   DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
388   DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
389   DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
390   DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
391   DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
392
393   END_TEST;
394 }
395
396
397 int UtcDaliTouchDataAPINegative(void)
398 {
399   TestApplication application;
400
401   Actor actor = Actor::New();
402   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
403   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
404   application.GetScene().Add(actor);
405
406   // Render and notify
407   application.SendNotification();
408   application.Render();
409
410   // Connect to actor's touched signal
411   OutOfBoundsData data;
412   OutOfBoundsFunctor functor( data, true );
413   actor.TouchSignal().Connect( &application, functor );
414
415   Vector2 screenCoordinates( 10.0f, 10.0f );
416   Vector2 localCoordinates;
417   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
418
419   // Emit a down signal
420   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
421
422   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
423   DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
424   DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
425   DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
426   DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
427   DALI_TEST_CHECK( ! data.point.hitActor );
428
429   END_TEST;
430 }
431
432
433 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
434 {
435   TestApplication application;
436
437   Integration::Scene scene = application.GetScene();
438   Vector2 sceneSize = scene.GetSize();
439
440   Actor actor = Actor::New();
441   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
442   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
443   actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
444   scene.Add(actor);
445
446   // Render and notify
447   application.SendNotification();
448   application.Render();
449
450   // Get the camera's near and far planes
451   RenderTaskList taskList = scene.GetRenderTaskList();
452   Dali::RenderTask task = taskList.GetTask(0);
453   CameraActor camera = task.GetCameraActor();
454   float nearPlane = camera.GetNearClippingPlane();
455   float farPlane = camera.GetFarClippingPlane();
456
457   // Calculate the current distance of the actor from the camera
458   float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
459   float distance = (sceneSize.y * 0.5f) / tanHalfFov;
460
461   // Connect to actor's touched signal
462   SignalData data;
463   TouchDataFunctor functor( data );
464   actor.TouchSignal().Connect( &application, functor );
465
466   Vector2 screenCoordinates( sceneSize.x * 0.5f, sceneSize.y * 0.5f );
467
468   // Emit a down signal
469   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
470   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
471   data.Reset();
472
473   // Emit a down signal where actor is just at the camera's near plane
474   actor.SetProperty( Actor::Property::POSITION_Z, distance - nearPlane);
475
476   // Render and notify
477   application.SendNotification();
478   application.Render();
479
480   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
481   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
482   data.Reset();
483
484   // Emit a down signal where actor is closer than the camera's near plane
485   actor.SetProperty( Actor::Property::POSITION_Z, (distance - nearPlane) + 1.0f);
486
487   // Render and notify
488   application.SendNotification();
489   application.Render();
490
491   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
492   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
493   data.Reset();
494
495   // Emit a down signal where actor is just at the camera's far plane
496   actor.SetProperty( Actor::Property::POSITION_Z, distance - farPlane);
497
498   // Render and notify
499   application.SendNotification();
500   application.Render();
501
502   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
503   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
504   data.Reset();
505
506   // Emit a down signal where actor is further than the camera's far plane
507   actor.SetProperty( Actor::Property::POSITION_Z, (distance - farPlane) - 1.0f);
508
509   // Render and notify
510   application.SendNotification();
511   application.Render();
512
513   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
514   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
515   data.Reset();
516   END_TEST;
517 }
518
519 int UtcDaliTouchDataEmitEmpty(void)
520 {
521   TestApplication application;
522
523   try
524   {
525     // Emit an empty TouchEvent
526     Integration::TouchEvent event;
527     application.ProcessEvent( event );
528     tet_result( TET_FAIL );
529   }
530   catch ( Dali::DaliException& e )
531   {
532     DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
533   }
534   END_TEST;
535 }
536
537 int UtcDaliTouchDataInterrupted(void)
538 {
539   TestApplication application;
540
541   Actor actor = Actor::New();
542   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
543   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
544   application.GetScene().Add(actor);
545
546   // Render and notify
547   application.SendNotification();
548   application.Render();
549
550   // Connect to actor's touched signal
551   SignalData data;
552   TouchDataFunctor functor( data );
553   actor.TouchSignal().Connect( &application, functor );
554
555   // Emit a down signal
556   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
557   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
558   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
559   data.Reset();
560
561   // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
562   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
563   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
564   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
565   data.Reset();
566
567   // Emit another interrupted signal, our signal handler should not be called.
568   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
569   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
570   END_TEST;
571 }
572
573 int UtcDaliTouchDataParentConsumer(void)
574 {
575   TestApplication application;
576   Actor rootActor( application.GetScene().GetRootLayer() );
577
578   Actor actor = Actor::New();
579   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
580   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
581   application.GetScene().Add(actor);
582
583   // Render and notify
584   application.SendNotification();
585   application.Render();
586
587   // Connect to actor's touched signal
588   SignalData data;
589   TouchDataFunctor functor( data, false );
590   actor.TouchSignal().Connect( &application, functor );
591
592   // Connect to root actor's touched signal
593   SignalData rootData;
594   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
595   rootActor.TouchSignal().Connect( &application, rootFunctor );
596
597   Vector2 screenCoordinates( 10.0f, 10.0f );
598   Vector2 actorCoordinates, rootCoordinates;
599   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
600   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
601
602   // Emit a down signal
603   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
604   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
605   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
606   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
607   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
608   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
609   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
610   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
611   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
612   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
613   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
614   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
615   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
616   data.Reset();
617   rootData.Reset();
618
619   // Emit a motion signal
620   screenCoordinates.x = screenCoordinates.y = 11.0f;
621   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
622   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
623   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
624   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
625   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
626   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
627   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
628   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
629   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
630   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
631   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
632   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
633   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
634   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
635   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
636   data.Reset();
637   rootData.Reset();
638
639   // Emit an up signal
640   screenCoordinates.x = screenCoordinates.y = 12.0f;
641   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
642   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
643   application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
644   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
645   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
646   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
647   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
648   DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
649   DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
650   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
651   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
652   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
653   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
654   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
655   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
656   data.Reset();
657   rootData.Reset();
658
659   // Emit a down signal where the actor is not present, will hit the root actor though
660   screenCoordinates.x = screenCoordinates.y = 200.0f;
661   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
662   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
663   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
664   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
665   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
666   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
667   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
668   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
669   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
670   END_TEST;
671 }
672
673 int UtcDaliTouchDataInterruptedParentConsumer(void)
674 {
675   TestApplication application;
676   Actor rootActor( application.GetScene().GetRootLayer() );
677
678   Actor actor = Actor::New();
679   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
680   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
681   application.GetScene().Add(actor);
682
683   // Render and notify
684   application.SendNotification();
685   application.Render();
686
687   // Connect to actor's touched signal
688   SignalData data;
689   TouchDataFunctor functor( data, false );
690   actor.TouchSignal().Connect( &application, functor );
691
692   // Connect to root actor's touched signal
693   SignalData rootData;
694   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
695   rootActor.TouchSignal().Connect( &application, rootFunctor );
696
697   // Emit a down signal
698   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
699   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
700   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
701   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
702   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
703   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
704   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
705   data.Reset();
706   rootData.Reset();
707
708   // Emit an interrupted signal
709   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
710   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
711   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
712   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
713   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
714   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
715   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
716   data.Reset();
717   rootData.Reset();
718
719   // Emit another down signal
720   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
721   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
722   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
723   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
724   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
725   data.Reset();
726   rootData.Reset();
727
728   // Remove actor from scene
729   application.GetScene().Remove( actor );
730   data.Reset();
731   rootData.Reset();
732
733   // Render and notify
734   application.SendNotification();
735   application.Render();
736
737   // Emit an interrupted signal, only root actor's signal should be called.
738   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
739   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
740   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
741   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
742   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
743   data.Reset();
744   rootData.Reset();
745
746   // Emit another interrupted state, none of the signal's should be called.
747   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
748   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
749   DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
750   END_TEST;
751 }
752
753 int UtcDaliTouchDataLeave(void)
754 {
755   TestApplication application;
756
757   Actor actor = Actor::New();
758   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
759   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
760   application.GetScene().Add(actor);
761
762   // Render and notify
763   application.SendNotification();
764   application.Render();
765
766   // Connect to actor's touched signal
767   SignalData data;
768   TouchDataFunctor functor( data );
769   actor.TouchSignal().Connect( &application, functor );
770
771   // Set actor to require leave events
772   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
773
774   // Emit a down signal
775   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
776   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
777   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
778   data.Reset();
779
780   // Emit a motion signal outside of actor, should be signalled with a Leave
781   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
782   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
783   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
784   data.Reset();
785
786   // Another motion outside of actor, no signalling
787   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
788   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
789   data.Reset();
790
791   // Another motion event inside actor, signalled with motion
792   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
793   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
794   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
795   data.Reset();
796
797   // We do not want to listen to leave events anymore
798   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
799
800   // Another motion event outside of actor, no signalling
801   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
802   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
803   data.Reset();
804   END_TEST;
805 }
806
807 int UtcDaliTouchDataLeaveParentConsumer(void)
808 {
809   TestApplication application;
810   Actor rootActor( application.GetScene().GetRootLayer() );
811
812   Actor actor = Actor::New();
813   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
814   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
815   application.GetScene().Add(actor);
816
817   // Render and notify
818   application.SendNotification();
819   application.Render();
820
821   // Connect to actor's touched signal
822   SignalData data;
823   TouchDataFunctor functor( data, false );
824   actor.TouchSignal().Connect( &application, functor );
825
826   // Connect to root actor's touched signal
827   SignalData rootData;
828   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
829   rootActor.TouchSignal().Connect( &application, rootFunctor );
830
831   // Set actor to require leave events
832   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
833   rootActor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
834
835   // Emit a down signal
836   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
837   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
838   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
839   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
840   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
841   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
842   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
843   data.Reset();
844   rootData.Reset();
845
846   // Emit a motion signal outside of actor, should be signalled with a Leave
847   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
848   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
849   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
850   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
851   DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
852   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
853   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
854   data.Reset();
855   rootData.Reset();
856
857   // Another motion outside of actor, only rootActor signalled
858   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
859   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
860   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
861   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
862   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
863   data.Reset();
864   rootData.Reset();
865
866   // Another motion event inside actor, signalled with motion
867   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
868   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
869   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
870   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
871   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
872   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
873   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
874   data.Reset();
875   rootData.Reset();
876
877   // We do not want to listen to leave events of actor anymore
878   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
879
880   // Another motion event outside of root actor, only root signalled
881   Vector2 sceneSize( application.GetScene().GetSize() );
882   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( sceneSize.width + 10.0f, sceneSize.height + 10.0f )) );
883   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
884   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
885   DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
886   END_TEST;
887 }
888
889 int UtcDaliTouchDataActorBecomesInsensitive(void)
890 {
891   TestApplication application;
892
893   Actor actor = Actor::New();
894   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
895   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
896   application.GetScene().Add(actor);
897
898   // Render and notify
899   application.SendNotification();
900   application.Render();
901
902   // Connect to actor's touched signal
903   SignalData data;
904   TouchDataFunctor functor( data );
905   actor.TouchSignal().Connect( &application, functor );
906
907   // Emit a down signal
908   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
909   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
910   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
911   data.Reset();
912
913   // Change actor to insensitive
914   actor.SetProperty( Actor::Property::SENSITIVE, false );
915
916   // Emit a motion signal, signalled with an interrupted
917   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
918   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
919   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
920   data.Reset();
921   END_TEST;
922 }
923
924 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
925 {
926   TestApplication application;
927   Actor rootActor( application.GetScene().GetRootLayer() );
928
929   Actor actor = Actor::New();
930   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
931   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
932   application.GetScene().Add(actor);
933
934   // Render and notify
935   application.SendNotification();
936   application.Render();
937
938   // Connect to actor's touched signal
939   SignalData data;
940   TouchDataFunctor functor( data, false );
941   actor.TouchSignal().Connect( &application, functor );
942
943   // Connect to root actor's touched signal
944   SignalData rootData;
945   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
946   rootActor.TouchSignal().Connect( &application, rootFunctor );
947
948   // Emit a down signal
949   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
950   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
951   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
952   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
953   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
954   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
955   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
956   data.Reset();
957   rootData.Reset();
958
959   // Render and notify
960   application.SendNotification();
961   application.Render();
962
963   // Make root actor insensitive
964   rootActor.SetProperty( Actor::Property::SENSITIVE, false );
965
966   // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
967   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
968   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
969   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
970   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
971   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
972   END_TEST;
973 }
974
975 int UtcDaliTouchDataMultipleLayers(void)
976 {
977   TestApplication application;
978   Actor rootActor( application.GetScene().GetRootLayer() );
979
980   // Connect to actor's touched signal
981   SignalData data;
982   TouchDataFunctor functor( data );
983
984   Layer layer1 ( Layer::New() );
985   layer1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
986   layer1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
987   application.GetScene().Add( layer1 );
988
989   Actor actor1 ( Actor::New() );
990   actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
991   actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
992   actor1.SetProperty( Actor::Property::POSITION_Z,  1.0f ); // Should hit actor1 in this layer
993   layer1.Add( actor1 );
994
995   // Render and notify
996   application.SendNotification();
997   application.Render();
998
999   // Connect to layer1 and actor1
1000   layer1.TouchSignal().Connect( &application, functor );
1001   actor1.TouchSignal().Connect( &application, functor );
1002
1003   // Hit in hittable area, actor1 should be hit
1004   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1005   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1006   DALI_TEST_CHECK( data.touchedActor == actor1 );
1007   data.Reset();
1008
1009   // Make layer1 insensitive, nothing should be hit
1010   layer1.SetProperty( Actor::Property::SENSITIVE, false );
1011   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1012   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1013   data.Reset();
1014
1015   // Make layer1 sensitive again, again actor1 will be hit
1016   layer1.SetProperty( Actor::Property::SENSITIVE, true );
1017   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1018   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1019   DALI_TEST_CHECK( data.touchedActor == actor1 );
1020   data.Reset();
1021
1022   // Make rootActor insensitive, nothing should be hit
1023   rootActor.SetProperty( Actor::Property::SENSITIVE, false );
1024   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1025   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1026   data.Reset();
1027
1028   // Make rootActor sensitive
1029   rootActor.SetProperty( Actor::Property::SENSITIVE, true );
1030
1031   // Add another layer
1032   Layer layer2 ( Layer::New() );
1033   layer2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1034   layer2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1035   layer2.SetProperty( Actor::Property::POSITION_Z,  10.0f ); // Should hit layer2 in this layer rather than actor2
1036   application.GetScene().Add( layer2 );
1037
1038   Actor actor2 ( Actor::New() );
1039   actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1040   actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1041   layer2.Add( actor2 );
1042
1043   // Render and notify
1044   application.SendNotification();
1045   application.Render();
1046
1047   // Connect to layer2 and actor2
1048   layer2.TouchSignal().Connect( &application, functor );
1049   actor2.TouchSignal().Connect( &application, functor );
1050
1051   // Emit an event, should hit layer2
1052   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1053   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1054   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1055   data.Reset();
1056
1057   // Make layer2 insensitive, should hit actor1
1058   layer2.SetProperty( Actor::Property::SENSITIVE, false );
1059   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1060   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1061   DALI_TEST_CHECK( data.touchedActor == actor1 );
1062   data.Reset();
1063
1064   // Make layer2 sensitive again, should hit layer2
1065   layer2.SetProperty( Actor::Property::SENSITIVE, true );
1066   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1067   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1068   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1069   data.Reset();
1070
1071   // Make layer2 invisible, render and notify
1072   layer2.SetProperty( Actor::Property::VISIBLE, false );
1073   application.SendNotification();
1074   application.Render();
1075
1076   // Should hit actor1
1077   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1078   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1079   DALI_TEST_CHECK( data.touchedActor == actor1 );
1080   data.Reset();
1081
1082   // Make rootActor invisible, render and notify
1083   rootActor.SetProperty( Actor::Property::VISIBLE, false );
1084   application.SendNotification();
1085   application.Render();
1086
1087   // Should not hit anything
1088   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1089   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1090   data.Reset();
1091   END_TEST;
1092 }
1093
1094 int UtcDaliTouchDataMultipleRenderTasks(void)
1095 {
1096   TestApplication application;
1097   Integration::Scene scene ( application.GetScene() );
1098   Vector2 sceneSize ( scene.GetSize() );
1099
1100   Actor actor = Actor::New();
1101   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1102   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1103   scene.Add(actor);
1104
1105   // Create render task
1106   Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
1107   RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
1108   renderTask.SetViewport( viewport );
1109   renderTask.SetInputEnabled( true );
1110
1111   // Render and notify
1112   application.SendNotification();
1113   application.Render();
1114
1115   // Connect to actor's touched signal
1116   SignalData data;
1117   TouchDataFunctor functor( data );
1118   actor.TouchSignal().Connect( &application, functor );
1119
1120   // Emit a down signal
1121   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1122   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1123   data.Reset();
1124
1125   // Ensure renderTask actor can be hit too.
1126   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1127   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1128   data.Reset();
1129
1130   // Disable input on renderTask, should not be hittable
1131   renderTask.SetInputEnabled( false );
1132   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1133   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1134   data.Reset();
1135   END_TEST;
1136 }
1137
1138 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1139 {
1140   TestApplication application;
1141   Integration::Scene scene ( application.GetScene() );
1142   Vector2 sceneSize ( scene.GetSize() );
1143
1144   Actor actor = Actor::New();
1145   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1146   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1147   scene.Add(actor);
1148
1149   Layer layer = Layer::New();
1150   layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1151   layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1152   actor.Add(layer);
1153
1154   // Create render task
1155   Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
1156   RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
1157   renderTask.SetViewport( viewport );
1158   renderTask.SetInputEnabled( true );
1159   renderTask.SetSourceActor( actor );
1160
1161   // Render and notify
1162   application.SendNotification();
1163   application.Render();
1164
1165   // Connect to layer's touched signal
1166   SignalData data;
1167   TouchDataFunctor functor( data );
1168   actor.TouchSignal().Connect( &application, functor );
1169   layer.TouchSignal().Connect( &application, functor );
1170
1171   // Emit a down signal
1172   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1173   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1174   data.Reset();
1175
1176   // Ensure renderTask actor can be hit too.
1177   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1178   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1179   data.Reset();
1180
1181   // Disable input on renderTask, should not be hittable
1182   renderTask.SetInputEnabled( false );
1183   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1184   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1185   data.Reset();
1186   END_TEST;
1187 }
1188
1189 int UtcDaliTouchDataOffscreenRenderTasks(void)
1190 {
1191   TestApplication application;
1192   Integration::Scene scene ( application.GetScene() );
1193   Vector2 sceneSize ( scene.GetSize() );
1194
1195   // FrameBufferImage for offscreen RenderTask
1196   FrameBuffer frameBuffer = FrameBuffer::New(sceneSize.width, sceneSize.height);
1197
1198   // Create a renderable actor to display the FrameBufferImage
1199   Actor renderableActor = CreateRenderableActor(frameBuffer.GetColorTexture());
1200   renderableActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
1201   renderableActor.SetProperty( Actor::Property::SIZE, Vector2( sceneSize.x, sceneSize.y ) );
1202   renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1203   scene.Add( renderableActor );
1204
1205   Actor actor = Actor::New();
1206   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1207   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1208   scene.Add( actor );
1209   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1210
1211   scene.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1212
1213   // Create a RenderTask
1214   RenderTask renderTask = scene.GetRenderTaskList().CreateTask();
1215   renderTask.SetSourceActor( actor );
1216   renderTask.SetFrameBuffer(frameBuffer);
1217   renderTask.SetInputEnabled( true );
1218
1219   // Create another RenderTask
1220   RenderTask renderTask2( scene.GetRenderTaskList().CreateTask() );
1221   renderTask2.SetInputEnabled( true );
1222
1223   // Render and notify
1224   application.SendNotification();
1225   application.Render();
1226
1227   // Connect to actor's touched signal
1228   SignalData data;
1229   TouchDataFunctor functor( data );
1230   actor.TouchSignal().Connect( &application, functor );
1231
1232   // Emit a down signal
1233   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1234   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1235   data.Reset();
1236   END_TEST;
1237 }
1238
1239 int UtcDaliTouchDataMultipleRenderableActors(void)
1240 {
1241   TestApplication application;
1242   Integration::Scene scene ( application.GetScene() );
1243   Vector2 sceneSize ( scene.GetSize() );
1244
1245   Actor parent = CreateRenderableActor();
1246   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1247   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1248   scene.Add(parent);
1249
1250   Actor actor = CreateRenderableActor();
1251   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1252   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1253   parent.Add(actor);
1254
1255   // Render and notify
1256   application.SendNotification();
1257   application.Render();
1258
1259   // Connect to layer's touched signal
1260   SignalData data;
1261   TouchDataFunctor functor( data );
1262   parent.TouchSignal().Connect( &application, functor );
1263   actor.TouchSignal().Connect( &application, functor );
1264
1265   // Emit a down signal
1266   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1267   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1268   DALI_TEST_CHECK( actor == data.touchedActor );
1269   END_TEST;
1270 }
1271
1272 int UtcDaliTouchDataActorRemovedInSignal(void)
1273 {
1274   TestApplication application;
1275
1276   Actor actor = Actor::New();
1277   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1278   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1279   application.GetScene().Add(actor);
1280
1281   // Render and notify
1282   application.SendNotification();
1283   application.Render();
1284
1285   // Connect to actor's touched signal
1286   SignalData data;
1287   RemoveActorFunctor functor( data );
1288   actor.TouchSignal().Connect( &application, functor );
1289
1290   // Register for leave events
1291   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
1292
1293   // Emit a down signal
1294   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1295   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1296   data.Reset();
1297
1298   // Re-add, render and notify
1299   application.GetScene().Add(actor);
1300   application.SendNotification();
1301   application.Render();
1302
1303   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1304   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1305   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1306   data.Reset();
1307
1308   // Emit a down signal
1309   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1310   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1311   data.Reset();
1312
1313   // Render and notify
1314   application.SendNotification();
1315   application.Render();
1316
1317   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1318   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1319   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1320   data.Reset();
1321
1322   // Re-add actor back to scene, render and notify
1323   application.GetScene().Add(actor);
1324   application.SendNotification();
1325   application.Render();
1326
1327   // Emit another down event
1328   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1329   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1330   data.Reset();
1331
1332   // Completely delete the actor
1333   actor.Reset();
1334
1335   // Emit event, should not crash and should not receive an event.
1336   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1337   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1338   END_TEST;
1339 }
1340
1341 int UtcDaliTouchDataActorSignalNotConsumed(void)
1342 {
1343   TestApplication application;
1344
1345   Actor actor = Actor::New();
1346   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1347   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1348   application.GetScene().Add(actor);
1349
1350   // Render and notify
1351   application.SendNotification();
1352   application.Render();
1353
1354   // Connect to actor's touched signal
1355   SignalData data;
1356   TouchDataFunctor functor( data, false );
1357   actor.TouchSignal().Connect( &application, functor );
1358
1359   // Emit a down signal
1360   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1361   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1362   END_TEST;
1363 }
1364
1365 int UtcDaliTouchDataActorRemovedFromScene(void)
1366 {
1367   TestApplication application;
1368
1369   Actor actor = Actor::New();
1370   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1371   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1372   application.GetScene().Add(actor);
1373
1374   // Render and notify
1375   application.SendNotification();
1376   application.Render();
1377
1378   // Connect to actor's touched signal
1379   SignalData data;
1380   TouchDataFunctor functor( data );
1381   actor.TouchSignal().Connect( &application, functor );
1382
1383   // Emit a down signal
1384   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1385   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1386   data.Reset();
1387
1388   // Remove actor from scene
1389   application.GetScene().Remove( actor );
1390   data.Reset();
1391
1392   // Render and notify
1393   application.SendNotification();
1394   application.Render();
1395
1396   // Emit a move at the same point, we should not be signalled.
1397   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1398   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1399   data.Reset();
1400   END_TEST;
1401 }
1402
1403 int UtcDaliTouchDataLayerConsumesTouch(void)
1404 {
1405   TestApplication application;
1406
1407   Actor actor = Actor::New();
1408   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1409   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1410   application.GetScene().Add(actor);
1411
1412   // Render and notify
1413   application.SendNotification();
1414   application.Render();
1415
1416   // Connect to actor's touched signal
1417   SignalData data;
1418   TouchDataFunctor functor( data );
1419   actor.TouchSignal().Connect( &application, functor );
1420
1421   // Add a layer to overlap the actor
1422   Layer layer = Layer::New();
1423   layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1424   layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1425   application.GetScene().Add( layer );
1426   layer.RaiseToTop();
1427
1428   // Render and notify
1429   application.SendNotification();
1430   application.Render();
1431
1432   // Emit a few touch signals
1433   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1434   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1435   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1436   data.Reset();
1437
1438   // Set layer to consume all touch
1439   layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1440
1441   // Render and notify
1442   application.SendNotification();
1443   application.Render();
1444
1445   // Emit the same signals again, should not receive
1446   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1447   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1448   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1449   data.Reset();
1450
1451   END_TEST;
1452 }
1453
1454 int UtcDaliTouchDataLeaveActorReadded(void)
1455 {
1456   TestApplication application;
1457   Integration::Scene scene = application.GetScene();
1458
1459   Actor actor = Actor::New();
1460   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1461   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1462   scene.Add(actor);
1463
1464   // Set actor to receive touch-events
1465   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
1466
1467   // Render and notify
1468   application.SendNotification();
1469   application.Render();
1470
1471   // Connect to actor's touched signal
1472   SignalData data;
1473   TouchDataFunctor functor( data );
1474   actor.TouchSignal().Connect( &application, functor );
1475
1476   // Emit a down and motion
1477   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1478   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1479   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1480   data.Reset();
1481
1482   // Remove actor from scene and add again
1483   scene.Remove( actor );
1484   scene.Add( actor );
1485
1486   // Emit a motion within the actor's bounds
1487   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1488   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1489   data.Reset();
1490
1491   // Emit a motion outside the actor's bounds
1492   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1493   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1494   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1495   data.Reset();
1496
1497   END_TEST;
1498 }
1499
1500 int UtcDaliTouchDataClippedActor(void)
1501 {
1502   TestApplication application;
1503   Integration::Scene scene = application.GetScene();
1504
1505   Actor actor = Actor::New();
1506   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1507   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1508   scene.Add( actor );
1509
1510   Actor clippingActor = Actor::New();
1511   clippingActor.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
1512   clippingActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1513   clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1514   scene.Add( clippingActor );
1515
1516   // Add a child to the clipped region.
1517   Actor clippingChild = Actor::New();
1518   clippingChild.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
1519   clippingChild.SetProperty( Actor::Property::POSITION, Vector2( 25.0f, 25.0f ));
1520   clippingChild.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1521   clippingActor.Add( clippingChild );
1522
1523   // Render and notify.
1524   application.SendNotification();
1525   application.Render();
1526
1527   // Connect to actor's touch signal.
1528   SignalData data;
1529   TouchDataFunctor functor( data );
1530   actor.TouchSignal().Connect( &application, functor );
1531
1532   // Emit an event within clipped area - no hit.
1533   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1534   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1535   data.Reset();
1536
1537   // Emit an event outside the clipped area but within the actor area, we should have a hit.
1538   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1539   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1540   data.Reset();
1541
1542   clippingChild.TouchSignal().Connect( &application, functor );
1543
1544   // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1545   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 30.0f, 30.0f ) ) );
1546   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1547   data.Reset();
1548
1549   END_TEST;
1550 }
1551
1552 int UtcDaliTouchDataActorUnparented(void)
1553 {
1554   TestApplication application;
1555
1556   Actor actor = Actor::New();
1557   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1558   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1559   application.GetScene().Add(actor);
1560
1561   // Render and notify
1562   application.SendNotification();
1563   application.Render();
1564
1565   // Connect to actor's touched signal
1566   SignalData data;
1567   TouchDataFunctor functor( data );
1568   actor.TouchSignal().Connect( &application, functor );
1569
1570   // Emit a down signal
1571   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1572   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1573   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1574   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1575   data.Reset();
1576
1577   // Render and notify
1578   application.SendNotification();
1579   application.Render();
1580
1581   // Unparent the actor
1582   actor.Unparent();
1583
1584   // Should receive an interrupted event
1585   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1586   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1587   END_TEST;
1588 }
1589
1590 int UtcDaliTouchDataParentRemovedFromScene(void)
1591 {
1592   TestApplication application;
1593
1594   Actor parent = Actor::New();
1595   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1596   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1597   application.GetScene().Add(parent);
1598
1599   Actor actor = Actor::New();
1600   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1601   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1602   parent.Add(actor);
1603
1604   // Render and notify
1605   application.SendNotification();
1606   application.Render();
1607
1608   // Connect to actor's touched signal
1609   SignalData data;
1610   TouchDataFunctor functor( data );
1611   actor.TouchSignal().Connect( &application, functor );
1612
1613   // Emit a down signal
1614   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1615   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1616   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1617   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1618   data.Reset();
1619
1620   // Render and notify
1621   application.SendNotification();
1622   application.Render();
1623
1624   // Unparent the parent of the touchable actor
1625   parent.Unparent();
1626
1627   // Should receive an interrupted event
1628   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1629   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1630   END_TEST;
1631 }
1632
1633 int UtcDaliTouchDataActorRemovedFromSceneDifferentConsumer(void)
1634 {
1635   TestApplication application;
1636
1637   Actor parent = Actor::New();
1638   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1639   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1640   application.GetScene().Add(parent);
1641
1642   Actor actor = Actor::New();
1643   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1644   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1645   parent.Add(actor);
1646
1647   // Render and notify
1648   application.SendNotification();
1649   application.Render();
1650
1651   // Connect to actor's touched signal
1652   SignalData data;
1653   TouchDataFunctor functor( data, false /* Do not consume */ );
1654   actor.TouchSignal().Connect( &application, functor );
1655
1656   // Connect to parent's touched signal
1657   SignalData parentData;
1658   TouchDataFunctor parentFunctor( parentData );
1659   parent.TouchSignal().Connect( &application, parentFunctor );
1660
1661   // Emit a down signal
1662   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1663   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1664   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1665   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1666   DALI_TEST_CHECK( actor == data.touchedActor );
1667   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1668   DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1669   DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1670   DALI_TEST_CHECK( parent == parentData.touchedActor );
1671   data.Reset();
1672   parentData.Reset();
1673
1674   // Render and notify
1675   application.SendNotification();
1676   application.Render();
1677
1678   // Unparent the actor
1679   actor.Unparent();
1680
1681   // Should receive an interrupted event for both actor & parent
1682   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1683   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1684   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1685   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1686   data.Reset();
1687   parentData.Reset();
1688
1689   // Readd actor to parent
1690   parent.Add(actor);
1691
1692   // Render and notify
1693   application.SendNotification();
1694   application.Render();
1695
1696   // Emit a motion signal
1697   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1698   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1699   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1700   data.Reset();
1701   parentData.Reset();
1702
1703   // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1704   SignalData secondData;
1705   TouchDataFunctor secondFunctor( secondData /* Consume */ );
1706   actor.TouchSignal().Connect( &application, secondFunctor );
1707
1708   // Unparent the actor
1709   actor.Unparent();
1710
1711   // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1712   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1713   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1714   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1715   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1716   DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1717   DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1718   data.Reset();
1719   parentData.Reset();
1720   secondData.Reset();
1721
1722   END_TEST;
1723 }
1724
1725 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1726 {
1727   TestApplication application;
1728   Actor rootActor( application.GetScene().GetRootLayer() );
1729
1730   Actor parent = Actor::New();
1731   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1732   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1733   application.GetScene().Add(parent);
1734
1735   Actor actor = Actor::New();
1736   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1737   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1738   parent.Add(actor);
1739
1740   // Render and notify
1741   application.SendNotification();
1742   application.Render();
1743
1744   // Connect to actor's touched signal
1745   SignalData data;
1746   TouchDataFunctor functor( data, false /* Do not consume */ );
1747   actor.TouchSignal().Connect( &application, functor );
1748
1749   // Connect to parent's touched signal
1750   SignalData parentData;
1751   TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1752   parent.TouchSignal().Connect( &application, parentFunctor );
1753
1754   // Connect to root's touched signal and consume
1755   SignalData rootData;
1756   TouchDataFunctor rootFunctor( rootData );
1757   rootActor.TouchSignal().Connect( &application, rootFunctor );
1758
1759   // Emit a down signal
1760   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1761   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1762   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1763   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1764   DALI_TEST_CHECK( actor == data.touchedActor );
1765   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1766   DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1767   DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1768   DALI_TEST_CHECK( parent == parentData.touchedActor );
1769   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1770   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1771   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1772   DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1773   data.Reset();
1774   parentData.Reset();
1775   rootData.Reset();
1776
1777   // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1778   SignalData secondData;
1779   TouchDataFunctor secondFunctor( secondData /* Consume */ );
1780   parent.TouchSignal().Connect( &application, secondFunctor );
1781
1782   // Emit an interrupted signal, all three should STILL be called
1783   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1784   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1785   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1786   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1787   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1788   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1789   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1790   data.Reset();
1791   parentData.Reset();
1792   rootData.Reset();
1793
1794   END_TEST;
1795 }
1796
1797 int UtcDaliTouchDataGetRadius(void)
1798 {
1799   TestApplication application;
1800
1801   Actor actor = Actor::New();
1802   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1803   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1804   application.GetScene().Add(actor);
1805
1806   // Render and notify
1807   application.SendNotification();
1808   application.Render();
1809
1810   // Connect to actor's touched signal
1811   SignalData data;
1812   TouchDataFunctor functor( data );
1813   actor.TouchSignal().Connect( &application, functor );
1814
1815   // Emit a down signal with an angle
1816   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1817   touchEvent.points[ 0 ].SetRadius( 100.0f );
1818   application.ProcessEvent( touchEvent );
1819   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1820   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1821   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1822   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1823   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1824
1825   END_TEST;
1826 }
1827
1828 int UtcDaliTouchDataGetEllipseRadius(void)
1829 {
1830   TestApplication application;
1831
1832   Actor actor = Actor::New();
1833   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1834   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1835   application.GetScene().Add(actor);
1836
1837   // Render and notify
1838   application.SendNotification();
1839   application.Render();
1840
1841   // Connect to actor's touched signal
1842   SignalData data;
1843   TouchDataFunctor functor( data );
1844   actor.TouchSignal().Connect( &application, functor );
1845
1846   // Emit a down signal with an angle
1847   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1848   touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1849   application.ProcessEvent( touchEvent );
1850   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1851   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1852   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1853   DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1854   DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1855
1856   END_TEST;
1857 }
1858
1859 int UtcDaliTouchDataGetAngle(void)
1860 {
1861   TestApplication application;
1862
1863   Actor actor = Actor::New();
1864   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1865   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1866   application.GetScene().Add(actor);
1867
1868   // Render and notify
1869   application.SendNotification();
1870   application.Render();
1871
1872   // Connect to actor's touched signal
1873   SignalData data;
1874   TouchDataFunctor functor( data );
1875   actor.TouchSignal().Connect( &application, functor );
1876
1877   // Emit a down signal with an angle
1878   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1879   touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1880   application.ProcessEvent( touchEvent );
1881   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1882   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1883   DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1884
1885   END_TEST;
1886 }
1887
1888 int UtcDaliTouchDataGetPressure(void)
1889 {
1890   TestApplication application;
1891
1892   Actor actor = Actor::New();
1893   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1894   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1895   application.GetScene().Add(actor);
1896
1897   // Render and notify
1898   application.SendNotification();
1899   application.Render();
1900
1901   // Connect to actor's touched signal
1902   SignalData data;
1903   TouchDataFunctor functor( data );
1904   actor.TouchSignal().Connect( &application, functor );
1905
1906   // Emit a down signal with an angle
1907   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1908   touchEvent.points[ 0 ].SetPressure( 10.0f );
1909   application.ProcessEvent( touchEvent );
1910   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1911   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1912   DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1913
1914   END_TEST;
1915 }
1916
1917 int UtcDaliTouchDataAndEventUsage(void)
1918 {
1919   TestApplication application;
1920
1921   Actor actor = Actor::New();
1922   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1923   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1924   application.GetScene().Add(actor);
1925
1926   // Render and notify
1927   application.SendNotification();
1928   application.Render();
1929
1930   // Connect to actor's touched signal
1931   SignalData data;
1932   TouchDataFunctor functor( data );
1933   actor.TouchSignal().Connect( &application, functor );
1934
1935   // Connect to actor's touched signal (OLD)
1936   bool touchEventFunctorCalled = false;
1937   TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1938   actor.TouchedSignal().Connect( &application, eventFunctor );
1939
1940   // Emit a down signal with an angle
1941   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1942   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1943   DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );
1944
1945   END_TEST;
1946 }
1947
1948 int UtcDaliTouchDataGetDeviceAPINegative(void)
1949 {
1950   TestApplication application;
1951
1952   Actor actor = Actor::New();
1953   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1954   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1955   application.GetScene().Add(actor);
1956
1957   // Render and notify
1958   application.SendNotification();
1959   application.Render();
1960
1961   // Connect to actor's touched signal
1962   HandleData handleData;
1963   TouchDataHandleFunctor functor( handleData );
1964   actor.TouchSignal().Connect( &application, functor );
1965
1966   Vector2 screenCoordinates( 10.0f, 10.0f );
1967   Vector2 localCoordinates;
1968   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
1969
1970   // Emit a down signal
1971   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
1972
1973   TouchData data = handleData.touchData;
1974   DALI_TEST_EQUALS( data.GetDeviceClass( -1 ), Device::Class::NONE, TEST_LOCATION );
1975   DALI_TEST_EQUALS( data.GetDeviceSubclass( -1 ), Device::Subclass::NONE, TEST_LOCATION );
1976   END_TEST;
1977 }
1978
1979 int UtcDaliTouchDataGetMouseButtonPositive(void)
1980 {
1981   TestApplication application;
1982
1983   Actor actor = Actor::New();
1984   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1985   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1986   application.GetScene().Add(actor);
1987
1988   // Render and notify
1989   application.SendNotification();
1990   application.Render();
1991
1992   // Connect to actor's touched signal
1993   HandleData handleData;
1994   TouchDataHandleFunctor functor( handleData );
1995   actor.TouchSignal().Connect( &application, functor );
1996
1997   // Emit a down signal with MouseButton
1998   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1999   touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 3 ) );
2000   application.ProcessEvent( touchEvent );
2001
2002   TouchData data = handleData.touchData;
2003   DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::SECONDARY, TEST_LOCATION );
2004
2005   END_TEST;
2006 }
2007
2008 int UtcDaliTouchDataGetMouseButtonNagative(void)
2009 {
2010   TestApplication application;
2011
2012   Actor actor = Actor::New();
2013   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2014   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2015   application.GetScene().Add(actor);
2016
2017   // Render and notify
2018   application.SendNotification();
2019   application.Render();
2020
2021   // Connect to actor's touched signal
2022   HandleData handleData;
2023   TouchDataHandleFunctor functor( handleData );
2024   actor.TouchSignal().Connect( &application, functor );
2025
2026   // Emit a down signal with MouseButton
2027   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
2028   touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 2 ) );
2029   application.ProcessEvent( touchEvent );
2030
2031   TouchData data = handleData.touchData;
2032   DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::TERTIARY, TEST_LOCATION );
2033   DALI_TEST_EQUALS( data.GetMouseButton( 3 ), MouseButton::INVALID, TEST_LOCATION );
2034
2035   END_TEST;
2036 }
2037
2038 int UtcDaliTouchDataCapturePropertySet(void)
2039 {
2040   TestApplication application;
2041
2042   Actor actor = Actor::New();
2043   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2044   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2045   application.GetScene().Add(actor);
2046
2047   // Render and notify
2048   application.SendNotification();
2049   application.Render();
2050
2051   // Connect to actor's touched signal
2052   SignalData data;
2053   TouchDataFunctor functor( data );
2054   actor.TouchSignal().Connect( &application, functor );
2055
2056   // Emit a down signal
2057   application.ProcessEvent( GenerateSingleTouch( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) );
2058   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2059   data.Reset();
2060
2061   // Now motion outside of actor, we should not receive the event
2062   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 110.0f, 110.0f ) ) );
2063   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
2064   data.Reset();
2065
2066   // Up event, should receive an interrupted
2067   application.ProcessEvent( GenerateSingleTouch( PointState::FINISHED, Vector2( 110.0f, 110.0f ) ) );
2068   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2069   DALI_TEST_EQUALS( data.touchData.GetPoint(0).state, PointState::INTERRUPTED, TEST_LOCATION );
2070
2071   // Now set the capture property
2072   actor.SetProperty( DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
2073
2074   // Emit a down signal
2075   application.ProcessEvent( GenerateSingleTouch( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) );
2076   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2077   data.Reset();
2078
2079   // Now motion outside of actor, we now SHOULD receive the event
2080   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 110.0f, 110.0f ) ) );
2081   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2082   data.Reset();
2083
2084   // Up event, we should receive it again, but as ended rather than interrupted
2085   application.ProcessEvent( GenerateSingleTouch( PointState::FINISHED, Vector2( 110.0f, 110.0f ) ) );
2086   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2087   DALI_TEST_EQUALS( data.touchData.GetPoint(0).state, PointState::FINISHED, TEST_LOCATION );
2088
2089   END_TEST;
2090 }