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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/system-overlay.h>
26 #include <dali-test-suite-utils.h>
30 static void Startup();
31 static void Cleanup();
34 void (*tet_startup)() = Startup;
35 void (*tet_cleanup)() = Cleanup;
39 POSITIVE_TC_IDX = 0x01,
43 #define MAX_NUMBER_OF_TESTS 10000
45 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
48 TEST_FUNCTION( UtcDaliTouchNormalProcessing, POSITIVE_TC_IDX );
49 TEST_FUNCTION( UtcDaliTouchOutsideCameraNearFarPlanes, POSITIVE_TC_IDX );
50 TEST_FUNCTION( UtcDaliTouchEmitEmpty, NEGATIVE_TC_IDX );
51 TEST_FUNCTION( UtcDaliTouchInterrupted, NEGATIVE_TC_IDX );
52 TEST_FUNCTION( UtcDaliTouchParentConsumer, POSITIVE_TC_IDX );
53 TEST_FUNCTION( UtcDaliTouchInterruptedParentConsumer, NEGATIVE_TC_IDX );
54 TEST_FUNCTION( UtcDaliTouchLeave, POSITIVE_TC_IDX );
55 TEST_FUNCTION( UtcDaliTouchLeaveParentConsumer, POSITIVE_TC_IDX );
56 TEST_FUNCTION( UtcDaliTouchActorBecomesInsensitive, NEGATIVE_TC_IDX );
57 TEST_FUNCTION( UtcDaliTouchActorBecomesInsensitiveParentConsumer, NEGATIVE_TC_IDX );
58 TEST_FUNCTION( UtcDaliTouchMultipleLayers, POSITIVE_TC_IDX );
59 TEST_FUNCTION( UtcDaliTouchMultipleRenderTasks, POSITIVE_TC_IDX );
60 TEST_FUNCTION( UtcDaliTouchMultipleRenderTasksWithChildLayer, POSITIVE_TC_IDX );
61 TEST_FUNCTION( UtcDaliTouchOffscreenRenderTasks, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliTouchMultipleRenderableActors, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliTouchActorRemovedInSignal, NEGATIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliTouchActorSignalNotConsumed, NEGATIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliTouchActorUnStaged, NEGATIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliTouchSystemOverlayActor, POSITIVE_TC_IDX );
68 // Called only once before first test is run.
73 // Called only once after last test is run
78 ///////////////////////////////////////////////////////////////////////////////
80 // Stores data that is populated in the callback and will be read by the TET cases
84 : functorCalled( false ),
92 functorCalled = false;
95 touchEvent.points.clear();
101 TouchEvent touchEvent;
105 // Functor that sets the data when called
106 struct TouchEventFunctor
110 * @param[in] data Reference to the data to store callback information.
111 * @param[in] returnValue What the functor should return.
113 TouchEventFunctor( SignalData& data, bool returnValue = true )
114 : signalData( data ),
115 returnValue( returnValue )
119 bool operator()( Actor actor, const TouchEvent& touchEvent )
121 signalData.functorCalled = true;
122 signalData.touchedActor = actor;
123 signalData.touchEvent = touchEvent;
128 SignalData& signalData;
132 // Functor that removes the actor when called.
133 struct RemoveActorFunctor : public TouchEventFunctor
137 * @param[in] data Reference to the data to store callback information.
138 * @param[in] returnValue What the functor should return.
140 RemoveActorFunctor( SignalData& data, bool returnValue = true )
141 : TouchEventFunctor( data, returnValue )
145 bool operator()( Actor actor, const TouchEvent& touchEvent )
147 Actor parent( actor.GetParent() );
150 parent.Remove( actor );
153 return TouchEventFunctor::operator()( actor, touchEvent );
157 Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition )
159 Integration::TouchEvent touchEvent;
160 touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) );
164 ///////////////////////////////////////////////////////////////////////////////
166 void UtcDaliTouchNormalProcessing()
168 TestApplication application;
170 Actor actor = Actor::New();
171 actor.SetSize(100.0f, 100.0f);
172 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
173 Stage::GetCurrent().Add(actor);
176 application.SendNotification();
177 application.Render();
179 // Connect to actor's touched signal
181 TouchEventFunctor functor( data );
182 actor.TouchedSignal().Connect( &application, functor );
184 Vector2 screenCoordinates( 10.0f, 10.0f );
185 Vector2 localCoordinates;
186 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
188 // Emit a down signal
189 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
190 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
191 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
192 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
193 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
194 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
197 // Emit a motion signal
198 screenCoordinates.x = screenCoordinates.y = 11.0f;
199 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
200 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
201 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
202 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
203 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
204 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
205 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
209 screenCoordinates.x = screenCoordinates.y = 12.0f;
210 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
211 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
212 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
213 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
214 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
215 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
216 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
219 // Emit a down signal where the actor is not present
220 screenCoordinates.x = screenCoordinates.y = 200.0f;
221 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
222 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
225 void UtcDaliTouchOutsideCameraNearFarPlanes()
227 TestApplication application;
229 Stage stage = Stage::GetCurrent();
230 Vector2 stageSize = stage.GetSize();
232 Actor actor = Actor::New();
233 actor.SetSize(100.0f, 100.0f);
234 actor.SetAnchorPoint(AnchorPoint::CENTER);
235 actor.SetParentOrigin(ParentOrigin::CENTER);
239 application.SendNotification();
240 application.Render();
242 // Get the camera's near and far planes
243 RenderTaskList taskList = stage.GetRenderTaskList();
244 Dali::RenderTask task = taskList.GetTask(0);
245 CameraActor camera = task.GetCameraActor();
246 float nearPlane = camera.GetNearClippingPlane();
247 float farPlane = camera.GetFarClippingPlane();
249 // Calculate the current distance of the actor from the camera
250 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
251 float distance = (stageSize.y * 0.5f) / tanHalfFov;
253 // Connect to actor's touched signal
255 TouchEventFunctor functor( data );
256 actor.TouchedSignal().Connect( &application, functor );
258 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
260 // Emit a down signal
261 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
262 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
265 // Emit a down signal where actor is just at the camera's near plane
266 actor.SetZ(distance - nearPlane);
269 application.SendNotification();
270 application.Render();
272 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
273 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
276 // Emit a down signal where actor is closer than the camera's near plane
277 actor.SetZ((distance - nearPlane) + 1.0f);
280 application.SendNotification();
281 application.Render();
283 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
284 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
287 // Emit a down signal where actor is just at the camera's far plane
288 actor.SetZ(distance - farPlane);
291 application.SendNotification();
292 application.Render();
294 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
295 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
298 // Emit a down signal where actor is further than the camera's far plane
299 actor.SetZ((distance - farPlane) - 1.0f);
302 application.SendNotification();
303 application.Render();
305 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
306 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
310 void UtcDaliTouchEmitEmpty()
312 TestApplication application;
316 // Emit an empty TouchEvent
317 Integration::TouchEvent event;
318 application.ProcessEvent( event );
319 tet_result( TET_FAIL );
321 catch ( Dali::DaliException& e )
323 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
327 void UtcDaliTouchInterrupted()
329 TestApplication application;
331 Actor actor = Actor::New();
332 actor.SetSize(100.0f, 100.0f);
333 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
334 Stage::GetCurrent().Add(actor);
337 application.SendNotification();
338 application.Render();
340 // Connect to actor's touched signal
342 TouchEventFunctor functor( data );
343 actor.TouchedSignal().Connect( &application, functor );
345 // Emit a down signal
346 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
347 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
348 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
351 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
352 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
353 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
354 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
357 // Emit another interrupted signal, our signal handler should not be called.
358 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
359 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
362 void UtcDaliTouchParentConsumer()
364 TestApplication application;
365 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
367 Actor actor = Actor::New();
368 actor.SetSize(100.0f, 100.0f);
369 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
370 Stage::GetCurrent().Add(actor);
373 application.SendNotification();
374 application.Render();
376 // Connect to actor's touched signal
378 TouchEventFunctor functor( data, false );
379 actor.TouchedSignal().Connect( &application, functor );
381 // Connect to root actor's touched signal
383 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
384 rootActor.TouchedSignal().Connect( &application, rootFunctor );
386 Vector2 screenCoordinates( 10.0f, 10.0f );
387 Vector2 actorCoordinates, rootCoordinates;
388 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
389 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
391 // Emit a down signal
392 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
393 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
394 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
395 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
396 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
397 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
398 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
399 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
400 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
401 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
402 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
403 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
404 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
408 // Emit a motion signal
409 screenCoordinates.x = screenCoordinates.y = 11.0f;
410 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
411 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
412 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
413 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
414 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
415 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
416 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
417 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
418 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
419 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
420 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
421 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
422 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
423 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
424 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
429 screenCoordinates.x = screenCoordinates.y = 12.0f;
430 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
431 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
432 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
433 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
434 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
435 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
436 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
437 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
438 DALI_TEST_EQUALS( TouchPoint::Up, rootData.touchEvent.points[0].state, TEST_LOCATION );
439 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
440 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
441 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
442 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
443 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
444 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
448 // Emit a down signal where the actor is not present, will hit the root actor though
449 screenCoordinates.x = screenCoordinates.y = 200.0f;
450 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
451 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
452 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
453 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
454 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
455 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
456 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
457 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
458 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
461 void UtcDaliTouchInterruptedParentConsumer()
463 TestApplication application;
464 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
466 Actor actor = Actor::New();
467 actor.SetSize(100.0f, 100.0f);
468 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
469 Stage::GetCurrent().Add(actor);
472 application.SendNotification();
473 application.Render();
475 // Connect to actor's touched signal
477 TouchEventFunctor functor( data, false );
478 actor.TouchedSignal().Connect( &application, functor );
480 // Connect to root actor's touched signal
482 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
483 rootActor.TouchedSignal().Connect( &application, rootFunctor );
485 // Emit a down signal
486 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
487 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
488 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
489 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
490 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
491 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
492 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
496 // Emit an interrupted signal
497 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
498 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
499 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
500 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
501 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
502 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
503 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
507 // Emit another down signal
508 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
509 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
510 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
511 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
512 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
516 // Remove actor from Stage
517 Stage::GetCurrent().Remove( actor );
520 application.SendNotification();
521 application.Render();
523 // Emit an interrupted signal, only root actor's signal should be called.
524 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
525 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
526 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
527 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
528 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
532 // Emit another interrupted state, none of the signal's should be called.
533 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
534 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
535 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
538 void UtcDaliTouchLeave()
540 TestApplication application;
542 Actor actor = Actor::New();
543 actor.SetSize(100.0f, 100.0f);
544 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
545 Stage::GetCurrent().Add(actor);
548 application.SendNotification();
549 application.Render();
551 // Connect to actor's touched signal
553 TouchEventFunctor functor( data );
554 actor.TouchedSignal().Connect( &application, functor );
556 // Set actor to require leave events
557 actor.SetLeaveRequired( true );
559 // Emit a down signal
560 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
561 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
562 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
565 // Emit a motion signal outside of actor, should be signalled with a Leave
566 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
567 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
568 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
571 // Another motion outside of actor, no signalling
572 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
573 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
576 // Another motion event inside actor, signalled with motion
577 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
578 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
579 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
582 // We do not want to listen to leave events anymore
583 actor.SetLeaveRequired( false );
585 // Another motion event outside of actor, no signalling
586 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
587 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
591 void UtcDaliTouchLeaveParentConsumer()
593 TestApplication application;
594 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
596 Actor actor = Actor::New();
597 actor.SetSize(100.0f, 100.0f);
598 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
599 Stage::GetCurrent().Add(actor);
602 application.SendNotification();
603 application.Render();
605 // Connect to actor's touched signal
607 TouchEventFunctor functor( data, false );
608 actor.TouchedSignal().Connect( &application, functor );
610 // Connect to root actor's touched signal
612 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
613 rootActor.TouchedSignal().Connect( &application, rootFunctor );
615 // Set actor to require leave events
616 actor.SetLeaveRequired( true );
617 rootActor.SetLeaveRequired( true );
619 // Emit a down signal
620 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
621 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
622 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
623 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
624 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
625 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
626 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
630 // Emit a motion signal outside of actor, should be signalled with a Leave
631 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
632 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
633 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
634 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
635 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
636 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
637 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
641 // Another motion outside of actor, only rootActor signalled
642 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
643 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
644 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
645 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
646 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
650 // Another motion event inside actor, signalled with motion
651 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
652 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
653 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
654 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
655 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
656 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
657 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
661 // We do not want to listen to leave events of actor anymore
662 actor.SetLeaveRequired( false );
664 // Another motion event outside of root actor, only root signalled
665 Vector2 stageSize( Stage::GetCurrent().GetSize() );
666 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
667 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
668 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
669 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
672 void UtcDaliTouchActorBecomesInsensitive()
674 TestApplication application;
676 Actor actor = Actor::New();
677 actor.SetSize(100.0f, 100.0f);
678 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
679 Stage::GetCurrent().Add(actor);
682 application.SendNotification();
683 application.Render();
685 // Connect to actor's touched signal
687 TouchEventFunctor functor( data );
688 actor.TouchedSignal().Connect( &application, functor );
690 // Emit a down signal
691 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
692 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
693 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
696 // Change actor to insensitive
697 actor.SetSensitive( false );
699 // Emit a motion signal, signalled with an interrupted
700 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
701 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
702 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
706 void UtcDaliTouchActorBecomesInsensitiveParentConsumer()
708 TestApplication application;
709 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
711 Actor actor = Actor::New();
712 actor.SetSize(100.0f, 100.0f);
713 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
714 Stage::GetCurrent().Add(actor);
717 application.SendNotification();
718 application.Render();
720 // Connect to actor's touched signal
722 TouchEventFunctor functor( data, false );
723 actor.TouchedSignal().Connect( &application, functor );
725 // Connect to root actor's touched signal
727 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
728 rootActor.TouchedSignal().Connect( &application, rootFunctor );
730 // Emit a down signal
731 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
732 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
733 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
734 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
735 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
736 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
737 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
741 // Remove actor from Stage
742 Stage::GetCurrent().Remove( actor );
745 application.SendNotification();
746 application.Render();
748 // Make root actor insensitive
749 rootActor.SetSensitive( false );
751 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
752 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
753 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
754 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
755 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
758 void UtcDaliTouchMultipleLayers()
760 TestApplication application;
761 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
763 // Connect to actor's touched signal
765 TouchEventFunctor functor( data );
767 Layer layer1 ( Layer::New() );
768 layer1.SetSize(100.0f, 100.0f);
769 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
770 Stage::GetCurrent().Add( layer1 );
772 Actor actor1 ( Actor::New() );
773 actor1.SetSize( 100.0f, 100.0f );
774 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
775 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
776 layer1.Add( actor1 );
779 application.SendNotification();
780 application.Render();
782 // Connect to layer1 and actor1
783 layer1.TouchedSignal().Connect( &application, functor );
784 actor1.TouchedSignal().Connect( &application, functor );
786 // Hit in hittable area, actor1 should be hit
787 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
788 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
789 DALI_TEST_CHECK( data.touchedActor == actor1 );
792 // Make layer1 insensitive, nothing should be hit
793 layer1.SetSensitive( false );
794 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
795 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
798 // Make layer1 sensitive again, again actor1 will be hit
799 layer1.SetSensitive( true );
800 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
801 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
802 DALI_TEST_CHECK( data.touchedActor == actor1 );
805 // Make rootActor insensitive, nothing should be hit
806 rootActor.SetSensitive( false );
807 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
808 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
811 // Make rootActor sensitive
812 rootActor.SetSensitive( true );
815 Layer layer2 ( Layer::New() );
816 layer2.SetSize(100.0f, 100.0f );
817 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
818 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
819 Stage::GetCurrent().Add( layer2 );
821 Actor actor2 ( Actor::New() );
822 actor2.SetSize(100.0f, 100.0f);
823 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
824 layer2.Add( actor2 );
827 application.SendNotification();
828 application.Render();
830 // Connect to layer2 and actor2
831 layer2.TouchedSignal().Connect( &application, functor );
832 actor2.TouchedSignal().Connect( &application, functor );
834 // Emit an event, should hit layer2
835 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
836 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
837 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
840 // Make layer2 insensitive, should hit actor1
841 layer2.SetSensitive( false );
842 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
843 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
844 DALI_TEST_CHECK( data.touchedActor == actor1 );
847 // Make layer2 sensitive again, should hit layer2
848 layer2.SetSensitive( true );
849 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
850 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
851 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
854 // Make layer2 invisible, render and notify
855 layer2.SetVisible( false );
856 application.SendNotification();
857 application.Render();
860 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
861 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
862 DALI_TEST_CHECK( data.touchedActor == actor1 );
865 // Make rootActor invisible, render and notify
866 rootActor.SetVisible( false );
867 application.SendNotification();
868 application.Render();
870 // Should not hit anything
871 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
872 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
876 void UtcDaliTouchMultipleRenderTasks()
878 TestApplication application;
879 Stage stage ( Stage::GetCurrent() );
880 Vector2 stageSize ( stage.GetSize() );
882 Actor actor = Actor::New();
883 actor.SetSize(100.0f, 100.0f);
884 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
887 // Create render task
888 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
889 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
890 renderTask.SetViewport( viewport );
891 renderTask.SetInputEnabled( true );
894 application.SendNotification();
895 application.Render();
897 // Connect to actor's touched signal
899 TouchEventFunctor functor( data );
900 actor.TouchedSignal().Connect( &application, functor );
902 // Emit a down signal
903 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
904 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
907 // Ensure renderTask actor can be hit too.
908 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
909 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
912 // Disable input on renderTask, should not be hittable
913 renderTask.SetInputEnabled( false );
914 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
915 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
919 void UtcDaliTouchMultipleRenderTasksWithChildLayer()
921 TestApplication application;
922 Stage stage ( Stage::GetCurrent() );
923 Vector2 stageSize ( stage.GetSize() );
925 Actor actor = Actor::New();
926 actor.SetSize(100.0f, 100.0f);
927 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
930 Layer layer = Layer::New();
931 layer.SetSize(100.0f, 100.0f);
932 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
935 // Create render task
936 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
937 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
938 renderTask.SetViewport( viewport );
939 renderTask.SetInputEnabled( true );
940 renderTask.SetSourceActor( actor );
943 application.SendNotification();
944 application.Render();
946 // Connect to layer's touched signal
948 TouchEventFunctor functor( data );
949 actor.TouchedSignal().Connect( &application, functor );
950 layer.TouchedSignal().Connect( &application, functor );
952 // Emit a down signal
953 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
954 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
957 // Ensure renderTask actor can be hit too.
958 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
959 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
962 // Disable input on renderTask, should not be hittable
963 renderTask.SetInputEnabled( false );
964 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
965 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
969 void UtcDaliTouchOffscreenRenderTasks()
971 TestApplication application;
972 Stage stage ( Stage::GetCurrent() );
973 Vector2 stageSize ( stage.GetSize() );
975 // FrameBufferImage for offscreen RenderTask
976 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
978 // Create an image actor to display the FrameBufferImage
979 ImageActor imageActor ( ImageActor::New( frameBufferImage ) );
980 imageActor.SetParentOrigin(ParentOrigin::CENTER);
981 imageActor.SetSize( stageSize.x, stageSize.y );
982 imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
983 stage.Add( imageActor );
985 Actor actor = Actor::New();
986 actor.SetSize(100.0f, 100.0f);
987 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
989 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
991 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
993 // Create a RenderTask
994 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
995 renderTask.SetSourceActor( actor );
996 renderTask.SetTargetFrameBuffer( frameBufferImage );
997 renderTask.SetInputEnabled( true );
999 // Create another RenderTask
1000 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1001 renderTask2.SetInputEnabled( true );
1003 // Render and notify
1004 application.SendNotification();
1005 application.Render();
1007 // Connect to actor's touched signal
1009 TouchEventFunctor functor( data );
1010 actor.TouchedSignal().Connect( &application, functor );
1012 // Emit a down signal
1013 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1014 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1018 void UtcDaliTouchMultipleRenderableActors()
1020 TestApplication application;
1021 Stage stage ( Stage::GetCurrent() );
1022 Vector2 stageSize ( stage.GetSize() );
1024 Actor parent = ImageActor::New();
1025 parent.SetSize(100.0f, 100.0f);
1026 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1029 Actor actor = ImageActor::New();
1030 actor.SetSize(100.0f, 100.0f);
1031 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1034 // Render and notify
1035 application.SendNotification();
1036 application.Render();
1038 // Connect to layer's touched signal
1040 TouchEventFunctor functor( data );
1041 parent.TouchedSignal().Connect( &application, functor );
1042 actor.TouchedSignal().Connect( &application, functor );
1044 // Emit a down signal
1045 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1046 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1047 DALI_TEST_CHECK( actor == data.touchedActor );
1050 void UtcDaliTouchActorRemovedInSignal()
1052 TestApplication application;
1054 Actor actor = Actor::New();
1055 actor.SetSize(100.0f, 100.0f);
1056 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1057 Stage::GetCurrent().Add(actor);
1059 // Render and notify
1060 application.SendNotification();
1061 application.Render();
1063 // Connect to actor's touched signal
1065 RemoveActorFunctor functor( data );
1066 actor.TouchedSignal().Connect( &application, functor );
1068 // Register for leave events
1069 actor.SetLeaveRequired( true );
1071 // Emit a down signal
1072 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1073 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1076 // Re-add, render and notify
1077 Stage::GetCurrent().Add(actor);
1078 application.SendNotification();
1079 application.Render();
1081 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1082 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1083 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1086 // Emit a down signal
1087 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1088 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1091 // Render and notify
1092 application.SendNotification();
1093 application.Render();
1095 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1096 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1097 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1100 // Re-add actor back to stage, render and notify
1101 Stage::GetCurrent().Add(actor);
1102 application.SendNotification();
1103 application.Render();
1105 // Emit another down event
1106 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1107 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1110 // Completely delete the actor
1113 // Emit event, should not crash and should not receive an event.
1114 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1115 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1118 void UtcDaliTouchActorSignalNotConsumed()
1120 TestApplication application;
1122 Actor actor = Actor::New();
1123 actor.SetSize(100.0f, 100.0f);
1124 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1125 Stage::GetCurrent().Add(actor);
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Connect to actor's touched signal
1133 TouchEventFunctor functor( data, false );
1134 actor.TouchedSignal().Connect( &application, functor );
1136 // Emit a down signal
1137 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1138 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1141 void UtcDaliTouchActorUnStaged()
1143 TestApplication application;
1145 Actor actor = Actor::New();
1146 actor.SetSize(100.0f, 100.0f);
1147 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1148 Stage::GetCurrent().Add(actor);
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Connect to actor's touched signal
1156 TouchEventFunctor functor( data );
1157 actor.TouchedSignal().Connect( &application, functor );
1159 // Emit a down signal
1160 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1161 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1164 // Remove actor from stage
1165 Stage::GetCurrent().Remove( actor );
1167 // Render and notify
1168 application.SendNotification();
1169 application.Render();
1171 // Emit a move at the same point, we should not be signalled.
1172 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1173 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1177 void UtcDaliTouchSystemOverlayActor()
1179 TestApplication application;
1180 Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().GetSystemOverlay() );
1181 systemOverlay.GetOverlayRenderTasks().CreateTask();
1183 // Create an actor and add it to the system overlay.
1184 Actor systemActor = Actor::New();
1185 systemActor.SetSize(100.0f, 100.0f);
1186 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1187 systemOverlay.Add( systemActor );
1189 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1190 Actor actor = Actor::New();
1191 actor.SetSize(100.0f, 100.0f);
1192 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1193 Stage::GetCurrent().Add(actor);
1195 // Connect to the touch signals.
1197 TouchEventFunctor functor( data );
1198 systemActor.TouchedSignal().Connect( &application, functor );
1199 actor.TouchedSignal().Connect( &application, functor );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1206 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1207 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1208 DALI_TEST_CHECK( systemActor == data.touchedActor );