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