X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=5f3309947549c027657b70d165ac98ac107a8732;hb=4255529cd62def14c042f78edd30b6919fa591e1;hp=82b0f801dd9171248fd38be11c6c596427f7f822;hpb=ff6ce970724ccc8bee65f7c93411b274907c09d7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 82b0f80..5f33099 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) @@ -462,7 +513,7 @@ int UtcDaliToolkitTextFieldCopyConstructorP(void) TextField copy(textField); DALI_TEST_CHECK(copy); - DALI_TEST_CHECK(copy.GetProperty(TextLabel::Property::TEXT) == textField.GetProperty(TextLabel::Property::TEXT)); + DALI_TEST_CHECK(copy.GetProperty(TextField::Property::TEXT) == textField.GetProperty(TextField::Property::TEXT)); END_TEST; } @@ -1737,6 +1788,57 @@ int utcDaliTextFieldPositionWithInputMethodContext(void) END_TEST; } +int utcDaliTextFieldInputFilterWithInputMethodContext(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext"); + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + Property::Map inputFilter; + inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]"; + inputFilter[InputFilter::Property::REJECTED] = "[5-7]"; + + // Set input filter to TextField. + field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter); + + application.GetScene().Add(field); + + // connect to the input filtered signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback); + bool inputFilteredSignal = false; + field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal)); + + // get InputMethodContext + std::string text; + InputMethodContext::EventData imfEvent; + InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field); + + field.SetKeyInputFocus(); + field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true); + + // input text + gInputFilteredAcceptedCallbackCalled = false; + imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled); + DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION); + + inputFilteredSignal = false; + gInputFilteredRejectedCallbackCalled = false; + imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled); + DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION); + + END_TEST; +} + // Negative test for the textChanged signal. int utcDaliTextFieldTextChangedN(void) { @@ -2650,14 +2752,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(); @@ -2880,7 +2982,8 @@ int utcDaliTextFieldEvent08(void) tet_infoline(" utcDaliTextFieldEvent08"); Dali::Clipboard clipboard = Clipboard::Get(); - clipboard.SetItem("testTextFieldEvent"); + Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent"); + clipboard.SetData(data); // Checks Longpress when only place holder text @@ -2961,6 +3064,7 @@ int utcDaliTextFieldEvent09(void) application.Render(); field.SetProperty(TextField::Property::TEXT, "Hello"); + field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text"); field.SetProperty(TextField::Property::POINT_SIZE, 10.f); field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f)); field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); @@ -2980,6 +3084,12 @@ int utcDaliTextFieldEvent09(void) application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); application.SendNotification(); application.Render(); + for(unsigned int index = 0u; index < 6u; ++index) + { + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + } map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL; map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23; @@ -3286,6 +3396,14 @@ int utcDaliTextFieldSomeSpecialKeys(void) application.SendNotification(); application.Render(); + // Generate a Back key event. Nothing happens to the text field. + application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + + // Render and notify + application.SendNotification(); + application.Render(); + // The text shouldn't be deleted. DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT), longText, TEST_LOCATION); @@ -4672,7 +4790,7 @@ int utcDaliTextFieldGeometryEllipsisStart(void) Vector expectedPositions; expectedPositions.PushBack(Vector2(14, 0)); - expectedSizes.PushBack(Vector2(106, 25)); + expectedSizes.PushBack(Vector2(107, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -4719,7 +4837,7 @@ int utcDaliTextFieldGeometryEllipsisEnd(void) Vector expectedPositions; expectedPositions.PushBack(Vector2(-2, 0)); - expectedSizes.PushBack(Vector2(122, 25)); + expectedSizes.PushBack(Vector2(123, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -4764,7 +4882,7 @@ int utcDaliTextFieldGeometryRTL(void) Vector expectedPositions; expectedPositions.PushBack(Vector2(38, 0)); - expectedSizes.PushBack(Vector2(73, 25)); + expectedSizes.PushBack(Vector2(75, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); @@ -4809,13 +4927,51 @@ int utcDaliTextFieldGeometryGlyphMiddle(void) Vector expectedPositions; expectedPositions.PushBack(Vector2(6, 0)); - expectedSizes.PushBack(Vector2(124, 25)); + expectedSizes.PushBack(Vector2(125, 25)); TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes); END_TEST; } + +int utcDaliTextFieldGeometryNullPtr(void) +{ + ToolkitTestApplication application; + tet_infoline("utcDaliTextFieldGeometryNullPtr"); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + field.SetProperty(TextField::Property::POINT_SIZE, 7.f); + field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + field.SetProperty(TextField::Property::ENABLE_MARKUP, true); + field.SetProperty(TextField::Property::TEXT, ""); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + unsigned int expectedCount = 0; + unsigned int startIndex = 0; + unsigned int endIndex = 0; + + Vector positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex); + Vector sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION); + + END_TEST; +} + int utcDaliTextFieldSelectionClearedSignal(void) { ToolkitTestApplication application; @@ -5558,4 +5714,110 @@ int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void) application.Render(); END_TEST; +} + +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; +} + +int utcDaliTextFieldGetTextBoundingRectangle(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle"); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + field.SetProperty(TextField::Property::POINT_SIZE, 7.f); + field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC"); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + // Render and notify + application.SendNotification(); + application.Render(); + + unsigned int startIndex = 0; + unsigned int endIndex = 15; + + Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex); + Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25}; + + TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle); + + END_TEST; } \ No newline at end of file