Merge branch devel/master (1.0.49) 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 an image actor to display the FrameBufferImage
960   ImageActor imageActor ( ImageActor::New( frameBufferImage ) );
961   imageActor.SetParentOrigin(ParentOrigin::CENTER);
962   imageActor.SetSize( stageSize.x, stageSize.y );
963   imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
964   stage.Add( imageActor );
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   ImageActor parent = ImageActor::New();
1007   parent.SetSize(100.0f, 100.0f);
1008   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1009   stage.Add(parent);
1010
1011   ImageActor actor = ImageActor::New();
1012   actor.SetSize(100.0f, 100.0f);
1013   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1014   actor.SetSortModifier( 1.0f );
1015   parent.Add(actor);
1016
1017   // Render and notify
1018   application.SendNotification();
1019   application.Render();
1020
1021   // Connect to layer's touched signal
1022   SignalData data;
1023   TouchEventFunctor functor( data );
1024   parent.TouchedSignal().Connect( &application, functor );
1025   actor.TouchedSignal().Connect( &application, functor );
1026
1027   // Emit a down signal
1028   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1029   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1030   DALI_TEST_CHECK( actor == data.touchedActor );
1031   END_TEST;
1032 }
1033
1034 int UtcDaliTouchActorRemovedInSignal(void)
1035 {
1036   TestApplication application;
1037
1038   Actor actor = Actor::New();
1039   actor.SetSize(100.0f, 100.0f);
1040   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1041   Stage::GetCurrent().Add(actor);
1042
1043   // Render and notify
1044   application.SendNotification();
1045   application.Render();
1046
1047   // Connect to actor's touched signal
1048   SignalData data;
1049   RemoveActorFunctor functor( data );
1050   actor.TouchedSignal().Connect( &application, functor );
1051
1052   // Register for leave events
1053   actor.SetLeaveRequired( true );
1054
1055   // Emit a down signal
1056   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1057   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1058   data.Reset();
1059
1060   // Re-add, render and notify
1061   Stage::GetCurrent().Add(actor);
1062   application.SendNotification();
1063   application.Render();
1064
1065   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1066   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1067   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1068   data.Reset();
1069
1070   // Emit a down signal
1071   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1072   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1073   data.Reset();
1074
1075   // Render and notify
1076   application.SendNotification();
1077   application.Render();
1078
1079   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1080   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1081   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1082   data.Reset();
1083
1084   // Re-add actor back to stage, render and notify
1085   Stage::GetCurrent().Add(actor);
1086   application.SendNotification();
1087   application.Render();
1088
1089   // Emit another down event
1090   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1091   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1092   data.Reset();
1093
1094   // Completely delete the actor
1095   actor.Reset();
1096
1097   // Emit event, should not crash and should not receive an event.
1098   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1099   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1100   END_TEST;
1101 }
1102
1103 int UtcDaliTouchActorSignalNotConsumed(void)
1104 {
1105   TestApplication application;
1106
1107   Actor actor = Actor::New();
1108   actor.SetSize(100.0f, 100.0f);
1109   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1110   Stage::GetCurrent().Add(actor);
1111
1112   // Render and notify
1113   application.SendNotification();
1114   application.Render();
1115
1116   // Connect to actor's touched signal
1117   SignalData data;
1118   TouchEventFunctor functor( data, false );
1119   actor.TouchedSignal().Connect( &application, functor );
1120
1121   // Emit a down signal
1122   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1123   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1124   END_TEST;
1125 }
1126
1127 int UtcDaliTouchActorUnStaged(void)
1128 {
1129   TestApplication application;
1130
1131   Actor actor = Actor::New();
1132   actor.SetSize(100.0f, 100.0f);
1133   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1134   Stage::GetCurrent().Add(actor);
1135
1136   // Render and notify
1137   application.SendNotification();
1138   application.Render();
1139
1140   // Connect to actor's touched signal
1141   SignalData data;
1142   TouchEventFunctor functor( data );
1143   actor.TouchedSignal().Connect( &application, functor );
1144
1145   // Emit a down signal
1146   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1147   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1148   data.Reset();
1149
1150   // Remove actor from stage
1151   Stage::GetCurrent().Remove( actor );
1152   data.Reset();
1153
1154   // Render and notify
1155   application.SendNotification();
1156   application.Render();
1157
1158   // Emit a move at the same point, we should not be signalled.
1159   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1160   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1161   data.Reset();
1162   END_TEST;
1163 }
1164
1165 int UtcDaliTouchSystemOverlayActor(void)
1166 {
1167   TestApplication application;
1168   Dali::Integration::Core& core( application.GetCore() );
1169   Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1170   systemOverlay.GetOverlayRenderTasks().CreateTask();
1171
1172   // Create an actor and add it to the system overlay.
1173   Actor systemActor = Actor::New();
1174   systemActor.SetSize(100.0f, 100.0f);
1175   systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1176   systemOverlay.Add( systemActor );
1177
1178   // Create an actor and add it to the stage as per normal, same position and size as systemActor
1179   Actor actor = Actor::New();
1180   actor.SetSize(100.0f, 100.0f);
1181   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1182   Stage::GetCurrent().Add(actor);
1183
1184   // Connect to the touch signals.
1185   SignalData data;
1186   TouchEventFunctor functor( data );
1187   systemActor.TouchedSignal().Connect( &application, functor );
1188   actor.TouchedSignal().Connect( &application, functor );
1189
1190   // Render and notify
1191   application.SendNotification();
1192   application.Render();
1193
1194   // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1195   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1196   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1197   DALI_TEST_CHECK( systemActor == data.touchedActor );
1198   END_TEST;
1199 }
1200
1201 int UtcDaliTouchLayerConsumesTouch(void)
1202 {
1203   TestApplication application;
1204
1205   Actor actor = Actor::New();
1206   actor.SetSize(100.0f, 100.0f);
1207   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1208   Stage::GetCurrent().Add(actor);
1209
1210   // Render and notify
1211   application.SendNotification();
1212   application.Render();
1213
1214   // Connect to actor's touched signal
1215   SignalData data;
1216   TouchEventFunctor functor( data );
1217   actor.TouchedSignal().Connect( &application, functor );
1218
1219   // Add a layer to overlap the actor
1220   Layer layer = Layer::New();
1221   layer.SetSize(100.0f, 100.0f);
1222   layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1223   Stage::GetCurrent().Add( layer );
1224   layer.RaiseToTop();
1225
1226   // Render and notify
1227   application.SendNotification();
1228   application.Render();
1229
1230   // Emit a few touch signals
1231   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1232   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1233   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1234   data.Reset();
1235
1236   // Set layer to consume all touch
1237   layer.SetTouchConsumed( true );
1238
1239   // Render and notify
1240   application.SendNotification();
1241   application.Render();
1242
1243   // Emit the same signals again, should not receive
1244   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1245   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1246   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1247   data.Reset();
1248
1249   END_TEST;
1250 }
1251
1252 int UtcDaliTouchLeaveActorReadded(void)
1253 {
1254   TestApplication application;
1255   Stage stage = Stage::GetCurrent();
1256
1257   Actor actor = Actor::New();
1258   actor.SetSize(100.0f, 100.0f);
1259   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1260   stage.Add(actor);
1261
1262   // Set actor to receive touch-events
1263   actor.SetLeaveRequired( true );
1264
1265   // Render and notify
1266   application.SendNotification();
1267   application.Render();
1268
1269   // Connect to actor's touched signal
1270   SignalData data;
1271   TouchEventFunctor functor( data );
1272   actor.TouchedSignal().Connect( &application, functor );
1273
1274   // Emit a down and motion
1275   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1276   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) );
1277   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1278   data.Reset();
1279
1280   // Remove actor from stage and add again
1281   stage.Remove( actor );
1282   stage.Add( actor );
1283
1284   // Emit a motion within the actor's bounds
1285   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) );
1286   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1287   data.Reset();
1288
1289   // Emit a motion outside the actor's bounds
1290   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) );
1291   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1292   DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
1293   data.Reset();
1294
1295   END_TEST;
1296 }
1297
1298 int UtcDaliTouchStencilNonRenderableActor(void)
1299 {
1300   TestApplication application;
1301   Stage stage = Stage::GetCurrent();
1302
1303   Actor actor = Actor::New();
1304   actor.SetSize(100.0f, 100.0f);
1305   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1306   stage.Add(actor);
1307
1308   Actor stencil = Actor::New();
1309   stencil.SetSize(50.0f, 50.0f);
1310   stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1311   stencil.SetDrawMode( DrawMode::STENCIL );
1312   stage.Add(stencil);
1313
1314   // Render and notify
1315   application.SendNotification();
1316   application.Render();
1317
1318   // Connect to actor's touched signal
1319   SignalData data;
1320   TouchEventFunctor functor( data );
1321   actor.TouchedSignal().Connect( &application, functor );
1322
1323   // Emit an event within stencil area
1324   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1325   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1326   data.Reset();
1327
1328   // Emit an event outside the stencil area but within the actor area, we should have a hit!
1329   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
1330   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1331   data.Reset();
1332
1333   END_TEST;
1334 }
1335
1336 int UtcDaliTouchActorUnstaged(void)
1337 {
1338   TestApplication application;
1339
1340   Actor actor = Actor::New();
1341   actor.SetSize(100.0f, 100.0f);
1342   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1343   Stage::GetCurrent().Add(actor);
1344
1345   // Render and notify
1346   application.SendNotification();
1347   application.Render();
1348
1349   // Connect to actor's touched signal
1350   SignalData data;
1351   TouchEventFunctor functor( data );
1352   actor.TouchedSignal().Connect( &application, functor );
1353
1354   // Emit a down signal
1355   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1356   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1357   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1358   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1359   data.Reset();
1360
1361   // Render and notify
1362   application.SendNotification();
1363   application.Render();
1364
1365   // Unparent the actor
1366   actor.Unparent();
1367
1368   // Should receive an interrupted event
1369   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1370   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1371   END_TEST;
1372 }
1373
1374 int UtcDaliTouchParentUnstaged(void)
1375 {
1376   TestApplication application;
1377
1378   Actor parent = Actor::New();
1379   parent.SetSize(100.0f, 100.0f);
1380   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1381   Stage::GetCurrent().Add(parent);
1382
1383   Actor actor = Actor::New();
1384   actor.SetSize(100.0f, 100.0f);
1385   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1386   parent.Add(actor);
1387
1388   // Render and notify
1389   application.SendNotification();
1390   application.Render();
1391
1392   // Connect to actor's touched signal
1393   SignalData data;
1394   TouchEventFunctor functor( data );
1395   actor.TouchedSignal().Connect( &application, functor );
1396
1397   // Emit a down signal
1398   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1399   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1400   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1401   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1402   data.Reset();
1403
1404   // Render and notify
1405   application.SendNotification();
1406   application.Render();
1407
1408   // Unparent the parent of the touchable actor
1409   parent.Unparent();
1410
1411   // Should receive an interrupted event
1412   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1413   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1414   END_TEST;
1415 }
1416
1417 int UtcDaliTouchActorUnstagedDifferentConsumer(void)
1418 {
1419   TestApplication application;
1420
1421   Actor parent = Actor::New();
1422   parent.SetSize(100.0f, 100.0f);
1423   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1424   Stage::GetCurrent().Add(parent);
1425
1426   Actor actor = Actor::New();
1427   actor.SetSize(100.0f, 100.0f);
1428   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1429   parent.Add(actor);
1430
1431   // Render and notify
1432   application.SendNotification();
1433   application.Render();
1434
1435   // Connect to actor's touched signal
1436   SignalData data;
1437   TouchEventFunctor functor( data, false /* Do not consume */ );
1438   actor.TouchedSignal().Connect( &application, functor );
1439
1440   // Connect to parent's touched signal
1441   SignalData parentData;
1442   TouchEventFunctor parentFunctor( parentData );
1443   parent.TouchedSignal().Connect( &application, parentFunctor );
1444
1445   // Emit a down signal
1446   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1447   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1448   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1449   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1450   DALI_TEST_CHECK( actor == data.touchedActor );
1451   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1452   DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1453   DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1454   DALI_TEST_CHECK( parent == parentData.touchedActor );
1455   data.Reset();
1456   parentData.Reset();
1457
1458   // Render and notify
1459   application.SendNotification();
1460   application.Render();
1461
1462   // Unparent the actor
1463   actor.Unparent();
1464
1465   // Should receive an interrupted event for both actor & parent
1466   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1467   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1468   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1469   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1470   data.Reset();
1471   parentData.Reset();
1472
1473   // Readd actor to parent
1474   parent.Add(actor);
1475
1476   // Render and notify
1477   application.SendNotification();
1478   application.Render();
1479
1480   // Emit a motion signal
1481   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1482   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1483   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1484   data.Reset();
1485   parentData.Reset();
1486
1487   // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1488   SignalData secondData;
1489   TouchEventFunctor secondFunctor( secondData /* Consume */ );
1490   actor.TouchedSignal().Connect( &application, secondFunctor );
1491
1492   // Unparent the actor
1493   actor.Unparent();
1494
1495   // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1496   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1497   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1498   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1499   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1500   DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1501   DALI_TEST_EQUALS( TouchPoint::Interrupted, secondData.touchEvent.points[0].state, TEST_LOCATION );
1502   data.Reset();
1503   parentData.Reset();
1504   secondData.Reset();
1505
1506   END_TEST;
1507 }
1508
1509 int UtcDaliTouchInterruptedDifferentConsumer(void)
1510 {
1511   TestApplication application;
1512   Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1513
1514   Actor parent = Actor::New();
1515   parent.SetSize(100.0f, 100.0f);
1516   parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1517   Stage::GetCurrent().Add(parent);
1518
1519   Actor actor = Actor::New();
1520   actor.SetSize(100.0f, 100.0f);
1521   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1522   parent.Add(actor);
1523
1524   // Render and notify
1525   application.SendNotification();
1526   application.Render();
1527
1528   // Connect to actor's touched signal
1529   SignalData data;
1530   TouchEventFunctor functor( data, false /* Do not consume */ );
1531   actor.TouchedSignal().Connect( &application, functor );
1532
1533   // Connect to parent's touched signal
1534   SignalData parentData;
1535   TouchEventFunctor parentFunctor( parentData, false /* Do not consume */ );
1536   parent.TouchedSignal().Connect( &application, parentFunctor );
1537
1538   // Connect to root's touched signal and consume
1539   SignalData rootData;
1540   TouchEventFunctor rootFunctor( rootData );
1541   rootActor.TouchedSignal().Connect( &application, rootFunctor );
1542
1543   // Emit a down signal
1544   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1545   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1546   DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1547   DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1548   DALI_TEST_CHECK( actor == data.touchedActor );
1549   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1550   DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1551   DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1552   DALI_TEST_CHECK( parent == parentData.touchedActor );
1553   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1554   DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
1555   DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
1556   DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1557   data.Reset();
1558   parentData.Reset();
1559   rootData.Reset();
1560
1561   // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1562   SignalData secondData;
1563   TouchEventFunctor secondFunctor( secondData /* Consume */ );
1564   parent.TouchedSignal().Connect( &application, secondFunctor );
1565
1566   // Emit an interrupted signal, all three should STILL be called
1567   application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 10.0f, 10.0f ) ) );
1568   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1569   DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1570   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1571   DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1572   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1573   DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
1574   data.Reset();
1575   parentData.Reset();
1576   rootData.Reset();
1577
1578   END_TEST;
1579 }