X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-PinchGestureDetector.cpp;h=84b6c671774552ad3289ea16b7910a3731b3d0ee;hb=bba33c0f3be4f27b3b67559aad388937f2ffd0a7;hp=13ae5b50eee54437966c6907c746d68ac9f56d8e;hpb=fab6bd2494d4c9420bd6722e992be1a22ec104da;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index 13ae5b5..84b6c67 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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,16 +15,14 @@ * */ -#include - -#include -#include +#include #include -#include -#include #include -#include -#include +#include +#include +#include + +#include using namespace Dali; @@ -41,46 +39,45 @@ void utc_dali_pinch_gesture_detector_cleanup(void) /////////////////////////////////////////////////////////////////////////////// namespace { - // Stores data that is populated in the callback and will be read by the TET cases struct SignalData { SignalData() : functorCalled(false), voidFunctorCalled(false), - receivedGesture(Gesture::Started) - {} + receivedGesture() + { + } void Reset() { - functorCalled = false; + functorCalled = false; voidFunctorCalled = false; - receivedGesture.state = Gesture::Started; - receivedGesture.scale = 0.0f; - receivedGesture.speed = 0.0f; - receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f); - receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f); + receivedGesture.Reset(); pinchedActor.Reset(); } - bool functorCalled; - bool voidFunctorCalled; + bool functorCalled; + bool voidFunctorCalled; PinchGesture receivedGesture; - Actor pinchedActor; + Actor pinchedActor; }; // Functor that sets the data when called struct GestureReceivedFunctor { - GestureReceivedFunctor(SignalData& data) : signalData(data) { } + GestureReceivedFunctor(SignalData& data) + : signalData(data) + { + } void operator()(Actor actor, const PinchGesture& pinch) { - signalData.functorCalled = true; + signalData.functorCalled = true; signalData.receivedGesture = pinch; - signalData.pinchedActor = actor; + signalData.pinchedActor = actor; } void operator()() @@ -94,51 +91,28 @@ struct GestureReceivedFunctor // Functor that removes the gestured actor from stage struct UnstageActorFunctor : public GestureReceivedFunctor { - UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage ) - : GestureReceivedFunctor( data ), - stateToUnstage( stateToUnstage ) + UnstageActorFunctor(SignalData& data, GestureState& stateToUnstage, Integration::Scene scene) + : GestureReceivedFunctor(data), + stateToUnstage(stateToUnstage), + scene(scene) { } - void operator()( Actor actor, const PinchGesture& pinch ) + void operator()(Actor actor, const PinchGesture& pinch) { - GestureReceivedFunctor::operator()( actor, pinch ); + GestureReceivedFunctor::operator()(actor, pinch); - if ( pinch.state == stateToUnstage ) + if(pinch.GetState() == stateToUnstage) { - Stage::GetCurrent().Remove( actor ); + scene.Remove(actor); } } - Gesture::State& stateToUnstage; + GestureState& stateToUnstage; + Integration::Scene scene; }; -// Functor for receiving a touch event -struct TouchEventFunctor -{ - bool operator()(Actor actor, const TouchEvent& touch) - { - return false; - } -}; - -// Generate a PinchGestureEvent to send to Core -Integration::PinchGestureEvent GeneratePinch( - Gesture::State state, - float scale, - float speed, - Vector2 centerpoint) -{ - Integration::PinchGestureEvent pinch(state); - - pinch.scale = scale; - pinch.speed = speed; - pinch.centerPoint = centerpoint; - - return pinch; -} - -} // anon namespace +} // namespace /////////////////////////////////////////////////////////////////////////////// @@ -155,10 +129,11 @@ int UtcDaliPinchGestureDetectorCopyConstructorP(void) { TestApplication application; - PinchGestureDetector detector = PinchGestureDetector::New();; + PinchGestureDetector detector = PinchGestureDetector::New(); + ; - PinchGestureDetector copy( detector ); - DALI_TEST_CHECK( detector ); + PinchGestureDetector copy(detector); + DALI_TEST_CHECK(detector); END_TEST; } @@ -166,13 +141,14 @@ int UtcDaliPinchGestureDetectorAssignmentOperatorP(void) { TestApplication application; - PinchGestureDetector detector = PinchGestureDetector::New();; + PinchGestureDetector detector = PinchGestureDetector::New(); + ; PinchGestureDetector assign; assign = detector; - DALI_TEST_CHECK( detector ); + DALI_TEST_CHECK(detector); - DALI_TEST_CHECK( detector == assign ); + DALI_TEST_CHECK(detector == assign); END_TEST; } @@ -186,9 +162,9 @@ int UtcDaliPinchGestureDetectorNew(void) // Attach an actor and emit a touch event on the actor to ensure complete line coverage 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(); @@ -197,17 +173,17 @@ int UtcDaliPinchGestureDetectorNew(void) detector.Attach(actor); Integration::TouchEvent touchEvent(1); - Integration::Point point; - point.SetDeviceId( 1 ); - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); + Integration::Point point; + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(20.0f, 20.0f)); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); Integration::Point point2; - point.SetDeviceId( 1 ); - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(20.0f, 20.0f)); touchEvent.AddPoint(point2); application.ProcessEvent(touchEvent); END_TEST; @@ -225,17 +201,17 @@ int UtcDaliPinchGestureDetectorDownCast(void) PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object); DALI_TEST_CHECK(detector2); - PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object); + PinchGestureDetector detector3 = DownCast(object); DALI_TEST_CHECK(detector3); - BaseHandle unInitializedObject; + BaseHandle unInitializedObject; PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject); DALI_TEST_CHECK(!detector4); - PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject); + PinchGestureDetector detector5 = DownCast(unInitializedObject); DALI_TEST_CHECK(!detector5); - GestureDetector detector6 = PinchGestureDetector::New(); + GestureDetector detector6 = PinchGestureDetector::New(); PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6); DALI_TEST_CHECK(detector7); END_TEST; @@ -247,15 +223,15 @@ int UtcDaliPinchGestureSignalReceptionNegative(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -263,17 +239,20 @@ int UtcDaliPinchGestureSignalReceptionNegative(void) detector.DetectedSignal().Connect(&application, functor); // Do a pinch outside actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f))); + TestStartPinch(application, Vector2(112.0f, 62.0f), Vector2(112.0f, 162.0f), Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), 100); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Continue pinch into actor's area - we should still not receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Stop pinching - we should still not receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f))); + TestEndPinch(application, Vector2(6.0f, 6.0f), Vector2(18.0f, 18.0f), Vector2(10.0f, 8.0f), Vector2(14.0f, 16.0f), 300); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -283,15 +262,15 @@ int UtcDaliPinchGestureSignalReceptionDownMotionLeave(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -299,39 +278,43 @@ int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void) detector.DetectedSignal().Connect(&application, functor); // Start pan within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch(application, Vector2(5.0f, 20.0f), Vector2(35.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the pan within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), 400); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.2666f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(80.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); - // Pan Gesture leaves actor's area - we should still receive the signal + // Pinch Gesture leaves actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f))); + TestContinuePinch(application, Vector2(17.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(1.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(213.333f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends - we would receive a finished state data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f))); + TestEndPinch(application, Vector2(300.0f, 10.0f), Vector2(340.0f, 10.0f), Vector2(305.0f, 10.0f), Vector2(315.0f, 10.0f), 1500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.333f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(600.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -340,15 +323,15 @@ int UtcDaliPinchGestureSignalReceptionDownMotionUp(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -356,70 +339,33 @@ int UtcDaliPinchGestureSignalReceptionDownMotionUp(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.555f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(106.667f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.277f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Gesture ends within actor's area - we would receive a finished state data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); - END_TEST; -} - -int UtcDaliPinchGestureSignalReceptionCancelled(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - - - // Continue the pinch within the actor's area - we should still receive the signal - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - - // The gesture is cancelled - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -428,15 +374,15 @@ int UtcDaliPinchGestureSignalReceptionDetach(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -444,31 +390,28 @@ int UtcDaliPinchGestureSignalReceptionDetach(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - + DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::FINISHED, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor detector.DetachAll(); // Ensure we are no longer signalled data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestGeneratePinch(application); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -478,15 +421,15 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -494,22 +437,22 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); // Detach actor during the pinch, we should not receive the next event detector.DetachAll(); // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -518,7 +461,7 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) { TestApplication application; - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -527,17 +470,17 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor // is destroyed. Actor tempActor = Actor::New(); - tempActor.SetSize(100.0f, 100.0f); - tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - Stage::GetCurrent().Add(tempActor); + tempActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + tempActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT); + application.GetScene().Add(tempActor); detector.Attach(tempActor); // Actor lifetime is scoped { 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(); @@ -546,18 +489,18 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) detector.Attach(actor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(GestureState::CONTINUING, data.receivedGesture.GetState(), TEST_LOCATION); // Remove the actor from stage and reset the data - Stage::GetCurrent().Remove(actor); + application.GetScene().Remove(actor); // Render and notify application.SendNotification(); @@ -568,7 +511,7 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) // Gesture ends within the area where the actor used to be data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -578,15 +521,15 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) TestApplication application; Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS); - Stage::GetCurrent().Add(actor); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS)); + application.GetScene().Add(actor); // Render and notify a couple of times application.SendNotification(); application.Render(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -594,41 +537,44 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) detector.DetectedSignal().Connect(&application, functor); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(70.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify - actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS); + actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS)); application.SendNotification(); application.Render(); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(30.0f, 30.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); // Rotate actor again and render and notify - actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS); + actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS)); application.SendNotification(); application.Render(); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 4100); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 5000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(30.0f, 70.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -637,28 +583,25 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) TestApplication application; Actor parent = Actor::New(); - parent.SetSize(100.0f, 100.0f); - parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(parent); + parent.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(parent); // Set child to completely cover parent. // Change rotation of child to be different from parent so that we can check if our local coordinate // conversion of the parent actor is correct. Actor child = Actor::New(); - child.SetSize(100.0f, 100.0f); - child.SetAnchorPoint(AnchorPoint::CENTER); - child.SetParentOrigin(ParentOrigin::CENTER); - child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS); + child.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + child.SetProperty(Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS)); parent.Add(child); - TouchEventFunctor touchFunctor; - child.TouchedSignal().Connect(&application, touchFunctor); - // Render and notify application.SendNotification(); application.Render(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -666,14 +609,14 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) detector.DetectedSignal().Connect(&application, functor); // Do an entire pan, only check finished value - hits child area but parent should still receive it - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); // Attach child and generate same touch points to yield same results // (Also proves that you can detach and then re-attach another actor) @@ -681,14 +624,15 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) detector.Detach(parent); // Do an entire pan, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 2100); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.GetScale(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.GetScreenCenterPoint(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 80.0f), data.receivedGesture.GetLocalCenterPoint(), 0.01f, TEST_LOCATION); END_TEST; } @@ -697,21 +641,21 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) TestApplication application; Actor first = Actor::New(); - first.SetSize(100.0f, 100.0f); - first.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(first); + first.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(first); Actor second = Actor::New(); - second.SetSize(100.0f, 100.0f); - second.SetX(100.0f); - second.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(second); + second.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + second.SetProperty(Actor::Property::POSITION_X, 100.0f); + second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(second); // Render and notify application.SendNotification(); application.Render(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -720,13 +664,13 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within second actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + TestStartPinch(application, Vector2(102.0f, 20.0f), Vector2(138.0f, 20.0f), Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); // Pinch moves into first actor's area - second actor should receive the pinch data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestContinuePinch(application, Vector2(110.0f, 20.0f), Vector2(130.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); @@ -735,7 +679,7 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(119.0f, 20.0f), Vector2(121.0f, 20.0f), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -745,15 +689,15 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(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(); - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); PinchGestureDetector detector = PinchGestureDetector::New(); @@ -761,16 +705,16 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch in actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); // Pan continues within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); // Actor become invisible - actor should not receive the next pinch - actor.SetVisible(false); + actor.SetProperty(Actor::Property::VISIBLE, false); // Render and notify application.SendNotification(); @@ -778,7 +722,7 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -788,30 +732,30 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(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); Actor actor2 = Actor::New(); - actor2.SetSize(100.0f, 100.0f); - actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - Stage::GetCurrent().Add(actor2); + actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT); + application.GetScene().Add(actor2); // Render and notify application.SendNotification(); application.Render(); // Attach actor to one detector - SignalData firstData; + SignalData firstData; GestureReceivedFunctor firstFunctor(firstData); - PinchGestureDetector firstDetector = PinchGestureDetector::New(); + PinchGestureDetector firstDetector = PinchGestureDetector::New(); firstDetector.Attach(actor); firstDetector.DetectedSignal().Connect(&application, firstFunctor); // Attach actor to another detector - SignalData secondData; + SignalData secondData; GestureReceivedFunctor secondFunctor(secondData); - PinchGestureDetector secondDetector = PinchGestureDetector::New(); + PinchGestureDetector secondDetector = PinchGestureDetector::New(); secondDetector.Attach(actor); secondDetector.DetectedSignal().Connect(&application, secondFunctor); @@ -821,14 +765,14 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) secondDetector.Attach(actor2); // Pinch in actor's area - both detector's functors should be called - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); // Pinch continues in actor's area - both detector's functors should be called firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); @@ -836,14 +780,14 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) firstDetector.Detach(actor); firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); // New pinch on actor, only secondDetector has actor attached firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); @@ -851,91 +795,34 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) secondDetector.Detach(actor); firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureSignalReceptionMultipleStarted(void) -{ - // Should handle two started events gracefully. - - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Start pan in actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Add a child actor to overlap actor and send another start in actor's area - Actor child = Actor::New(); - child.SetSize(100.0f, 100.0f); - child.SetAnchorPoint(AnchorPoint::CENTER); - child.SetParentOrigin(ParentOrigin::CENTER); - actor.Add(child); - - TouchEventFunctor touchFunctor; - child.TouchedSignal().Connect(&application, touchFunctor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - END_TEST; -} - int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) { TestApplication application; Actor actor1 = Actor::New(); - actor1.SetSize(100.0f, 100.0f); - actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor1); - SignalData data1; + actor1.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor1); + SignalData data1; GestureReceivedFunctor functor1(data1); - PinchGestureDetector detector1 = PinchGestureDetector::New(); + PinchGestureDetector detector1 = PinchGestureDetector::New(); detector1.Attach(actor1); detector1.DetectedSignal().Connect(&application, functor1); Actor actor2 = Actor::New(); - actor2.SetSize(100.0f, 100.0f); - actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - Stage::GetCurrent().Add(actor2); - SignalData data2; + actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT); + actor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT); + application.GetScene().Add(actor2); + SignalData data2; GestureReceivedFunctor functor2(data2); - PinchGestureDetector detector2 = PinchGestureDetector::New(); + PinchGestureDetector detector2 = PinchGestureDetector::New(); detector2.Attach(actor2); detector2.DetectedSignal().Connect(&application, functor2); @@ -944,106 +831,40 @@ int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) application.Render(); // Start pan in actor1's area, only data1 should be set - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureEmitIncorrectStateClear(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Attach actor to detector - SignalData data; - GestureReceivedFunctor functor( data ); - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); - - // Try a Clear state - try - { - application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - tet_result(TET_FAIL); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION ); - } - END_TEST; -} - -int UtcDaliPinchGestureEmitIncorrectStatePossible(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Attach actor to detector - SignalData data; - GestureReceivedFunctor functor( data ); - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); - - // Try a Possible state - try - { - application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - tet_result(TET_FAIL); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION ); - } - END_TEST; -} - int UtcDaliPinchGestureActorUnstaged(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(); // State to remove actor in. - Gesture::State stateToUnstage( Gesture::Started ); + GestureState stateToUnstage(GestureState::STARTED); // Attach actor to detector - SignalData data; - UnstageActorFunctor functor( data, stateToUnstage ); + SignalData data; + UnstageActorFunctor functor(data, stateToUnstage, application.GetScene()); PinchGestureDetector detector = PinchGestureDetector::New(); detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); + detector.DetectedSignal().Connect(&application, functor); // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1052,23 +873,23 @@ int UtcDaliPinchGestureActorUnstaged(void) application.Render(); // Re-add actor to stage - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); - // Change state to Gesture::Continuing to remove - stateToUnstage = Gesture::Continuing; + // Change state to GestureState::CONTINUING to remove + stateToUnstage = GestureState::CONTINUING; // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1077,25 +898,25 @@ int UtcDaliPinchGestureActorUnstaged(void) application.Render(); // Re-add actor to stage - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); - // Change state to Gesture::Continuing to remove - stateToUnstage = Gesture::Finished; + // Change state to GestureState::CONTINUING to remove + stateToUnstage = GestureState::FINISHED; // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully. + tet_result(TET_PASS); // If we get here then we have handled actor stage removal gracefully. END_TEST; } @@ -1104,38 +925,38 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(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); // Create and add a second actor so that GestureDetector destruction does not come into play. - Actor dummyActor( Actor::New() ); - dummyActor.SetSize( 100.0f, 100.0f ); - dummyActor.SetPosition( 100.0f, 100.0f ); - dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(dummyActor); + Actor dummyActor(Actor::New()); + dummyActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + dummyActor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f)); + dummyActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(dummyActor); // Render and notify application.SendNotification(); application.Render(); // State to remove actor in. - Gesture::State stateToUnstage( Gesture::Started ); + GestureState stateToUnstage(GestureState::STARTED); // Attach actor to detector - SignalData data; - UnstageActorFunctor functor( data, stateToUnstage ); + SignalData data; + UnstageActorFunctor functor(data, stateToUnstage, application.GetScene()); PinchGestureDetector detector = PinchGestureDetector::New(); detector.Attach(actor); detector.Attach(dummyActor); - detector.DetectedSignal().Connect( &application, functor ); + detector.DetectedSignal().Connect(&application, functor); - // Here we are testing a Started actor which is removed in the Started callback, but then added back + // Here we are testing a STARTED actor which is removed in the STARTED callback, but then added back // before we get a continuing state. As we were removed from the stage, even if we're at the same // position, we should still not be signalled. // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1144,24 +965,24 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) application.Render(); // Re add to the stage, we should not be signalled - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); // Render and notify application.SendNotification(); application.Render(); // Continue signal emission - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Here we delete an actor in started, we should not receive any subsequent signalling. // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1177,223 +998,57 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) application.Render(); // Continue signal emission - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 2000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - - Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New(); - Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor(); - Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor(); - Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor ); - systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList ); - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pan within the actor's area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliPinchGestureBehindTouchableSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - - Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New(); - Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor(); - Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor(); - Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor ); - systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList ); - - // SystemOverlay actor - Actor systemOverlayActor = Actor::New(); - systemOverlayActor.SetSize(100.0f, 100.0f); - systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(systemOverlayActor); - - // Stage actor - Actor stageActor = Actor::New(); - stageActor.SetSize(100.0f, 100.0f); - stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(stageActor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Set system-overlay actor to touchable - TouchEventData touchData; - TouchEventDataFunctor touchFunctor( touchData ); - systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor); - - // Set stage actor to receive the gesture - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(stageActor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pinch within the two actors' area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION ); - - data.Reset(); - touchData.Reset(); - - // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - - Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New(); - Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor(); - Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor(); - Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor ); - systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList ); - - // SystemOverlay actor - Actor systemOverlayActor = Actor::New(); - systemOverlayActor.SetSize(100.0f, 100.0f); - systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(systemOverlayActor); - - // Stage actor - Actor stageActor = Actor::New(); - stageActor.SetSize(100.0f, 100.0f); - stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(stageActor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Set stage actor to touchable - TouchEventData touchData; - TouchEventDataFunctor touchFunctor( touchData ); - stageActor.TouchedSignal().Connect(&application, touchFunctor); - - // Set system-overlay actor to have the gesture - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(systemOverlayActor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pinch within the two actors' area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION ); - - data.Reset(); - touchData.Reset(); - - // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliPinchGestureLayerConsumesTouch(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); // Add a detector - SignalData data; + SignalData data; GestureReceivedFunctor functor(data); - PinchGestureDetector detector = PinchGestureDetector::New(); + PinchGestureDetector detector = PinchGestureDetector::New(); detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); + detector.DetectedSignal().Connect(&application, functor); // Add a layer to overlap the actor Layer layer = Layer::New(); - layer.SetSize(100.0f, 100.0f); - layer.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add( layer ); + layer.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(layer); layer.RaiseToTop(); // Render and notify application.SendNotification(); application.Render(); - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - // Emit signals, should receive - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); // Set layer to consume all touch - layer.SetTouchConsumed( true ); + layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true); // Render and notify application.SendNotification(); application.Render(); // Emit the same signals again, should not receive - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); + TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 1500); + TestEndPinch(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(19.0f, 20.0f), Vector2(21.0f, 20.0f), 2000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset();