If Hittable is false, actor should not receive events except INTERRUPTED
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TouchProcessing.cpp
1 /*
2  * Copyright (c) 2022 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 <dali-test-suite-utils.h>
19 #include <dali/devel-api/actors/actor-devel.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali/integration-api/events/touch-integ.h>
22 #include <dali/integration-api/render-task-list-integ.h>
23 #include <dali/public-api/dali-core.h>
24 #include <stdlib.h>
25
26 #include <iostream>
27
28 using namespace Dali;
29
30 void utc_dali_touch_processing_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_touch_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{-1};
47   PointState::Type       state{PointState::FINISHED};
48   Actor                  hitActor;
49   Vector2                local;
50   Vector2                screen;
51   float                  radius{0};
52   Vector2                ellipseRadius;
53   float                  pressure{0};
54   Degree                 angle;
55   Device::Class::Type    deviceClass{Device::Class::NONE};
56   Device::Subclass::Type deviceSubclass{Device::Subclass::NONE};
57
58   TestPoint() = default;
59   static const TestPoint ZERO;
60 };
61
62 const TestPoint TestPoint::ZERO;
63
64 // Stores data that is populated in the callback and will be read by the TET cases
65 struct SignalData
66 {
67   SignalData()
68   : functorCalled(false),
69     receivedTouch(),
70     touchedActor()
71   {
72   }
73
74   struct TestTouchEvent
75   {
76     unsigned long          time;
77     std::vector<TestPoint> points;
78
79     const TestPoint& GetPoint(size_t i)
80     {
81       if(i < points.size())
82       {
83         return points[i];
84       }
85       return TestPoint::ZERO;
86     }
87     size_t GetPointCount()
88     {
89       return points.size();
90     }
91   };
92
93   void Reset()
94   {
95     functorCalled = false;
96
97     receivedTouch.time = 0u;
98     receivedTouch.points.clear();
99
100     touchedActor.Reset();
101   }
102
103   bool           functorCalled;
104   TestTouchEvent receivedTouch;
105   Actor          touchedActor;
106 };
107
108 // Functor that sets the data when called
109 struct TouchEventFunctor
110 {
111   /**
112    * Constructor.
113    * @param[in]  data         Reference to the data to store callback information.
114    * @param[in]  returnValue  What the functor should return.
115    */
116   TouchEventFunctor(SignalData& data, bool returnValue = true)
117   : signalData(data),
118     returnValue(returnValue)
119   {
120   }
121
122   bool operator()(Actor actor, const TouchEvent& touch)
123   {
124     signalData.functorCalled = true;
125     signalData.touchedActor  = actor;
126
127     signalData.receivedTouch.time = touch.GetTime();
128     signalData.receivedTouch.points.clear();
129
130     for(size_t i = 0; i < touch.GetPointCount(); ++i)
131     {
132       TestPoint p;
133       p.deviceId       = touch.GetDeviceId(i);
134       p.state          = touch.GetState(i);
135       p.hitActor       = touch.GetHitActor(i);
136       p.local          = touch.GetLocalPosition(i);
137       p.screen         = touch.GetScreenPosition(i);
138       p.radius         = touch.GetRadius(i);
139       p.ellipseRadius  = touch.GetEllipseRadius(i);
140       p.pressure       = touch.GetPressure(i);
141       p.angle          = touch.GetAngle(i);
142       p.deviceClass    = touch.GetDeviceClass(i);
143       p.deviceSubclass = touch.GetDeviceSubclass(i);
144       signalData.receivedTouch.points.push_back(p);
145     }
146
147     return returnValue;
148   }
149
150   SignalData& signalData;
151   bool        returnValue;
152 };
153
154 struct HandleData
155 {
156   bool       signalReceived;
157   TouchEvent receivedTouchHandle;
158
159   HandleData()
160   : signalReceived(false)
161   {
162   }
163 };
164
165 struct TouchEventHandleFunctor
166 {
167   /**
168    * Constructor.
169    * @param[in]  data         Reference to the data to store callback information.
170    * @param[in]  returnValue  What the functor should return.
171    */
172   TouchEventHandleFunctor(HandleData& handleData, bool returnValue = true)
173   : handleData(handleData),
174     returnValue(returnValue)
175   {
176   }
177
178   bool operator()(Actor actor, const TouchEvent& someTouchEvent)
179   {
180     handleData.signalReceived      = true;
181     handleData.receivedTouchHandle = someTouchEvent;
182     return returnValue;
183   }
184
185   HandleData& handleData;
186   bool        returnValue;
187 };
188
189 // Functor that removes the actor when called.
190 struct RemoveActorFunctor : public TouchEventFunctor
191 {
192   /**
193    * Constructor.
194    * @param[in]  data         Reference to the data to store callback information.
195    * @param[in]  returnValue  What the functor should return.
196    */
197   RemoveActorFunctor(SignalData& data, bool returnValue = true)
198   : TouchEventFunctor(data, returnValue)
199   {
200   }
201
202   bool operator()(Actor actor, const TouchEvent& touch)
203   {
204     Actor parent(actor.GetParent());
205     if(parent)
206     {
207       parent.Remove(actor);
208     }
209
210     return TouchEventFunctor::operator()(actor, touch);
211   }
212 };
213
214 struct OutOfBoundsData
215 {
216   TestPoint point;
217   bool      functorCalled;
218
219   OutOfBoundsData()
220   : functorCalled(false)
221   {
222   }
223 };
224
225 // Functor that reads out of bounds data when called
226 struct OutOfBoundsFunctor
227 {
228   /**
229    * Constructor.
230    * @param[in]  data         Reference to the data to store callback information.
231    * @param[in]  returnValue  What the functor should return.
232    */
233   OutOfBoundsFunctor(OutOfBoundsData& data, bool returnValue = true)
234   : outOfBoundsData(data),
235     returnValue(returnValue)
236   {
237   }
238
239   bool operator()(Actor actor, const TouchEvent& touch)
240   {
241     outOfBoundsData.functorCalled = true;
242     size_t count                  = touch.GetPointCount();
243
244     // Read out of bounds data
245     outOfBoundsData.point.deviceId = touch.GetDeviceId(count + 1);
246     outOfBoundsData.point.state    = touch.GetState(count + 1);
247     outOfBoundsData.point.hitActor = touch.GetHitActor(count + 1);
248     outOfBoundsData.point.local    = touch.GetLocalPosition(count + 1);
249     outOfBoundsData.point.screen   = touch.GetScreenPosition(count + 1);
250
251     return returnValue;
252   }
253
254   OutOfBoundsData& outOfBoundsData;
255   bool             returnValue;
256 };
257
258 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition)
259 {
260   Integration::TouchEvent touchEvent;
261   Integration::Point      point;
262   point.SetState(state);
263   point.SetScreenPosition(screenPosition);
264   point.SetDeviceClass(Device::Class::TOUCH);
265   point.SetDeviceSubclass(Device::Subclass::NONE);
266   touchEvent.points.push_back(point);
267   return touchEvent;
268 }
269
270 Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time)
271 {
272   Integration::TouchEvent touchEvent;
273   Integration::Point      point;
274   point.SetState(stateA);
275   point.SetDeviceId(4);
276   point.SetScreenPosition(screenPositionA);
277   point.SetDeviceClass(Device::Class::TOUCH);
278   point.SetDeviceSubclass(Device::Subclass::NONE);
279   touchEvent.points.push_back(point);
280   point.SetScreenPosition(screenPositionB);
281   point.SetState(stateB);
282   point.SetDeviceId(7);
283   point.SetDeviceClass(Device::Class::TOUCH);
284   point.SetDeviceSubclass(Device::Subclass::NONE);
285   touchEvent.points.push_back(point);
286   touchEvent.time = time;
287   return touchEvent;
288 }
289
290 } // namespace
291
292 ///////////////////////////////////////////////////////////////////////////////
293
294 int UtcDaliTouchEventNormalProcessing01(void)
295 {
296   TestApplication application;
297
298   Actor actor = Actor::New();
299   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
300   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
301   application.GetScene().Add(actor);
302
303   // Render and notify
304   application.SendNotification();
305   application.Render();
306
307   // Connect to actor's touch signal
308   SignalData        data;
309   TouchEventFunctor functor(data);
310   actor.TouchedSignal().Connect(&application, functor);
311
312   Vector2 screenCoordinates(10.0f, 10.0f);
313   Vector2 localCoordinates;
314   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
315
316   // Emit a down signal
317   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
318   const TestPoint* point1 = &data.receivedTouch.GetPoint(0);
319   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
320   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
321   DALI_TEST_EQUALS(PointState::DOWN, point1->state, TEST_LOCATION);
322   DALI_TEST_EQUALS(screenCoordinates, point1->screen, TEST_LOCATION);
323   DALI_TEST_EQUALS(localCoordinates, point1->local, 0.1f, TEST_LOCATION);
324   data.Reset();
325
326   // Emit a motion signal
327   screenCoordinates.x = screenCoordinates.y = 11.0f;
328   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
329   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
330   const TestPoint* point2 = &data.receivedTouch.GetPoint(0);
331   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
332   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
333   DALI_TEST_EQUALS(PointState::MOTION, point2->state, TEST_LOCATION);
334   DALI_TEST_EQUALS(screenCoordinates, point2->screen, TEST_LOCATION);
335   DALI_TEST_EQUALS(localCoordinates, point2->local, 0.1f, TEST_LOCATION);
336   data.Reset();
337
338   // Emit an up signal
339   screenCoordinates.x = screenCoordinates.y = 12.0f;
340   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
341   application.ProcessEvent(GenerateSingleTouch(PointState::UP, screenCoordinates));
342   const TestPoint* point3 = &data.receivedTouch.GetPoint(0);
343   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
344   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
345   DALI_TEST_EQUALS(PointState::UP, point3->state, TEST_LOCATION);
346   DALI_TEST_EQUALS(screenCoordinates, point3->screen, TEST_LOCATION);
347   DALI_TEST_EQUALS(localCoordinates, point3->local, 0.1f, TEST_LOCATION);
348   data.Reset();
349
350   // Emit a down signal where the actor is not present
351   screenCoordinates.x = screenCoordinates.y = 200.0f;
352   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
353   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
354   END_TEST;
355 }
356
357 int UtcDaliTouchEventNormalProcessing02(void)
358 {
359   TestApplication application;
360
361   Actor actor = Actor::New();
362   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
363   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
364   application.GetScene().Add(actor);
365
366   // Render and notify
367   application.SendNotification();
368   application.Render();
369
370   // Connect to actor's touched signal
371   HandleData              handleData;
372   TouchEventHandleFunctor functor(handleData);
373   actor.TouchedSignal().Connect(&application, functor);
374
375   Vector2 screenCoordinates(10.0f, 10.0f);
376   Vector2 localCoordinates;
377   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
378
379   // Emit a down signal
380   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
381   DALI_TEST_EQUALS(true, handleData.signalReceived, TEST_LOCATION);
382   DALI_TEST_EQUALS(1u, handleData.receivedTouchHandle.GetPointCount(), TEST_LOCATION);
383   DALI_TEST_EQUALS(PointState::DOWN, handleData.receivedTouchHandle.GetState(0), TEST_LOCATION);
384   DALI_TEST_EQUALS(screenCoordinates, handleData.receivedTouchHandle.GetScreenPosition(0), TEST_LOCATION);
385   DALI_TEST_EQUALS(localCoordinates, handleData.receivedTouchHandle.GetLocalPosition(0), 0.1f, TEST_LOCATION);
386
387   END_TEST;
388 }
389
390 int UtcDaliTouchEventAPINegative(void)
391 {
392   TestApplication application;
393
394   Actor actor = Actor::New();
395   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
396   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
397   application.GetScene().Add(actor);
398
399   // Render and notify
400   application.SendNotification();
401   application.Render();
402
403   // Connect to actor's touched signal
404   OutOfBoundsData    data;
405   OutOfBoundsFunctor functor(data, true);
406   actor.TouchedSignal().Connect(&application, functor);
407
408   Vector2 screenCoordinates(10.0f, 10.0f);
409   Vector2 localCoordinates;
410   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
411
412   // Emit a down signal
413   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
414
415   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
416   DALI_TEST_EQUALS(-1, data.point.deviceId, TEST_LOCATION);
417   DALI_TEST_EQUALS(PointState::FINISHED, data.point.state, TEST_LOCATION);
418   DALI_TEST_EQUALS(Vector2::ZERO, data.point.screen, TEST_LOCATION);
419   DALI_TEST_EQUALS(Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION);
420   DALI_TEST_CHECK(!data.point.hitActor);
421
422   END_TEST;
423 }
424
425 int UtcDaliTouchEventOutsideCameraNearFarPlanes(void)
426 {
427   TestApplication application;
428
429   Integration::Scene scene     = application.GetScene();
430   Vector2            sceneSize = scene.GetSize();
431
432   Actor actor = Actor::New();
433   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
434   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
435   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
436   scene.Add(actor);
437
438   // Render and notify
439   application.SendNotification();
440   application.Render();
441
442   // Get the camera's near and far planes
443   RenderTaskList   taskList  = scene.GetRenderTaskList();
444   Dali::RenderTask task      = taskList.GetTask(0);
445   CameraActor      camera    = task.GetCameraActor();
446   float            nearPlane = camera.GetNearClippingPlane();
447   float            farPlane  = camera.GetFarClippingPlane();
448
449   // Calculate the current distance of the actor from the camera
450   float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
451   float distance   = (sceneSize.y * 0.5f) / tanHalfFov;
452
453   // Connect to actor's touched signal
454   SignalData        data;
455   TouchEventFunctor functor(data);
456   actor.TouchedSignal().Connect(&application, functor);
457
458   Vector2 screenCoordinates(sceneSize.x * 0.5f, sceneSize.y * 0.5f);
459
460   // Emit a down signal
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 just at the camera's near plane
466   actor.SetProperty(Actor::Property::POSITION_Z, distance - nearPlane);
467
468   // Render and notify
469   application.SendNotification();
470   application.Render();
471
472   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
473   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
474   data.Reset();
475
476   // Emit a down signal where actor is closer than the camera's near plane
477   actor.SetProperty(Actor::Property::POSITION_Z, (distance - nearPlane) + 1.0f);
478
479   // Render and notify
480   application.SendNotification();
481   application.Render();
482
483   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
484   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
485   data.Reset();
486
487   // Emit a down signal where actor is just at the camera's far plane
488   actor.SetProperty(Actor::Property::POSITION_Z, distance - farPlane);
489
490   // Render and notify
491   application.SendNotification();
492   application.Render();
493
494   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
495   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
496   data.Reset();
497
498   // Emit a down signal where actor is further than the camera's far plane
499   actor.SetProperty(Actor::Property::POSITION_Z, (distance - farPlane) - 1.0f);
500
501   // Render and notify
502   application.SendNotification();
503   application.Render();
504
505   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
506   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
507   data.Reset();
508   END_TEST;
509 }
510
511 int UtcDaliTouchEventEmitEmpty(void)
512 {
513   TestApplication application;
514
515   try
516   {
517     // Emit an empty TouchEvent
518     Integration::TouchEvent event;
519     application.ProcessEvent(event);
520     tet_result(TET_FAIL);
521   }
522   catch(Dali::DaliException& e)
523   {
524     DALI_TEST_ASSERT(e, "!event.points.empty()", TEST_LOCATION);
525   }
526   END_TEST;
527 }
528
529 int UtcDaliTouchEventInterrupted(void)
530 {
531   TestApplication application;
532
533   Actor actor = Actor::New();
534   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
535   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
536   application.GetScene().Add(actor);
537
538   // Render and notify
539   application.SendNotification();
540   application.Render();
541
542   // Connect to actor's touched signal
543   SignalData        data;
544   TouchEventFunctor functor(data);
545   actor.TouchedSignal().Connect(&application, functor);
546
547   // Emit a down signal
548   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
549   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
550   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
551   data.Reset();
552
553   // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
554   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f /* Outside actor */)));
555   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
556   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
557   data.Reset();
558
559   // Emit another interrupted signal, our signal handler should not be called.
560   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f)));
561   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
562   END_TEST;
563 }
564
565 int UtcDaliTouchEventParentConsumer(void)
566 {
567   TestApplication application;
568   Actor           rootActor(application.GetScene().GetRootLayer());
569
570   Actor actor = Actor::New();
571   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
572   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
573   application.GetScene().Add(actor);
574
575   // Render and notify
576   application.SendNotification();
577   application.Render();
578
579   // Connect to actor's touched signal
580   SignalData        data;
581   TouchEventFunctor functor(data, false);
582   actor.TouchedSignal().Connect(&application, functor);
583
584   // Connect to root actor's touched signal
585   SignalData        rootData;
586   TouchEventFunctor rootFunctor(rootData); // Consumes signal
587   rootActor.TouchedSignal().Connect(&application, rootFunctor);
588
589   Vector2 screenCoordinates(10.0f, 10.0f);
590   Vector2 actorCoordinates, rootCoordinates;
591   actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y);
592   rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y);
593
594   // Emit a down signal
595   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
596   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
597   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
598   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
599   DALI_TEST_EQUALS(1u, rootData.receivedTouch.GetPointCount(), TEST_LOCATION);
600   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
601   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
602   DALI_TEST_EQUALS(screenCoordinates, data.receivedTouch.points[0].screen, TEST_LOCATION);
603   DALI_TEST_EQUALS(screenCoordinates, rootData.receivedTouch.points[0].screen, TEST_LOCATION);
604   DALI_TEST_EQUALS(actorCoordinates, data.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
605   DALI_TEST_EQUALS(rootCoordinates, rootData.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
606   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
607   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
608   data.Reset();
609   rootData.Reset();
610
611   // Emit a motion signal
612   screenCoordinates.x = screenCoordinates.y = 11.0f;
613   actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y);
614   rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y);
615   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
616   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
617   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
618   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
619   DALI_TEST_EQUALS(1u, rootData.receivedTouch.GetPointCount(), TEST_LOCATION);
620   DALI_TEST_EQUALS(PointState::MOTION, data.receivedTouch.points[0].state, TEST_LOCATION);
621   DALI_TEST_EQUALS(PointState::MOTION, rootData.receivedTouch.points[0].state, TEST_LOCATION);
622   DALI_TEST_EQUALS(screenCoordinates, data.receivedTouch.points[0].screen, TEST_LOCATION);
623   DALI_TEST_EQUALS(screenCoordinates, rootData.receivedTouch.points[0].screen, TEST_LOCATION);
624   DALI_TEST_EQUALS(actorCoordinates, data.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
625   DALI_TEST_EQUALS(rootCoordinates, rootData.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
626   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
627   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
628   data.Reset();
629   rootData.Reset();
630
631   // Emit an up signal
632   screenCoordinates.x = screenCoordinates.y = 12.0f;
633   actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y);
634   rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y);
635   application.ProcessEvent(GenerateSingleTouch(PointState::UP, screenCoordinates));
636   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
637   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
638   DALI_TEST_EQUALS(1u, data.receivedTouch.GetPointCount(), TEST_LOCATION);
639   DALI_TEST_EQUALS(1u, rootData.receivedTouch.GetPointCount(), TEST_LOCATION);
640   DALI_TEST_EQUALS(PointState::UP, data.receivedTouch.points[0].state, TEST_LOCATION);
641   DALI_TEST_EQUALS(PointState::UP, rootData.receivedTouch.points[0].state, TEST_LOCATION);
642   DALI_TEST_EQUALS(screenCoordinates, data.receivedTouch.points[0].screen, TEST_LOCATION);
643   DALI_TEST_EQUALS(screenCoordinates, rootData.receivedTouch.points[0].screen, TEST_LOCATION);
644   DALI_TEST_EQUALS(actorCoordinates, data.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
645   DALI_TEST_EQUALS(rootCoordinates, rootData.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
646   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
647   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
648   data.Reset();
649   rootData.Reset();
650
651   // Emit a down signal where the actor is not present, will hit the root actor though
652   screenCoordinates.x = screenCoordinates.y = 200.0f;
653   rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y);
654   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
655   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
656   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
657   DALI_TEST_EQUALS(1u, rootData.receivedTouch.GetPointCount(), TEST_LOCATION);
658   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
659   DALI_TEST_EQUALS(screenCoordinates, rootData.receivedTouch.points[0].screen, TEST_LOCATION);
660   DALI_TEST_EQUALS(rootCoordinates, rootData.receivedTouch.points[0].local, 0.1f, TEST_LOCATION);
661   DALI_TEST_CHECK(rootActor == rootData.receivedTouch.points[0].hitActor);
662   END_TEST;
663 }
664
665 int UtcDaliTouchEventInterruptedParentConsumer(void)
666 {
667   TestApplication application;
668   Actor           rootActor(application.GetScene().GetRootLayer());
669
670   Actor actor = Actor::New();
671   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
672   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
673   application.GetScene().Add(actor);
674
675   // Render and notify
676   application.SendNotification();
677   application.Render();
678
679   // Connect to actor's touched signal
680   SignalData        data;
681   TouchEventFunctor functor(data, false);
682   actor.TouchedSignal().Connect(&application, functor);
683
684   // Connect to root actor's touched signal
685   SignalData        rootData;
686   TouchEventFunctor rootFunctor(rootData); // Consumes signal
687   rootActor.TouchedSignal().Connect(&application, rootFunctor);
688
689   // Emit a down signal
690   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
691   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
692   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
693   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
694   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
695   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
696   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
697   data.Reset();
698   rootData.Reset();
699
700   // Emit an interrupted signal
701   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f)));
702   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
703   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
704   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
705   DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.receivedTouch.points[0].state, TEST_LOCATION);
706   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
707   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
708   data.Reset();
709   rootData.Reset();
710
711   // Emit another down signal
712   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
713   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
714   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
715   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
716   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
717   data.Reset();
718   rootData.Reset();
719
720   // Remove actor from scene
721   application.GetScene().Remove(actor);
722   data.Reset();
723   rootData.Reset();
724
725   // Render and notify
726   application.SendNotification();
727   application.Render();
728
729   // Emit an interrupted signal, only root actor's signal should be called.
730   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f /* Outside actor */)));
731   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
732   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
733   DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.receivedTouch.points[0].state, TEST_LOCATION);
734   DALI_TEST_CHECK(rootActor == rootData.receivedTouch.points[0].hitActor);
735   data.Reset();
736   rootData.Reset();
737
738   // Emit another interrupted state, none of the signal's should be called.
739   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(200.0f, 200.0f)));
740   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
741   DALI_TEST_EQUALS(false, rootData.functorCalled, TEST_LOCATION);
742   END_TEST;
743 }
744
745 int UtcDaliTouchEventLeave(void)
746 {
747   TestApplication application;
748
749   Actor actor = Actor::New();
750   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
751   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
752   application.GetScene().Add(actor);
753
754   // Render and notify
755   application.SendNotification();
756   application.Render();
757
758   // Connect to actor's touched signal
759   SignalData        data;
760   TouchEventFunctor functor(data);
761   actor.TouchedSignal().Connect(&application, functor);
762
763   // Set actor to require leave events
764   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
765
766   // Emit a down signal
767   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
768   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
769   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
770   data.Reset();
771
772   // Emit a motion signal outside of actor, should be signalled with a Leave
773   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
774   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
775   DALI_TEST_EQUALS(PointState::LEAVE, data.receivedTouch.points[0].state, TEST_LOCATION);
776   data.Reset();
777
778   // Another motion outside of actor, no signalling
779   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(201.0f, 201.0f)));
780   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
781   data.Reset();
782
783   // Another motion event inside actor, signalled with motion
784   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(10.0f, 10.0f)));
785   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
786   DALI_TEST_EQUALS(PointState::MOTION, data.receivedTouch.points[0].state, TEST_LOCATION);
787   data.Reset();
788
789   // We do not want to listen to leave events anymore
790   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
791
792   // Another motion event outside of actor, no signalling
793   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
794   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
795   data.Reset();
796   END_TEST;
797 }
798
799 int UtcDaliTouchEventLeaveParentConsumer(void)
800 {
801   TestApplication application;
802   Actor           rootActor(application.GetScene().GetRootLayer());
803
804   Actor actor = Actor::New();
805   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
806   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
807   application.GetScene().Add(actor);
808
809   // Render and notify
810   application.SendNotification();
811   application.Render();
812
813   // Connect to actor's touched signal
814   SignalData        data;
815   TouchEventFunctor functor(data, false);
816   actor.TouchedSignal().Connect(&application, functor);
817
818   // Connect to root actor's touched signal
819   SignalData        rootData;
820   TouchEventFunctor rootFunctor(rootData); // Consumes signal
821   rootActor.TouchedSignal().Connect(&application, rootFunctor);
822
823   // Set actor to require leave events
824   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
825   rootActor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
826
827   // Emit a down signal
828   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
829   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
830   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
831   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
832   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
833   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
834   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
835   data.Reset();
836   rootData.Reset();
837
838   // Emit a motion signal outside of actor, should be signalled with a Leave
839   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
840   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
841   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
842   DALI_TEST_EQUALS(PointState::LEAVE, data.receivedTouch.points[0].state, TEST_LOCATION);
843   DALI_TEST_EQUALS(PointState::LEAVE, rootData.receivedTouch.points[0].state, TEST_LOCATION);
844   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
845   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
846   data.Reset();
847   rootData.Reset();
848
849   // Another motion outside of actor, only rootActor signalled
850   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(201.0f, 201.0f)));
851   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
852   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
853   DALI_TEST_EQUALS(PointState::MOTION, rootData.receivedTouch.points[0].state, TEST_LOCATION);
854   DALI_TEST_CHECK(rootActor == rootData.receivedTouch.points[0].hitActor);
855   data.Reset();
856   rootData.Reset();
857
858   // Another motion event inside actor, signalled with motion
859   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(10.0f, 10.0f)));
860   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
861   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
862   DALI_TEST_EQUALS(PointState::MOTION, data.receivedTouch.points[0].state, TEST_LOCATION);
863   DALI_TEST_EQUALS(PointState::MOTION, rootData.receivedTouch.points[0].state, TEST_LOCATION);
864   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
865   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
866   data.Reset();
867   rootData.Reset();
868
869   // We do not want to listen to leave events of actor anymore
870   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
871
872   // Another motion event outside of root actor, only root signalled
873   Vector2 sceneSize(application.GetScene().GetSize());
874   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(sceneSize.width + 10.0f, sceneSize.height + 10.0f)));
875   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
876   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
877   DALI_TEST_EQUALS(PointState::LEAVE, rootData.receivedTouch.points[0].state, TEST_LOCATION);
878   END_TEST;
879 }
880
881 int UtcDaliTouchEventActorBecomesInsensitive(void)
882 {
883   TestApplication application;
884
885   Actor actor = Actor::New();
886   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
887   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
888   application.GetScene().Add(actor);
889
890   // Render and notify
891   application.SendNotification();
892   application.Render();
893
894   // Connect to actor's touched signal
895   SignalData        data;
896   TouchEventFunctor functor(data);
897   actor.TouchedSignal().Connect(&application, functor);
898
899   // Emit a down signal
900   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
901   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
902   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
903   data.Reset();
904
905   // Change actor to insensitive
906   actor.SetProperty(Actor::Property::SENSITIVE, false);
907
908   // Emit a motion signal, signalled with an interrupted
909   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
910   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
911   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
912   data.Reset();
913   END_TEST;
914 }
915
916 int UtcDaliTouchEventActorBecomesInsensitiveParentConsumer(void)
917 {
918   TestApplication application;
919   Actor           rootActor(application.GetScene().GetRootLayer());
920
921   Actor actor = Actor::New();
922   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
923   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
924   application.GetScene().Add(actor);
925
926   // Render and notify
927   application.SendNotification();
928   application.Render();
929
930   // Connect to actor's touched signal
931   SignalData        data;
932   TouchEventFunctor functor(data, false);
933   actor.TouchedSignal().Connect(&application, functor);
934
935   // Connect to root actor's touched signal
936   SignalData        rootData;
937   TouchEventFunctor rootFunctor(rootData); // Consumes signal
938   rootActor.TouchedSignal().Connect(&application, rootFunctor);
939
940   // Emit a down signal
941   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
942   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
943   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
944   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
945   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
946   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
947   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
948   data.Reset();
949   rootData.Reset();
950
951   // Render and notify
952   application.SendNotification();
953   application.Render();
954
955   // Make root actor insensitive
956   rootActor.SetProperty(Actor::Property::SENSITIVE, false);
957
958   // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
959   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
960   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
961   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
962   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
963   DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.receivedTouch.points[0].state, TEST_LOCATION);
964   END_TEST;
965 }
966
967 int UtcDaliTouchEventActorBecomesUserInteractionDisabled(void)
968 {
969   TestApplication application;
970
971   Actor actor = Actor::New();
972   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
973   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
974   application.GetScene().Add(actor);
975
976   // Render and notify
977   application.SendNotification();
978   application.Render();
979
980   // Connect to actor's touched signal
981   SignalData        data;
982   TouchEventFunctor functor(data);
983   actor.TouchedSignal().Connect(&application, functor);
984
985   // Emit a down signal
986   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
987   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
988   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
989   data.Reset();
990
991   // Change actor to disable user interaction.
992   actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
993
994   // Emit a motion signal, signalled with an interrupted
995   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
996   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
997   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
998   data.Reset();
999   END_TEST;
1000 }
1001
1002 int UtcDaliTouchEventMultipleLayers(void)
1003 {
1004   TestApplication application;
1005   Actor           rootActor(application.GetScene().GetRootLayer());
1006
1007   // Connect to actor's touched signal
1008   SignalData        data;
1009   TouchEventFunctor functor(data);
1010
1011   Layer layer1(Layer::New());
1012   layer1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1013   layer1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1014   application.GetScene().Add(layer1);
1015
1016   Actor actor1(Actor::New());
1017   actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1018   actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1019   actor1.SetProperty(Actor::Property::POSITION_Z, 1.0f); // Should hit actor1 in this layer
1020   layer1.Add(actor1);
1021
1022   // Render and notify
1023   application.SendNotification();
1024   application.Render();
1025
1026   // Connect to layer1 and actor1
1027   layer1.TouchedSignal().Connect(&application, functor);
1028   actor1.TouchedSignal().Connect(&application, functor);
1029
1030   // Hit in hittable area, actor1 should be hit
1031   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1032   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1033   DALI_TEST_CHECK(data.touchedActor == actor1);
1034   data.Reset();
1035
1036   // Make layer1 insensitive, nothing should be hit
1037   layer1.SetProperty(Actor::Property::SENSITIVE, false);
1038   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1039   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1040   data.Reset();
1041
1042   // Make layer1 sensitive again, again actor1 will be hit
1043   layer1.SetProperty(Actor::Property::SENSITIVE, true);
1044   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1045   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1046   DALI_TEST_CHECK(data.touchedActor == actor1);
1047   data.Reset();
1048
1049   // Make rootActor insensitive, nothing should be hit
1050   rootActor.SetProperty(Actor::Property::SENSITIVE, false);
1051   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1052   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1053   data.Reset();
1054
1055   // Make rootActor sensitive
1056   rootActor.SetProperty(Actor::Property::SENSITIVE, true);
1057
1058   // Add another layer
1059   Layer layer2(Layer::New());
1060   layer2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1061   layer2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1062   layer2.SetProperty(Actor::Property::POSITION_Z, 10.0f); // Should hit layer2 in this layer rather than actor2
1063   application.GetScene().Add(layer2);
1064
1065   Actor actor2(Actor::New());
1066   actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1067   actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1068   layer2.Add(actor2);
1069
1070   // Render and notify
1071   application.SendNotification();
1072   application.Render();
1073
1074   // Connect to layer2 and actor2
1075   layer2.TouchedSignal().Connect(&application, functor);
1076   actor2.TouchedSignal().Connect(&application, functor);
1077
1078   // Emit an event, should hit layer2
1079   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1080   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1081   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1082   data.Reset();
1083
1084   // Make layer2 insensitive, should hit actor1
1085   layer2.SetProperty(Actor::Property::SENSITIVE, false);
1086   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1087   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1088   DALI_TEST_CHECK(data.touchedActor == actor1);
1089   data.Reset();
1090
1091   // Make layer2 sensitive again, should hit layer2
1092   layer2.SetProperty(Actor::Property::SENSITIVE, true);
1093   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1094   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1095   //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1096   data.Reset();
1097
1098   // Make layer2 invisible, render and notify
1099   layer2.SetProperty(Actor::Property::VISIBLE, false);
1100   application.SendNotification();
1101   application.Render();
1102
1103   // Should hit actor1
1104   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1105   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1106   DALI_TEST_CHECK(data.touchedActor == actor1);
1107   data.Reset();
1108
1109   // Make rootActor invisible, render and notify
1110   rootActor.SetProperty(Actor::Property::VISIBLE, false);
1111   application.SendNotification();
1112   application.Render();
1113
1114   // Should not hit anything
1115   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1116   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1117   data.Reset();
1118   END_TEST;
1119 }
1120
1121 int UtcDaliTouchEventMultipleRenderTasks(void)
1122 {
1123   TestApplication    application;
1124   Integration::Scene scene(application.GetScene());
1125   Vector2            sceneSize(scene.GetSize());
1126
1127   Actor actor = Actor::New();
1128   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1129   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1130   scene.Add(actor);
1131
1132   // Create render task
1133   Viewport   viewport(sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f);
1134   RenderTask renderTask(application.GetScene().GetRenderTaskList().CreateTask());
1135   renderTask.SetViewport(viewport);
1136   renderTask.SetInputEnabled(true);
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(PointState::DOWN, Vector2(10.0f, 10.0f)));
1149   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1150   data.Reset();
1151
1152   // Ensure renderTask actor can be hit too.
1153   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(viewport.x + 5.0f, viewport.y + 5.0f)));
1154   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1155   data.Reset();
1156
1157   // Disable input on renderTask, should not be hittable
1158   renderTask.SetInputEnabled(false);
1159   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(viewport.x + 5.0f, viewport.y + 5.0f)));
1160   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1161   data.Reset();
1162   END_TEST;
1163 }
1164
1165 int UtcDaliTouchEventMultipleRenderTasksWithChildLayer(void)
1166 {
1167   TestApplication    application;
1168   Integration::Scene scene(application.GetScene());
1169   Vector2            sceneSize(scene.GetSize());
1170
1171   Actor actor = Actor::New();
1172   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1173   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1174   scene.Add(actor);
1175
1176   Layer layer = Layer::New();
1177   layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1178   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1179   actor.Add(layer);
1180
1181   // Create render task
1182   Viewport   viewport(sceneSize.width * 0.5f, sceneSize.height * 0.5f, sceneSize.width * 0.5f, sceneSize.height * 0.5f);
1183   RenderTask renderTask(application.GetScene().GetRenderTaskList().CreateTask());
1184   renderTask.SetViewport(viewport);
1185   renderTask.SetInputEnabled(true);
1186   renderTask.SetSourceActor(actor);
1187
1188   // Render and notify
1189   application.SendNotification();
1190   application.Render();
1191
1192   // Connect to layer's touched signal
1193   SignalData        data;
1194   TouchEventFunctor functor(data);
1195   actor.TouchedSignal().Connect(&application, functor);
1196   layer.TouchedSignal().Connect(&application, functor);
1197
1198   // Emit a down signal
1199   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1200   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1201   data.Reset();
1202
1203   // Ensure renderTask actor can be hit too.
1204   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(viewport.x + 5.0f, viewport.y + 5.0f)));
1205   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1206   data.Reset();
1207
1208   // Disable input on renderTask, should not be hittable
1209   renderTask.SetInputEnabled(false);
1210   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(viewport.x + 5.0f, viewport.y + 5.0f)));
1211   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1212   data.Reset();
1213   END_TEST;
1214 }
1215
1216 int UtcDaliTouchEventOffscreenRenderTasks(void)
1217 {
1218   TestApplication    application;
1219   Integration::Scene scene(application.GetScene());
1220   Vector2            sceneSize(scene.GetSize());
1221
1222   // FrameBufferImage for offscreen RenderTask
1223   FrameBuffer frameBuffer = FrameBuffer::New(sceneSize.width, sceneSize.height);
1224
1225   // Create a renderable actor to display the FrameBufferImage
1226   Actor renderableActor = CreateRenderableActor(frameBuffer.GetColorTexture());
1227   renderableActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1228   renderableActor.SetProperty(Actor::Property::SIZE, Vector2(sceneSize.x, sceneSize.y));
1229   renderableActor.ScaleBy(Vector3(1.0f, -1.0f, 1.0f)); // FIXME
1230   scene.Add(renderableActor);
1231
1232   Actor actor = Actor::New();
1233   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1234   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1235   scene.Add(actor);
1236   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); // Ensure framebuffer connects
1237
1238   scene.GetRenderTaskList().GetTask(0u).SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1239
1240   // Create a RenderTask
1241   RenderTask renderTask = scene.GetRenderTaskList().CreateTask();
1242   renderTask.SetSourceActor(actor);
1243   renderTask.SetFrameBuffer(frameBuffer);
1244   renderTask.SetInputEnabled(true);
1245
1246   // Create another RenderTask
1247   RenderTask renderTask2(scene.GetRenderTaskList().CreateTask());
1248   renderTask2.SetInputEnabled(true);
1249
1250   // Render and notify
1251   application.SendNotification();
1252   application.Render();
1253
1254   // Connect to actor's touched signal
1255   SignalData        data;
1256   TouchEventFunctor functor(data);
1257   actor.TouchedSignal().Connect(&application, functor);
1258
1259   // Emit a down signal
1260   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1261   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1262   data.Reset();
1263   END_TEST;
1264 }
1265
1266 int UtcDaliTouchEventMultipleRenderableActors(void)
1267 {
1268   TestApplication    application;
1269   Integration::Scene scene(application.GetScene());
1270   Vector2            sceneSize(scene.GetSize());
1271
1272   Actor parent = CreateRenderableActor();
1273   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1274   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1275   scene.Add(parent);
1276
1277   Actor actor = CreateRenderableActor();
1278   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1279   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1280   parent.Add(actor);
1281
1282   // Render and notify
1283   application.SendNotification();
1284   application.Render();
1285
1286   // Connect to layer's touched signal
1287   SignalData        data;
1288   TouchEventFunctor functor(data);
1289   parent.TouchedSignal().Connect(&application, functor);
1290   actor.TouchedSignal().Connect(&application, functor);
1291
1292   // Emit a down signal
1293   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1294   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1295   DALI_TEST_CHECK(actor == data.touchedActor);
1296   END_TEST;
1297 }
1298
1299 int UtcDaliTouchEventActorRemovedInSignal(void)
1300 {
1301   TestApplication application;
1302
1303   Actor actor = Actor::New();
1304   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1305   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1306   application.GetScene().Add(actor);
1307
1308   // Render and notify
1309   application.SendNotification();
1310   application.Render();
1311
1312   // Connect to actor's touched signal
1313   SignalData         data;
1314   RemoveActorFunctor functor(data);
1315   actor.TouchedSignal().Connect(&application, functor);
1316
1317   // Register for leave events
1318   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
1319
1320   // Emit a down signal
1321   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1322   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1323   data.Reset();
1324
1325   // Re-add, render and notify
1326   application.GetScene().Add(actor);
1327   application.SendNotification();
1328   application.Render();
1329
1330   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1331   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(210.0f, 210.0f)));
1332   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1333   data.Reset();
1334
1335   // Emit a down signal
1336   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1337   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1338   data.Reset();
1339
1340   // Render and notify
1341   application.SendNotification();
1342   application.Render();
1343
1344   // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1345   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(210.0f, 210.0f)));
1346   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1347   data.Reset();
1348
1349   // Re-add actor back to scene, render and notify
1350   application.GetScene().Add(actor);
1351   application.SendNotification();
1352   application.Render();
1353
1354   // Emit another down event
1355   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1356   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1357   data.Reset();
1358
1359   // Completely delete the actor
1360   actor.Reset();
1361
1362   // Emit event, should not crash and should not receive an event.
1363   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(210.0f, 210.0f)));
1364   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1365   END_TEST;
1366 }
1367
1368 int UtcDaliTouchEventActorSignalNotConsumed(void)
1369 {
1370   TestApplication application;
1371
1372   Actor actor = Actor::New();
1373   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1374   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1375   application.GetScene().Add(actor);
1376
1377   // Render and notify
1378   application.SendNotification();
1379   application.Render();
1380
1381   // Connect to actor's touched signal
1382   SignalData        data;
1383   TouchEventFunctor functor(data, false);
1384   actor.TouchedSignal().Connect(&application, functor);
1385
1386   // Emit a down signal
1387   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1388   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1389   END_TEST;
1390 }
1391
1392 int UtcDaliTouchEventActorRemovedFromScene(void)
1393 {
1394   TestApplication application;
1395
1396   Actor actor = Actor::New();
1397   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1398   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1399   application.GetScene().Add(actor);
1400
1401   // Render and notify
1402   application.SendNotification();
1403   application.Render();
1404
1405   // Connect to actor's touched signal
1406   SignalData        data;
1407   TouchEventFunctor functor(data);
1408   actor.TouchedSignal().Connect(&application, functor);
1409
1410   // Emit a down signal
1411   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1412   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1413   data.Reset();
1414
1415   // Remove actor from scene
1416   application.GetScene().Remove(actor);
1417   data.Reset();
1418
1419   // Render and notify
1420   application.SendNotification();
1421   application.Render();
1422
1423   // Emit a move at the same point, we should not be signalled.
1424   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(10.0f, 10.0f)));
1425   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1426   data.Reset();
1427   END_TEST;
1428 }
1429
1430 int UtcDaliTouchEventLayerConsumesTouch(void)
1431 {
1432   TestApplication application;
1433
1434   Actor actor = Actor::New();
1435   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1436   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1437   application.GetScene().Add(actor);
1438
1439   // Render and notify
1440   application.SendNotification();
1441   application.Render();
1442
1443   // Connect to actor's touched signal
1444   SignalData        data;
1445   TouchEventFunctor functor(data);
1446   actor.TouchedSignal().Connect(&application, functor);
1447
1448   // Add a layer to overlap the actor
1449   Layer layer = Layer::New();
1450   layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1451   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1452   application.GetScene().Add(layer);
1453   layer.RaiseToTop();
1454
1455   // Render and notify
1456   application.SendNotification();
1457   application.Render();
1458
1459   // Emit a few touch signals
1460   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1461   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(10.0f, 10.0f)));
1462   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1463   data.Reset();
1464
1465   // Set layer to consume all touch
1466   layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
1467
1468   // Render and notify
1469   application.SendNotification();
1470   application.Render();
1471
1472   // Emit the same signals again, should not receive
1473   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1474   application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(10.0f, 10.0f)));
1475   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1476   data.Reset();
1477
1478   END_TEST;
1479 }
1480
1481 int UtcDaliTouchEventLeaveActorReadded(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   // Set actor to receive touch-events
1492   actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
1493
1494   // Render and notify
1495   application.SendNotification();
1496   application.Render();
1497
1498   // Connect to actor's touched signal
1499   SignalData        data;
1500   TouchEventFunctor functor(data);
1501   actor.TouchedSignal().Connect(&application, functor);
1502
1503   // Emit a down and motion
1504   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1505   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(11.0f, 10.0f)));
1506   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1507   data.Reset();
1508
1509   // Remove actor from scene and add again
1510   scene.Remove(actor);
1511   scene.Add(actor);
1512
1513   // Emit a motion within the actor's bounds
1514   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(12.0f, 10.0f)));
1515   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1516   data.Reset();
1517
1518   // Emit a motion outside the actor's bounds
1519   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(200.0f, 200.0f)));
1520   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1521   DALI_TEST_EQUALS(PointState::LEAVE, data.receivedTouch.points[0].state, TEST_LOCATION);
1522   data.Reset();
1523
1524   END_TEST;
1525 }
1526
1527 int UtcDaliTouchEventClippedActor(void)
1528 {
1529   TestApplication    application;
1530   Integration::Scene scene = application.GetScene();
1531
1532   Actor actor = Actor::New();
1533   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1534   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1535   scene.Add(actor);
1536
1537   Actor clippingActor = Actor::New();
1538   clippingActor.SetProperty(Actor::Property::SIZE, Vector2(50.0f, 50.0f));
1539   clippingActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1540   clippingActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
1541   scene.Add(clippingActor);
1542
1543   // Add a child to the clipped region.
1544   Actor clippingChild = Actor::New();
1545   clippingChild.SetProperty(Actor::Property::SIZE, Vector2(50.0f, 50.0f));
1546   clippingChild.SetProperty(Actor::Property::POSITION, Vector2(25.0f, 25.0f));
1547   clippingChild.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1548   clippingActor.Add(clippingChild);
1549
1550   // Render and notify.
1551   application.SendNotification();
1552   application.Render();
1553
1554   // Connect to actor's touch signal.
1555   SignalData        data;
1556   TouchEventFunctor functor(data);
1557   actor.TouchedSignal().Connect(&application, functor);
1558
1559   // Emit an event within clipped area - we should have a hit.
1560   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1561   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1562   data.Reset();
1563
1564   // Emit an event within clipped child area - we should still have a hit.
1565   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
1566   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1567   data.Reset();
1568
1569   // Now connect to the clippingChild's touch signal
1570   SignalData        clippingChildData;
1571   TouchEventFunctor clippingChildFunctor(clippingChildData);
1572   clippingChild.TouchedSignal().Connect(&application, clippingChildFunctor);
1573
1574   // Emit an event within clipped child area - no hit on actor, but hit on clipped child.
1575   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
1576   DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
1577   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1578   data.Reset();
1579   clippingChildData.Reset();
1580
1581   // Emit an event outside the clipped area but within the actor area, we should have a hit.
1582   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(60.0f, 60.0f)));
1583   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1584   data.Reset();
1585   clippingChildData.Reset();
1586
1587   // Emit an event inside part of the child which is within the clipped area, we should have a hit on the clipped child but not the actor.
1588   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f)));
1589   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1590   DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
1591   data.Reset();
1592   clippingChildData.Reset();
1593
1594   END_TEST;
1595 }
1596
1597 int UtcDaliTouchEventActorUnparented(void)
1598 {
1599   TestApplication application;
1600
1601   Actor actor = Actor::New();
1602   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1603   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1604   application.GetScene().Add(actor);
1605
1606   // Render and notify
1607   application.SendNotification();
1608   application.Render();
1609
1610   // Connect to actor's touched signal
1611   SignalData        data;
1612   TouchEventFunctor functor(data);
1613   actor.TouchedSignal().Connect(&application, functor);
1614
1615   // Emit a down signal
1616   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1617   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1618   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1619   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
1620   data.Reset();
1621
1622   // Render and notify
1623   application.SendNotification();
1624   application.Render();
1625
1626   // Unparent the actor
1627   actor.Unparent();
1628
1629   // Should receive an interrupted event
1630   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1631   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
1632   END_TEST;
1633 }
1634
1635 int UtcDaliTouchEventParentRemovedFromScene(void)
1636 {
1637   TestApplication application;
1638
1639   Actor parent = Actor::New();
1640   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1641   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1642   application.GetScene().Add(parent);
1643
1644   Actor actor = Actor::New();
1645   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1646   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1647   parent.Add(actor);
1648
1649   // Render and notify
1650   application.SendNotification();
1651   application.Render();
1652
1653   // Connect to actor's touched signal
1654   SignalData        data;
1655   TouchEventFunctor functor(data);
1656   actor.TouchedSignal().Connect(&application, functor);
1657
1658   // Emit a down signal
1659   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1660   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1661   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1662   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
1663   data.Reset();
1664
1665   // Render and notify
1666   application.SendNotification();
1667   application.Render();
1668
1669   // Unparent the parent of the touchable actor
1670   parent.Unparent();
1671
1672   // Should receive an interrupted event
1673   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1674   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
1675   END_TEST;
1676 }
1677
1678 int UtcDaliTouchEventActorRemovedFromSceneDifferentConsumer(void)
1679 {
1680   TestApplication application;
1681
1682   Actor parent = Actor::New();
1683   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1684   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1685   application.GetScene().Add(parent);
1686
1687   Actor actor = Actor::New();
1688   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1689   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1690   parent.Add(actor);
1691
1692   // Render and notify
1693   application.SendNotification();
1694   application.Render();
1695
1696   // Connect to actor's touched signal
1697   SignalData        data;
1698   TouchEventFunctor functor(data, false /* Do not consume */);
1699   actor.TouchedSignal().Connect(&application, functor);
1700
1701   // Connect to parent's touched signal
1702   SignalData        parentData;
1703   TouchEventFunctor parentFunctor(parentData);
1704   parent.TouchedSignal().Connect(&application, parentFunctor);
1705
1706   // Emit a down signal
1707   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1708   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1709   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1710   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
1711   DALI_TEST_CHECK(actor == data.touchedActor);
1712   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1713   DALI_TEST_EQUALS(PointState::DOWN, parentData.receivedTouch.points[0].state, TEST_LOCATION);
1714   DALI_TEST_CHECK(actor == parentData.receivedTouch.points[0].hitActor);
1715   DALI_TEST_CHECK(parent == parentData.touchedActor);
1716   data.Reset();
1717   parentData.Reset();
1718
1719   // Render and notify
1720   application.SendNotification();
1721   application.Render();
1722
1723   // Unparent the actor
1724   actor.Unparent();
1725
1726   // Should receive an interrupted event for both actor & parent
1727   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1728   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
1729   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1730   DALI_TEST_EQUALS(PointState::INTERRUPTED, parentData.receivedTouch.points[0].state, TEST_LOCATION);
1731   data.Reset();
1732   parentData.Reset();
1733
1734   // Readd actor to parent
1735   parent.Add(actor);
1736
1737   // Render and notify
1738   application.SendNotification();
1739   application.Render();
1740
1741   // Emit a motion signal
1742   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(10.0f, 10.0f)));
1743   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1744   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1745   data.Reset();
1746   parentData.Reset();
1747
1748   // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1749   SignalData        secondData;
1750   TouchEventFunctor secondFunctor(secondData /* Consume */);
1751   actor.TouchedSignal().Connect(&application, secondFunctor);
1752
1753   // Unparent the actor
1754   actor.Unparent();
1755
1756   // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1757   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1758   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
1759   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1760   DALI_TEST_EQUALS(PointState::INTERRUPTED, parentData.receivedTouch.points[0].state, TEST_LOCATION);
1761   DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
1762   DALI_TEST_EQUALS(PointState::INTERRUPTED, secondData.receivedTouch.points[0].state, TEST_LOCATION);
1763   data.Reset();
1764   parentData.Reset();
1765   secondData.Reset();
1766
1767   END_TEST;
1768 }
1769
1770 int UtcDaliTouchEventInterruptedDifferentConsumer(void)
1771 {
1772   TestApplication application;
1773   Actor           rootActor(application.GetScene().GetRootLayer());
1774
1775   Actor parent = Actor::New();
1776   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1777   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1778   application.GetScene().Add(parent);
1779
1780   Actor actor = Actor::New();
1781   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1782   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1783   parent.Add(actor);
1784
1785   // Render and notify
1786   application.SendNotification();
1787   application.Render();
1788
1789   // Connect to actor's touched signal
1790   SignalData        data;
1791   TouchEventFunctor functor(data, false /* Do not consume */);
1792   actor.TouchedSignal().Connect(&application, functor);
1793
1794   // Connect to parent's touched signal
1795   SignalData        parentData;
1796   TouchEventFunctor parentFunctor(parentData, false /* Do not consume */);
1797   parent.TouchedSignal().Connect(&application, parentFunctor);
1798
1799   // Connect to root's touched signal and consume
1800   SignalData        rootData;
1801   TouchEventFunctor rootFunctor(rootData);
1802   rootActor.TouchedSignal().Connect(&application, rootFunctor);
1803
1804   // Emit a down signal
1805   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1806   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1807   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1808   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
1809   DALI_TEST_CHECK(actor == data.touchedActor);
1810   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1811   DALI_TEST_EQUALS(PointState::DOWN, parentData.receivedTouch.points[0].state, TEST_LOCATION);
1812   DALI_TEST_CHECK(actor == parentData.receivedTouch.points[0].hitActor);
1813   DALI_TEST_CHECK(parent == parentData.touchedActor);
1814   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
1815   DALI_TEST_EQUALS(PointState::DOWN, rootData.receivedTouch.points[0].state, TEST_LOCATION);
1816   DALI_TEST_CHECK(actor == rootData.receivedTouch.points[0].hitActor);
1817   DALI_TEST_CHECK(rootActor == rootData.touchedActor);
1818   data.Reset();
1819   parentData.Reset();
1820   rootData.Reset();
1821
1822   // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1823   SignalData        secondData;
1824   TouchEventFunctor secondFunctor(secondData /* Consume */);
1825   parent.TouchedSignal().Connect(&application, secondFunctor);
1826
1827   // Emit an interrupted signal, all three should STILL be called
1828   application.ProcessEvent(GenerateSingleTouch(PointState::INTERRUPTED, Vector2(10.0f, 10.0f)));
1829   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1830   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
1831   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
1832   DALI_TEST_EQUALS(PointState::INTERRUPTED, parentData.receivedTouch.points[0].state, TEST_LOCATION);
1833   DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION);
1834   DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.receivedTouch.points[0].state, TEST_LOCATION);
1835   data.Reset();
1836   parentData.Reset();
1837   rootData.Reset();
1838
1839   END_TEST;
1840 }
1841
1842 int UtcDaliTouchEventGetRadius(void)
1843 {
1844   TestApplication application;
1845
1846   Actor actor = Actor::New();
1847   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1848   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1849   application.GetScene().Add(actor);
1850
1851   // Render and notify
1852   application.SendNotification();
1853   application.Render();
1854
1855   // Connect to actor's touched signal
1856   SignalData        data;
1857   TouchEventFunctor functor(data);
1858   actor.TouchedSignal().Connect(&application, functor);
1859
1860   // Emit a down signal with an angle
1861   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
1862   touchEvent.points[0].SetRadius(100.0f);
1863   application.ProcessEvent(touchEvent);
1864   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1865   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1866   DALI_TEST_EQUALS(100.0f, data.receivedTouch.points[0].radius, TEST_LOCATION);
1867   DALI_TEST_EQUALS(100.0f, data.receivedTouch.points[0].ellipseRadius.x, TEST_LOCATION);
1868   DALI_TEST_EQUALS(100.0f, data.receivedTouch.points[0].ellipseRadius.y, TEST_LOCATION);
1869
1870   END_TEST;
1871 }
1872
1873 int UtcDaliTouchEventGetEllipseRadius(void)
1874 {
1875   TestApplication application;
1876
1877   Actor actor = Actor::New();
1878   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1879   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1880   application.GetScene().Add(actor);
1881
1882   // Render and notify
1883   application.SendNotification();
1884   application.Render();
1885
1886   // Connect to actor's touched signal
1887   SignalData        data;
1888   TouchEventFunctor functor(data);
1889   actor.TouchedSignal().Connect(&application, functor);
1890
1891   // Emit a down signal with an angle
1892   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
1893   touchEvent.points[0].SetRadius(100.0f, Vector2(20.0f, 10.0f));
1894   application.ProcessEvent(touchEvent);
1895   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1896   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1897   DALI_TEST_EQUALS(100.0f, data.receivedTouch.points[0].radius, TEST_LOCATION);
1898   DALI_TEST_EQUALS(20.0f, data.receivedTouch.points[0].ellipseRadius.x, TEST_LOCATION);
1899   DALI_TEST_EQUALS(10.0f, data.receivedTouch.points[0].ellipseRadius.y, TEST_LOCATION);
1900
1901   END_TEST;
1902 }
1903
1904 int UtcDaliTouchEventGetAngle(void)
1905 {
1906   TestApplication application;
1907
1908   Actor actor = Actor::New();
1909   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1910   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1911   application.GetScene().Add(actor);
1912
1913   // Render and notify
1914   application.SendNotification();
1915   application.Render();
1916
1917   // Connect to actor's touched signal
1918   SignalData        data;
1919   TouchEventFunctor functor(data);
1920   actor.TouchedSignal().Connect(&application, functor);
1921
1922   // Emit a down signal with an angle
1923   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
1924   touchEvent.points[0].SetAngle(Degree(90.0f));
1925   application.ProcessEvent(touchEvent);
1926   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1927   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1928   DALI_TEST_EQUALS(Degree(90.0f), data.receivedTouch.points[0].angle, TEST_LOCATION);
1929
1930   END_TEST;
1931 }
1932
1933 int UtcDaliTouchEventGetPressure(void)
1934 {
1935   TestApplication application;
1936
1937   Actor actor = Actor::New();
1938   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1939   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1940   application.GetScene().Add(actor);
1941
1942   // Render and notify
1943   application.SendNotification();
1944   application.Render();
1945
1946   // Connect to actor's touched signal
1947   SignalData        data;
1948   TouchEventFunctor functor(data);
1949   actor.TouchedSignal().Connect(&application, functor);
1950
1951   // Emit a down signal with an angle
1952   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
1953   touchEvent.points[0].SetPressure(10.0f);
1954   application.ProcessEvent(touchEvent);
1955   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1956   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
1957   DALI_TEST_EQUALS(10.0f, data.receivedTouch.points[0].pressure, TEST_LOCATION);
1958
1959   END_TEST;
1960 }
1961
1962 int UtcDaliTouchEventUsage(void)
1963 {
1964   TestApplication application;
1965
1966   Actor actor = Actor::New();
1967   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1968   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1969   application.GetScene().Add(actor);
1970
1971   // Render and notify
1972   application.SendNotification();
1973   application.Render();
1974
1975   // Connect to actor's touched signal
1976   SignalData        data;
1977   TouchEventFunctor functor(data);
1978   actor.TouchedSignal().Connect(&application, functor);
1979
1980   // Emit a down signal with an angle
1981   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
1982   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1983
1984   END_TEST;
1985 }
1986
1987 int UtcDaliTouchEventGetDeviceAPINegative(void)
1988 {
1989   TestApplication application;
1990
1991   Actor actor = Actor::New();
1992   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1993   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1994   application.GetScene().Add(actor);
1995
1996   // Render and notify
1997   application.SendNotification();
1998   application.Render();
1999
2000   // Connect to actor's touched signal
2001   HandleData              handleData;
2002   TouchEventHandleFunctor functor(handleData);
2003   actor.TouchedSignal().Connect(&application, functor);
2004
2005   Vector2 screenCoordinates(10.0f, 10.0f);
2006   Vector2 localCoordinates;
2007   actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y);
2008
2009   // Emit a down signal
2010   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, screenCoordinates));
2011
2012   TouchEvent data = handleData.receivedTouchHandle;
2013   DALI_TEST_EQUALS(data.GetDeviceClass(-1), Device::Class::NONE, TEST_LOCATION);
2014   DALI_TEST_EQUALS(data.GetDeviceSubclass(-1), Device::Subclass::NONE, TEST_LOCATION);
2015   END_TEST;
2016 }
2017
2018 int UtcDaliTouchEventGetMouseButtonPositive(void)
2019 {
2020   TestApplication application;
2021
2022   Actor actor = Actor::New();
2023   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2024   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2025   application.GetScene().Add(actor);
2026
2027   // Render and notify
2028   application.SendNotification();
2029   application.Render();
2030
2031   // Connect to actor's touched signal
2032   HandleData              handleData;
2033   TouchEventHandleFunctor functor(handleData);
2034   actor.TouchedSignal().Connect(&application, functor);
2035
2036   // Emit a down signal with MouseButton
2037   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
2038   touchEvent.points[0].SetMouseButton(static_cast<MouseButton::Type>(3));
2039   application.ProcessEvent(touchEvent);
2040
2041   TouchEvent data = handleData.receivedTouchHandle;
2042   DALI_TEST_EQUALS(data.GetMouseButton(0), MouseButton::SECONDARY, TEST_LOCATION);
2043
2044   END_TEST;
2045 }
2046
2047 int UtcDaliTouchEventGetMouseButtonNagative(void)
2048 {
2049   TestApplication application;
2050
2051   Actor actor = Actor::New();
2052   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2053   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2054   application.GetScene().Add(actor);
2055
2056   // Render and notify
2057   application.SendNotification();
2058   application.Render();
2059
2060   // Connect to actor's touched signal
2061   HandleData              handleData;
2062   TouchEventHandleFunctor functor(handleData);
2063   actor.TouchedSignal().Connect(&application, functor);
2064
2065   // Emit a down signal with MouseButton
2066   Integration::TouchEvent touchEvent = GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f));
2067   touchEvent.points[0].SetMouseButton(static_cast<MouseButton::Type>(2));
2068   application.ProcessEvent(touchEvent);
2069
2070   TouchEvent data = handleData.receivedTouchHandle;
2071   DALI_TEST_EQUALS(data.GetMouseButton(0), MouseButton::TERTIARY, TEST_LOCATION);
2072   DALI_TEST_EQUALS(data.GetMouseButton(3), MouseButton::INVALID, TEST_LOCATION);
2073
2074   END_TEST;
2075 }
2076
2077 int UtcDaliTouchEventCapturePropertySet(void)
2078 {
2079   TestApplication application;
2080
2081   Actor actor = Actor::New();
2082   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2083   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2084   application.GetScene().Add(actor);
2085
2086   // Render and notify
2087   application.SendNotification();
2088   application.Render();
2089
2090   // Connect to actor's touched signal
2091   SignalData        data;
2092   TouchEventFunctor functor(data);
2093   actor.TouchedSignal().Connect(&application, functor);
2094
2095   // Emit a down signal
2096   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(10.0f, 10.0f)));
2097   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2098   data.Reset();
2099
2100   // Now motion outside of actor, we should not receive the event
2101   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(110.0f, 110.0f)));
2102   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2103   data.Reset();
2104
2105   // Up event, should receive an interrupted
2106   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f)));
2107   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2108   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::INTERRUPTED, TEST_LOCATION);
2109
2110   // Now set the capture property
2111   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
2112
2113   // Emit a down signal
2114   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(10.0f, 10.0f)));
2115   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2116   data.Reset();
2117
2118   // Now motion outside of actor, we now SHOULD receive the event
2119   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(110.0f, 110.0f)));
2120   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2121   data.Reset();
2122
2123   // Up event, we should receive it again, but as ended rather than interrupted
2124   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f)));
2125   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2126   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::FINISHED, TEST_LOCATION);
2127
2128   END_TEST;
2129 }
2130
2131 int UtcDaliTouchEventCapturePropertySetWithMultiTouch(void)
2132 {
2133   TestApplication application;
2134
2135   Actor actor = Actor::New();
2136   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2137   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2138   application.GetScene().Add(actor);
2139
2140   // Render and notify
2141   application.SendNotification();
2142   application.Render();
2143
2144   // Connect to actor's touched signal
2145   SignalData        data;
2146   TouchEventFunctor functor(data);
2147   actor.TouchedSignal().Connect(&application, functor);
2148
2149   // Now set the capture property
2150   actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
2151
2152   // Emit a down signal
2153   application.ProcessEvent(GenerateDoubleTouch(PointState::STARTED, Vector2(10.0f, 10.0f), PointState::STARTED, Vector2(15.0f, 15.0f), 200));
2154   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2155   data.Reset();
2156
2157   // Now motion outside of actor, we now SHOULD receive the event
2158   application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(110.0f, 110.0f), PointState::MOTION, Vector2(115.0f, 115.0f), 210));
2159   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2160   data.Reset();
2161
2162   // Up event, we should receive it again, but as ended rather than interrupted
2163   application.ProcessEvent(GenerateDoubleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f), PointState::FINISHED, Vector2(115.0f, 115.0f), 220));
2164   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2165   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::FINISHED, TEST_LOCATION);
2166   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(1).state, PointState::FINISHED, TEST_LOCATION);
2167
2168   END_TEST;
2169 }
2170
2171 int UtcDaliTouchEventIntegNewTouchEvent(void)
2172 {
2173   uint32_t         timestamp = 92858u;
2174   TouchPoint       tp(1, PointState::STARTED, 34.4f, 123.89f, 5.0f, 7.0f);
2175   Dali::TouchEvent touchEvent = Integration::NewTouchEvent(timestamp, tp);
2176
2177   DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1u, TEST_LOCATION);
2178   DALI_TEST_EQUALS(touchEvent.GetState(0), PointState::STARTED, TEST_LOCATION);
2179   DALI_TEST_EQUALS(touchEvent.GetLocalPosition(0), Vector2(5.0f, 7.0f), TEST_LOCATION);
2180   DALI_TEST_EQUALS(touchEvent.GetScreenPosition(0), Vector2(34.4f, 123.89f), TEST_LOCATION);
2181
2182   END_TEST;
2183 }
2184
2185 int UtcDaliTouchEventIntercept01(void)
2186 {
2187   TestApplication application;
2188
2189   Actor actor = Actor::New();
2190   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2191   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2192   application.GetScene().Add(actor);
2193
2194   // Render and notify
2195   application.SendNotification();
2196   application.Render();
2197
2198   // Connect to actor's intercept touched signal
2199   SignalData        data;
2200   TouchEventFunctor functor(data, false /* Do not consume */);
2201   Dali::DevelActor::InterceptTouchedSignal(actor).Connect(&application, functor);
2202
2203   // Emit a down signal
2204   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
2205
2206   // It should be able to receive touch events by registering only InterceptTouchEvent.
2207   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2208   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
2209   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
2210   DALI_TEST_CHECK(actor == data.touchedActor);
2211   data.Reset();
2212
2213   END_TEST;
2214 }
2215
2216 int UtcDaliTouchEventIntercept02(void)
2217 {
2218   TestApplication application;
2219
2220   Actor parent = Actor::New();
2221   parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2222   parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2223   application.GetScene().Add(parent);
2224
2225   Actor actor = Actor::New();
2226   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2227   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2228   parent.Add(actor);
2229
2230   // Render and notify
2231   application.SendNotification();
2232   application.Render();
2233
2234   // Connect to actor's touched signal
2235   SignalData        data;
2236   TouchEventFunctor functor(data, false /* Do not consume */);
2237   actor.TouchedSignal().Connect(&application, functor);
2238
2239   // Connect to parent's touched signal
2240   SignalData        parentData;
2241   TouchEventFunctor parentFunctor(parentData, false /* Do not consume */);
2242   parent.TouchedSignal().Connect(&application, parentFunctor);
2243
2244   // Emit a down signal
2245   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
2246   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2247   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
2248
2249   data.Reset();
2250   parentData.Reset();
2251
2252   // Connect to parent's intercept touched signal
2253   SignalData        interceptData;
2254   TouchEventFunctor interceptFunctor(interceptData, true /* Do intercept */);
2255   Dali::DevelActor::InterceptTouchedSignal(parent).Connect(&application, interceptFunctor);
2256
2257   // Emit a down signal
2258   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
2259
2260   // The actor gets interrupted. Because touch is intercepted by parent.
2261   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2262   DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
2263   DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
2264   DALI_TEST_EQUALS(PointState::DOWN, interceptData.receivedTouch.points[0].state, TEST_LOCATION);
2265   DALI_TEST_CHECK(actor == interceptData.receivedTouch.points[0].hitActor);
2266   DALI_TEST_CHECK(parent == interceptData.touchedActor);
2267   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
2268   DALI_TEST_EQUALS(PointState::DOWN, parentData.receivedTouch.points[0].state, TEST_LOCATION);
2269   DALI_TEST_CHECK(actor == parentData.receivedTouch.points[0].hitActor);
2270   DALI_TEST_CHECK(parent == parentData.touchedActor);
2271   data.Reset();
2272   interceptData.Reset();
2273   parentData.Reset();
2274
2275   // Render and notify
2276   application.SendNotification();
2277   application.Render();
2278
2279   // Emit a move signal
2280   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 20.0f)));
2281
2282   // Since InterceptTouchEvent is not called because it has already been intercepted by the parent, only the parent will receive the touchEvent.
2283   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2284   DALI_TEST_EQUALS(false, interceptData.functorCalled, TEST_LOCATION);
2285   DALI_TEST_EQUALS(true, parentData.functorCalled, TEST_LOCATION);
2286   DALI_TEST_EQUALS(PointState::MOTION, parentData.receivedTouch.points[0].state, TEST_LOCATION);
2287   DALI_TEST_CHECK(actor == parentData.receivedTouch.points[0].hitActor);
2288   DALI_TEST_CHECK(parent == parentData.touchedActor);
2289   data.Reset();
2290   interceptData.Reset();
2291   parentData.Reset();
2292
2293
2294   END_TEST;
2295 }
2296
2297 int UtcDaliTouchEventIntercept03(void)
2298 {
2299   TestApplication application;
2300
2301   // Add a layer to overlap the actor
2302   Layer layer = Layer::New();
2303   layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2304   layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2305   application.GetScene().Add(layer);
2306   layer.RaiseToTop();
2307
2308   // Set layer to consume all touch
2309   layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
2310
2311   // Render and notify
2312   application.SendNotification();
2313   application.Render();
2314
2315   Actor actor = Actor::New();
2316   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2317   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2318   layer.Add(actor);
2319
2320   // Render and notify
2321   application.SendNotification();
2322   application.Render();
2323
2324   Actor           rootActor(application.GetScene().GetRootLayer());
2325
2326   // Connect to root actor's intercept touched signal
2327   SignalData        sceneData;
2328   TouchEventFunctor sceneFunctor(sceneData);
2329   Dali::DevelActor::InterceptTouchedSignal(rootActor).Connect(&application, sceneFunctor);
2330
2331   // Render and notify
2332   application.SendNotification();
2333   application.Render();
2334
2335   // Emit a down signal
2336   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
2337
2338   // Even if the layer is touch consumed, the root actor must be able to intercept touch.
2339   DALI_TEST_EQUALS(true, sceneData.functorCalled, TEST_LOCATION);
2340   sceneData.Reset();
2341
2342
2343   END_TEST;
2344 }
2345
2346 int UtcDaliTouchAreaOffset(void)
2347 {
2348   TestApplication application;
2349
2350   Actor actor = Actor::New();
2351   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2352   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2353
2354   application.GetScene().Add(actor);
2355
2356   // Render and notify
2357   application.SendNotification();
2358   application.Render();
2359
2360   // Connect to actor's touched signal
2361   SignalData        data;
2362   TouchEventFunctor functor(data, false /* Do not consume */);
2363   actor.TouchedSignal().Connect(&application, functor);
2364
2365   // Emit a down signal
2366   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(110.0f, 110.0f)));
2367   // The actor touched signal is not called because the touch area is outside actor.
2368   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2369   data.Reset();
2370
2371   // set a bigger touch area
2372   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(-70, 70, 70, -70)); // left, right, bottom, top
2373
2374   // Render and notify
2375   application.SendNotification();
2376   application.Render();
2377
2378   // Emit a down signal
2379   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(150.0f, 150.0f)));
2380   // The actor touched signal is called because the touch area is inside touchArea.
2381   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2382   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
2383   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
2384   data.Reset();
2385
2386   // set a offset touch area
2387   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 100, -50, 0)); // left, right, bottom, top
2388
2389   // Render and notify
2390   application.SendNotification();
2391   application.Render();
2392
2393   // Emit a down signal
2394   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(190.0f, 25.0f)));
2395   // The actor touched signal is called because the touch area is inside touchArea.
2396   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2397   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
2398   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
2399   data.Reset();
2400
2401   // set a smaller touch area
2402   actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 0, 0, 50));
2403
2404   // Render and notify
2405   application.SendNotification();
2406   application.Render();
2407
2408   // Emit a down signal
2409   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
2410   // The actor touched signal is not called because the touch area is outside touchArea.
2411   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2412   data.Reset();
2413
2414   // Emit a down signal
2415   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(90.0f, 90.0f)));
2416   // The actor touched signal is called because the touch area is inside touchArea.
2417   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2418   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
2419   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
2420   data.Reset();
2421
2422   END_TEST;
2423 }
2424
2425 int UtcDaliTouchEventAllowOnlyOwnTouchPropertySet(void)
2426 {
2427   TestApplication application;
2428
2429   Actor actor = Actor::New();
2430   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2431   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2432   application.GetScene().Add(actor);
2433
2434   // Render and notify
2435   application.SendNotification();
2436   application.Render();
2437
2438   // Connect to actor's touched signal
2439   SignalData        data;
2440   TouchEventFunctor functor(data);
2441   actor.TouchedSignal().Connect(&application, functor);
2442
2443   // Emit a down signal outside of actor, we should not receive the event
2444   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(110.0f, 110.0f)));
2445   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2446   data.Reset();
2447
2448   // Now motion inside of actor, we should receive the event
2449   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f)));
2450   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2451   data.Reset();
2452
2453   // Up event, should not receive the event
2454   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f)));
2455   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2456   data.Reset();
2457
2458   // Now set the only allow own touch property
2459   actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
2460
2461   // Emit a down signal outside of actor, we should not receive the event
2462   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(110.0f, 110.0f)));
2463   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2464   data.Reset();
2465
2466   // Now motion inside of actor, we should NOT receive the event
2467   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f)));
2468   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2469   data.Reset();
2470
2471   // Up event, should not receive the event
2472   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f)));
2473   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2474   data.Reset();
2475
2476   // Emit a down signal inside of actor, we should receive the event
2477   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(10.0f, 10.0f)));
2478   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2479   data.Reset();
2480
2481   // Now motion inside of actor, we should receive the event
2482   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(80.0f, 80.0f)));
2483   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2484   data.Reset();
2485
2486   // Now motion outsize of actor, we should receive the event
2487   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(110.0f, 110.0f)));
2488   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2489   data.Reset();
2490
2491   // Up event, should receive an interrupted
2492   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(110.0f, 110.0f)));
2493   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2494   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::INTERRUPTED, TEST_LOCATION);
2495   data.Reset();
2496
2497   END_TEST;
2498 }
2499
2500 int UtcDaliTouchEventDispatchTouchMotionPropertySet(void)
2501 {
2502   TestApplication application;
2503
2504   Actor actor = Actor::New();
2505   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2506   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2507   application.GetScene().Add(actor);
2508
2509   // Render and notify
2510   application.SendNotification();
2511   application.Render();
2512
2513   // Connect to actor's touched signal
2514   SignalData        data;
2515   TouchEventFunctor functor(data);
2516   actor.TouchedSignal().Connect(&application, functor);
2517
2518   // Emit a down signal actor, we should receive the event
2519   application.ProcessEvent(GenerateSingleTouch(PointState::STARTED, Vector2(10.0f, 10.0f)));
2520   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2521   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::STARTED, TEST_LOCATION);
2522   data.Reset();
2523
2524   // Emit a motion signal actor, we should receive the event
2525   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 20.0f)));
2526   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2527   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::MOTION, TEST_LOCATION);
2528   data.Reset();
2529
2530   // Now set the dispatch touch motion property
2531   actor.SetProperty(DevelActor::Property::DISPATCH_TOUCH_MOTION, false);
2532
2533   // Emit a motion signal actor, we should not receive the event
2534   application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(30.0f, 30.0f)));
2535   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
2536   data.Reset();
2537
2538   // Up event, should receive the event
2539   application.ProcessEvent(GenerateSingleTouch(PointState::FINISHED, Vector2(40.0f, 40.0f)));
2540   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
2541   DALI_TEST_EQUALS(data.receivedTouch.GetPoint(0).state, PointState::FINISHED, TEST_LOCATION);
2542   data.Reset();
2543
2544   data.Reset();
2545
2546   END_TEST;
2547 }