If a RenderTask's exclusive actor is destoryed, then ensure the RenderTaskList of...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TouchProcessing.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/render-task-list-integ.h>
24 #include <dali-test-suite-utils.h>
25 #include <dali/devel-api/events/touch-data-devel.h>
26
27 using namespace Dali;
28
29 void utc_dali_touch_processing_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_touch_processing_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 ///////////////////////////////////////////////////////////////////////////////
40
41 namespace
42 {
43
44 // Stores data that is populated in the callback and will be read by the TET cases
45 struct SignalData
46 {
47   SignalData()
48   : functorCalled( false ),
49     touchEvent(),
50     touchedActor()
51   {
52   }
53
54   void Reset()
55   {
56     functorCalled = false;
57
58     touchEvent.time = 0u;
59     touchEvent.points.clear();
60
61     touchedActor.Reset();
62   }
63
64   bool functorCalled;
65   TouchEvent touchEvent;
66   Actor touchedActor;
67 };
68
69 // Functor that sets the data when called
70 struct TouchEventFunctor
71 {
72   /**
73    * Constructor.
74    * @param[in]  data         Reference to the data to store callback information.
75    * @param[in]  returnValue  What the functor should return.
76    */
77   TouchEventFunctor( SignalData& data, bool returnValue = true )
78   : signalData( data ),
79     returnValue( returnValue )
80   {
81   }
82
83   bool operator()( Actor actor, const TouchEvent& touchEvent )
84   {
85     signalData.functorCalled = true;
86     signalData.touchedActor = actor;
87     signalData.touchEvent = touchEvent;
88
89     return returnValue;
90   }
91
92   SignalData& signalData;
93   bool returnValue;
94 };
95
96 // Functor that removes the actor when called.
97 struct RemoveActorFunctor : public TouchEventFunctor
98 {
99   /**
100    * Constructor.
101    * @param[in]  data         Reference to the data to store callback information.
102    * @param[in]  returnValue  What the functor should return.
103    */
104   RemoveActorFunctor( SignalData& data, bool returnValue = true )
105   : TouchEventFunctor( data, returnValue )
106   {
107   }
108
109   bool operator()( Actor actor, const TouchEvent& touchEvent )
110   {
111     Actor parent( actor.GetParent() );
112     if ( parent )
113     {
114       parent.Remove( actor );
115     }
116
117     return TouchEventFunctor::operator()( actor, touchEvent );
118   }
119 };
120
121 Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, const Vector2& screenPosition )
122 {
123   Integration::TouchEvent touchEvent;
124   Integration::Point point;
125   point.SetState( static_cast< PointState::Type >( state ) );
126   point.SetScreenPosition( screenPosition );
127   touchEvent.points.push_back( point );
128   return touchEvent;
129 }
130
131 } // anon namespace
132
133 ///////////////////////////////////////////////////////////////////////////////
134
135 int UtcDaliTouchNormalProcessing(void)
136 {
137   TestApplication application;
138
139   Actor actor = Actor::New();
140   actor.SetSize(100.0f, 100.0f);
141   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
142   Stage::GetCurrent().Add(actor);
143
144   // Render and notify
145   application.SendNotification();
146   application.Render();
147
148   // Connect to actor's touched signal
149   SignalData data;
150   TouchEventFunctor functor( data );
151   actor.TouchedSignal().Connect( &application, functor );
152
153   Vector2 screenCoordinates( 10.0f, 10.0f );
154   Vector2 localCoordinates;
155   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
156
157   // Emit a down signal
158   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
159   const TouchPoint *point1 = &data.touchEvent.GetPoint(0);
160   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
161   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
162   DALI_TEST_EQUALS( TouchPoint::Down, point1->state, TEST_LOCATION );
163   DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
164   DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
165   data.Reset();
166
167   // Emit a motion signal
168   screenCoordinates.x = screenCoordinates.y = 11.0f;
169   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
170   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
171   const TouchPoint *point2 = &data.touchEvent.GetPoint(0);
172   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
173   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
174   DALI_TEST_EQUALS( TouchPoint::Motion, point2->state, TEST_LOCATION );
175   DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
176   DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
177   data.Reset();
178
179   // Emit an up signal
180   screenCoordinates.x = screenCoordinates.y = 12.0f;
181   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
182   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
183
184   const TouchPoint *point3ptr = &data.touchEvent.GetPoint(0);
185   TouchPoint point3( point3ptr->deviceId, point3ptr->state, point3ptr->screen.x, point3ptr->screen.y, point3ptr->local.x, point3ptr->local.y );
186
187   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
188   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
189   DALI_TEST_EQUALS( TouchPoint::Up, point3.state, TEST_LOCATION );
190   DALI_TEST_EQUALS( screenCoordinates, point3.screen, TEST_LOCATION );
191   DALI_TEST_EQUALS( localCoordinates, point3.local, 0.1f, TEST_LOCATION );
192   data.Reset();
193
194   // Emit a down signal where the actor is not present
195   screenCoordinates.x = screenCoordinates.y = 200.0f;
196   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
197   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
198   END_TEST;
199 }
200
201 int UtcDaliTouchOutsideCameraNearFarPlanes(void)
202 {
203   TestApplication application;
204
205   Stage stage = Stage::GetCurrent();
206   Vector2 stageSize = stage.GetSize();
207
208   Actor actor = Actor::New();
209   actor.SetSize(100.0f, 100.0f);
210   actor.SetAnchorPoint(AnchorPoint::CENTER);
211   actor.SetParentOrigin(ParentOrigin::CENTER);
212   stage.Add(actor);
213
214   // Render and notify
215   application.SendNotification();
216   application.Render();
217
218   // Get the camera's near and far planes
219   RenderTaskList taskList = stage.GetRenderTaskList();
220   Dali::RenderTask task = taskList.GetTask(0);
221   CameraActor camera = task.GetCameraActor();
222   float nearPlane = camera.GetNearClippingPlane();
223   float farPlane = camera.GetFarClippingPlane();
224
225   // Calculate the current distance of the actor from the camera
226   float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
227   float distance = (stageSize.y * 0.5f) / tanHalfFov;
228
229   // Connect to actor's touched signal
230   SignalData data;
231   TouchEventFunctor functor( data );
232   actor.TouchedSignal().Connect( &application, functor );
233
234   Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
235
236   // Emit a down signal
237   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
238   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
239   data.Reset();
240
241   // Emit a down signal where actor is just at the camera's near plane
242   actor.SetZ(distance - nearPlane);
243
244   // Render and notify
245   application.SendNotification();
246   application.Render();
247
248   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
249   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
250   data.Reset();
251
252   // Emit a down signal where actor is closer than the camera's near plane
253   actor.SetZ((distance - nearPlane) + 1.0f);
254
255   // Render and notify
256   application.SendNotification();
257   application.Render();
258
259   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
260   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
261   data.Reset();
262
263   // Emit a down signal where actor is just at the camera's far plane
264   actor.SetZ(distance - farPlane);
265
266   // Render and notify
267   application.SendNotification();
268   application.Render();
269
270   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
271   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
272   data.Reset();
273
274   // Emit a down signal where actor is further than the camera's far plane
275   actor.SetZ((distance - farPlane) - 1.0f);
276
277   // Render and notify
278   application.SendNotification();
279   application.Render();
280
281   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
282   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
283   data.Reset();
284   END_TEST;
285 }
286
287 int UtcDaliTouchEmitEmpty(void)
288 {
289   TestApplication application;
290
291   try
292   {
293     // Emit an empty TouchEvent
294     Integration::TouchEvent event;
295     application.ProcessEvent( event );
296     tet_result( TET_FAIL );
297   }
298   catch ( Dali::DaliException& e )
299   {
300     DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
301   }
302   END_TEST;
303 }
304
305 int UtcDaliTouchInterrupted(void)
306 {
307   TestApplication application;
308
309   Actor actor = Actor::New();
310   actor.SetSize(100.0f, 100.0f);
311   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
312   Stage::GetCurrent().Add(actor);
313
314   // Render and notify
315   application.SendNotification();
316   application.Render();
317
318   // Connect to actor's touched signal
319   SignalData data;
320   TouchEventFunctor functor( data );
321   actor.TouchedSignal().Connect( &application, functor );
322
323   // Emit a down signal
324   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
325   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
326   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
327   data.Reset();
328
329   // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
330   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
331   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
332   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
333   data.Reset();
334
335   // Emit another interrupted signal, our signal handler should not be called.
336   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
337   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
338   END_TEST;
339 }
340
341 int UtcDaliTouchParentConsumer(void)
342 {
343   TestApplication application;
344   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
345
346   Actor actor = Actor::New();
347   actor.SetSize(100.0f, 100.0f);
348   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
349   Stage::GetCurrent().Add(actor);
350
351   // Render and notify
352   application.SendNotification();
353   application.Render();
354
355   // Connect to actor's touched signal
356   SignalData data;
357   TouchEventFunctor functor( data, false );
358   actor.TouchedSignal().Connect( &application, functor );
359
360   // Connect to root actor's touched signal
361   SignalData rootData;
362   TouchEventFunctor rootFunctor( rootData ); // Consumes signal
363   rootActor.TouchedSignal().Connect( &application, rootFunctor );
364
365   Vector2 screenCoordinates( 10.0f, 10.0f );
366   Vector2 actorCoordinates, rootCoordinates;
367   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
368   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
369
370   // Emit a down signal
371   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
372   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
373   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
374   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
375   DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
376   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
377   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
378   DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
379   DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
380   DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
381   DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
382   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
383   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
384   data.Reset();
385   rootData.Reset();
386
387   // Emit a motion signal
388   screenCoordinates.x = screenCoordinates.y = 11.0f;
389   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
390   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
391   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
392   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
393   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
394   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
395   DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
396   DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
397   DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
398   DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
399   DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
400   DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
401   DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
402   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
403   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
404   data.Reset();
405   rootData.Reset();
406
407   // Emit an up signal
408   screenCoordinates.x = screenCoordinates.y = 12.0f;
409   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
410   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
411   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
412   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
413   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
414   DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
415   DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
416   DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
417   DALI_TEST_EQUALS( TouchPoint::Up, rootData.touchEvent.points[0].state, TEST_LOCATION );
418   DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
419   DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
420   DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
421   DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
422   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
423   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
424   data.Reset();
425   rootData.Reset();
426
427   // Emit a down signal where the actor is not present, will hit the root actor though
428   screenCoordinates.x = screenCoordinates.y = 200.0f;
429   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
430   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
431   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
432   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
433   DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
434   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
435   DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
436   DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
437   DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
438   END_TEST;
439 }
440
441 int UtcDaliTouchInterruptedParentConsumer(void)
442 {
443   TestApplication application;
444   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
445
446   Actor actor = Actor::New();
447   actor.SetSize(100.0f, 100.0f);
448   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
449   Stage::GetCurrent().Add(actor);
450
451   // Render and notify
452   application.SendNotification();
453   application.Render();
454
455   // Connect to actor's touched signal
456   SignalData data;
457   TouchEventFunctor functor( data, false );
458   actor.TouchedSignal().Connect( &application, functor );
459
460   // Connect to root actor's touched signal
461   SignalData rootData;
462   TouchEventFunctor rootFunctor( rootData ); // Consumes signal
463   rootActor.TouchedSignal().Connect( &application, rootFunctor );
464
465   // Emit a down signal
466   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
467   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
468   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
469   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
470   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
471   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
472   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
473   data.Reset();
474   rootData.Reset();
475
476   // Emit an interrupted signal
477   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
478   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
479   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
480   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
481   DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
482   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
483   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
484   data.Reset();
485   rootData.Reset();
486
487   // Emit another down signal
488   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
489   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
490   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
491   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
492   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
493   data.Reset();
494   rootData.Reset();
495
496   // Remove actor from Stage
497   Stage::GetCurrent().Remove( actor );
498   data.Reset();
499   rootData.Reset();
500
501   // Render and notify
502   application.SendNotification();
503   application.Render();
504
505   // Emit an interrupted signal, only root actor's signal should be called.
506   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
507   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
508   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
509   DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
510   DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
511   data.Reset();
512   rootData.Reset();
513
514   // Emit another interrupted state, none of the signal's should be called.
515   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
516   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
517   DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
518   END_TEST;
519 }
520
521 int UtcDaliTouchLeave(void)
522 {
523   TestApplication application;
524
525   Actor actor = Actor::New();
526   actor.SetSize(100.0f, 100.0f);
527   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
528   Stage::GetCurrent().Add(actor);
529
530   // Render and notify
531   application.SendNotification();
532   application.Render();
533
534   // Connect to actor's touched signal
535   SignalData data;
536   TouchEventFunctor functor( data );
537   actor.TouchedSignal().Connect( &application, functor );
538
539   // Set actor to require leave events
540   actor.SetLeaveRequired( true );
541
542   // Emit a down signal
543   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
544   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
545   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
546   data.Reset();
547
548   // Emit a motion signal outside of actor, should be signalled with a Leave
549   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
550   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
551   DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
552   data.Reset();
553
554   // Another motion outside of actor, no signalling
555   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
556   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
557   data.Reset();
558
559   // Another motion event inside actor, signalled with motion
560   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
561   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
562   DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
563   data.Reset();
564
565   // We do not want to listen to leave events anymore
566   actor.SetLeaveRequired( false );
567
568   // Another motion event outside of actor, no signalling
569   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
570   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
571   data.Reset();
572   END_TEST;
573 }
574
575 int UtcDaliTouchLeaveParentConsumer(void)
576 {
577   TestApplication application;
578   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
579
580   Actor actor = Actor::New();
581   actor.SetSize(100.0f, 100.0f);
582   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
583   Stage::GetCurrent().Add(actor);
584
585   // Render and notify
586   application.SendNotification();
587   application.Render();
588
589   // Connect to actor's touched signal
590   SignalData data;
591   TouchEventFunctor functor( data, false );
592   actor.TouchedSignal().Connect( &application, functor );
593
594   // Connect to root actor's touched signal
595   SignalData rootData;
596   TouchEventFunctor rootFunctor( rootData ); // Consumes signal
597   rootActor.TouchedSignal().Connect( &application, rootFunctor );
598
599   // Set actor to require leave events
600   actor.SetLeaveRequired( true );
601   rootActor.SetLeaveRequired( true );
602
603   // Emit a down signal
604   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
605   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
606   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
607   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
608   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
609   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
610   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
611   data.Reset();
612   rootData.Reset();
613
614   // Emit a motion signal outside of actor, should be signalled with a Leave
615   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
616   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
617   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
618   DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
619   DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
620   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
621   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
622   data.Reset();
623   rootData.Reset();
624
625   // Another motion outside of actor, only rootActor signalled
626   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
627   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
628   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
629   DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
630   DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
631   data.Reset();
632   rootData.Reset();
633
634   // Another motion event inside actor, signalled with motion
635   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
636   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
637   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
638   DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
639   DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
640   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
641   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
642   data.Reset();
643   rootData.Reset();
644
645   // We do not want to listen to leave events of actor anymore
646   actor.SetLeaveRequired( false );
647
648   // Another motion event outside of root actor, only root signalled
649   Vector2 stageSize( Stage::GetCurrent().GetSize() );
650   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
651   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
652   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
653   DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
654   END_TEST;
655 }
656
657 int UtcDaliTouchActorBecomesInsensitive(void)
658 {
659   TestApplication application;
660
661   Actor actor = Actor::New();
662   actor.SetSize(100.0f, 100.0f);
663   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
664   Stage::GetCurrent().Add(actor);
665
666   // Render and notify
667   application.SendNotification();
668   application.Render();
669
670   // Connect to actor's touched signal
671   SignalData data;
672   TouchEventFunctor functor( data );
673   actor.TouchedSignal().Connect( &application, functor );
674
675   // Emit a down signal
676   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
677   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
678   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
679   data.Reset();
680
681   // Change actor to insensitive
682   actor.SetSensitive( false );
683
684   // Emit a motion signal, signalled with an interrupted
685   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
686   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
687   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
688   data.Reset();
689   END_TEST;
690 }
691
692 int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void)
693 {
694   TestApplication application;
695   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
696
697   Actor actor = Actor::New();
698   actor.SetSize(100.0f, 100.0f);
699   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
700   Stage::GetCurrent().Add(actor);
701
702   // Render and notify
703   application.SendNotification();
704   application.Render();
705
706   // Connect to actor's touched signal
707   SignalData data;
708   TouchEventFunctor functor( data, false );
709   actor.TouchedSignal().Connect( &application, functor );
710
711   // Connect to root actor's touched signal
712   SignalData rootData;
713   TouchEventFunctor rootFunctor( rootData ); // Consumes signal
714   rootActor.TouchedSignal().Connect( &application, rootFunctor );
715
716   // Emit a down signal
717   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
718   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
719   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
720   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
721   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
722   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
723   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
724   data.Reset();
725   rootData.Reset();
726
727   // Render and notify
728   application.SendNotification();
729   application.Render();
730
731   // Make root actor insensitive
732   rootActor.SetSensitive( false );
733
734   // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
735   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
736   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
737   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
738   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
739   DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
740   END_TEST;
741 }
742
743 int UtcDaliTouchMultipleLayers(void)
744 {
745   TestApplication application;
746   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
747
748   // Connect to actor's touched signal
749   SignalData data;
750   TouchEventFunctor functor( data );
751
752   Layer layer1 ( Layer::New() );
753   layer1.SetSize(100.0f, 100.0f);
754   layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
755   Stage::GetCurrent().Add( layer1 );
756
757   Actor actor1 ( Actor::New() );
758   actor1.SetSize( 100.0f, 100.0f );
759   actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
760   actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
761   layer1.Add( actor1 );
762
763   // Render and notify
764   application.SendNotification();
765   application.Render();
766
767   // Connect to layer1 and actor1
768   layer1.TouchedSignal().Connect( &application, functor );
769   actor1.TouchedSignal().Connect( &application, functor );
770
771   // Hit in hittable area, actor1 should be hit
772   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
773   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
774   DALI_TEST_CHECK( data.touchedActor == actor1 );
775   data.Reset();
776
777   // Make layer1 insensitive, nothing should be hit
778   layer1.SetSensitive( false );
779   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
780   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
781   data.Reset();
782
783   // Make layer1 sensitive again, again actor1 will be hit
784   layer1.SetSensitive( true );
785   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
786   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
787   DALI_TEST_CHECK( data.touchedActor == actor1 );
788   data.Reset();
789
790   // Make rootActor insensitive, nothing should be hit
791   rootActor.SetSensitive( false );
792   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
793   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
794   data.Reset();
795
796   // Make rootActor sensitive
797   rootActor.SetSensitive( true );
798
799   // Add another layer
800   Layer layer2 ( Layer::New() );
801   layer2.SetSize(100.0f, 100.0f );
802   layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
803   layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
804   Stage::GetCurrent().Add( layer2 );
805
806   Actor actor2 ( Actor::New() );
807   actor2.SetSize(100.0f, 100.0f);
808   actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
809   layer2.Add( actor2 );
810
811   // Render and notify
812   application.SendNotification();
813   application.Render();
814
815   // Connect to layer2 and actor2
816   layer2.TouchedSignal().Connect( &application, functor );
817   actor2.TouchedSignal().Connect( &application, functor );
818
819   // Emit an event, should hit layer2
820   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
821   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
822   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
823   data.Reset();
824
825   // Make layer2 insensitive, should hit actor1
826   layer2.SetSensitive( false );
827   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
828   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
829   DALI_TEST_CHECK( data.touchedActor == actor1 );
830   data.Reset();
831
832   // Make layer2 sensitive again, should hit layer2
833   layer2.SetSensitive( true );
834   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
835   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
836   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
837   data.Reset();
838
839   // Make layer2 invisible, render and notify
840   layer2.SetVisible( false );
841   application.SendNotification();
842   application.Render();
843
844   // Should hit actor1
845   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
846   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
847   DALI_TEST_CHECK( data.touchedActor == actor1 );
848   data.Reset();
849
850   // Make rootActor invisible, render and notify
851   rootActor.SetVisible( false );
852   application.SendNotification();
853   application.Render();
854
855   // Should not hit anything
856   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
857   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
858   data.Reset();
859   END_TEST;
860 }
861
862 int UtcDaliTouchMultipleRenderTasks(void)
863 {
864   TestApplication application;
865   Stage stage ( Stage::GetCurrent() );
866   Vector2 stageSize ( stage.GetSize() );
867
868   Actor actor = Actor::New();
869   actor.SetSize(100.0f, 100.0f);
870   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
871   stage.Add(actor);
872
873   // Create render task
874   Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
875   RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
876   renderTask.SetViewport( viewport );
877   renderTask.SetInputEnabled( true );
878
879   // Render and notify
880   application.SendNotification();
881   application.Render();
882
883   // Connect to actor's touched signal
884   SignalData data;
885   TouchEventFunctor functor( data );
886   actor.TouchedSignal().Connect( &application, functor );
887
888   // Emit a down signal
889   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
890   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
891   data.Reset();
892
893   // Ensure renderTask actor can be hit too.
894   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
895   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
896   data.Reset();
897
898   // Disable input on renderTask, should not be hittable
899   renderTask.SetInputEnabled( false );
900   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
901   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
902   data.Reset();
903   END_TEST;
904 }
905
906 int UtcDaliTouchMultipleRenderTasksWithChildLayer(void)
907 {
908   TestApplication application;
909   Stage stage ( Stage::GetCurrent() );
910   Vector2 stageSize ( stage.GetSize() );
911
912   Actor actor = Actor::New();
913   actor.SetSize(100.0f, 100.0f);
914   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
915   stage.Add(actor);
916
917   Layer layer = Layer::New();
918   layer.SetSize(100.0f, 100.0f);
919   layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
920   actor.Add(layer);
921
922   // Create render task
923   Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
924   RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
925   renderTask.SetViewport( viewport );
926   renderTask.SetInputEnabled( true );
927   renderTask.SetSourceActor( actor );
928
929   // Render and notify
930   application.SendNotification();
931   application.Render();
932
933   // Connect to layer's touched signal
934   SignalData data;
935   TouchEventFunctor functor( data );
936   actor.TouchedSignal().Connect( &application, functor );
937   layer.TouchedSignal().Connect( &application, functor );
938
939   // Emit a down signal
940   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
941   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
942   data.Reset();
943
944   // Ensure renderTask actor can be hit too.
945   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
946   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
947   data.Reset();
948
949   // Disable input on renderTask, should not be hittable
950   renderTask.SetInputEnabled( false );
951   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
952   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
953   data.Reset();
954   END_TEST;
955 }
956
957 int UtcDaliTouchOffscreenRenderTasks(void)
958 {
959   TestApplication application;
960   Stage stage ( Stage::GetCurrent() );
961   Vector2 stageSize ( stage.GetSize() );
962
963   // FrameBufferImage for offscreen RenderTask
964   FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
965
966   // Create a renderable actor to display the FrameBufferImage
967   Actor renderableActor = CreateRenderableActor( frameBufferImage );
968   renderableActor.SetParentOrigin(ParentOrigin::CENTER);
969   renderableActor.SetSize( stageSize.x, stageSize.y );
970   renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
971   stage.Add( renderableActor );
972
973   Actor actor = Actor::New();
974   actor.SetSize(100.0f, 100.0f);
975   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
976   stage.Add( actor );
977   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
978
979   stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
980
981   // Create a RenderTask
982   RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
983   renderTask.SetSourceActor( actor );
984   renderTask.SetTargetFrameBuffer( frameBufferImage );
985   renderTask.SetInputEnabled( true );
986
987   // Create another RenderTask
988   RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
989   renderTask2.SetInputEnabled( true );
990
991   // Render and notify
992   application.SendNotification();
993   application.Render();
994
995   // Connect to actor's touched signal
996   SignalData data;
997   TouchEventFunctor functor( data );
998   actor.TouchedSignal().Connect( &application, functor );
999
1000   // Emit a down signal
1001   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1002   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1003   data.Reset();
1004   END_TEST;
1005 }
1006
1007 int UtcDaliTouchRenderTaskWithExclusiveActor(void)
1008 {
1009   TestApplication application;
1010   auto stage = Stage::GetCurrent();
1011   auto stageSize( stage.GetSize() );
1012
1013   auto actor = CreateRenderableActor();
1014   actor.SetSize( stageSize.x, stageSize.y );
1015   stage.Add( actor );
1016
1017   auto renderTask = stage.GetRenderTaskList().CreateTask();
1018   renderTask.SetSourceActor( actor );
1019   renderTask.SetExclusive( true );
1020
1021   // Render and notify
1022   application.SendNotification();
1023   application.Render();
1024
1025   // Connect to actor's touched signal
1026   SignalData data;
1027   TouchEventFunctor functor( data );
1028   actor.TouchedSignal().Connect( &application, functor );
1029
1030   // Emit a down signal
1031   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1032   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1033   data.Reset();
1034
1035   END_TEST;
1036 }
1037
1038 int UtcDaliTouchMultipleRenderableActors(void)
1039 {
1040   TestApplication application;
1041   Stage stage ( Stage::GetCurrent() );
1042   Vector2 stageSize ( stage.GetSize() );
1043
1044   Actor parent = CreateRenderableActor();
1045   parent.SetSize(100.0f, 100.0f);
1046   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1047   stage.Add(parent);
1048
1049   Actor actor = CreateRenderableActor();
1050   actor.SetSize(100.0f, 100.0f);
1051   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1052   parent.Add(actor);
1053
1054   // Render and notify
1055   application.SendNotification();
1056   application.Render();
1057
1058   // Connect to layer's touched signal
1059   SignalData data;
1060   TouchEventFunctor functor( data );
1061   parent.TouchedSignal().Connect( &application, functor );
1062   actor.TouchedSignal().Connect( &application, functor );
1063
1064   // Emit a down signal
1065   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1066   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1067   DALI_TEST_CHECK( actor == data.touchedActor );
1068   END_TEST;
1069 }
1070
1071 int UtcDaliTouchActorRemovedInSignal(void)
1072 {
1073   TestApplication application;
1074
1075   Actor actor = Actor::New();
1076   actor.SetSize(100.0f, 100.0f);
1077   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1078   Stage::GetCurrent().Add(actor);
1079
1080   // Render and notify
1081   application.SendNotification();
1082   application.Render();
1083
1084   // Connect to actor's touched signal
1085   SignalData data;
1086   RemoveActorFunctor functor( data );
1087   actor.TouchedSignal().Connect( &application, functor );
1088
1089   // Register for leave events
1090   actor.SetLeaveRequired( true );
1091
1092   // Emit a down signal
1093   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1094   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1095   data.Reset();
1096
1097   // Re-add, render and notify
1098   Stage::GetCurrent().Add(actor);
1099   application.SendNotification();
1100   application.Render();
1101
1102   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1103   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1104   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1105   data.Reset();
1106
1107   // Emit a down signal
1108   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1109   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1110   data.Reset();
1111
1112   // Render and notify
1113   application.SendNotification();
1114   application.Render();
1115
1116   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1117   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1118   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1119   data.Reset();
1120
1121   // Re-add actor back to stage, render and notify
1122   Stage::GetCurrent().Add(actor);
1123   application.SendNotification();
1124   application.Render();
1125
1126   // Emit another down event
1127   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1128   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1129   data.Reset();
1130
1131   // Completely delete the actor
1132   actor.Reset();
1133
1134   // Emit event, should not crash and should not receive an event.
1135   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1136   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1137   END_TEST;
1138 }
1139
1140 int UtcDaliTouchActorSignalNotConsumed(void)
1141 {
1142   TestApplication application;
1143
1144   Actor actor = Actor::New();
1145   actor.SetSize(100.0f, 100.0f);
1146   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1147   Stage::GetCurrent().Add(actor);
1148
1149   // Render and notify
1150   application.SendNotification();
1151   application.Render();
1152
1153   // Connect to actor's touched signal
1154   SignalData data;
1155   TouchEventFunctor functor( data, false );
1156   actor.TouchedSignal().Connect( &application, functor );
1157
1158   // Emit a down signal
1159   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1160   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1161   END_TEST;
1162 }
1163
1164 int UtcDaliTouchActorUnStaged(void)
1165 {
1166   TestApplication application;
1167
1168   Actor actor = Actor::New();
1169   actor.SetSize(100.0f, 100.0f);
1170   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1171   Stage::GetCurrent().Add(actor);
1172
1173   // Render and notify
1174   application.SendNotification();
1175   application.Render();
1176
1177   // Connect to actor's touched signal
1178   SignalData data;
1179   TouchEventFunctor functor( data );
1180   actor.TouchedSignal().Connect( &application, functor );
1181
1182   // Emit a down signal
1183   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1184   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1185   data.Reset();
1186
1187   // Remove actor from stage
1188   Stage::GetCurrent().Remove( actor );
1189   data.Reset();
1190
1191   // Render and notify
1192   application.SendNotification();
1193   application.Render();
1194
1195   // Emit a move at the same point, we should not be signalled.
1196   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1197   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1198   data.Reset();
1199   END_TEST;
1200 }
1201
1202 int UtcDaliTouchLayerConsumesTouch(void)
1203 {
1204   TestApplication application;
1205
1206   Actor actor = Actor::New();
1207   actor.SetSize(100.0f, 100.0f);
1208   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1209   Stage::GetCurrent().Add(actor);
1210
1211   // Render and notify
1212   application.SendNotification();
1213   application.Render();
1214
1215   // Connect to actor's touched signal
1216   SignalData data;
1217   TouchEventFunctor functor( data );
1218   actor.TouchedSignal().Connect( &application, functor );
1219
1220   // Add a layer to overlap the actor
1221   Layer layer = Layer::New();
1222   layer.SetSize(100.0f, 100.0f);
1223   layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1224   Stage::GetCurrent().Add( layer );
1225   layer.RaiseToTop();
1226
1227   // Render and notify
1228   application.SendNotification();
1229   application.Render();
1230
1231   // Emit a few touch signals
1232   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1233   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1234   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1235   data.Reset();
1236
1237   // Set layer to consume all touch
1238   layer.SetTouchConsumed( true );
1239
1240   // Render and notify
1241   application.SendNotification();
1242   application.Render();
1243
1244   // Emit the same signals again, should not receive
1245   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1246   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1247   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1248   data.Reset();
1249
1250   END_TEST;
1251 }
1252
1253 int UtcDaliTouchLeaveActorReadded(void)
1254 {
1255   TestApplication application;
1256   Stage stage = Stage::GetCurrent();
1257
1258   Actor actor = Actor::New();
1259   actor.SetSize(100.0f, 100.0f);
1260   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1261   stage.Add(actor);
1262
1263   // Set actor to receive touch-events
1264   actor.SetLeaveRequired( true );
1265
1266   // Render and notify
1267   application.SendNotification();
1268   application.Render();
1269
1270   // Connect to actor's touched signal
1271   SignalData data;
1272   TouchEventFunctor functor( data );
1273   actor.TouchedSignal().Connect( &application, functor );
1274
1275   // Emit a down and motion
1276   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1277   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) );
1278   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1279   data.Reset();
1280
1281   // Remove actor from stage and add again
1282   stage.Remove( actor );
1283   stage.Add( actor );
1284
1285   // Emit a motion within the actor's bounds
1286   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) );
1287   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1288   data.Reset();
1289
1290   // Emit a motion outside the actor's bounds
1291   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) );
1292   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1293   DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
1294   data.Reset();
1295
1296   END_TEST;
1297 }
1298
1299 int UtcDaliTouchClippingActor(void)
1300 {
1301   TestApplication application;
1302   Stage stage = Stage::GetCurrent();
1303
1304   Actor actor = Actor::New();
1305   actor.SetSize( 100.0f, 100.0f );
1306   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1307   stage.Add( actor );
1308
1309   Actor clippingActor = Actor::New();
1310   clippingActor.SetSize( 50.0f, 50.0f );
1311   clippingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1312   clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1313   stage.Add( clippingActor );
1314
1315   // Add a child to the clipped region.
1316   Actor clippingChild = Actor::New();
1317   clippingChild.SetSize( 50.0f, 50.0f );
1318   clippingChild.SetPosition( 25.0f, 25.0f );
1319   clippingChild.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1320   clippingActor.Add( clippingChild );
1321
1322   // Render and notify.
1323   application.SendNotification();
1324   application.Render();
1325
1326   // Connect to actor's touched signal.
1327   SignalData data;
1328   TouchEventFunctor functor( data );
1329   actor.TouchedSignal().Connect( &application, functor );
1330
1331   // Emit an event within clipped area - no hit.
1332   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1333   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1334   data.Reset();
1335
1336   // Emit an event outside the clipped area but within the actor area, we should have a hit.
1337   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
1338   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1339   data.Reset();
1340
1341   clippingChild.TouchedSignal().Connect( &application, functor );
1342
1343   // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1344   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 30.0f, 30.0f ) ) );
1345   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1346   data.Reset();
1347
1348   END_TEST;
1349 }
1350
1351 int UtcDaliTouchActorUnstaged(void)
1352 {
1353   TestApplication application;
1354
1355   Actor actor = Actor::New();
1356   actor.SetSize(100.0f, 100.0f);
1357   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1358   Stage::GetCurrent().Add(actor);
1359
1360   // Render and notify
1361   application.SendNotification();
1362   application.Render();
1363
1364   // Connect to actor's touched signal
1365   SignalData data;
1366   TouchEventFunctor functor( data );
1367   actor.TouchedSignal().Connect( &application, functor );
1368
1369   // Emit a down signal
1370   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1371   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1372   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1373   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1374   data.Reset();
1375
1376   // Render and notify
1377   application.SendNotification();
1378   application.Render();
1379
1380   // Unparent the actor
1381   actor.Unparent();
1382
1383   // Should receive an interrupted event
1384   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1385   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1386   END_TEST;
1387 }
1388
1389 int UtcDaliTouchParentUnstaged(void)
1390 {
1391   TestApplication application;
1392
1393   Actor parent = Actor::New();
1394   parent.SetSize(100.0f, 100.0f);
1395   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1396   Stage::GetCurrent().Add(parent);
1397
1398   Actor actor = Actor::New();
1399   actor.SetSize(100.0f, 100.0f);
1400   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1401   parent.Add(actor);
1402
1403   // Render and notify
1404   application.SendNotification();
1405   application.Render();
1406
1407   // Connect to actor's touched signal
1408   SignalData data;
1409   TouchEventFunctor functor( data );
1410   actor.TouchedSignal().Connect( &application, functor );
1411
1412   // Emit a down signal
1413   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1414   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1415   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1416   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1417   data.Reset();
1418
1419   // Render and notify
1420   application.SendNotification();
1421   application.Render();
1422
1423   // Unparent the parent of the touchable actor
1424   parent.Unparent();
1425
1426   // Should receive an interrupted event
1427   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1428   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1429   END_TEST;
1430 }
1431
1432 int UtcDaliTouchActorUnstagedDifferentConsumer(void)
1433 {
1434   TestApplication application;
1435
1436   Actor parent = Actor::New();
1437   parent.SetSize(100.0f, 100.0f);
1438   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1439   Stage::GetCurrent().Add(parent);
1440
1441   Actor actor = Actor::New();
1442   actor.SetSize(100.0f, 100.0f);
1443   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1444   parent.Add(actor);
1445
1446   // Render and notify
1447   application.SendNotification();
1448   application.Render();
1449
1450   // Connect to actor's touched signal
1451   SignalData data;
1452   TouchEventFunctor functor( data, false /* Do not consume */ );
1453   actor.TouchedSignal().Connect( &application, functor );
1454
1455   // Connect to parent's touched signal
1456   SignalData parentData;
1457   TouchEventFunctor parentFunctor( parentData );
1458   parent.TouchedSignal().Connect( &application, parentFunctor );
1459
1460   // Emit a down signal
1461   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1462   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1463   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1464   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1465   DALI_TEST_CHECK( actor == data.touchedActor );
1466   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1467   DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1468   DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1469   DALI_TEST_CHECK( parent == parentData.touchedActor );
1470   data.Reset();
1471   parentData.Reset();
1472
1473   // Render and notify
1474   application.SendNotification();
1475   application.Render();
1476
1477   // Unparent the actor
1478   actor.Unparent();
1479
1480   // Should receive an interrupted event for both actor & parent
1481   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1482   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1483   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1484   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1485   data.Reset();
1486   parentData.Reset();
1487
1488   // Readd actor to parent
1489   parent.Add(actor);
1490
1491   // Render and notify
1492   application.SendNotification();
1493   application.Render();
1494
1495   // Emit a motion signal
1496   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1497   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1498   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1499   data.Reset();
1500   parentData.Reset();
1501
1502   // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1503   SignalData secondData;
1504   TouchEventFunctor secondFunctor( secondData /* Consume */ );
1505   actor.TouchedSignal().Connect( &application, secondFunctor );
1506
1507   // Unparent the actor
1508   actor.Unparent();
1509
1510   // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1511   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1512   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1513   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1514   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1515   DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1516   DALI_TEST_EQUALS( TouchPoint::Interrupted, secondData.touchEvent.points[0].state, TEST_LOCATION );
1517   data.Reset();
1518   parentData.Reset();
1519   secondData.Reset();
1520
1521   END_TEST;
1522 }
1523
1524 int UtcDaliTouchInterruptedDifferentConsumer(void)
1525 {
1526   TestApplication application;
1527   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1528
1529   Actor parent = Actor::New();
1530   parent.SetSize(100.0f, 100.0f);
1531   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1532   Stage::GetCurrent().Add(parent);
1533
1534   Actor actor = Actor::New();
1535   actor.SetSize(100.0f, 100.0f);
1536   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1537   parent.Add(actor);
1538
1539   // Render and notify
1540   application.SendNotification();
1541   application.Render();
1542
1543   // Connect to actor's touched signal
1544   SignalData data;
1545   TouchEventFunctor functor( data, false /* Do not consume */ );
1546   actor.TouchedSignal().Connect( &application, functor );
1547
1548   // Connect to parent's touched signal
1549   SignalData parentData;
1550   TouchEventFunctor parentFunctor( parentData, false /* Do not consume */ );
1551   parent.TouchedSignal().Connect( &application, parentFunctor );
1552
1553   // Connect to root's touched signal and consume
1554   SignalData rootData;
1555   TouchEventFunctor rootFunctor( rootData );
1556   rootActor.TouchedSignal().Connect( &application, rootFunctor );
1557
1558   // Emit a down signal
1559   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1560   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1561   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1562   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1563   DALI_TEST_CHECK( actor == data.touchedActor );
1564   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1565   DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1566   DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1567   DALI_TEST_CHECK( parent == parentData.touchedActor );
1568   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1569   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
1570   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
1571   DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1572   data.Reset();
1573   parentData.Reset();
1574   rootData.Reset();
1575
1576   // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1577   SignalData secondData;
1578   TouchEventFunctor secondFunctor( secondData /* Consume */ );
1579   parent.TouchedSignal().Connect( &application, secondFunctor );
1580
1581   // Emit an interrupted signal, all three should STILL be called
1582   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 10.0f, 10.0f ) ) );
1583   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1584   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1585   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1586   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1587   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1588   DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
1589   data.Reset();
1590   parentData.Reset();
1591   rootData.Reset();
1592
1593   END_TEST;
1594 }
1595
1596 int UtcDaliTouchDataConvert(void)
1597 {
1598   TestApplication application;
1599
1600   Actor actor = Actor::New();
1601   actor.SetSize(100.0f, 100.0f);
1602   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1603   Stage::GetCurrent().Add(actor);
1604
1605   // Render and notify
1606   application.SendNotification();
1607   application.Render();
1608
1609   // Connect to actor's touch signal
1610   SignalData data;
1611   TouchEventFunctor functor(data);
1612   actor.TouchedSignal().Connect(&application, functor);
1613
1614   Vector2 screenCoordiantes(10.0f, 10.0f);
1615   Vector2 localCoordinates;
1616   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordiantes.x, screenCoordiantes.y);
1617
1618   // Emit a down signal
1619   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordiantes));
1620   Dali::TouchData touchData = Dali::DevelTouchData::Convert(data.touchEvent);
1621
1622   DALI_TEST_EQUALS( 1u, touchData.GetPointCount(), TEST_LOCATION );
1623   DALI_TEST_EQUALS( screenCoordiantes, touchData.GetScreenPosition(0), TEST_LOCATION );
1624   DALI_TEST_EQUALS( localCoordinates, touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
1625   DALI_TEST_EQUALS( PointState::DOWN, touchData.GetState(0), TEST_LOCATION );
1626   DALI_TEST_EQUALS( actor, touchData.GetHitActor(0), TEST_LOCATION );
1627
1628   data.Reset();
1629
1630   END_TEST;
1631
1632 }