X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=f762e8df4d78bf658e0546341f0bc8d463cfda8d;hp=5ec103583be9a721464529a2338b4469b24adef8;hb=ea3acc2d51380bd70ebe63cf121bcaa8d423b340;hpb=ce4a6e3803b711fa4c399160c48bcaa9f51f31e4 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 5ec1035..f762e8d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -19,10 +19,6 @@ #include #include -#include -#include -#include -#include #include #include @@ -30,8 +26,13 @@ #include #include #include +#include #include +#include #include +#include +#include +#include #include "test-text-geometry-utils.h" #include "toolkit-clipboard.h" @@ -405,6 +406,56 @@ bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map return true; } + +// Stores data that is populated in the callback and will be read by the test cases +struct SignalData +{ + SignalData() + : functorCalled(false), + voidFunctorCalled(false), + receivedGesture() + { + } + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.Reset(); + + pannedActor.Reset(); + } + + bool functorCalled; + bool voidFunctorCalled; + PanGesture receivedGesture; + Actor pannedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) + : signalData(data) + { + } + + void operator()(Actor actor, const PanGesture& pan) + { + signalData.functorCalled = true; + signalData.receivedGesture = pan; + signalData.pannedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + } // namespace int UtcDaliToolkitTextFieldConstructorP(void) @@ -2650,14 +2701,14 @@ int utcDaliTextFieldEvent03(void) application.Render(); // Tap first to get the focus. - TestGenerateTap(application, 3.0f, 25.0f); + TestGenerateTap(application, 3.0f, 25.0f, 100); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - TestGenerateTap(application, 3.0f, 25.0f); + TestGenerateTap(application, 3.0f, 25.0f, 200); // Render and notify application.SendNotification(); @@ -5566,4 +5617,76 @@ int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void) application.Render(); END_TEST; -} \ No newline at end of file +} + +int utcDaliTextFieldPanGesturePropagation(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldPanGesturePropagation"); + + 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); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field."); + field.SetProperty(TextField::Property::POINT_SIZE, 10.f); + + field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f)); + field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + actor.Add(field); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Tap first to get the focus. + TestGenerateTap(application, 3.0f, 25.0f, 100); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Pan the text field + uint32_t time = 100; + TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time); + TestMovePan(application, Vector2(10.0f, 50.0f), time); + TestEndPan(application, Vector2(40.0f, 50.0f), time); + application.SendNotification(); + application.Render(); + + // The text scrolls because there is text that is scrolling. + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Set the size large enough to prevent scrolling. + field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f)); + + // Render and notify + application.SendNotification(); + application.Render(); + + time = 200; + TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time); + TestMovePan(application, Vector2(10.0f, 50.0f), time); + TestEndPan(application, Vector2(40.0f, 50.0f), time); + + // Because scrolling is not possible, the pan gesture is propagated. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + + END_TEST; +}