X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=202ca9960cfc99f88f6e3e36f9f6653d95d9f510;hb=1a97610fdd1db086680bf33ef0b7b138cd2a9f96;hp=94855caa4032bc180db3f70f9cc86c3dadef43b2;hpb=f5c4eea32ac6eff21edbc662f5e879c9614da165;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 94855ca..202ca99 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -170,8 +170,8 @@ static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField) textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap); textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap); textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap); - textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap); - textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap); + textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png"); + textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png"); } /* @@ -1788,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) { @@ -2931,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 @@ -4738,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); @@ -4785,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); @@ -4830,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); @@ -4875,7 +4927,7 @@ 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); @@ -5735,3 +5787,104 @@ int utcDaliTextFieldPanGesturePropagation(void) 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; +} + + +int utcDaliTextFieldDecoratorColor(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldDecoratorColor"); + TextField textField = TextField::New(); + DALI_TEST_CHECK(textField); + LoadMarkerImages(application, textField); + application.GetScene().Add(textField); + + // Render and notify + application.SendNotification(); + application.Render(); + + textField.SetProperty(TextField::Property::TEXT, "العالم Hello"); + textField.SetProperty(TextField::Property::POINT_SIZE, 10.f); + textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f)); + textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + application.SendNotification(); + application.Render(); + + textField.SetKeyInputFocus(); + + application.SendNotification(); + application.Render(); + + // Create a tap event to touch the text field. + TestGenerateTap(application, 1.0f, 25.0f, 100); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Double tap to select a word. + TestGenerateTap(application, 1.0f, 25.0f, 200); + + application.SendNotification(); + application.Render(); + + // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created. + // Check some properties for coverage. + textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION); + + textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION); + + textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN); + DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION); + + textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION); + + textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; +} \ No newline at end of file