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