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