2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali/integration-api/render-task-list-integ.h>
25 #include <dali-test-suite-utils.h>
29 void utc_dali_touch_data_processing_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_touch_data_processing_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
46 PointState::Type state;
51 Vector2 ellipseRadius;
54 Device::Class::Type deviceClass;
55 Device::Subclass::Type deviceSubclass;
58 : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
61 static const TestPoint ZERO;
64 const TestPoint TestPoint::ZERO;
67 // Stores data that is populated in the callback and will be read by the TET cases
71 : functorCalled( false ),
80 std::vector<TestPoint> points;
82 const TestPoint& GetPoint(size_t i)
84 if( i < points.size() )
88 return TestPoint::ZERO;
90 size_t GetPointCount()
98 functorCalled = false;
101 touchData.points.clear();
103 touchedActor.Reset();
107 TestTouchData touchData;
111 // Functor that sets the data when called
112 struct TouchDataFunctor
116 * @param[in] data Reference to the data to store callback information.
117 * @param[in] returnValue What the functor should return.
119 TouchDataFunctor( SignalData& data, bool returnValue = true )
120 : signalData( data ),
121 returnValue( returnValue )
125 bool operator()( Actor actor, const TouchData& touchData )
127 signalData.functorCalled = true;
128 signalData.touchedActor = actor;
130 signalData.touchData.time = touchData.GetTime();
131 signalData.touchData.points.clear();
133 for( size_t i=0; i<touchData.GetPointCount(); ++i )
136 p.deviceId = touchData.GetDeviceId(i);
137 p.state = touchData.GetState(i);
138 p.hitActor = touchData.GetHitActor(i);
139 p.local = touchData.GetLocalPosition(i);
140 p.screen = touchData.GetScreenPosition(i);
141 p.radius = touchData.GetRadius(i);
142 p.ellipseRadius = touchData.GetEllipseRadius(i);
143 p.pressure = touchData.GetPressure(i);
144 p.angle = touchData.GetAngle(i);
145 p.deviceClass = touchData.GetDeviceClass(i);
146 p.deviceSubclass = touchData.GetDeviceSubclass(i);
147 signalData.touchData.points.push_back(p);
153 SignalData& signalData;
163 : signalReceived(false)
168 struct TouchDataHandleFunctor
172 * @param[in] data Reference to the data to store callback information.
173 * @param[in] returnValue What the functor should return.
175 TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
176 : handleData(handleData),
177 returnValue( returnValue )
181 bool operator()( Actor actor, const TouchData& someTouchData )
183 handleData.signalReceived = true;
184 TouchData handle(someTouchData);
185 handleData.touchData = handle;
189 HandleData& handleData;
194 // Functor that removes the actor when called.
195 struct RemoveActorFunctor : public TouchDataFunctor
199 * @param[in] data Reference to the data to store callback information.
200 * @param[in] returnValue What the functor should return.
202 RemoveActorFunctor( SignalData& data, bool returnValue = true )
203 : TouchDataFunctor( data, returnValue )
207 bool operator()( Actor actor, const TouchData& touchData )
209 Actor parent( actor.GetParent() );
212 parent.Remove( actor );
215 return TouchDataFunctor::operator()( actor, touchData );
219 struct OutOfBoundsData
225 :functorCalled(false)
230 // Functor that reads out of bounds data when called
231 struct OutOfBoundsFunctor
235 * @param[in] data Reference to the data to store callback information.
236 * @param[in] returnValue What the functor should return.
238 OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
239 : outOfBoundsData ( data ),
240 returnValue( returnValue )
244 bool operator()( Actor actor, const TouchData& touchData )
246 outOfBoundsData.functorCalled = true;
247 size_t count = touchData.GetPointCount();
249 // Read out of bounds data
250 outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
251 outOfBoundsData.point.state = touchData.GetState(count+1);
252 outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
253 outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
254 outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
259 OutOfBoundsData& outOfBoundsData;
263 struct TouchEventFunctor
267 * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called.
269 TouchEventFunctor( bool& functorCalled )
270 : functorCalled( functorCalled )
274 bool operator()( Actor actor, const TouchEvent& touch )
276 functorCalled = true;
283 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
285 Integration::TouchEvent touchEvent;
286 Integration::Point point;
287 point.SetState( state );
288 point.SetScreenPosition( screenPosition );
289 point.SetDeviceClass( Device::Class::TOUCH );
290 point.SetDeviceSubclass( Device::Subclass::NONE );
291 touchEvent.points.push_back( point );
297 ///////////////////////////////////////////////////////////////////////////////
299 int UtcDaliTouchDataNormalProcessing01(void)
301 TestApplication application;
303 Actor actor = Actor::New();
304 actor.SetSize(100.0f, 100.0f);
305 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
306 Stage::GetCurrent().Add(actor);
309 application.SendNotification();
310 application.Render();
312 // Connect to actor's touched signal
314 TouchDataFunctor functor( data );
315 actor.TouchSignal().Connect( &application, functor );
317 Vector2 screenCoordinates( 10.0f, 10.0f );
318 Vector2 localCoordinates;
319 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
321 // Emit a down signal
322 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
323 const TestPoint *point1 = &data.touchData.GetPoint(0);
324 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
325 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
326 DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
327 DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
328 DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
331 // Emit a motion signal
332 screenCoordinates.x = screenCoordinates.y = 11.0f;
333 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
334 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
335 const TestPoint *point2 = &data.touchData.GetPoint(0);
336 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
337 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
338 DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
339 DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
340 DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
344 screenCoordinates.x = screenCoordinates.y = 12.0f;
345 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
346 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
347 const TestPoint *point3 = &data.touchData.GetPoint(0);
348 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
349 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
350 DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
351 DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
352 DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
355 // Emit a down signal where the actor is not present
356 screenCoordinates.x = screenCoordinates.y = 200.0f;
357 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
358 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
363 int UtcDaliTouchDataNormalProcessing02(void)
365 TestApplication application;
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
377 HandleData handleData;
378 TouchDataHandleFunctor functor( handleData );
379 actor.TouchSignal().Connect( &application, functor );
381 Vector2 screenCoordinates( 10.0f, 10.0f );
382 Vector2 localCoordinates;
383 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
385 // Emit a down signal
386 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
387 DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
388 DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
389 DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
390 DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
391 DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
397 int UtcDaliTouchDataAPINegative(void)
399 TestApplication application;
401 Actor actor = Actor::New();
402 actor.SetSize(100.0f, 100.0f);
403 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
404 Stage::GetCurrent().Add(actor);
407 application.SendNotification();
408 application.Render();
410 // Connect to actor's touched signal
411 OutOfBoundsData data;
412 OutOfBoundsFunctor functor( data, true );
413 actor.TouchSignal().Connect( &application, functor );
415 Vector2 screenCoordinates( 10.0f, 10.0f );
416 Vector2 localCoordinates;
417 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
419 // Emit a down signal
420 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
422 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
423 DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
424 DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
425 DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
426 DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
427 DALI_TEST_CHECK( ! data.point.hitActor );
433 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
435 TestApplication application;
437 Stage stage = Stage::GetCurrent();
438 Vector2 stageSize = stage.GetSize();
440 Actor actor = Actor::New();
441 actor.SetSize(100.0f, 100.0f);
442 actor.SetAnchorPoint(AnchorPoint::CENTER);
443 actor.SetParentOrigin(ParentOrigin::CENTER);
447 application.SendNotification();
448 application.Render();
450 // Get the camera's near and far planes
451 RenderTaskList taskList = stage.GetRenderTaskList();
452 Dali::RenderTask task = taskList.GetTask(0);
453 CameraActor camera = task.GetCameraActor();
454 float nearPlane = camera.GetNearClippingPlane();
455 float farPlane = camera.GetFarClippingPlane();
457 // Calculate the current distance of the actor from the camera
458 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
459 float distance = (stageSize.y * 0.5f) / tanHalfFov;
461 // Connect to actor's touched signal
463 TouchDataFunctor functor( data );
464 actor.TouchSignal().Connect( &application, functor );
466 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
468 // Emit a down signal
469 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
470 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
473 // Emit a down signal where actor is just at the camera's near plane
474 actor.SetZ(distance - nearPlane);
477 application.SendNotification();
478 application.Render();
480 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
481 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
484 // Emit a down signal where actor is closer than the camera's near plane
485 actor.SetZ((distance - nearPlane) + 1.0f);
488 application.SendNotification();
489 application.Render();
491 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
492 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
495 // Emit a down signal where actor is just at the camera's far plane
496 actor.SetZ(distance - farPlane);
499 application.SendNotification();
500 application.Render();
502 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
503 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
506 // Emit a down signal where actor is further than the camera's far plane
507 actor.SetZ((distance - farPlane) - 1.0f);
510 application.SendNotification();
511 application.Render();
513 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
514 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
519 int UtcDaliTouchDataEmitEmpty(void)
521 TestApplication application;
525 // Emit an empty TouchEvent
526 Integration::TouchEvent event;
527 application.ProcessEvent( event );
528 tet_result( TET_FAIL );
530 catch ( Dali::DaliException& e )
532 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
537 int UtcDaliTouchDataInterrupted(void)
539 TestApplication application;
541 Actor actor = Actor::New();
542 actor.SetSize(100.0f, 100.0f);
543 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
544 Stage::GetCurrent().Add(actor);
547 application.SendNotification();
548 application.Render();
550 // Connect to actor's touched signal
552 TouchDataFunctor functor( data );
553 actor.TouchSignal().Connect( &application, functor );
555 // Emit a down signal
556 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
557 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
558 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
561 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
562 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
563 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
564 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
567 // Emit another interrupted signal, our signal handler should not be called.
568 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
569 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
573 int UtcDaliTouchDataParentConsumer(void)
575 TestApplication application;
576 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
578 Actor actor = Actor::New();
579 actor.SetSize(100.0f, 100.0f);
580 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
581 Stage::GetCurrent().Add(actor);
584 application.SendNotification();
585 application.Render();
587 // Connect to actor's touched signal
589 TouchDataFunctor functor( data, false );
590 actor.TouchSignal().Connect( &application, functor );
592 // Connect to root actor's touched signal
594 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
595 rootActor.TouchSignal().Connect( &application, rootFunctor );
597 Vector2 screenCoordinates( 10.0f, 10.0f );
598 Vector2 actorCoordinates, rootCoordinates;
599 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
600 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
602 // Emit a down signal
603 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
604 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
605 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
606 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
607 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
608 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
609 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
610 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
611 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
612 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
613 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
614 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
615 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
619 // Emit a motion signal
620 screenCoordinates.x = screenCoordinates.y = 11.0f;
621 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
622 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
623 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
624 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
625 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
626 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
627 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
628 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
629 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
630 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
631 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
632 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
633 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
634 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
635 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
640 screenCoordinates.x = screenCoordinates.y = 12.0f;
641 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
642 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
643 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
644 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
645 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
646 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
647 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
648 DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
649 DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
650 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
651 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
652 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
653 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
654 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
655 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
659 // Emit a down signal where the actor is not present, will hit the root actor though
660 screenCoordinates.x = screenCoordinates.y = 200.0f;
661 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
662 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
663 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
664 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
665 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
666 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
667 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
668 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
669 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
673 int UtcDaliTouchDataInterruptedParentConsumer(void)
675 TestApplication application;
676 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
678 Actor actor = Actor::New();
679 actor.SetSize(100.0f, 100.0f);
680 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
681 Stage::GetCurrent().Add(actor);
684 application.SendNotification();
685 application.Render();
687 // Connect to actor's touched signal
689 TouchDataFunctor functor( data, false );
690 actor.TouchSignal().Connect( &application, functor );
692 // Connect to root actor's touched signal
694 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
695 rootActor.TouchSignal().Connect( &application, rootFunctor );
697 // Emit a down signal
698 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
699 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
700 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
701 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
702 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
703 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
704 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
708 // Emit an interrupted signal
709 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
710 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
711 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
712 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
713 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
714 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
715 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
719 // Emit another down signal
720 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
721 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
722 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
723 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
724 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
728 // Remove actor from Stage
729 Stage::GetCurrent().Remove( actor );
734 application.SendNotification();
735 application.Render();
737 // Emit an interrupted signal, only root actor's signal should be called.
738 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
739 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
740 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
741 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
742 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
746 // Emit another interrupted state, none of the signal's should be called.
747 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
748 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
749 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
753 int UtcDaliTouchDataLeave(void)
755 TestApplication application;
757 Actor actor = Actor::New();
758 actor.SetSize(100.0f, 100.0f);
759 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
760 Stage::GetCurrent().Add(actor);
763 application.SendNotification();
764 application.Render();
766 // Connect to actor's touched signal
768 TouchDataFunctor functor( data );
769 actor.TouchSignal().Connect( &application, functor );
771 // Set actor to require leave events
772 actor.SetLeaveRequired( true );
774 // Emit a down signal
775 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
776 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
777 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
780 // Emit a motion signal outside of actor, should be signalled with a Leave
781 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
782 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
783 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
786 // Another motion outside of actor, no signalling
787 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
788 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
791 // Another motion event inside actor, signalled with motion
792 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
793 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
794 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
797 // We do not want to listen to leave events anymore
798 actor.SetLeaveRequired( false );
800 // Another motion event outside of actor, no signalling
801 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
802 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
807 int UtcDaliTouchDataLeaveParentConsumer(void)
809 TestApplication application;
810 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
812 Actor actor = Actor::New();
813 actor.SetSize(100.0f, 100.0f);
814 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
815 Stage::GetCurrent().Add(actor);
818 application.SendNotification();
819 application.Render();
821 // Connect to actor's touched signal
823 TouchDataFunctor functor( data, false );
824 actor.TouchSignal().Connect( &application, functor );
826 // Connect to root actor's touched signal
828 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
829 rootActor.TouchSignal().Connect( &application, rootFunctor );
831 // Set actor to require leave events
832 actor.SetLeaveRequired( true );
833 rootActor.SetLeaveRequired( true );
835 // Emit a down signal
836 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
837 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
838 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
839 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
840 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
841 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
842 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
846 // Emit a motion signal outside of actor, should be signalled with a Leave
847 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
848 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
849 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
850 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
851 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
852 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
853 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
857 // Another motion outside of actor, only rootActor signalled
858 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
859 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
860 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
861 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
862 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
866 // Another motion event inside actor, signalled with motion
867 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
868 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
869 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
870 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
871 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
872 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
873 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
877 // We do not want to listen to leave events of actor anymore
878 actor.SetLeaveRequired( false );
880 // Another motion event outside of root actor, only root signalled
881 Vector2 stageSize( Stage::GetCurrent().GetSize() );
882 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
883 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
884 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
885 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
889 int UtcDaliTouchDataActorBecomesInsensitive(void)
891 TestApplication application;
893 Actor actor = Actor::New();
894 actor.SetSize(100.0f, 100.0f);
895 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
896 Stage::GetCurrent().Add(actor);
899 application.SendNotification();
900 application.Render();
902 // Connect to actor's touched signal
904 TouchDataFunctor functor( data );
905 actor.TouchSignal().Connect( &application, functor );
907 // Emit a down signal
908 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
909 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
910 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
913 // Change actor to insensitive
914 actor.SetSensitive( false );
916 // Emit a motion signal, signalled with an interrupted
917 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
918 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
919 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
924 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
926 TestApplication application;
927 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
929 Actor actor = Actor::New();
930 actor.SetSize(100.0f, 100.0f);
931 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
932 Stage::GetCurrent().Add(actor);
935 application.SendNotification();
936 application.Render();
938 // Connect to actor's touched signal
940 TouchDataFunctor functor( data, false );
941 actor.TouchSignal().Connect( &application, functor );
943 // Connect to root actor's touched signal
945 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
946 rootActor.TouchSignal().Connect( &application, rootFunctor );
948 // Emit a down signal
949 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
950 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
951 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
952 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
953 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
954 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
955 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
960 application.SendNotification();
961 application.Render();
963 // Make root actor insensitive
964 rootActor.SetSensitive( false );
966 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
967 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
968 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
969 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
970 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
971 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
975 int UtcDaliTouchDataMultipleLayers(void)
977 TestApplication application;
978 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
980 // Connect to actor's touched signal
982 TouchDataFunctor functor( data );
984 Layer layer1 ( Layer::New() );
985 layer1.SetSize(100.0f, 100.0f);
986 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
987 Stage::GetCurrent().Add( layer1 );
989 Actor actor1 ( Actor::New() );
990 actor1.SetSize( 100.0f, 100.0f );
991 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
992 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
993 layer1.Add( actor1 );
996 application.SendNotification();
997 application.Render();
999 // Connect to layer1 and actor1
1000 layer1.TouchSignal().Connect( &application, functor );
1001 actor1.TouchSignal().Connect( &application, functor );
1003 // Hit in hittable area, actor1 should be hit
1004 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1005 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1006 DALI_TEST_CHECK( data.touchedActor == actor1 );
1009 // Make layer1 insensitive, nothing should be hit
1010 layer1.SetSensitive( false );
1011 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1012 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1015 // Make layer1 sensitive again, again actor1 will be hit
1016 layer1.SetSensitive( true );
1017 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1018 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1019 DALI_TEST_CHECK( data.touchedActor == actor1 );
1022 // Make rootActor insensitive, nothing should be hit
1023 rootActor.SetSensitive( false );
1024 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1025 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1028 // Make rootActor sensitive
1029 rootActor.SetSensitive( true );
1031 // Add another layer
1032 Layer layer2 ( Layer::New() );
1033 layer2.SetSize(100.0f, 100.0f );
1034 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1035 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
1036 Stage::GetCurrent().Add( layer2 );
1038 Actor actor2 ( Actor::New() );
1039 actor2.SetSize(100.0f, 100.0f);
1040 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1041 layer2.Add( actor2 );
1043 // Render and notify
1044 application.SendNotification();
1045 application.Render();
1047 // Connect to layer2 and actor2
1048 layer2.TouchSignal().Connect( &application, functor );
1049 actor2.TouchSignal().Connect( &application, functor );
1051 // Emit an event, should hit layer2
1052 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1053 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1054 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1057 // Make layer2 insensitive, should hit actor1
1058 layer2.SetSensitive( false );
1059 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1060 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1061 DALI_TEST_CHECK( data.touchedActor == actor1 );
1064 // Make layer2 sensitive again, should hit layer2
1065 layer2.SetSensitive( true );
1066 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1067 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1068 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1071 // Make layer2 invisible, render and notify
1072 layer2.SetVisible( false );
1073 application.SendNotification();
1074 application.Render();
1076 // Should hit actor1
1077 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1078 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1079 DALI_TEST_CHECK( data.touchedActor == actor1 );
1082 // Make rootActor invisible, render and notify
1083 rootActor.SetVisible( false );
1084 application.SendNotification();
1085 application.Render();
1087 // Should not hit anything
1088 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1089 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1094 int UtcDaliTouchDataMultipleRenderTasks(void)
1096 TestApplication application;
1097 Stage stage ( Stage::GetCurrent() );
1098 Vector2 stageSize ( stage.GetSize() );
1100 Actor actor = Actor::New();
1101 actor.SetSize(100.0f, 100.0f);
1102 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1105 // Create render task
1106 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1107 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1108 renderTask.SetViewport( viewport );
1109 renderTask.SetInputEnabled( true );
1111 // Render and notify
1112 application.SendNotification();
1113 application.Render();
1115 // Connect to actor's touched signal
1117 TouchDataFunctor functor( data );
1118 actor.TouchSignal().Connect( &application, functor );
1120 // Emit a down signal
1121 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1122 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
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 );
1130 // Disable input on renderTask, should not be hittable
1131 renderTask.SetInputEnabled( false );
1132 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1133 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1138 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1140 TestApplication application;
1141 Stage stage ( Stage::GetCurrent() );
1142 Vector2 stageSize ( stage.GetSize() );
1144 Actor actor = Actor::New();
1145 actor.SetSize(100.0f, 100.0f);
1146 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1149 Layer layer = Layer::New();
1150 layer.SetSize(100.0f, 100.0f);
1151 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1154 // Create render task
1155 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1156 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1157 renderTask.SetViewport( viewport );
1158 renderTask.SetInputEnabled( true );
1159 renderTask.SetSourceActor( actor );
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Connect to layer's touched signal
1167 TouchDataFunctor functor( data );
1168 actor.TouchSignal().Connect( &application, functor );
1169 layer.TouchSignal().Connect( &application, functor );
1171 // Emit a down signal
1172 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1173 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1176 // Ensure renderTask actor can be hit too.
1177 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1178 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1181 // Disable input on renderTask, should not be hittable
1182 renderTask.SetInputEnabled( false );
1183 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1184 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1189 int UtcDaliTouchDataOffscreenRenderTasks(void)
1191 TestApplication application;
1192 Stage stage ( Stage::GetCurrent() );
1193 Vector2 stageSize ( stage.GetSize() );
1195 // FrameBufferImage for offscreen RenderTask
1196 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
1198 // Create a renderable actor to display the FrameBufferImage
1199 Actor renderableActor = CreateRenderableActor( frameBufferImage );
1200 renderableActor.SetParentOrigin(ParentOrigin::CENTER);
1201 renderableActor.SetSize( stageSize.x, stageSize.y );
1202 renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1203 stage.Add( renderableActor );
1205 Actor actor = Actor::New();
1206 actor.SetSize(100.0f, 100.0f);
1207 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1211 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1213 // Create a RenderTask
1214 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
1215 renderTask.SetSourceActor( actor );
1216 renderTask.SetTargetFrameBuffer( frameBufferImage );
1217 renderTask.SetInputEnabled( true );
1219 // Create another RenderTask
1220 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1221 renderTask2.SetInputEnabled( true );
1223 // Render and notify
1224 application.SendNotification();
1225 application.Render();
1227 // Connect to actor's touched signal
1229 TouchDataFunctor functor( data );
1230 actor.TouchSignal().Connect( &application, functor );
1232 // Emit a down signal
1233 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1234 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1239 int UtcDaliTouchDataMultipleRenderableActors(void)
1241 TestApplication application;
1242 Stage stage ( Stage::GetCurrent() );
1243 Vector2 stageSize ( stage.GetSize() );
1245 Actor parent = CreateRenderableActor();
1246 parent.SetSize(100.0f, 100.0f);
1247 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1250 Actor actor = CreateRenderableActor();
1251 actor.SetSize(100.0f, 100.0f);
1252 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Connect to layer's touched signal
1261 TouchDataFunctor functor( data );
1262 parent.TouchSignal().Connect( &application, functor );
1263 actor.TouchSignal().Connect( &application, functor );
1265 // Emit a down signal
1266 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1267 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1268 DALI_TEST_CHECK( actor == data.touchedActor );
1272 int UtcDaliTouchDataActorRemovedInSignal(void)
1274 TestApplication application;
1276 Actor actor = Actor::New();
1277 actor.SetSize(100.0f, 100.0f);
1278 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1279 Stage::GetCurrent().Add(actor);
1281 // Render and notify
1282 application.SendNotification();
1283 application.Render();
1285 // Connect to actor's touched signal
1287 RemoveActorFunctor functor( data );
1288 actor.TouchSignal().Connect( &application, functor );
1290 // Register for leave events
1291 actor.SetLeaveRequired( true );
1293 // Emit a down signal
1294 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1295 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1298 // Re-add, render and notify
1299 Stage::GetCurrent().Add(actor);
1300 application.SendNotification();
1301 application.Render();
1303 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1304 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1305 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1308 // Emit a down signal
1309 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1310 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1313 // Render and notify
1314 application.SendNotification();
1315 application.Render();
1317 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1318 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1319 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1322 // Re-add actor back to stage, render and notify
1323 Stage::GetCurrent().Add(actor);
1324 application.SendNotification();
1325 application.Render();
1327 // Emit another down event
1328 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1329 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1332 // Completely delete the actor
1335 // Emit event, should not crash and should not receive an event.
1336 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1337 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1341 int UtcDaliTouchDataActorSignalNotConsumed(void)
1343 TestApplication application;
1345 Actor actor = Actor::New();
1346 actor.SetSize(100.0f, 100.0f);
1347 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1348 Stage::GetCurrent().Add(actor);
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Connect to actor's touched signal
1356 TouchDataFunctor functor( data, false );
1357 actor.TouchSignal().Connect( &application, functor );
1359 // Emit a down signal
1360 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1361 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1365 int UtcDaliTouchDataActorUnStaged(void)
1367 TestApplication application;
1369 Actor actor = Actor::New();
1370 actor.SetSize(100.0f, 100.0f);
1371 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1372 Stage::GetCurrent().Add(actor);
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Connect to actor's touched signal
1380 TouchDataFunctor functor( data );
1381 actor.TouchSignal().Connect( &application, functor );
1383 // Emit a down signal
1384 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1385 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1388 // Remove actor from stage
1389 Stage::GetCurrent().Remove( actor );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // Emit a move at the same point, we should not be signalled.
1397 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1398 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1403 int UtcDaliTouchDataSystemOverlayActor(void)
1405 TestApplication application;
1406 Dali::Integration::Core& core( application.GetCore() );
1407 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1409 Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
1410 Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor();
1411 Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor();
1412 Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
1413 systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList );
1415 // Create an actor and add it to the system overlay.
1416 Actor systemActor = Actor::New();
1417 systemActor.SetSize(100.0f, 100.0f);
1418 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1419 systemOverlay.Add( systemActor );
1421 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1422 Actor actor = Actor::New();
1423 actor.SetSize(100.0f, 100.0f);
1424 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1425 Stage::GetCurrent().Add(actor);
1427 // Connect to the touch signals.
1429 TouchDataFunctor functor( data );
1430 systemActor.TouchSignal().Connect( &application, functor );
1431 actor.TouchSignal().Connect( &application, functor );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1438 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1439 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1440 DALI_TEST_CHECK( systemActor == data.touchedActor );
1444 int UtcDaliTouchDataLayerConsumesTouch(void)
1446 TestApplication application;
1448 Actor actor = Actor::New();
1449 actor.SetSize(100.0f, 100.0f);
1450 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1451 Stage::GetCurrent().Add(actor);
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 // Connect to actor's touched signal
1459 TouchDataFunctor functor( data );
1460 actor.TouchSignal().Connect( &application, functor );
1462 // Add a layer to overlap the actor
1463 Layer layer = Layer::New();
1464 layer.SetSize(100.0f, 100.0f);
1465 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1466 Stage::GetCurrent().Add( layer );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 // Emit a few touch signals
1474 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1475 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1476 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1479 // Set layer to consume all touch
1480 layer.SetTouchConsumed( true );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Emit the same signals again, should not receive
1487 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1488 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1489 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1495 int UtcDaliTouchDataLeaveActorReadded(void)
1497 TestApplication application;
1498 Stage stage = Stage::GetCurrent();
1500 Actor actor = Actor::New();
1501 actor.SetSize(100.0f, 100.0f);
1502 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1505 // Set actor to receive touch-events
1506 actor.SetLeaveRequired( true );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Connect to actor's touched signal
1514 TouchDataFunctor functor( data );
1515 actor.TouchSignal().Connect( &application, functor );
1517 // Emit a down and motion
1518 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1519 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1520 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1523 // Remove actor from stage and add again
1524 stage.Remove( actor );
1527 // Emit a motion within the actor's bounds
1528 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1529 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1532 // Emit a motion outside the actor's bounds
1533 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1534 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1535 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1541 int UtcDaliTouchDataClippedActor(void)
1543 TestApplication application;
1544 Stage stage = Stage::GetCurrent();
1546 Actor actor = Actor::New();
1547 actor.SetSize( 100.0f, 100.0f );
1548 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1551 Actor clippingActor = Actor::New();
1552 clippingActor.SetSize( 50.0f, 50.0f );
1553 clippingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1554 clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1555 stage.Add( clippingActor );
1557 // Add a child to the clipped region.
1558 Actor clippingChild = Actor::New();
1559 clippingChild.SetSize( 50.0f, 50.0f );
1560 clippingChild.SetPosition( 25.0f, 25.0f );
1561 clippingChild.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1562 clippingActor.Add( clippingChild );
1564 // Render and notify.
1565 application.SendNotification();
1566 application.Render();
1568 // Connect to actor's touch signal.
1570 TouchDataFunctor functor( data );
1571 actor.TouchSignal().Connect( &application, functor );
1573 // Emit an event within clipped area - no hit.
1574 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1575 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1578 // Emit an event outside the clipped area but within the actor area, we should have a hit.
1579 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1580 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1583 clippingChild.TouchSignal().Connect( &application, functor );
1585 // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1586 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 30.0f, 30.0f ) ) );
1587 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1593 int UtcDaliTouchDataActorUnstaged(void)
1595 TestApplication application;
1597 Actor actor = Actor::New();
1598 actor.SetSize(100.0f, 100.0f);
1599 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1600 Stage::GetCurrent().Add(actor);
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 // Connect to actor's touched signal
1608 TouchDataFunctor functor( data );
1609 actor.TouchSignal().Connect( &application, functor );
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::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1615 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 // Unparent the actor
1625 // Should receive an interrupted event
1626 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1627 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1631 int UtcDaliTouchDataParentUnstaged(void)
1633 TestApplication application;
1635 Actor parent = Actor::New();
1636 parent.SetSize(100.0f, 100.0f);
1637 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1638 Stage::GetCurrent().Add(parent);
1640 Actor actor = Actor::New();
1641 actor.SetSize(100.0f, 100.0f);
1642 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // Connect to actor's touched signal
1651 TouchDataFunctor functor( data );
1652 actor.TouchSignal().Connect( &application, functor );
1654 // Emit a down signal
1655 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1656 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1657 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1658 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 // Unparent the parent of the touchable actor
1668 // Should receive an interrupted event
1669 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1670 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1674 int UtcDaliTouchDataActorUnstagedDifferentConsumer(void)
1676 TestApplication application;
1678 Actor parent = Actor::New();
1679 parent.SetSize(100.0f, 100.0f);
1680 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1681 Stage::GetCurrent().Add(parent);
1683 Actor actor = Actor::New();
1684 actor.SetSize(100.0f, 100.0f);
1685 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1688 // Render and notify
1689 application.SendNotification();
1690 application.Render();
1692 // Connect to actor's touched signal
1694 TouchDataFunctor functor( data, false /* Do not consume */ );
1695 actor.TouchSignal().Connect( &application, functor );
1697 // Connect to parent's touched signal
1698 SignalData parentData;
1699 TouchDataFunctor parentFunctor( parentData );
1700 parent.TouchSignal().Connect( &application, parentFunctor );
1702 // Emit a down signal
1703 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1704 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1705 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1706 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1707 DALI_TEST_CHECK( actor == data.touchedActor );
1708 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1709 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1710 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1711 DALI_TEST_CHECK( parent == parentData.touchedActor );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Unparent the actor
1722 // Should receive an interrupted event for both actor & parent
1723 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1724 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1725 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1726 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1730 // Readd actor to parent
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // Emit a motion signal
1738 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1739 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1740 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1744 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1745 SignalData secondData;
1746 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1747 actor.TouchSignal().Connect( &application, secondFunctor );
1749 // Unparent the actor
1752 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1753 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1754 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1755 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1756 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1757 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1758 DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1766 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1768 TestApplication application;
1769 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1771 Actor parent = Actor::New();
1772 parent.SetSize(100.0f, 100.0f);
1773 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1774 Stage::GetCurrent().Add(parent);
1776 Actor actor = Actor::New();
1777 actor.SetSize(100.0f, 100.0f);
1778 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1781 // Render and notify
1782 application.SendNotification();
1783 application.Render();
1785 // Connect to actor's touched signal
1787 TouchDataFunctor functor( data, false /* Do not consume */ );
1788 actor.TouchSignal().Connect( &application, functor );
1790 // Connect to parent's touched signal
1791 SignalData parentData;
1792 TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1793 parent.TouchSignal().Connect( &application, parentFunctor );
1795 // Connect to root's touched signal and consume
1796 SignalData rootData;
1797 TouchDataFunctor rootFunctor( rootData );
1798 rootActor.TouchSignal().Connect( &application, rootFunctor );
1800 // Emit a down signal
1801 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1802 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1803 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1804 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1805 DALI_TEST_CHECK( actor == data.touchedActor );
1806 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1807 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1808 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1809 DALI_TEST_CHECK( parent == parentData.touchedActor );
1810 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1811 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1812 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1813 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1818 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1819 SignalData secondData;
1820 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1821 parent.TouchSignal().Connect( &application, secondFunctor );
1823 // Emit an interrupted signal, all three should STILL be called
1824 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1825 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1826 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1827 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1828 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1829 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1830 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1838 int UtcDaliTouchDataGetRadius(void)
1840 TestApplication application;
1842 Actor actor = Actor::New();
1843 actor.SetSize(100.0f, 100.0f);
1844 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1845 Stage::GetCurrent().Add(actor);
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 // Connect to actor's touched signal
1853 TouchDataFunctor functor( data );
1854 actor.TouchSignal().Connect( &application, functor );
1856 // Emit a down signal with an angle
1857 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1858 touchEvent.points[ 0 ].SetRadius( 100.0f );
1859 application.ProcessEvent( touchEvent );
1860 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1861 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1862 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1863 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1864 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1869 int UtcDaliTouchDataGetEllipseRadius(void)
1871 TestApplication application;
1873 Actor actor = Actor::New();
1874 actor.SetSize(100.0f, 100.0f);
1875 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1876 Stage::GetCurrent().Add(actor);
1878 // Render and notify
1879 application.SendNotification();
1880 application.Render();
1882 // Connect to actor's touched signal
1884 TouchDataFunctor functor( data );
1885 actor.TouchSignal().Connect( &application, functor );
1887 // Emit a down signal with an angle
1888 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1889 touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1890 application.ProcessEvent( touchEvent );
1891 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1892 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1893 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1894 DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1895 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1900 int UtcDaliTouchDataGetAngle(void)
1902 TestApplication application;
1904 Actor actor = Actor::New();
1905 actor.SetSize(100.0f, 100.0f);
1906 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1907 Stage::GetCurrent().Add(actor);
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 // Connect to actor's touched signal
1915 TouchDataFunctor functor( data );
1916 actor.TouchSignal().Connect( &application, functor );
1918 // Emit a down signal with an angle
1919 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1920 touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1921 application.ProcessEvent( touchEvent );
1922 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1923 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1924 DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1929 int UtcDaliTouchDataGetPressure(void)
1931 TestApplication application;
1933 Actor actor = Actor::New();
1934 actor.SetSize(100.0f, 100.0f);
1935 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1936 Stage::GetCurrent().Add(actor);
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Connect to actor's touched signal
1944 TouchDataFunctor functor( data );
1945 actor.TouchSignal().Connect( &application, functor );
1947 // Emit a down signal with an angle
1948 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1949 touchEvent.points[ 0 ].SetPressure( 10.0f );
1950 application.ProcessEvent( touchEvent );
1951 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1952 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1953 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1958 int UtcDaliTouchDataAndEventUsage(void)
1960 TestApplication application;
1962 Actor actor = Actor::New();
1963 actor.SetSize(100.0f, 100.0f);
1964 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1965 Stage::GetCurrent().Add(actor);
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 // Connect to actor's touched signal
1973 TouchDataFunctor functor( data );
1974 actor.TouchSignal().Connect( &application, functor );
1976 // Connect to actor's touched signal (OLD)
1977 bool touchEventFunctorCalled = false;
1978 TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1979 actor.TouchedSignal().Connect( &application, eventFunctor );
1981 // Emit a down signal with an angle
1982 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1983 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1984 DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );
1989 int UtcDaliTouchDataGetDeviceAPINegative(void)
1991 TestApplication application;
1993 Actor actor = Actor::New();
1994 actor.SetSize(100.0f, 100.0f);
1995 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1996 Stage::GetCurrent().Add(actor);
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2002 // Connect to actor's touched signal
2003 HandleData handleData;
2004 TouchDataHandleFunctor functor( handleData );
2005 actor.TouchSignal().Connect( &application, functor );
2007 Vector2 screenCoordinates( 10.0f, 10.0f );
2008 Vector2 localCoordinates;
2009 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
2011 // Emit a down signal
2012 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
2014 TouchData data = handleData.touchData;
2015 DALI_TEST_EQUALS( data.GetDeviceClass( -1 ), Device::Class::NONE, TEST_LOCATION );
2016 DALI_TEST_EQUALS( data.GetDeviceSubclass( -1 ), Device::Subclass::NONE, TEST_LOCATION );
2020 int UtcDaliTouchDataGetMouseButtonPositive(void)
2022 TestApplication application;
2024 Actor actor = Actor::New();
2025 actor.SetSize(100.0f, 100.0f);
2026 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2027 Stage::GetCurrent().Add(actor);
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 // Connect to actor's touched signal
2034 HandleData handleData;
2035 TouchDataHandleFunctor functor( handleData );
2036 actor.TouchSignal().Connect( &application, functor );
2038 // Emit a down signal with MouseButton
2039 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
2040 touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 3 ) );
2041 application.ProcessEvent( touchEvent );
2043 TouchData data = handleData.touchData;
2044 DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::SECONDARY, TEST_LOCATION );
2049 int UtcDaliTouchDataGetMouseButtonNagative(void)
2051 TestApplication application;
2053 Actor actor = Actor::New();
2054 actor.SetSize(100.0f, 100.0f);
2055 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2056 Stage::GetCurrent().Add(actor);
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 // Connect to actor's touched signal
2063 HandleData handleData;
2064 TouchDataHandleFunctor functor( handleData );
2065 actor.TouchSignal().Connect( &application, functor );
2067 // Emit a down signal with MouseButton
2068 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
2069 touchEvent.points[ 0 ].SetMouseButton( static_cast< MouseButton::Type >( 2 ) );
2070 application.ProcessEvent( touchEvent );
2072 TouchData data = handleData.touchData;
2073 DALI_TEST_EQUALS( data.GetMouseButton( 0 ), MouseButton::TERTIARY, TEST_LOCATION );
2074 DALI_TEST_EQUALS( data.GetMouseButton( 3 ), MouseButton::INVALID, TEST_LOCATION );