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