Revert "Revert "Removed TouchEvent from actor & stage""
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TouchDataProcessing.cpp
1 /*
2  * Copyright (c) 2020 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/events/touch-data-integ.h>
24 #include <dali/integration-api/render-task-list-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <dali/devel-api/actors/actor-devel.h>
27
28 using namespace Dali;
29
30 void utc_dali_touch_data_processing_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_touch_data_processing_cleanup(void)
36 {
37   test_return_value = TET_PASS;
38 }
39
40 ///////////////////////////////////////////////////////////////////////////////
41
42 namespace
43 {
44 struct TestPoint
45 {
46   int32_t deviceId;
47   PointState::Type state;
48   Actor hitActor;
49   Vector2 local;
50   Vector2 screen;
51   float radius;
52   Vector2 ellipseRadius;
53   float pressure;
54   Degree angle;
55   Device::Class::Type deviceClass;
56   Device::Subclass::Type deviceSubclass;
57
58   TestPoint()
59   : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
60   {
61   }
62   static const TestPoint ZERO;
63 };
64
65 const TestPoint TestPoint::ZERO;
66
67
68 // Stores data that is populated in the callback and will be read by the TET cases
69 struct SignalData
70 {
71   SignalData()
72   : functorCalled( false ),
73     touchData(),
74     touchedActor()
75   {
76   }
77
78   struct TestTouchData
79   {
80     unsigned long time;
81     std::vector<TestPoint> points;
82
83     const TestPoint& GetPoint(size_t i)
84     {
85       if( i < points.size() )
86       {
87         return points[i];
88       }
89       return TestPoint::ZERO;
90     }
91     size_t GetPointCount()
92     {
93       return points.size();
94     }
95   };
96
97   void Reset()
98   {
99     functorCalled = false;
100
101     touchData.time = 0u;
102     touchData.points.clear();
103
104     touchedActor.Reset();
105   }
106
107   bool functorCalled;
108   TestTouchData touchData;
109   Actor touchedActor;
110 };
111
112 // Functor that sets the data when called
113 struct TouchDataFunctor
114 {
115   /**
116    * Constructor.
117    * @param[in]  data         Reference to the data to store callback information.
118    * @param[in]  returnValue  What the functor should return.
119    */
120   TouchDataFunctor( SignalData& data, bool returnValue = true )
121   : signalData( data ),
122     returnValue( returnValue )
123   {
124   }
125
126   bool operator()( Actor actor, const TouchData& touchData )
127   {
128     signalData.functorCalled = true;
129     signalData.touchedActor = actor;
130
131     signalData.touchData.time = touchData.GetTime();
132     signalData.touchData.points.clear();
133
134     for( size_t i=0; i<touchData.GetPointCount(); ++i )
135     {
136       TestPoint p;
137       p.deviceId = touchData.GetDeviceId(i);
138       p.state = touchData.GetState(i);
139       p.hitActor = touchData.GetHitActor(i);
140       p.local = touchData.GetLocalPosition(i);
141       p.screen = touchData.GetScreenPosition(i);
142       p.radius = touchData.GetRadius(i);
143       p.ellipseRadius = touchData.GetEllipseRadius(i);
144       p.pressure = touchData.GetPressure(i);
145       p.angle = touchData.GetAngle(i);
146       p.deviceClass = touchData.GetDeviceClass(i);
147       p.deviceSubclass = touchData.GetDeviceSubclass(i);
148       signalData.touchData.points.push_back(p);
149     }
150
151     return returnValue;
152   }
153
154   SignalData& signalData;
155   bool returnValue;
156 };
157
158 struct HandleData
159 {
160   bool signalReceived;
161   TouchData touchData;
162
163   HandleData()
164   : signalReceived(false)
165   {
166   }
167 };
168
169 struct TouchDataHandleFunctor
170 {
171   /**
172    * Constructor.
173    * @param[in]  data         Reference to the data to store callback information.
174    * @param[in]  returnValue  What the functor should return.
175    */
176   TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
177   : handleData(handleData),
178     returnValue( returnValue )
179   {
180   }
181
182   bool operator()( Actor actor, const TouchData& someTouchData )
183   {
184     handleData.signalReceived = true;
185     TouchData handle(someTouchData);
186     handleData.touchData = handle;
187     return returnValue;
188   }
189
190   HandleData& handleData;
191   bool returnValue;
192 };
193
194
195 // Functor that removes the actor when called.
196 struct RemoveActorFunctor : public TouchDataFunctor
197 {
198   /**
199    * Constructor.
200    * @param[in]  data         Reference to the data to store callback information.
201    * @param[in]  returnValue  What the functor should return.
202    */
203   RemoveActorFunctor( SignalData& data, bool returnValue = true )
204   : TouchDataFunctor( data, returnValue )
205   {
206   }
207
208   bool operator()( Actor actor, const TouchData& touchData )
209   {
210     Actor parent( actor.GetParent() );
211     if ( parent )
212     {
213       parent.Remove( actor );
214     }
215
216     return TouchDataFunctor::operator()( actor, touchData );
217   }
218 };
219
220 struct OutOfBoundsData
221 {
222   TestPoint point;
223   bool functorCalled;
224
225   OutOfBoundsData()
226   :functorCalled(false)
227   {
228   }
229 };
230
231 // Functor that reads out of bounds data when called
232 struct OutOfBoundsFunctor
233 {
234   /**
235    * Constructor.
236    * @param[in]  data         Reference to the data to store callback information.
237    * @param[in]  returnValue  What the functor should return.
238    */
239   OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
240   : outOfBoundsData ( data ),
241     returnValue( returnValue )
242   {
243   }
244
245   bool operator()( Actor actor, const TouchData& touchData )
246   {
247     outOfBoundsData.functorCalled = true;
248     size_t count = touchData.GetPointCount();
249
250     // Read out of bounds data
251     outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
252     outOfBoundsData.point.state = touchData.GetState(count+1);
253     outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
254     outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
255     outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
256
257     return returnValue;
258   }
259
260   OutOfBoundsData& outOfBoundsData;
261   bool returnValue;
262 };
263
264 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
265 {
266   Integration::TouchEvent touchEvent;
267   Integration::Point point;
268   point.SetState( state );
269   point.SetScreenPosition( screenPosition );
270   point.SetDeviceClass( Device::Class::TOUCH );
271   point.SetDeviceSubclass( Device::Subclass::NONE );
272   touchEvent.points.push_back( point );
273   return touchEvent;
274 }
275
276 } // anon namespace
277
278 ///////////////////////////////////////////////////////////////////////////////
279
280 int UtcDaliTouchDataNormalProcessing01(void)
281 {
282   TestApplication application;
283
284   Actor actor = Actor::New();
285   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
286   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
287   application.GetScene().Add(actor);
288
289   // Render and notify
290   application.SendNotification();
291   application.Render();
292
293   // Connect to actor's touch signal
294   SignalData data;
295   TouchDataFunctor functor( data );
296   actor.TouchSignal().Connect( &application, functor );
297
298   Vector2 screenCoordinates( 10.0f, 10.0f );
299   Vector2 localCoordinates;
300   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
301
302   // Emit a down signal
303   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
304   const TestPoint *point1 = &data.touchData.GetPoint(0);
305   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
306   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
307   DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
308   DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
309   DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
310   data.Reset();
311
312   // Emit a motion signal
313   screenCoordinates.x = screenCoordinates.y = 11.0f;
314   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
315   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
316   const TestPoint *point2 = &data.touchData.GetPoint(0);
317   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
318   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
319   DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
320   DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
321   DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
322   data.Reset();
323
324   // Emit an up signal
325   screenCoordinates.x = screenCoordinates.y = 12.0f;
326   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
327   application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
328   const TestPoint *point3 = &data.touchData.GetPoint(0);
329   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
330   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
331   DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
332   DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
333   DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
334   data.Reset();
335
336   // Emit a down signal where the actor is not present
337   screenCoordinates.x = screenCoordinates.y = 200.0f;
338   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
339   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
340   END_TEST;
341 }
342
343
344 int UtcDaliTouchDataNormalProcessing02(void)
345 {
346   TestApplication application;
347
348   Actor actor = Actor::New();
349   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
350   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
351   application.GetScene().Add(actor);
352
353   // Render and notify
354   application.SendNotification();
355   application.Render();
356
357   // Connect to actor's touched signal
358   HandleData handleData;
359   TouchDataHandleFunctor functor( handleData );
360   actor.TouchSignal().Connect( &application, functor );
361
362   Vector2 screenCoordinates( 10.0f, 10.0f );
363   Vector2 localCoordinates;
364   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
365
366   // Emit a down signal
367   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
368   DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
369   DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
370   DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
371   DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
372   DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
373
374   END_TEST;
375 }
376
377
378 int UtcDaliTouchDataAPINegative(void)
379 {
380   TestApplication application;
381
382   Actor actor = Actor::New();
383   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
384   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
385   application.GetScene().Add(actor);
386
387   // Render and notify
388   application.SendNotification();
389   application.Render();
390
391   // Connect to actor's touched signal
392   OutOfBoundsData data;
393   OutOfBoundsFunctor functor( data, true );
394   actor.TouchSignal().Connect( &application, functor );
395
396   Vector2 screenCoordinates( 10.0f, 10.0f );
397   Vector2 localCoordinates;
398   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
399
400   // Emit a down signal
401   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
402
403   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
404   DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
405   DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
406   DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
407   DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
408   DALI_TEST_CHECK( ! data.point.hitActor );
409
410   END_TEST;
411 }
412
413
414 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
415 {
416   TestApplication application;
417
418   Integration::Scene scene = application.GetScene();
419   Vector2 sceneSize = scene.GetSize();
420
421   Actor actor = Actor::New();
422   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
423   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
424   actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
425   scene.Add(actor);
426
427   // Render and notify
428   application.SendNotification();
429   application.Render();
430
431   // Get the camera's near and far planes
432   RenderTaskList taskList = scene.GetRenderTaskList();
433   Dali::RenderTask task = taskList.GetTask(0);
434   CameraActor camera = task.GetCameraActor();
435   float nearPlane = camera.GetNearClippingPlane();
436   float farPlane = camera.GetFarClippingPlane();
437
438   // Calculate the current distance of the actor from the camera
439   float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
440   float distance = (sceneSize.y * 0.5f) / tanHalfFov;
441
442   // Connect to actor's touched signal
443   SignalData data;
444   TouchDataFunctor functor( data );
445   actor.TouchSignal().Connect( &application, functor );
446
447   Vector2 screenCoordinates( sceneSize.x * 0.5f, sceneSize.y * 0.5f );
448
449   // Emit a down signal
450   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
451   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
452   data.Reset();
453
454   // Emit a down signal where actor is just at the camera's near plane
455   actor.SetProperty( Actor::Property::POSITION_Z, distance - nearPlane);
456
457   // Render and notify
458   application.SendNotification();
459   application.Render();
460
461   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
462   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
463   data.Reset();
464
465   // Emit a down signal where actor is closer than the camera's near plane
466   actor.SetProperty( Actor::Property::POSITION_Z, (distance - nearPlane) + 1.0f);
467
468   // Render and notify
469   application.SendNotification();
470   application.Render();
471
472   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
473   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
474   data.Reset();
475
476   // Emit a down signal where actor is just at the camera's far plane
477   actor.SetProperty( Actor::Property::POSITION_Z, distance - farPlane);
478
479   // Render and notify
480   application.SendNotification();
481   application.Render();
482
483   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
484   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
485   data.Reset();
486
487   // Emit a down signal where actor is further than the camera's far plane
488   actor.SetProperty( Actor::Property::POSITION_Z, (distance - farPlane) - 1.0f);
489
490   // Render and notify
491   application.SendNotification();
492   application.Render();
493
494   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
495   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
496   data.Reset();
497   END_TEST;
498 }
499
500 int UtcDaliTouchDataEmitEmpty(void)
501 {
502   TestApplication application;
503
504   try
505   {
506     // Emit an empty TouchEvent
507     Integration::TouchEvent event;
508     application.ProcessEvent( event );
509     tet_result( TET_FAIL );
510   }
511   catch ( Dali::DaliException& e )
512   {
513     DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
514   }
515   END_TEST;
516 }
517
518 int UtcDaliTouchDataInterrupted(void)
519 {
520   TestApplication application;
521
522   Actor actor = Actor::New();
523   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
524   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
525   application.GetScene().Add(actor);
526
527   // Render and notify
528   application.SendNotification();
529   application.Render();
530
531   // Connect to actor's touched signal
532   SignalData data;
533   TouchDataFunctor functor( data );
534   actor.TouchSignal().Connect( &application, functor );
535
536   // Emit a down signal
537   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
538   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
539   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
540   data.Reset();
541
542   // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
543   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
544   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
545   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
546   data.Reset();
547
548   // Emit another interrupted signal, our signal handler should not be called.
549   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
550   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
551   END_TEST;
552 }
553
554 int UtcDaliTouchDataParentConsumer(void)
555 {
556   TestApplication application;
557   Actor rootActor( application.GetScene().GetRootLayer() );
558
559   Actor actor = Actor::New();
560   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
561   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
562   application.GetScene().Add(actor);
563
564   // Render and notify
565   application.SendNotification();
566   application.Render();
567
568   // Connect to actor's touched signal
569   SignalData data;
570   TouchDataFunctor functor( data, false );
571   actor.TouchSignal().Connect( &application, functor );
572
573   // Connect to root actor's touched signal
574   SignalData rootData;
575   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
576   rootActor.TouchSignal().Connect( &application, rootFunctor );
577
578   Vector2 screenCoordinates( 10.0f, 10.0f );
579   Vector2 actorCoordinates, rootCoordinates;
580   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
581   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
582
583   // Emit a down signal
584   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
585   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
586   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
587   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
588   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
589   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
590   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
591   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
592   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
593   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
594   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
595   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
596   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
597   data.Reset();
598   rootData.Reset();
599
600   // Emit a motion signal
601   screenCoordinates.x = screenCoordinates.y = 11.0f;
602   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
603   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
604   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
605   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
606   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
607   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
608   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
609   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
610   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
611   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
612   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
613   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
614   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
615   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
616   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
617   data.Reset();
618   rootData.Reset();
619
620   // Emit an up signal
621   screenCoordinates.x = screenCoordinates.y = 12.0f;
622   actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
623   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
624   application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
625   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
626   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
627   DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
628   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
629   DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
630   DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
631   DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
632   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
633   DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
634   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
635   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
636   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
637   data.Reset();
638   rootData.Reset();
639
640   // Emit a down signal where the actor is not present, will hit the root actor though
641   screenCoordinates.x = screenCoordinates.y = 200.0f;
642   rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
643   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
644   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
645   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
646   DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
647   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
648   DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
649   DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
650   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
651   END_TEST;
652 }
653
654 int UtcDaliTouchDataInterruptedParentConsumer(void)
655 {
656   TestApplication application;
657   Actor rootActor( application.GetScene().GetRootLayer() );
658
659   Actor actor = Actor::New();
660   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
661   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
662   application.GetScene().Add(actor);
663
664   // Render and notify
665   application.SendNotification();
666   application.Render();
667
668   // Connect to actor's touched signal
669   SignalData data;
670   TouchDataFunctor functor( data, false );
671   actor.TouchSignal().Connect( &application, functor );
672
673   // Connect to root actor's touched signal
674   SignalData rootData;
675   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
676   rootActor.TouchSignal().Connect( &application, rootFunctor );
677
678   // Emit a down signal
679   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
680   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
681   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
682   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
683   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
684   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
685   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
686   data.Reset();
687   rootData.Reset();
688
689   // Emit an interrupted signal
690   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
691   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
692   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
693   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
694   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
695   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
696   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
697   data.Reset();
698   rootData.Reset();
699
700   // Emit another down signal
701   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
702   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
703   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
704   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
705   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
706   data.Reset();
707   rootData.Reset();
708
709   // Remove actor from scene
710   application.GetScene().Remove( actor );
711   data.Reset();
712   rootData.Reset();
713
714   // Render and notify
715   application.SendNotification();
716   application.Render();
717
718   // Emit an interrupted signal, only root actor's signal should be called.
719   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
720   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
721   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
722   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
723   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
724   data.Reset();
725   rootData.Reset();
726
727   // Emit another interrupted state, none of the signal's should be called.
728   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
729   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
730   DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
731   END_TEST;
732 }
733
734 int UtcDaliTouchDataLeave(void)
735 {
736   TestApplication application;
737
738   Actor actor = Actor::New();
739   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
740   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
741   application.GetScene().Add(actor);
742
743   // Render and notify
744   application.SendNotification();
745   application.Render();
746
747   // Connect to actor's touched signal
748   SignalData data;
749   TouchDataFunctor functor( data );
750   actor.TouchSignal().Connect( &application, functor );
751
752   // Set actor to require leave events
753   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
754
755   // Emit a down signal
756   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
757   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
758   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
759   data.Reset();
760
761   // Emit a motion signal outside of actor, should be signalled with a Leave
762   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
763   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
764   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
765   data.Reset();
766
767   // Another motion outside of actor, no signalling
768   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
769   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
770   data.Reset();
771
772   // Another motion event inside actor, signalled with motion
773   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
774   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
775   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
776   data.Reset();
777
778   // We do not want to listen to leave events anymore
779   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
780
781   // Another motion event outside of actor, no signalling
782   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
783   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
784   data.Reset();
785   END_TEST;
786 }
787
788 int UtcDaliTouchDataLeaveParentConsumer(void)
789 {
790   TestApplication application;
791   Actor rootActor( application.GetScene().GetRootLayer() );
792
793   Actor actor = Actor::New();
794   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
795   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
796   application.GetScene().Add(actor);
797
798   // Render and notify
799   application.SendNotification();
800   application.Render();
801
802   // Connect to actor's touched signal
803   SignalData data;
804   TouchDataFunctor functor( data, false );
805   actor.TouchSignal().Connect( &application, functor );
806
807   // Connect to root actor's touched signal
808   SignalData rootData;
809   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
810   rootActor.TouchSignal().Connect( &application, rootFunctor );
811
812   // Set actor to require leave events
813   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
814   rootActor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
815
816   // Emit a down signal
817   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
818   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
819   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
820   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
821   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
822   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
823   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
824   data.Reset();
825   rootData.Reset();
826
827   // Emit a motion signal outside of actor, should be signalled with a Leave
828   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
829   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
830   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
831   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
832   DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
833   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
834   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
835   data.Reset();
836   rootData.Reset();
837
838   // Another motion outside of actor, only rootActor signalled
839   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
840   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
841   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
842   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
843   DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
844   data.Reset();
845   rootData.Reset();
846
847   // Another motion event inside actor, signalled with motion
848   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
849   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
850   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
851   DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
852   DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
853   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
854   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
855   data.Reset();
856   rootData.Reset();
857
858   // We do not want to listen to leave events of actor anymore
859   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, false );
860
861   // Another motion event outside of root actor, only root signalled
862   Vector2 sceneSize( application.GetScene().GetSize() );
863   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( sceneSize.width + 10.0f, sceneSize.height + 10.0f )) );
864   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
865   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
866   DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
867   END_TEST;
868 }
869
870 int UtcDaliTouchDataActorBecomesInsensitive(void)
871 {
872   TestApplication application;
873
874   Actor actor = Actor::New();
875   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
876   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
877   application.GetScene().Add(actor);
878
879   // Render and notify
880   application.SendNotification();
881   application.Render();
882
883   // Connect to actor's touched signal
884   SignalData data;
885   TouchDataFunctor functor( data );
886   actor.TouchSignal().Connect( &application, functor );
887
888   // Emit a down signal
889   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
890   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
891   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
892   data.Reset();
893
894   // Change actor to insensitive
895   actor.SetProperty( Actor::Property::SENSITIVE, false );
896
897   // Emit a motion signal, signalled with an interrupted
898   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
899   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
900   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
901   data.Reset();
902   END_TEST;
903 }
904
905 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
906 {
907   TestApplication application;
908   Actor rootActor( application.GetScene().GetRootLayer() );
909
910   Actor actor = Actor::New();
911   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
912   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
913   application.GetScene().Add(actor);
914
915   // Render and notify
916   application.SendNotification();
917   application.Render();
918
919   // Connect to actor's touched signal
920   SignalData data;
921   TouchDataFunctor functor( data, false );
922   actor.TouchSignal().Connect( &application, functor );
923
924   // Connect to root actor's touched signal
925   SignalData rootData;
926   TouchDataFunctor rootFunctor( rootData ); // Consumes signal
927   rootActor.TouchSignal().Connect( &application, rootFunctor );
928
929   // Emit a down signal
930   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
931   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
932   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
933   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
934   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
935   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
936   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
937   data.Reset();
938   rootData.Reset();
939
940   // Render and notify
941   application.SendNotification();
942   application.Render();
943
944   // Make root actor insensitive
945   rootActor.SetProperty( Actor::Property::SENSITIVE, false );
946
947   // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
948   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
949   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
950   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
951   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
952   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
953   END_TEST;
954 }
955
956 int UtcDaliTouchDataMultipleLayers(void)
957 {
958   TestApplication application;
959   Actor rootActor( application.GetScene().GetRootLayer() );
960
961   // Connect to actor's touched signal
962   SignalData data;
963   TouchDataFunctor functor( data );
964
965   Layer layer1 ( Layer::New() );
966   layer1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
967   layer1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
968   application.GetScene().Add( layer1 );
969
970   Actor actor1 ( Actor::New() );
971   actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
972   actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
973   actor1.SetProperty( Actor::Property::POSITION_Z,  1.0f ); // Should hit actor1 in this layer
974   layer1.Add( actor1 );
975
976   // Render and notify
977   application.SendNotification();
978   application.Render();
979
980   // Connect to layer1 and actor1
981   layer1.TouchSignal().Connect( &application, functor );
982   actor1.TouchSignal().Connect( &application, functor );
983
984   // Hit in hittable area, actor1 should be hit
985   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
986   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
987   DALI_TEST_CHECK( data.touchedActor == actor1 );
988   data.Reset();
989
990   // Make layer1 insensitive, nothing should be hit
991   layer1.SetProperty( Actor::Property::SENSITIVE, false );
992   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
993   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
994   data.Reset();
995
996   // Make layer1 sensitive again, again actor1 will be hit
997   layer1.SetProperty( Actor::Property::SENSITIVE, true );
998   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
999   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1000   DALI_TEST_CHECK( data.touchedActor == actor1 );
1001   data.Reset();
1002
1003   // Make rootActor insensitive, nothing should be hit
1004   rootActor.SetProperty( Actor::Property::SENSITIVE, false );
1005   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1006   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1007   data.Reset();
1008
1009   // Make rootActor sensitive
1010   rootActor.SetProperty( Actor::Property::SENSITIVE, true );
1011
1012   // Add another layer
1013   Layer layer2 ( Layer::New() );
1014   layer2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1015   layer2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1016   layer2.SetProperty( Actor::Property::POSITION_Z,  10.0f ); // Should hit layer2 in this layer rather than actor2
1017   application.GetScene().Add( layer2 );
1018
1019   Actor actor2 ( Actor::New() );
1020   actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1021   actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1022   layer2.Add( actor2 );
1023
1024   // Render and notify
1025   application.SendNotification();
1026   application.Render();
1027
1028   // Connect to layer2 and actor2
1029   layer2.TouchSignal().Connect( &application, functor );
1030   actor2.TouchSignal().Connect( &application, functor );
1031
1032   // Emit an event, should hit layer2
1033   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1034   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1035   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1036   data.Reset();
1037
1038   // Make layer2 insensitive, should hit actor1
1039   layer2.SetProperty( Actor::Property::SENSITIVE, false );
1040   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1041   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1042   DALI_TEST_CHECK( data.touchedActor == actor1 );
1043   data.Reset();
1044
1045   // Make layer2 sensitive again, should hit layer2
1046   layer2.SetProperty( Actor::Property::SENSITIVE, true );
1047   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1048   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1049   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1050   data.Reset();
1051
1052   // Make layer2 invisible, render and notify
1053   layer2.SetProperty( Actor::Property::VISIBLE, false );
1054   application.SendNotification();
1055   application.Render();
1056
1057   // Should hit actor1
1058   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1059   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1060   DALI_TEST_CHECK( data.touchedActor == actor1 );
1061   data.Reset();
1062
1063   // Make rootActor invisible, render and notify
1064   rootActor.SetProperty( Actor::Property::VISIBLE, false );
1065   application.SendNotification();
1066   application.Render();
1067
1068   // Should not hit anything
1069   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1070   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1071   data.Reset();
1072   END_TEST;
1073 }
1074
1075 int UtcDaliTouchDataMultipleRenderTasks(void)
1076 {
1077   TestApplication application;
1078   Integration::Scene scene ( application.GetScene() );
1079   Vector2 sceneSize ( scene.GetSize() );
1080
1081   Actor actor = Actor::New();
1082   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1083   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1084   scene.Add(actor);
1085
1086   // Create render task
1087   Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
1088   RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
1089   renderTask.SetViewport( viewport );
1090   renderTask.SetInputEnabled( true );
1091
1092   // Render and notify
1093   application.SendNotification();
1094   application.Render();
1095
1096   // Connect to actor's touched signal
1097   SignalData data;
1098   TouchDataFunctor functor( data );
1099   actor.TouchSignal().Connect( &application, functor );
1100
1101   // Emit a down signal
1102   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1103   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1104   data.Reset();
1105
1106   // Ensure renderTask actor can be hit too.
1107   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1108   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1109   data.Reset();
1110
1111   // Disable input on renderTask, should not be hittable
1112   renderTask.SetInputEnabled( false );
1113   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1114   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1115   data.Reset();
1116   END_TEST;
1117 }
1118
1119 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1120 {
1121   TestApplication application;
1122   Integration::Scene scene ( application.GetScene() );
1123   Vector2 sceneSize ( scene.GetSize() );
1124
1125   Actor actor = Actor::New();
1126   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1127   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1128   scene.Add(actor);
1129
1130   Layer layer = Layer::New();
1131   layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1132   layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1133   actor.Add(layer);
1134
1135   // Create render task
1136   Viewport viewport( sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f );
1137   RenderTask renderTask ( application.GetScene().GetRenderTaskList().CreateTask() );
1138   renderTask.SetViewport( viewport );
1139   renderTask.SetInputEnabled( true );
1140   renderTask.SetSourceActor( actor );
1141
1142   // Render and notify
1143   application.SendNotification();
1144   application.Render();
1145
1146   // Connect to layer's touched signal
1147   SignalData data;
1148   TouchDataFunctor functor( data );
1149   actor.TouchSignal().Connect( &application, functor );
1150   layer.TouchSignal().Connect( &application, functor );
1151
1152   // Emit a down signal
1153   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1154   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1155   data.Reset();
1156
1157   // Ensure renderTask actor can be hit too.
1158   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1159   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1160   data.Reset();
1161
1162   // Disable input on renderTask, should not be hittable
1163   renderTask.SetInputEnabled( false );
1164   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1165   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1166   data.Reset();
1167   END_TEST;
1168 }
1169
1170 int UtcDaliTouchDataOffscreenRenderTasks(void)
1171 {
1172   TestApplication application;
1173   Integration::Scene scene ( application.GetScene() );
1174   Vector2 sceneSize ( scene.GetSize() );
1175
1176   // FrameBufferImage for offscreen RenderTask
1177   FrameBuffer frameBuffer = FrameBuffer::New(sceneSize.width, sceneSize.height);
1178
1179   // Create a renderable actor to display the FrameBufferImage
1180   Actor renderableActor = CreateRenderableActor(frameBuffer.GetColorTexture());
1181   renderableActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
1182   renderableActor.SetProperty( Actor::Property::SIZE, Vector2( sceneSize.x, sceneSize.y ) );
1183   renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1184   scene.Add( renderableActor );
1185
1186   Actor actor = Actor::New();
1187   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1188   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1189   scene.Add( actor );
1190   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1191
1192   scene.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1193
1194   // Create a RenderTask
1195   RenderTask renderTask = scene.GetRenderTaskList().CreateTask();
1196   renderTask.SetSourceActor( actor );
1197   renderTask.SetFrameBuffer(frameBuffer);
1198   renderTask.SetInputEnabled( true );
1199
1200   // Create another RenderTask
1201   RenderTask renderTask2( scene.GetRenderTaskList().CreateTask() );
1202   renderTask2.SetInputEnabled( true );
1203
1204   // Render and notify
1205   application.SendNotification();
1206   application.Render();
1207
1208   // Connect to actor's touched signal
1209   SignalData data;
1210   TouchDataFunctor functor( data );
1211   actor.TouchSignal().Connect( &application, functor );
1212
1213   // Emit a down signal
1214   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1215   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1216   data.Reset();
1217   END_TEST;
1218 }
1219
1220 int UtcDaliTouchDataMultipleRenderableActors(void)
1221 {
1222   TestApplication application;
1223   Integration::Scene scene ( application.GetScene() );
1224   Vector2 sceneSize ( scene.GetSize() );
1225
1226   Actor parent = CreateRenderableActor();
1227   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1228   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1229   scene.Add(parent);
1230
1231   Actor actor = CreateRenderableActor();
1232   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1233   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1234   parent.Add(actor);
1235
1236   // Render and notify
1237   application.SendNotification();
1238   application.Render();
1239
1240   // Connect to layer's touched signal
1241   SignalData data;
1242   TouchDataFunctor functor( data );
1243   parent.TouchSignal().Connect( &application, functor );
1244   actor.TouchSignal().Connect( &application, functor );
1245
1246   // Emit a down signal
1247   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1248   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1249   DALI_TEST_CHECK( actor == data.touchedActor );
1250   END_TEST;
1251 }
1252
1253 int UtcDaliTouchDataActorRemovedInSignal(void)
1254 {
1255   TestApplication application;
1256
1257   Actor actor = Actor::New();
1258   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1259   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1260   application.GetScene().Add(actor);
1261
1262   // Render and notify
1263   application.SendNotification();
1264   application.Render();
1265
1266   // Connect to actor's touched signal
1267   SignalData data;
1268   RemoveActorFunctor functor( data );
1269   actor.TouchSignal().Connect( &application, functor );
1270
1271   // Register for leave events
1272   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
1273
1274   // Emit a down signal
1275   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1276   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1277   data.Reset();
1278
1279   // Re-add, render and notify
1280   application.GetScene().Add(actor);
1281   application.SendNotification();
1282   application.Render();
1283
1284   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1285   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1286   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1287   data.Reset();
1288
1289   // Emit a down signal
1290   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1291   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1292   data.Reset();
1293
1294   // Render and notify
1295   application.SendNotification();
1296   application.Render();
1297
1298   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1299   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1300   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1301   data.Reset();
1302
1303   // Re-add actor back to scene, render and notify
1304   application.GetScene().Add(actor);
1305   application.SendNotification();
1306   application.Render();
1307
1308   // Emit another down event
1309   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1310   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1311   data.Reset();
1312
1313   // Completely delete the actor
1314   actor.Reset();
1315
1316   // Emit event, should not crash and should not receive an event.
1317   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1318   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1319   END_TEST;
1320 }
1321
1322 int UtcDaliTouchDataActorSignalNotConsumed(void)
1323 {
1324   TestApplication application;
1325
1326   Actor actor = Actor::New();
1327   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1328   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1329   application.GetScene().Add(actor);
1330
1331   // Render and notify
1332   application.SendNotification();
1333   application.Render();
1334
1335   // Connect to actor's touched signal
1336   SignalData data;
1337   TouchDataFunctor functor( data, false );
1338   actor.TouchSignal().Connect( &application, functor );
1339
1340   // Emit a down signal
1341   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1342   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1343   END_TEST;
1344 }
1345
1346 int UtcDaliTouchDataActorRemovedFromScene(void)
1347 {
1348   TestApplication application;
1349
1350   Actor actor = Actor::New();
1351   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1352   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1353   application.GetScene().Add(actor);
1354
1355   // Render and notify
1356   application.SendNotification();
1357   application.Render();
1358
1359   // Connect to actor's touched signal
1360   SignalData data;
1361   TouchDataFunctor functor( data );
1362   actor.TouchSignal().Connect( &application, functor );
1363
1364   // Emit a down signal
1365   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1366   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1367   data.Reset();
1368
1369   // Remove actor from scene
1370   application.GetScene().Remove( actor );
1371   data.Reset();
1372
1373   // Render and notify
1374   application.SendNotification();
1375   application.Render();
1376
1377   // Emit a move at the same point, we should not be signalled.
1378   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1379   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1380   data.Reset();
1381   END_TEST;
1382 }
1383
1384 int UtcDaliTouchDataLayerConsumesTouch(void)
1385 {
1386   TestApplication application;
1387
1388   Actor actor = Actor::New();
1389   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1390   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1391   application.GetScene().Add(actor);
1392
1393   // Render and notify
1394   application.SendNotification();
1395   application.Render();
1396
1397   // Connect to actor's touched signal
1398   SignalData data;
1399   TouchDataFunctor functor( data );
1400   actor.TouchSignal().Connect( &application, functor );
1401
1402   // Add a layer to overlap the actor
1403   Layer layer = Layer::New();
1404   layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1405   layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1406   application.GetScene().Add( layer );
1407   layer.RaiseToTop();
1408
1409   // Render and notify
1410   application.SendNotification();
1411   application.Render();
1412
1413   // Emit a few touch signals
1414   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1415   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1416   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1417   data.Reset();
1418
1419   // Set layer to consume all touch
1420   layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1421
1422   // Render and notify
1423   application.SendNotification();
1424   application.Render();
1425
1426   // Emit the same signals again, should not receive
1427   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1428   application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1429   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1430   data.Reset();
1431
1432   END_TEST;
1433 }
1434
1435 int UtcDaliTouchDataLeaveActorReadded(void)
1436 {
1437   TestApplication application;
1438   Integration::Scene scene = application.GetScene();
1439
1440   Actor actor = Actor::New();
1441   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1442   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1443   scene.Add(actor);
1444
1445   // Set actor to receive touch-events
1446   actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
1447
1448   // Render and notify
1449   application.SendNotification();
1450   application.Render();
1451
1452   // Connect to actor's touched signal
1453   SignalData data;
1454   TouchDataFunctor functor( data );
1455   actor.TouchSignal().Connect( &application, functor );
1456
1457   // Emit a down and motion
1458   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1459   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1460   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1461   data.Reset();
1462
1463   // Remove actor from scene and add again
1464   scene.Remove( actor );
1465   scene.Add( actor );
1466
1467   // Emit a motion within the actor's bounds
1468   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1469   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1470   data.Reset();
1471
1472   // Emit a motion outside the actor's bounds
1473   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1474   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1475   DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1476   data.Reset();
1477
1478   END_TEST;
1479 }
1480
1481 int UtcDaliTouchDataClippedActor(void)
1482 {
1483   TestApplication application;
1484   Integration::Scene scene = application.GetScene();
1485
1486   Actor actor = Actor::New();
1487   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1488   actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1489   scene.Add( actor );
1490
1491   Actor clippingActor = Actor::New();
1492   clippingActor.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
1493   clippingActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1494   clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1495   scene.Add( clippingActor );
1496
1497   // Add a child to the clipped region.
1498   Actor clippingChild = Actor::New();
1499   clippingChild.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
1500   clippingChild.SetProperty( Actor::Property::POSITION, Vector2( 25.0f, 25.0f ));
1501   clippingChild.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1502   clippingActor.Add( clippingChild );
1503
1504   // Render and notify.
1505   application.SendNotification();
1506   application.Render();
1507
1508   // Connect to actor's touch signal.
1509   SignalData data;
1510   TouchDataFunctor functor( data );
1511   actor.TouchSignal().Connect( &application, functor );
1512
1513   // Emit an event within clipped area - no hit.
1514   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1515   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1516   data.Reset();
1517
1518   // Emit an event outside the clipped area but within the actor area, we should have a hit.
1519   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1520   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1521   data.Reset();
1522
1523   clippingChild.TouchSignal().Connect( &application, functor );
1524
1525   // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1526   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 30.0f, 30.0f ) ) );
1527   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1528   data.Reset();
1529
1530   END_TEST;
1531 }
1532
1533 int UtcDaliTouchDataActorUnparented(void)
1534 {
1535   TestApplication application;
1536
1537   Actor actor = Actor::New();
1538   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1539   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1540   application.GetScene().Add(actor);
1541
1542   // Render and notify
1543   application.SendNotification();
1544   application.Render();
1545
1546   // Connect to actor's touched signal
1547   SignalData data;
1548   TouchDataFunctor functor( data );
1549   actor.TouchSignal().Connect( &application, functor );
1550
1551   // Emit a down signal
1552   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1553   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1554   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1555   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1556   data.Reset();
1557
1558   // Render and notify
1559   application.SendNotification();
1560   application.Render();
1561
1562   // Unparent the actor
1563   actor.Unparent();
1564
1565   // Should receive an interrupted event
1566   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1567   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1568   END_TEST;
1569 }
1570
1571 int UtcDaliTouchDataParentRemovedFromScene(void)
1572 {
1573   TestApplication application;
1574
1575   Actor parent = Actor::New();
1576   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1577   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1578   application.GetScene().Add(parent);
1579
1580   Actor actor = Actor::New();
1581   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1582   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1583   parent.Add(actor);
1584
1585   // Render and notify
1586   application.SendNotification();
1587   application.Render();
1588
1589   // Connect to actor's touched signal
1590   SignalData data;
1591   TouchDataFunctor functor( data );
1592   actor.TouchSignal().Connect( &application, functor );
1593
1594   // Emit a down signal
1595   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1596   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1597   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1598   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1599   data.Reset();
1600
1601   // Render and notify
1602   application.SendNotification();
1603   application.Render();
1604
1605   // Unparent the parent of the touchable actor
1606   parent.Unparent();
1607
1608   // Should receive an interrupted event
1609   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1610   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1611   END_TEST;
1612 }
1613
1614 int UtcDaliTouchDataActorRemovedFromSceneDifferentConsumer(void)
1615 {
1616   TestApplication application;
1617
1618   Actor parent = Actor::New();
1619   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1620   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1621   application.GetScene().Add(parent);
1622
1623   Actor actor = Actor::New();
1624   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1625   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1626   parent.Add(actor);
1627
1628   // Render and notify
1629   application.SendNotification();
1630   application.Render();
1631
1632   // Connect to actor's touched signal
1633   SignalData data;
1634   TouchDataFunctor functor( data, false /* Do not consume */ );
1635   actor.TouchSignal().Connect( &application, functor );
1636
1637   // Connect to parent's touched signal
1638   SignalData parentData;
1639   TouchDataFunctor parentFunctor( parentData );
1640   parent.TouchSignal().Connect( &application, parentFunctor );
1641
1642   // Emit a down signal
1643   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1644   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1645   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1646   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1647   DALI_TEST_CHECK( actor == data.touchedActor );
1648   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1649   DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1650   DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1651   DALI_TEST_CHECK( parent == parentData.touchedActor );
1652   data.Reset();
1653   parentData.Reset();
1654
1655   // Render and notify
1656   application.SendNotification();
1657   application.Render();
1658
1659   // Unparent the actor
1660   actor.Unparent();
1661
1662   // Should receive an interrupted event for both actor & parent
1663   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1664   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1665   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1666   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1667   data.Reset();
1668   parentData.Reset();
1669
1670   // Readd actor to parent
1671   parent.Add(actor);
1672
1673   // Render and notify
1674   application.SendNotification();
1675   application.Render();
1676
1677   // Emit a motion signal
1678   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1679   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1680   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1681   data.Reset();
1682   parentData.Reset();
1683
1684   // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1685   SignalData secondData;
1686   TouchDataFunctor secondFunctor( secondData /* Consume */ );
1687   actor.TouchSignal().Connect( &application, secondFunctor );
1688
1689   // Unparent the actor
1690   actor.Unparent();
1691
1692   // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1693   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1694   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1695   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1696   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1697   DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1698   DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1699   data.Reset();
1700   parentData.Reset();
1701   secondData.Reset();
1702
1703   END_TEST;
1704 }
1705
1706 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1707 {
1708   TestApplication application;
1709   Actor rootActor( application.GetScene().GetRootLayer() );
1710
1711   Actor parent = Actor::New();
1712   parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1713   parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1714   application.GetScene().Add(parent);
1715
1716   Actor actor = Actor::New();
1717   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1718   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1719   parent.Add(actor);
1720
1721   // Render and notify
1722   application.SendNotification();
1723   application.Render();
1724
1725   // Connect to actor's touched signal
1726   SignalData data;
1727   TouchDataFunctor functor( data, false /* Do not consume */ );
1728   actor.TouchSignal().Connect( &application, functor );
1729
1730   // Connect to parent's touched signal
1731   SignalData parentData;
1732   TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1733   parent.TouchSignal().Connect( &application, parentFunctor );
1734
1735   // Connect to root's touched signal and consume
1736   SignalData rootData;
1737   TouchDataFunctor rootFunctor( rootData );
1738   rootActor.TouchSignal().Connect( &application, rootFunctor );
1739
1740   // Emit a down signal
1741   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1742   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1743   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1744   DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1745   DALI_TEST_CHECK( actor == data.touchedActor );
1746   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1747   DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1748   DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1749   DALI_TEST_CHECK( parent == parentData.touchedActor );
1750   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1751   DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1752   DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1753   DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1754   data.Reset();
1755   parentData.Reset();
1756   rootData.Reset();
1757
1758   // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1759   SignalData secondData;
1760   TouchDataFunctor secondFunctor( secondData /* Consume */ );
1761   parent.TouchSignal().Connect( &application, secondFunctor );
1762
1763   // Emit an interrupted signal, all three should STILL be called
1764   application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1765   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1766   DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1767   DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1768   DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1769   DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1770   DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1771   data.Reset();
1772   parentData.Reset();
1773   rootData.Reset();
1774
1775   END_TEST;
1776 }
1777
1778 int UtcDaliTouchDataGetRadius(void)
1779 {
1780   TestApplication application;
1781
1782   Actor actor = Actor::New();
1783   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1784   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1785   application.GetScene().Add(actor);
1786
1787   // Render and notify
1788   application.SendNotification();
1789   application.Render();
1790
1791   // Connect to actor's touched signal
1792   SignalData data;
1793   TouchDataFunctor functor( data );
1794   actor.TouchSignal().Connect( &application, functor );
1795
1796   // Emit a down signal with an angle
1797   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1798   touchEvent.points[ 0 ].SetRadius( 100.0f );
1799   application.ProcessEvent( touchEvent );
1800   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1801   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1802   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1803   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1804   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1805
1806   END_TEST;
1807 }
1808
1809 int UtcDaliTouchDataGetEllipseRadius(void)
1810 {
1811   TestApplication application;
1812
1813   Actor actor = Actor::New();
1814   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1815   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1816   application.GetScene().Add(actor);
1817
1818   // Render and notify
1819   application.SendNotification();
1820   application.Render();
1821
1822   // Connect to actor's touched signal
1823   SignalData data;
1824   TouchDataFunctor functor( data );
1825   actor.TouchSignal().Connect( &application, functor );
1826
1827   // Emit a down signal with an angle
1828   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1829   touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1830   application.ProcessEvent( touchEvent );
1831   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1832   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1833   DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1834   DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1835   DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1836
1837   END_TEST;
1838 }
1839
1840 int UtcDaliTouchDataGetAngle(void)
1841 {
1842   TestApplication application;
1843
1844   Actor actor = Actor::New();
1845   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1846   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1847   application.GetScene().Add(actor);
1848
1849   // Render and notify
1850   application.SendNotification();
1851   application.Render();
1852
1853   // Connect to actor's touched signal
1854   SignalData data;
1855   TouchDataFunctor functor( data );
1856   actor.TouchSignal().Connect( &application, functor );
1857
1858   // Emit a down signal with an angle
1859   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1860   touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1861   application.ProcessEvent( touchEvent );
1862   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1863   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1864   DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1865
1866   END_TEST;
1867 }
1868
1869 int UtcDaliTouchDataGetPressure(void)
1870 {
1871   TestApplication application;
1872
1873   Actor actor = Actor::New();
1874   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1875   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1876   application.GetScene().Add(actor);
1877
1878   // Render and notify
1879   application.SendNotification();
1880   application.Render();
1881
1882   // Connect to actor's touched signal
1883   SignalData data;
1884   TouchDataFunctor functor( data );
1885   actor.TouchSignal().Connect( &application, functor );
1886
1887   // Emit a down signal with an angle
1888   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1889   touchEvent.points[ 0 ].SetPressure( 10.0f );
1890   application.ProcessEvent( touchEvent );
1891   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1892   DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1893   DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1894
1895   END_TEST;
1896 }
1897
1898 int UtcDaliTouchDataUsage(void)
1899 {
1900   TestApplication application;
1901
1902   Actor actor = Actor::New();
1903   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1904   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1905   application.GetScene().Add(actor);
1906
1907   // Render and notify
1908   application.SendNotification();
1909   application.Render();
1910
1911   // Connect to actor's touched signal
1912   SignalData data;
1913   TouchDataFunctor functor( data );
1914   actor.TouchSignal().Connect( &application, functor );
1915
1916
1917   // Emit a down signal with an angle
1918   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1919   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1920
1921
1922   END_TEST;
1923 }
1924
1925 int UtcDaliTouchDataGetDeviceAPINegative(void)
1926 {
1927   TestApplication application;
1928
1929   Actor actor = Actor::New();
1930   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1931   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1932   application.GetScene().Add(actor);
1933
1934   // Render and notify
1935   application.SendNotification();
1936   application.Render();
1937
1938   // Connect to actor's touched signal
1939   HandleData handleData;
1940   TouchDataHandleFunctor functor( handleData );
1941   actor.TouchSignal().Connect( &application, functor );
1942
1943   Vector2 screenCoordinates( 10.0f, 10.0f );
1944   Vector2 localCoordinates;
1945   actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
1946
1947   // Emit a down signal
1948   application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
1949
1950   TouchData data = handleData.touchData;
1951   DALI_TEST_EQUALS( data.GetDeviceClass( -1 ), Device::Class::NONE, TEST_LOCATION );
1952   DALI_TEST_EQUALS( data.GetDeviceSubclass( -1 ), Device::Subclass::NONE, TEST_LOCATION );
1953   END_TEST;
1954 }
1955
1956 int UtcDaliTouchDataGetMouseButtonPositive(void)
1957 {
1958   TestApplication application;
1959
1960   Actor actor = Actor::New();
1961   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1962   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1963   application.GetScene().Add(actor);
1964
1965   // Render and notify
1966   application.SendNotification();
1967   application.Render();
1968
1969   // Connect to actor's touched signal
1970   HandleData handleData;
1971   TouchDataHandleFunctor functor( handleData );
1972   actor.TouchSignal().Connect( &application, functor );
1973
1974   // Emit a down signal with MouseButton
1975   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1976   touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 3 ) );
1977   application.ProcessEvent( touchEvent );
1978
1979   TouchData data = handleData.touchData;
1980   DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::SECONDARY, TEST_LOCATION );
1981
1982   END_TEST;
1983 }
1984
1985 int UtcDaliTouchDataGetMouseButtonNagative(void)
1986 {
1987   TestApplication application;
1988
1989   Actor actor = Actor::New();
1990   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1991   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1992   application.GetScene().Add(actor);
1993
1994   // Render and notify
1995   application.SendNotification();
1996   application.Render();
1997
1998   // Connect to actor's touched signal
1999   HandleData handleData;
2000   TouchDataHandleFunctor functor( handleData );
2001   actor.TouchSignal().Connect( &application, functor );
2002
2003   // Emit a down signal with MouseButton
2004   Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
2005   touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 2 ) );
2006   application.ProcessEvent( touchEvent );
2007
2008   TouchData data = handleData.touchData;
2009   DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::TERTIARY, TEST_LOCATION );
2010   DALI_TEST_EQUALS( data.GetMouseButton( 3 ), MouseButton::INVALID, TEST_LOCATION );
2011
2012   END_TEST;
2013 }
2014
2015 int UtcDaliTouchDataCapturePropertySet(void)
2016 {
2017   TestApplication application;
2018
2019   Actor actor = Actor::New();
2020   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2021   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2022   application.GetScene().Add(actor);
2023
2024   // Render and notify
2025   application.SendNotification();
2026   application.Render();
2027
2028   // Connect to actor's touched signal
2029   SignalData data;
2030   TouchDataFunctor functor( data );
2031   actor.TouchSignal().Connect( &application, functor );
2032
2033   // Emit a down signal
2034   application.ProcessEvent( GenerateSingleTouch( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) );
2035   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2036   data.Reset();
2037
2038   // Now motion outside of actor, we should not receive the event
2039   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 110.0f, 110.0f ) ) );
2040   DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
2041   data.Reset();
2042
2043   // Up event, should receive an interrupted
2044   application.ProcessEvent( GenerateSingleTouch( PointState::FINISHED, Vector2( 110.0f, 110.0f ) ) );
2045   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2046   DALI_TEST_EQUALS( data.touchData.GetPoint(0).state, PointState::INTERRUPTED, TEST_LOCATION );
2047
2048   // Now set the capture property
2049   actor.SetProperty( DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
2050
2051   // Emit a down signal
2052   application.ProcessEvent( GenerateSingleTouch( PointState::STARTED, Vector2( 10.0f, 10.0f ) ) );
2053   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2054   data.Reset();
2055
2056   // Now motion outside of actor, we now SHOULD receive the event
2057   application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 110.0f, 110.0f ) ) );
2058   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2059   data.Reset();
2060
2061   // Up event, we should receive it again, but as ended rather than interrupted
2062   application.ProcessEvent( GenerateSingleTouch( PointState::FINISHED, Vector2( 110.0f, 110.0f ) ) );
2063   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
2064   DALI_TEST_EQUALS( data.touchData.GetPoint(0).state, PointState::FINISHED, TEST_LOCATION );
2065
2066   END_TEST;
2067 }
2068
2069 int UtcDaliTouchDataIntegNewTouchData(void)
2070 {
2071   uint32_t timestamp = 92858u;
2072   TouchPoint tp(1, TouchPoint::State::Started, 34.4f, 123.89f, 5.0f, 7.0f);
2073   Dali::TouchData touchData = Integration::NewTouchData(timestamp, tp);
2074
2075   DALI_TEST_EQUALS(touchData.GetPointCount(), 1u, TEST_LOCATION);
2076   DALI_TEST_EQUALS(touchData.GetState(0), PointState::Type::STARTED, TEST_LOCATION );
2077   DALI_TEST_EQUALS(touchData.GetLocalPosition(0), Vector2(5.0f, 7.0f), TEST_LOCATION );
2078   DALI_TEST_EQUALS(touchData.GetScreenPosition(0), Vector2(34.4f, 123.89f), TEST_LOCATION );
2079
2080
2081   END_TEST;
2082 }