2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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
8 // http://floralicense.org/license/
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.
20 #include <dali/dali.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/system-overlay.h>
23 #include <dali-test-suite-utils.h>
27 void utc_dali_touch_processing_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_touch_processing_cleanup(void)
34 test_return_value = TET_PASS;
37 ///////////////////////////////////////////////////////////////////////////////
42 // Stores data that is populated in the callback and will be read by the TET cases
46 : functorCalled( false ),
54 functorCalled = false;
57 touchEvent.points.clear();
63 TouchEvent touchEvent;
67 // Functor that sets the data when called
68 struct TouchEventFunctor
72 * @param[in] data Reference to the data to store callback information.
73 * @param[in] returnValue What the functor should return.
75 TouchEventFunctor( SignalData& data, bool returnValue = true )
77 returnValue( returnValue )
81 bool operator()( Actor actor, const TouchEvent& touchEvent )
83 signalData.functorCalled = true;
84 signalData.touchedActor = actor;
85 signalData.touchEvent = touchEvent;
90 SignalData& signalData;
94 // Functor that removes the actor when called.
95 struct RemoveActorFunctor : public TouchEventFunctor
99 * @param[in] data Reference to the data to store callback information.
100 * @param[in] returnValue What the functor should return.
102 RemoveActorFunctor( SignalData& data, bool returnValue = true )
103 : TouchEventFunctor( data, returnValue )
107 bool operator()( Actor actor, const TouchEvent& touchEvent )
109 Actor parent( actor.GetParent() );
112 parent.Remove( actor );
115 return TouchEventFunctor::operator()( actor, touchEvent );
119 Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition )
121 Integration::TouchEvent touchEvent;
122 touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) );
128 ///////////////////////////////////////////////////////////////////////////////
130 int UtcDaliTouchNormalProcessing(void)
132 TestApplication application;
134 Actor actor = Actor::New();
135 actor.SetSize(100.0f, 100.0f);
136 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
137 Stage::GetCurrent().Add(actor);
140 application.SendNotification();
141 application.Render();
143 // Connect to actor's touched signal
145 TouchEventFunctor functor( data );
146 actor.TouchedSignal().Connect( &application, functor );
148 Vector2 screenCoordinates( 10.0f, 10.0f );
149 Vector2 localCoordinates;
150 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
152 // Emit a down signal
153 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
154 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
155 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
156 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
157 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
158 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
161 // Emit a motion signal
162 screenCoordinates.x = screenCoordinates.y = 11.0f;
163 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
164 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
165 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
166 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
167 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
168 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
169 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
173 screenCoordinates.x = screenCoordinates.y = 12.0f;
174 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
175 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
176 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
177 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
178 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
179 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
180 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
183 // Emit a down signal where the actor is not present
184 screenCoordinates.x = screenCoordinates.y = 200.0f;
185 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
186 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
190 int UtcDaliTouchOutsideCameraNearFarPlanes(void)
192 TestApplication application;
194 Stage stage = Stage::GetCurrent();
195 Vector2 stageSize = stage.GetSize();
197 Actor actor = Actor::New();
198 actor.SetSize(100.0f, 100.0f);
199 actor.SetAnchorPoint(AnchorPoint::CENTER);
200 actor.SetParentOrigin(ParentOrigin::CENTER);
204 application.SendNotification();
205 application.Render();
207 // Get the camera's near and far planes
208 RenderTaskList taskList = stage.GetRenderTaskList();
209 Dali::RenderTask task = taskList.GetTask(0);
210 CameraActor camera = task.GetCameraActor();
211 float nearPlane = camera.GetNearClippingPlane();
212 float farPlane = camera.GetFarClippingPlane();
214 // Calculate the current distance of the actor from the camera
215 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
216 float distance = (stageSize.y * 0.5f) / tanHalfFov;
218 // Connect to actor's touched signal
220 TouchEventFunctor functor( data );
221 actor.TouchedSignal().Connect( &application, functor );
223 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
225 // Emit a down signal
226 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
227 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
230 // Emit a down signal where actor is just at the camera's near plane
231 actor.SetZ(distance - nearPlane);
234 application.SendNotification();
235 application.Render();
237 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
238 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
241 // Emit a down signal where actor is closer than the camera's near plane
242 actor.SetZ((distance - nearPlane) + 1.0f);
245 application.SendNotification();
246 application.Render();
248 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
249 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
252 // Emit a down signal where actor is just at the camera's far plane
253 actor.SetZ(distance - farPlane);
256 application.SendNotification();
257 application.Render();
259 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
260 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
263 // Emit a down signal where actor is further than the camera's far plane
264 actor.SetZ((distance - farPlane) - 1.0f);
267 application.SendNotification();
268 application.Render();
270 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
271 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
276 int UtcDaliTouchEmitEmpty(void)
278 TestApplication application;
282 // Emit an empty TouchEvent
283 Integration::TouchEvent event;
284 application.ProcessEvent( event );
285 tet_result( TET_FAIL );
287 catch ( Dali::DaliException& e )
289 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
294 int UtcDaliTouchInterrupted(void)
296 TestApplication application;
298 Actor actor = Actor::New();
299 actor.SetSize(100.0f, 100.0f);
300 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
301 Stage::GetCurrent().Add(actor);
304 application.SendNotification();
305 application.Render();
307 // Connect to actor's touched signal
309 TouchEventFunctor functor( data );
310 actor.TouchedSignal().Connect( &application, functor );
312 // Emit a down signal
313 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
314 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
315 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
318 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
319 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
320 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
321 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
324 // Emit another interrupted signal, our signal handler should not be called.
325 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
326 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
330 int UtcDaliTouchParentConsumer(void)
332 TestApplication application;
333 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
335 Actor actor = Actor::New();
336 actor.SetSize(100.0f, 100.0f);
337 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
338 Stage::GetCurrent().Add(actor);
341 application.SendNotification();
342 application.Render();
344 // Connect to actor's touched signal
346 TouchEventFunctor functor( data, false );
347 actor.TouchedSignal().Connect( &application, functor );
349 // Connect to root actor's touched signal
351 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
352 rootActor.TouchedSignal().Connect( &application, rootFunctor );
354 Vector2 screenCoordinates( 10.0f, 10.0f );
355 Vector2 actorCoordinates, rootCoordinates;
356 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
357 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
359 // Emit a down signal
360 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
361 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
362 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
363 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
364 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
365 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
366 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
367 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
368 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
369 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
370 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
371 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
372 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
376 // Emit a motion signal
377 screenCoordinates.x = screenCoordinates.y = 11.0f;
378 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
379 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
380 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
381 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
382 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
383 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
384 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
385 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
386 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
387 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
388 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
389 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
390 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
391 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
392 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
397 screenCoordinates.x = screenCoordinates.y = 12.0f;
398 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
399 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
400 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
401 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
402 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
403 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
404 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
405 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
406 DALI_TEST_EQUALS( TouchPoint::Up, rootData.touchEvent.points[0].state, TEST_LOCATION );
407 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
408 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
409 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
410 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
411 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
412 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
416 // Emit a down signal where the actor is not present, will hit the root actor though
417 screenCoordinates.x = screenCoordinates.y = 200.0f;
418 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
419 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
420 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
421 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
422 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
423 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
424 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
425 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
426 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
430 int UtcDaliTouchInterruptedParentConsumer(void)
432 TestApplication application;
433 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
435 Actor actor = Actor::New();
436 actor.SetSize(100.0f, 100.0f);
437 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
438 Stage::GetCurrent().Add(actor);
441 application.SendNotification();
442 application.Render();
444 // Connect to actor's touched signal
446 TouchEventFunctor functor( data, false );
447 actor.TouchedSignal().Connect( &application, functor );
449 // Connect to root actor's touched signal
451 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
452 rootActor.TouchedSignal().Connect( &application, rootFunctor );
454 // Emit a down signal
455 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
456 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
457 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
458 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
459 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
460 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
461 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
465 // Emit an interrupted signal
466 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
467 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
468 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
469 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
470 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
471 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
472 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
476 // Emit another down signal
477 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
478 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
479 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
480 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
481 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
485 // Remove actor from Stage
486 Stage::GetCurrent().Remove( actor );
489 application.SendNotification();
490 application.Render();
492 // Emit an interrupted signal, only root actor's signal should be called.
493 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
494 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
495 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
496 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
497 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
501 // Emit another interrupted state, none of the signal's should be called.
502 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
503 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
504 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
508 int UtcDaliTouchLeave(void)
510 TestApplication application;
512 Actor actor = Actor::New();
513 actor.SetSize(100.0f, 100.0f);
514 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
515 Stage::GetCurrent().Add(actor);
518 application.SendNotification();
519 application.Render();
521 // Connect to actor's touched signal
523 TouchEventFunctor functor( data );
524 actor.TouchedSignal().Connect( &application, functor );
526 // Set actor to require leave events
527 actor.SetLeaveRequired( true );
529 // Emit a down signal
530 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
531 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
532 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
535 // Emit a motion signal outside of actor, should be signalled with a Leave
536 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
537 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
538 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
541 // Another motion outside of actor, no signalling
542 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
543 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
546 // Another motion event inside actor, signalled with motion
547 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
548 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
549 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
552 // We do not want to listen to leave events anymore
553 actor.SetLeaveRequired( false );
555 // Another motion event outside of actor, no signalling
556 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
557 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
562 int UtcDaliTouchLeaveParentConsumer(void)
564 TestApplication application;
565 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
567 Actor actor = Actor::New();
568 actor.SetSize(100.0f, 100.0f);
569 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
570 Stage::GetCurrent().Add(actor);
573 application.SendNotification();
574 application.Render();
576 // Connect to actor's touched signal
578 TouchEventFunctor functor( data, false );
579 actor.TouchedSignal().Connect( &application, functor );
581 // Connect to root actor's touched signal
583 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
584 rootActor.TouchedSignal().Connect( &application, rootFunctor );
586 // Set actor to require leave events
587 actor.SetLeaveRequired( true );
588 rootActor.SetLeaveRequired( true );
590 // Emit a down signal
591 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
592 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
593 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
594 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
595 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
596 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
597 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
601 // Emit a motion signal outside of actor, should be signalled with a Leave
602 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
603 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
604 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
605 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
606 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
607 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
608 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
612 // Another motion outside of actor, only rootActor signalled
613 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
614 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
615 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
616 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
617 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
621 // Another motion event inside actor, signalled with motion
622 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
623 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
624 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
625 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
626 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
627 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
628 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
632 // We do not want to listen to leave events of actor anymore
633 actor.SetLeaveRequired( false );
635 // Another motion event outside of root actor, only root signalled
636 Vector2 stageSize( Stage::GetCurrent().GetSize() );
637 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
638 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
639 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
640 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
644 int UtcDaliTouchActorBecomesInsensitive(void)
646 TestApplication application;
648 Actor actor = Actor::New();
649 actor.SetSize(100.0f, 100.0f);
650 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
651 Stage::GetCurrent().Add(actor);
654 application.SendNotification();
655 application.Render();
657 // Connect to actor's touched signal
659 TouchEventFunctor functor( data );
660 actor.TouchedSignal().Connect( &application, functor );
662 // Emit a down signal
663 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
664 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
665 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
668 // Change actor to insensitive
669 actor.SetSensitive( false );
671 // Emit a motion signal, signalled with an interrupted
672 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
673 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
674 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
679 int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void)
681 TestApplication application;
682 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
684 Actor actor = Actor::New();
685 actor.SetSize(100.0f, 100.0f);
686 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
687 Stage::GetCurrent().Add(actor);
690 application.SendNotification();
691 application.Render();
693 // Connect to actor's touched signal
695 TouchEventFunctor functor( data, false );
696 actor.TouchedSignal().Connect( &application, functor );
698 // Connect to root actor's touched signal
700 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
701 rootActor.TouchedSignal().Connect( &application, rootFunctor );
703 // Emit a down signal
704 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
705 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
706 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
707 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
708 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
709 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
710 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
714 // Remove actor from Stage
715 Stage::GetCurrent().Remove( actor );
718 application.SendNotification();
719 application.Render();
721 // Make root actor insensitive
722 rootActor.SetSensitive( false );
724 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
725 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
726 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
727 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
728 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
732 int UtcDaliTouchMultipleLayers(void)
734 TestApplication application;
735 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
737 // Connect to actor's touched signal
739 TouchEventFunctor functor( data );
741 Layer layer1 ( Layer::New() );
742 layer1.SetSize(100.0f, 100.0f);
743 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
744 Stage::GetCurrent().Add( layer1 );
746 Actor actor1 ( Actor::New() );
747 actor1.SetSize( 100.0f, 100.0f );
748 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
749 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
750 layer1.Add( actor1 );
753 application.SendNotification();
754 application.Render();
756 // Connect to layer1 and actor1
757 layer1.TouchedSignal().Connect( &application, functor );
758 actor1.TouchedSignal().Connect( &application, functor );
760 // Hit in hittable area, actor1 should be hit
761 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
762 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
763 DALI_TEST_CHECK( data.touchedActor == actor1 );
766 // Make layer1 insensitive, nothing should be hit
767 layer1.SetSensitive( false );
768 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
769 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
772 // Make layer1 sensitive again, again actor1 will be hit
773 layer1.SetSensitive( true );
774 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
775 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
776 DALI_TEST_CHECK( data.touchedActor == actor1 );
779 // Make rootActor insensitive, nothing should be hit
780 rootActor.SetSensitive( false );
781 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
782 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
785 // Make rootActor sensitive
786 rootActor.SetSensitive( true );
789 Layer layer2 ( Layer::New() );
790 layer2.SetSize(100.0f, 100.0f );
791 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
792 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
793 Stage::GetCurrent().Add( layer2 );
795 Actor actor2 ( Actor::New() );
796 actor2.SetSize(100.0f, 100.0f);
797 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
798 layer2.Add( actor2 );
801 application.SendNotification();
802 application.Render();
804 // Connect to layer2 and actor2
805 layer2.TouchedSignal().Connect( &application, functor );
806 actor2.TouchedSignal().Connect( &application, functor );
808 // Emit an event, should hit layer2
809 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
810 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
811 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
814 // Make layer2 insensitive, should hit actor1
815 layer2.SetSensitive( false );
816 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
817 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
818 DALI_TEST_CHECK( data.touchedActor == actor1 );
821 // Make layer2 sensitive again, should hit layer2
822 layer2.SetSensitive( true );
823 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
824 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
825 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
828 // Make layer2 invisible, render and notify
829 layer2.SetVisible( false );
830 application.SendNotification();
831 application.Render();
834 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
835 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
836 DALI_TEST_CHECK( data.touchedActor == actor1 );
839 // Make rootActor invisible, render and notify
840 rootActor.SetVisible( false );
841 application.SendNotification();
842 application.Render();
844 // Should not hit anything
845 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
846 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
851 int UtcDaliTouchMultipleRenderTasks(void)
853 TestApplication application;
854 Stage stage ( Stage::GetCurrent() );
855 Vector2 stageSize ( stage.GetSize() );
857 Actor actor = Actor::New();
858 actor.SetSize(100.0f, 100.0f);
859 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
862 // Create render task
863 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
864 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
865 renderTask.SetViewport( viewport );
866 renderTask.SetInputEnabled( true );
869 application.SendNotification();
870 application.Render();
872 // Connect to actor's touched signal
874 TouchEventFunctor functor( data );
875 actor.TouchedSignal().Connect( &application, functor );
877 // Emit a down signal
878 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
879 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
882 // Ensure renderTask actor can be hit too.
883 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
884 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
887 // Disable input on renderTask, should not be hittable
888 renderTask.SetInputEnabled( false );
889 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
890 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
895 int UtcDaliTouchMultipleRenderTasksWithChildLayer(void)
897 TestApplication application;
898 Stage stage ( Stage::GetCurrent() );
899 Vector2 stageSize ( stage.GetSize() );
901 Actor actor = Actor::New();
902 actor.SetSize(100.0f, 100.0f);
903 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
906 Layer layer = Layer::New();
907 layer.SetSize(100.0f, 100.0f);
908 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
911 // Create render task
912 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
913 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
914 renderTask.SetViewport( viewport );
915 renderTask.SetInputEnabled( true );
916 renderTask.SetSourceActor( actor );
919 application.SendNotification();
920 application.Render();
922 // Connect to layer's touched signal
924 TouchEventFunctor functor( data );
925 actor.TouchedSignal().Connect( &application, functor );
926 layer.TouchedSignal().Connect( &application, functor );
928 // Emit a down signal
929 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
930 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
933 // Ensure renderTask actor can be hit too.
934 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
935 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
938 // Disable input on renderTask, should not be hittable
939 renderTask.SetInputEnabled( false );
940 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
941 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
946 int UtcDaliTouchOffscreenRenderTasks(void)
948 TestApplication application;
949 Stage stage ( Stage::GetCurrent() );
950 Vector2 stageSize ( stage.GetSize() );
952 // FrameBufferImage for offscreen RenderTask
953 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
955 // Create an image actor to display the FrameBufferImage
956 ImageActor imageActor ( ImageActor::New( frameBufferImage ) );
957 imageActor.SetParentOrigin(ParentOrigin::CENTER);
958 imageActor.SetSize( stageSize.x, stageSize.y );
959 imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
960 stage.Add( imageActor );
962 Actor actor = Actor::New();
963 actor.SetSize(100.0f, 100.0f);
964 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
968 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
970 // Create a RenderTask
971 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
972 renderTask.SetSourceActor( actor );
973 renderTask.SetTargetFrameBuffer( frameBufferImage );
974 renderTask.SetInputEnabled( true );
976 // Create another RenderTask
977 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
978 renderTask2.SetInputEnabled( true );
981 application.SendNotification();
982 application.Render();
984 // Connect to actor's touched signal
986 TouchEventFunctor functor( data );
987 actor.TouchedSignal().Connect( &application, functor );
989 // Emit a down signal
990 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
991 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
996 int UtcDaliTouchMultipleRenderableActors(void)
998 TestApplication application;
999 Stage stage ( Stage::GetCurrent() );
1000 Vector2 stageSize ( stage.GetSize() );
1002 Actor parent = ImageActor::New();
1003 parent.SetSize(100.0f, 100.0f);
1004 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1007 Actor actor = ImageActor::New();
1008 actor.SetSize(100.0f, 100.0f);
1009 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Connect to layer's touched signal
1018 TouchEventFunctor functor( data );
1019 parent.TouchedSignal().Connect( &application, functor );
1020 actor.TouchedSignal().Connect( &application, functor );
1022 // Emit a down signal
1023 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1024 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1025 DALI_TEST_CHECK( actor == data.touchedActor );
1029 int UtcDaliTouchActorRemovedInSignal(void)
1031 TestApplication application;
1033 Actor actor = Actor::New();
1034 actor.SetSize(100.0f, 100.0f);
1035 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1036 Stage::GetCurrent().Add(actor);
1038 // Render and notify
1039 application.SendNotification();
1040 application.Render();
1042 // Connect to actor's touched signal
1044 RemoveActorFunctor functor( data );
1045 actor.TouchedSignal().Connect( &application, functor );
1047 // Register for leave events
1048 actor.SetLeaveRequired( true );
1050 // Emit a down signal
1051 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1052 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1055 // Re-add, render and notify
1056 Stage::GetCurrent().Add(actor);
1057 application.SendNotification();
1058 application.Render();
1060 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1061 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1062 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1065 // Emit a down signal
1066 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1067 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1070 // Render and notify
1071 application.SendNotification();
1072 application.Render();
1074 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1075 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1076 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1079 // Re-add actor back to stage, render and notify
1080 Stage::GetCurrent().Add(actor);
1081 application.SendNotification();
1082 application.Render();
1084 // Emit another down event
1085 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1086 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1089 // Completely delete the actor
1092 // Emit event, should not crash and should not receive an event.
1093 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1094 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1098 int UtcDaliTouchActorSignalNotConsumed(void)
1100 TestApplication application;
1102 Actor actor = Actor::New();
1103 actor.SetSize(100.0f, 100.0f);
1104 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1105 Stage::GetCurrent().Add(actor);
1107 // Render and notify
1108 application.SendNotification();
1109 application.Render();
1111 // Connect to actor's touched signal
1113 TouchEventFunctor functor( data, false );
1114 actor.TouchedSignal().Connect( &application, functor );
1116 // Emit a down signal
1117 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1118 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1122 int UtcDaliTouchActorUnStaged(void)
1124 TestApplication application;
1126 Actor actor = Actor::New();
1127 actor.SetSize(100.0f, 100.0f);
1128 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1129 Stage::GetCurrent().Add(actor);
1131 // Render and notify
1132 application.SendNotification();
1133 application.Render();
1135 // Connect to actor's touched signal
1137 TouchEventFunctor functor( data );
1138 actor.TouchedSignal().Connect( &application, functor );
1140 // Emit a down signal
1141 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1142 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1145 // Remove actor from stage
1146 Stage::GetCurrent().Remove( actor );
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Emit a move at the same point, we should not be signalled.
1153 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1154 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1159 int UtcDaliTouchSystemOverlayActor(void)
1161 TestApplication application;
1162 Dali::Integration::Core& core( application.GetCore() );
1163 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1164 systemOverlay.GetOverlayRenderTasks().CreateTask();
1166 // Create an actor and add it to the system overlay.
1167 Actor systemActor = Actor::New();
1168 systemActor.SetSize(100.0f, 100.0f);
1169 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1170 systemOverlay.Add( systemActor );
1172 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1173 Actor actor = Actor::New();
1174 actor.SetSize(100.0f, 100.0f);
1175 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1176 Stage::GetCurrent().Add(actor);
1178 // Connect to the touch signals.
1180 TouchEventFunctor functor( data );
1181 systemActor.TouchedSignal().Connect( &application, functor );
1182 actor.TouchedSignal().Connect( &application, functor );
1184 // Render and notify
1185 application.SendNotification();
1186 application.Render();
1188 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1189 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1190 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1191 DALI_TEST_CHECK( systemActor == data.touchedActor );