X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-HoverProcessing.cpp;h=f28d2029459e8ed886addf860baaef302aa8ae71;hb=fe58df83b2d72c4beceb101eb9cffcc5442f3d6e;hp=deac90ffd9e80582adb0240d8171ef2c70a18f46;hpb=6a51fca768ccd75d552b73c0a67056721dc86e44;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index deac90f..f28d202 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,15 @@ * */ -#include - -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include + +#include using namespace Dali; @@ -39,12 +41,11 @@ void utc_dali_hover_processing_cleanup(void) namespace { - // Stores data that is populated in the callback and will be read by the TET cases struct SignalData { SignalData() - : functorCalled( false ), + : functorCalled(false), hoverEvent(), hoveredActor() { @@ -53,16 +54,13 @@ struct SignalData void Reset() { functorCalled = false; - - hoverEvent.time = 0u; - hoverEvent.points.clear(); - + hoverEvent.Reset(); hoveredActor.Reset(); } - bool functorCalled; + bool functorCalled; HoverEvent hoverEvent; - Actor hoveredActor; + Actor hoveredActor; }; // Functor that sets the data when called @@ -73,23 +71,23 @@ struct HoverEventFunctor * @param[in] data Reference to the data to store callback information. * @param[in] returnValue What the functor should return. */ - HoverEventFunctor( SignalData& data, bool returnValue = true ) - : signalData( data ), - returnValue( returnValue ) + HoverEventFunctor(SignalData& data, bool returnValue = true) + : signalData(data), + returnValue(returnValue) { } - bool operator()( Actor actor, const HoverEvent& hoverEvent ) + bool operator()(Actor actor, const HoverEvent& hoverEvent) { signalData.functorCalled = true; - signalData.hoveredActor = actor; - signalData.hoverEvent = hoverEvent; + signalData.hoveredActor = actor; + signalData.hoverEvent = hoverEvent; return returnValue; } SignalData& signalData; - bool returnValue; + bool returnValue; }; // Functor that removes the actor when called. @@ -100,31 +98,34 @@ struct RemoveActorFunctor : public HoverEventFunctor * @param[in] data Reference to the data to store callback information. * @param[in] returnValue What the functor should return. */ - RemoveActorFunctor( SignalData& data, bool returnValue = true ) - : HoverEventFunctor( data, returnValue ) + RemoveActorFunctor(SignalData& data, bool returnValue = true) + : HoverEventFunctor(data, returnValue) { } - bool operator()( Actor actor, const HoverEvent& hoverEvent ) + bool operator()(Actor actor, const HoverEvent& hoverEvent) { - Actor parent( actor.GetParent() ); - if ( parent ) + Actor parent(actor.GetParent()); + if(parent) { - parent.Remove( actor ); + parent.Remove(actor); } - return HoverEventFunctor::operator()( actor, hoverEvent ); + return HoverEventFunctor::operator()(actor, hoverEvent); } }; -Integration::HoverEvent GenerateSingleHover( TouchPoint::State state, Vector2 screenPosition ) +Integration::HoverEvent GenerateSingleHover(PointState::Type state, const Vector2& screenPosition) { Integration::HoverEvent hoverEvent; - hoverEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + Integration::Point point; + point.SetState(state); + point.SetScreenPosition(screenPosition); + hoverEvent.points.push_back(point); return hoverEvent; } -} // anon namespace +} // namespace /////////////////////////////////////////////////////////////////////////////// @@ -133,58 +134,84 @@ int UtcDaliHoverNormalProcessing(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); - Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 screenCoordinates(10.0f, 10.0f); Vector2 localCoordinates; - actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(localCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(0, data.hoverEvent.GetDeviceId(0), TEST_LOCATION); + DALI_TEST_EQUALS(0u, data.hoverEvent.GetTime(), TEST_LOCATION); + DALI_TEST_EQUALS(actor, data.hoverEvent.GetHitActor(0), TEST_LOCATION); + DALI_TEST_EQUALS(-1, data.hoverEvent.GetDeviceId(1), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, data.hoverEvent.GetState(1), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetScreenPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetLocalPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Dali::Actor(), data.hoverEvent.GetHitActor(1), TEST_LOCATION); data.Reset(); // Emit a motion signal screenCoordinates.x = screenCoordinates.y = 11.0f; - actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); + actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::MOTION, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(localCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(0, data.hoverEvent.GetDeviceId(0), TEST_LOCATION); + DALI_TEST_EQUALS(0u, data.hoverEvent.GetTime(), TEST_LOCATION); + DALI_TEST_EQUALS(actor, data.hoverEvent.GetHitActor(0), TEST_LOCATION); + DALI_TEST_EQUALS(-1, data.hoverEvent.GetDeviceId(1), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, data.hoverEvent.GetState(1), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetScreenPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetLocalPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Dali::Actor(), data.hoverEvent.GetHitActor(1), TEST_LOCATION); data.Reset(); // Emit a finished signal screenCoordinates.x = screenCoordinates.y = 12.0f; - actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Finished, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( localCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); + actor.ScreenToLocal(localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y); + application.ProcessEvent(GenerateSingleHover(PointState::FINISHED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(localCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(0, data.hoverEvent.GetDeviceId(0), TEST_LOCATION); + DALI_TEST_EQUALS(0u, data.hoverEvent.GetTime(), TEST_LOCATION); + DALI_TEST_EQUALS(actor, data.hoverEvent.GetHitActor(0), TEST_LOCATION); + DALI_TEST_EQUALS(-1, data.hoverEvent.GetDeviceId(1), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, data.hoverEvent.GetState(1), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetScreenPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2::ZERO, data.hoverEvent.GetLocalPosition(1), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(Dali::Actor(), data.hoverEvent.GetHitActor(1), TEST_LOCATION); data.Reset(); // Emit a started signal where the actor is not present screenCoordinates.x = screenCoordinates.y = 200.0f; - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(!data.hoverEvent); + END_TEST; } @@ -192,13 +219,13 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) { TestApplication application; - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); + Integration::Scene stage = application.GetScene(); + Vector2 stageSize = stage.GetSize(); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::CENTER); - actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); stage.Add(actor); // Render and notify @@ -206,70 +233,70 @@ int UtcDaliHoverOutsideCameraNearFarPlanes(void) application.Render(); // Get the camera's near and far planes - RenderTaskList taskList = stage.GetRenderTaskList(); - Dali::RenderTask task = taskList.GetTask(0); - CameraActor camera = task.GetCameraActor(); - float nearPlane = camera.GetNearClippingPlane(); - float farPlane = camera.GetFarClippingPlane(); + RenderTaskList taskList = stage.GetRenderTaskList(); + Dali::RenderTask task = taskList.GetTask(0); + CameraActor camera = task.GetCameraActor(); + float nearPlane = camera.GetNearClippingPlane(); + float farPlane = camera.GetFarClippingPlane(); // Calculate the current distance of the actor from the camera float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f); - float distance = (stageSize.y * 0.5f) / tanHalfFov; + float distance = (stageSize.y * 0.5f) / tanHalfFov; // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); - Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f ); + Vector2 screenCoordinates(stageSize.x * 0.5f, stageSize.y * 0.5f); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a started signal where actor is just at the camera's near plane - actor.SetZ(distance - nearPlane); + actor.SetProperty(Actor::Property::POSITION_Z, distance - nearPlane); // Render and notify application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a started signal where actor is closer than the camera's near plane - actor.SetZ((distance - nearPlane) + 1.0f); + actor.SetProperty(Actor::Property::POSITION_Z, (distance - nearPlane) + 1.0f); // Render and notify application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a started signal where actor is just at the camera's far plane - actor.SetZ(distance - farPlane); + actor.SetProperty(Actor::Property::POSITION_Z, distance - farPlane); // Render and notify application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a started signal where actor is further than the camera's far plane - actor.SetZ((distance - farPlane) - 1.0f); + actor.SetProperty(Actor::Property::POSITION_Z, (distance - farPlane) - 1.0f); // Render and notify application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } @@ -282,12 +309,12 @@ int UtcDaliHoverEmitEmpty(void) { // Emit an empty HoverEvent Integration::HoverEvent event; - application.ProcessEvent( event ); - tet_result( TET_FAIL ); + application.ProcessEvent(event); + tet_result(TET_FAIL); } - catch ( Dali::DaliException& e ) + catch(Dali::DaliException& e) { - DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION ); + DALI_TEST_ASSERT(e, "!event.points.empty()", TEST_LOCATION); } END_TEST; } @@ -297,212 +324,212 @@ int UtcDaliHoverInterrupted(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::INTERRUPTED, Vector2(200.0f, 200.0f /* Outside actor */))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // Emit another interrupted signal, our signal handler should not be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::INTERRUPTED, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } int UtcDaliHoverParentConsumer(void) { TestApplication application; - Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + Actor rootActor(application.GetScene().GetRootLayer()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data, false ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data, false); + actor.HoveredSignal().Connect(&application, functor); // Connect to root actor's hovered signal - SignalData rootData; - HoverEventFunctor rootFunctor( rootData ); // Consumes signal - rootActor.HoveredSignal().Connect( &application, rootFunctor ); + SignalData rootData; + HoverEventFunctor rootFunctor(rootData); // Consumes signal + rootActor.HoveredSignal().Connect(&application, rootFunctor); - Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 screenCoordinates(10.0f, 10.0f); Vector2 actorCoordinates, rootCoordinates; - actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y); + rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, rootData.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(actorCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(rootCoordinates, rootData.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit a motion signal screenCoordinates.x = screenCoordinates.y = 11.0f; - actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y); + rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::MOTION, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::MOTION, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, rootData.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(actorCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(rootCoordinates, rootData.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit a finished signal screenCoordinates.x = screenCoordinates.y = 12.0f; - actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Finished, screenCoordinates ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, data.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Finished, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, data.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( actorCoordinates, data.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + actor.ScreenToLocal(actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y); + rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y); + application.ProcessEvent(GenerateSingleHover(PointState::FINISHED, screenCoordinates)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::FINISHED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, data.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, rootData.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(actorCoordinates, data.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(rootCoordinates, rootData.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit a started signal where the actor is not present, will hit the root actor though screenCoordinates.x = screenCoordinates.y = 200.0f; - rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, screenCoordinates ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( 1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( screenCoordinates, rootData.hoverEvent.points[0].screen, TEST_LOCATION ); - DALI_TEST_EQUALS( rootCoordinates, rootData.hoverEvent.points[0].local, 0.1f, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + rootActor.ScreenToLocal(rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, screenCoordinates)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, rootData.hoverEvent.GetPointCount(), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(screenCoordinates, rootData.hoverEvent.GetScreenPosition(0), TEST_LOCATION); + DALI_TEST_EQUALS(rootCoordinates, rootData.hoverEvent.GetLocalPosition(0), 0.1f, TEST_LOCATION); + DALI_TEST_CHECK(rootActor == rootData.hoverEvent.GetHitActor(0)); END_TEST; } int UtcDaliHoverInterruptedParentConsumer(void) { TestApplication application; - Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + Actor rootActor(application.GetScene().GetRootLayer()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data, false ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data, false); + actor.HoveredSignal().Connect(&application, functor); // Connect to root actor's hovered signal - SignalData rootData; - HoverEventFunctor rootFunctor( rootData ); // Consumes signal - rootActor.HoveredSignal().Connect( &application, rootFunctor ); + SignalData rootData; + HoverEventFunctor rootFunctor(rootData); // Consumes signal + rootActor.HoveredSignal().Connect(&application, rootFunctor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit an interrupted signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::INTERRUPTED, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit another started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); rootData.Reset(); // Remove actor from Stage - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); // Render and notify application.SendNotification(); application.Render(); // Emit an interrupted signal, only root actor's signal should be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::INTERRUPTED, Vector2(200.0f, 200.0f /* Outside actor */))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(rootActor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit another interrupted state, none of the signal's should be called. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::INTERRUPTED, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(false, rootData.functorCalled, TEST_LOCATION); END_TEST; } @@ -511,51 +538,51 @@ int UtcDaliHoverLeave(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Set actor to require leave events - actor.SetLeaveRequired( true ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::LEAVE, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // Another motion outside of actor, no signalling - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(201.0f, 201.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - // Another motion event inside actor, signalled with motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); + // Another motion event inside actor, signalled with start. This is because a new hover event was started on that actor. + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // We do not want to listen to leave events anymore - actor.SetLeaveRequired( false ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false); // Another motion event outside of actor, no signalling - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } @@ -563,82 +590,82 @@ int UtcDaliHoverLeave(void) int UtcDaliHoverLeaveParentConsumer(void) { TestApplication application; - Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + Actor rootActor(application.GetScene().GetRootLayer()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data, false ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data, false); + actor.HoveredSignal().Connect(&application, functor); // Connect to root actor's hovered signal - SignalData rootData; - HoverEventFunctor rootFunctor( rootData ); // Consumes signal - rootActor.HoveredSignal().Connect( &application, rootFunctor ); + SignalData rootData; + HoverEventFunctor rootFunctor(rootData); // Consumes signal + rootActor.HoveredSignal().Connect(&application, rootFunctor); // Set actor to require leave events - actor.SetLeaveRequired( true ); - rootActor.SetLeaveRequired( true ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true); + rootActor.SetProperty(Actor::Property::LEAVE_REQUIRED, true); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Emit a motion signal outside of actor, should be signalled with a Leave - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::LEAVE, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::LEAVE, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Another motion outside of actor, only rootActor signalled - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( rootActor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(201.0f, 201.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::MOTION, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(rootActor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); - // Another motion event inside actor, signalled with motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Motion, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + // Another motion event inside actor, signalled with start. This is because a new hover event was started on that actor. + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // We do not want to listen to leave events of actor anymore - actor.SetLeaveRequired( false ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false); // Another motion event outside of root actor, only root signalled - Vector2 stageSize( Stage::GetCurrent().GetSize() ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + Vector2 stageSize(application.GetScene().GetSize()); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(stageSize.width + 10.0f, stageSize.height + 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::LEAVE, rootData.hoverEvent.GetState(0), TEST_LOCATION); END_TEST; } @@ -647,32 +674,32 @@ int UtcDaliHoverActorBecomesInsensitive(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // Change actor to insensitive - actor.SetSensitive( false ); + actor.SetProperty(Actor::Property::SENSITIVE, false); // Emit a motion signal, signalled with an interrupted - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); END_TEST; } @@ -680,334 +707,369 @@ int UtcDaliHoverActorBecomesInsensitive(void) int UtcDaliHoverActorBecomesInsensitiveParentConsumer(void) { TestApplication application; - Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + Actor rootActor(application.GetScene().GetRootLayer()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data, false ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data, false); + actor.HoveredSignal().Connect(&application, functor); // Connect to root actor's hovered signal - SignalData rootData; - HoverEventFunctor rootFunctor( rootData ); // Consumes signal - rootActor.HoveredSignal().Connect( &application, rootFunctor ); + SignalData rootData; + HoverEventFunctor rootFunctor(rootData); // Consumes signal + rootActor.HoveredSignal().Connect(&application, rootFunctor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, data.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Started, rootData.hoverEvent.points[0].state, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoverEvent.points[0].hitActor ); - DALI_TEST_CHECK( actor == rootData.hoverEvent.points[0].hitActor ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); + DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); rootData.Reset(); // Remove actor from Stage - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); // Render and notify application.SendNotification(); application.Render(); // Make root actor insensitive - rootActor.SetSensitive( false ); + rootActor.SetProperty(Actor::Property::SENSITIVE, false); // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor) - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); + END_TEST; +} + +int UtcDaliHoverActorBecomesUserInteractionDisabled(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's hovered signal + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); + + // Emit a started signal + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + data.Reset(); + + // Change actor to disable user interaction. + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false); + + // Emit a motion signal, signalled with an interrupted + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::INTERRUPTED, data.hoverEvent.GetState(0), TEST_LOCATION); + data.Reset(); END_TEST; } int UtcDaliHoverMultipleLayers(void) { TestApplication application; - Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + Actor rootActor(application.GetScene().GetRootLayer()); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); + SignalData data; + HoverEventFunctor functor(data); - Layer layer1 ( Layer::New() ); - layer1.SetSize(100.0f, 100.0f); - layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add( layer1 ); + Layer layer1(Layer::New()); + layer1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + layer1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(layer1); - Actor actor1 ( Actor::New() ); - actor1.SetSize( 100.0f, 100.0f ); - actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); - actor1.SetZ( 1.0f ); // Should hit actor1 in this layer - layer1.Add( actor1 ); + Actor actor1(Actor::New()); + actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor1.SetProperty(Actor::Property::POSITION_Z, 1.0f); // Should hit actor1 in this layer + layer1.Add(actor1); // Render and notify application.SendNotification(); application.Render(); // Connect to layer1 and actor1 - layer1.HoveredSignal().Connect( &application, functor ); - actor1.HoveredSignal().Connect( &application, functor ); + layer1.HoveredSignal().Connect(&application, functor); + actor1.HoveredSignal().Connect(&application, functor); // Hit in hittable area, actor1 should be hit - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( data.hoveredActor == actor1 ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(data.hoveredActor == actor1); data.Reset(); // Make layer1 insensitive, nothing should be hit - layer1.SetSensitive( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + layer1.SetProperty(Actor::Property::SENSITIVE, false); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Make layer1 sensitive again, again actor1 will be hit - layer1.SetSensitive( true ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( data.hoveredActor == actor1 ); + layer1.SetProperty(Actor::Property::SENSITIVE, true); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(data.hoveredActor == actor1); data.Reset(); // Make rootActor insensitive, nothing should be hit - rootActor.SetSensitive( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + rootActor.SetProperty(Actor::Property::SENSITIVE, false); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Make rootActor sensitive - rootActor.SetSensitive( true ); + rootActor.SetProperty(Actor::Property::SENSITIVE, true); // Add another layer - Layer layer2 ( Layer::New() ); - layer2.SetSize(100.0f, 100.0f ); - layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT); - layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2 - Stage::GetCurrent().Add( layer2 ); + Layer layer2(Layer::New()); + layer2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + layer2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + layer2.SetProperty(Actor::Property::POSITION_Z, 10.0f); // Should hit layer2 in this layer rather than actor2 + application.GetScene().Add(layer2); - Actor actor2 ( Actor::New() ); - actor2.SetSize(100.0f, 100.0f); - actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT); - layer2.Add( actor2 ); + Actor actor2(Actor::New()); + actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + layer2.Add(actor2); // Render and notify application.SendNotification(); application.Render(); // Connect to layer2 and actor2 - layer2.HoveredSignal().Connect( &application, functor ); - actor2.HoveredSignal().Connect( &application, functor ); + layer2.HoveredSignal().Connect(&application, functor); + actor2.HoveredSignal().Connect(&application, functor); // Emit an event, should hit layer2 - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); //DALI_TEST_CHECK( data.hoveredActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); // Make layer2 insensitive, should hit actor1 - layer2.SetSensitive( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( data.hoveredActor == actor1 ); + layer2.SetProperty(Actor::Property::SENSITIVE, false); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(data.hoveredActor == actor1); data.Reset(); // Make layer2 sensitive again, should hit layer2 - layer2.SetSensitive( true ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + layer2.SetProperty(Actor::Property::SENSITIVE, true); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); //DALI_TEST_CHECK( data.hoveredActor == layer2 ); // TODO: Uncomment this after removing renderable hack! data.Reset(); // Make layer2 invisible, render and notify - layer2.SetVisible( false ); + layer2.SetProperty(Actor::Property::VISIBLE, false); application.SendNotification(); application.Render(); // Should hit actor1 - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( data.hoveredActor == actor1 ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(data.hoveredActor == actor1); data.Reset(); // Make rootActor invisible, render and notify - rootActor.SetVisible( false ); + rootActor.SetProperty(Actor::Property::VISIBLE, false); application.SendNotification(); application.Render(); // Should not hit anything - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } int UtcDaliHoverMultipleRenderTasks(void) { - TestApplication application; - Stage stage ( Stage::GetCurrent() ); - Vector2 stageSize ( stage.GetSize() ); + TestApplication application; + Integration::Scene stage(application.GetScene()); + Vector2 stageSize(stage.GetSize()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); stage.Add(actor); // Create render task - Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f ); - RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() ); - renderTask.SetViewport( viewport ); - renderTask.SetInputEnabled( true ); + Viewport viewport(stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f); + RenderTask renderTask(application.GetScene().GetRenderTaskList().CreateTask()); + renderTask.SetViewport(viewport); + renderTask.SetInputEnabled(true); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(viewport.x + 5.0f, viewport.y + 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Disable input on renderTask, should not be hittable - renderTask.SetInputEnabled( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + renderTask.SetInputEnabled(false); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(viewport.x + 5.0f, viewport.y + 5.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } int UtcDaliHoverMultipleRenderTasksWithChildLayer(void) { - TestApplication application; - Stage stage ( Stage::GetCurrent() ); - Vector2 stageSize ( stage.GetSize() ); + TestApplication application; + Integration::Scene stage(application.GetScene()); + Vector2 stageSize(stage.GetSize()); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); stage.Add(actor); Layer layer = Layer::New(); - layer.SetSize(100.0f, 100.0f); - layer.SetAnchorPoint(AnchorPoint::TOP_LEFT); + layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); actor.Add(layer); // Create render task - Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f ); - RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() ); - renderTask.SetViewport( viewport ); - renderTask.SetInputEnabled( true ); - renderTask.SetSourceActor( actor ); + Viewport viewport(stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f); + RenderTask renderTask(application.GetScene().GetRenderTaskList().CreateTask()); + renderTask.SetViewport(viewport); + renderTask.SetInputEnabled(true); + renderTask.SetSourceActor(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to layer's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); - layer.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); + layer.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Ensure renderTask actor can be hit too. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(viewport.x + 5.0f, viewport.y + 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Disable input on renderTask, should not be hittable - renderTask.SetInputEnabled( false ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + renderTask.SetInputEnabled(false); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(viewport.x + 5.0f, viewport.y + 5.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } int UtcDaliHoverOffscreenRenderTasks(void) { - TestApplication application; - Stage stage ( Stage::GetCurrent() ); - Vector2 stageSize ( stage.GetSize() ); + TestApplication application; + Integration::Scene stage(application.GetScene()); + Vector2 stageSize(stage.GetSize()); // FrameBufferImage for offscreen RenderTask - FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) ); + FrameBuffer frameBuffer = FrameBuffer::New(stageSize.width, stageSize.height); - // Create an image actor to display the FrameBufferImage - ImageActor imageActor ( ImageActor::New( frameBufferImage ) ); - imageActor.SetParentOrigin(ParentOrigin::CENTER); - imageActor.SetSize( stageSize.x, stageSize.y ); - imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME - stage.Add( imageActor ); + // Create a renderable actor to display the FrameBufferImage + Actor renderableActor = CreateRenderableActor(frameBuffer.GetColorTexture()); + renderableActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + renderableActor.SetProperty(Actor::Property::SIZE, Vector2(stageSize.x, stageSize.y)); + renderableActor.ScaleBy(Vector3(1.0f, -1.0f, 1.0f)); // FIXME + stage.Add(renderableActor); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - stage.Add( actor ); - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + stage.Add(actor); + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); // Ensure framebuffer connects - stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION ); + stage.GetRenderTaskList().GetTask(0u).SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION); // Create a RenderTask RenderTask renderTask = stage.GetRenderTaskList().CreateTask(); - renderTask.SetSourceActor( actor ); - renderTask.SetTargetFrameBuffer( frameBufferImage ); - renderTask.SetInputEnabled( true ); + renderTask.SetSourceActor(actor); + renderTask.SetFrameBuffer(frameBuffer); + renderTask.SetInputEnabled(true); // Create another RenderTask - RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() ); - renderTask2.SetInputEnabled( true ); + RenderTask renderTask2(stage.GetRenderTaskList().CreateTask()); + renderTask2.SetInputEnabled(true); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } int UtcDaliHoverMultipleRenderableActors(void) { - TestApplication application; - Stage stage ( Stage::GetCurrent() ); - Vector2 stageSize ( stage.GetSize() ); + TestApplication application; + Integration::Scene stage(application.GetScene()); + Vector2 stageSize(stage.GetSize()); - Actor parent = ImageActor::New(); - parent.SetSize( 100.0f, 100.0f ); - parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Actor parent = CreateRenderableActor(); + parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); stage.Add(parent); - Actor actor = ImageActor::New(); - actor.SetSize( 100.0f, 100.0f ); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); parent.Add(actor); // Render and notify @@ -1015,15 +1077,15 @@ int UtcDaliHoverMultipleRenderableActors(void) application.Render(); // Connect to layer's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - parent.HoveredSignal().Connect( &application, functor ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + parent.HoveredSignal().Connect(&application, functor); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( actor == data.hoveredActor ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.hoveredActor); END_TEST; } @@ -1032,40 +1094,40 @@ int UtcDaliHoverActorRemovedInSignal(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - RemoveActorFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + RemoveActorFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Register for leave events - actor.SetLeaveRequired( true ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Re-add, render and notify - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); application.SendNotification(); application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(210.0f, 210.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Render and notify @@ -1073,26 +1135,26 @@ int UtcDaliHoverActorRemovedInSignal(void) application.Render(); // Emit another signal outside of actor's area, should not get anything as the scene has changed. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(210.0f, 210.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Re-add actor back to stage, render and notify - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); application.SendNotification(); application.Render(); // Emit another started event - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Completely delete the actor actor.Reset(); // Emit event, should not crash and should not receive an event. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(210.0f, 210.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -1101,22 +1163,22 @@ int UtcDaliHoverActorSignalNotConsumed(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data, false ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data, false); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -1125,155 +1187,146 @@ int UtcDaliHoverActorUnStaged(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started signal - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Remove actor from stage - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); // Render and notify application.SendNotification(); application.Render(); // Emit a move at the same point, we should not be signalled. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } -int UtcDaliHoverSystemOverlayActor(void) -{ - TestApplication application; - Dali::Integration::Core& core( application.GetCore() ); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - systemOverlay.GetOverlayRenderTasks().CreateTask(); - - // Create an actor and add it to the system overlay. - Actor systemActor = Actor::New(); - systemActor.SetSize(100.0f, 100.0f); - systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add( systemActor ); - - // Create an actor and add it to the stage as per normal, same position and size as systemActor - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Connect to the hover signals. - SignalData data; - HoverEventFunctor functor( data ); - systemActor.HoveredSignal().Connect( &application, functor ); - actor.HoveredSignal().Connect( &application, functor ); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Emit a started signal, the system overlay is drawn last so is at the top, should hit the systemActor. - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( systemActor == data.hoveredActor ); - END_TEST; -} - int UtcDaliHoverLeaveActorReadded(void) { - TestApplication application; - Stage stage = Stage::GetCurrent(); + TestApplication application; + Integration::Scene stage = application.GetScene(); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); stage.Add(actor); // Set actor to receive hover-events - actor.SetLeaveRequired( true ); + actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true); // Render and notify application.SendNotification(); application.Render(); // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); // Emit a started and motion - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(11.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Remove actor from stage and add again - stage.Remove( actor ); - stage.Add( actor ); + stage.Remove(actor); + stage.Add(actor); // Emit a motion within the actor's bounds - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(12.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Emit a motion outside the actor's bounds - application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION ); + application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(200.0f, 200.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::LEAVE, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); END_TEST; } - -int UtcDaliHoverStencilNonRenderableActor(void) +int UtcDaliHoverClippingActor(void) { - TestApplication application; - Stage stage = Stage::GetCurrent(); + TestApplication application; + Integration::Scene stage = application.GetScene(); Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); stage.Add(actor); - Actor stencil = Actor::New(); - stencil.SetSize(50.0f, 50.0f); - stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT); - stencil.SetDrawMode( DrawMode::STENCIL ); - stage.Add(stencil); + Actor clippingActor = Actor::New(); + clippingActor.SetProperty(Actor::Property::SIZE, Vector2(50.0f, 50.0f)); + clippingActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + clippingActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN); + stage.Add(clippingActor); - // Render and notify + // Add a child to the clipped region. + Actor clippingChild = Actor::New(); + clippingChild.SetProperty(Actor::Property::SIZE, Vector2(50.0f, 50.0f)); + clippingChild.SetProperty(Actor::Property::POSITION, Vector2(25.0f, 25.0f)); + clippingChild.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + clippingActor.Add(clippingChild); + + // Render and notify. application.SendNotification(); application.Render(); - // Connect to actor's hovered signal - SignalData data; - HoverEventFunctor functor( data ); - actor.HoveredSignal().Connect( &application, functor ); + // Connect to actor's hovered signal. + SignalData data; + HoverEventFunctor functor(data); + actor.HoveredSignal().Connect(&application, functor); + + // Emit an event within clipped area - we should have a hit. + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); - // Emit an event within stencil area - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + // Emit an event outside the clipped area but within the actor area, we should have a hit. + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(60.0f, 60.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - // Emit an event outside the stencil area but within the actor area, we should have a hit! - application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 60.0f, 60.0f ) ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + clippingChild.HoveredSignal().Connect(&application, functor); + + // Emit an event inside part of the child which is within the clipped area, we should have a hit. + application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(30.0f, 30.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); END_TEST; } + +int UtcDaliHoverEventCreate(void) +{ + TestApplication application; + + Dali::HoverEvent hoverEvent = DevelHoverEvent::New(100); + DALI_TEST_CHECK(hoverEvent); + + // Emit a started signal + DALI_TEST_EQUALS(100, hoverEvent.GetTime(), TEST_LOCATION); + DALI_TEST_EQUALS(0, hoverEvent.GetPointCount(), TEST_LOCATION); + + END_TEST; +}