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