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-TextEditor.cpp;h=9db4289d04677e30cac9db8759abcab6dab805b8;hp=f8b2799d25ad8ce8717643aa7a010ab778ced7ba;hb=6a219d0bbcfd016e24b5466d5fb1a666c92feae5;hpb=a4a06c5a4c6c02861972d1ea9029c64d60bed192 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index f8b2799..9db4289 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -20,6 +20,8 @@ #include #include #include + +#include #include #include #include @@ -3630,6 +3632,9 @@ int UtcDaliTextEditorEnableEditing(void) application.SendNotification(); application.Render(); + textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true); + DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get(), true, TEST_LOCATION); + textEditor.SetKeyInputFocus(); textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false); application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); @@ -3652,6 +3657,24 @@ int UtcDaliTextEditorEnableEditing(void) DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get(), "D", TEST_LOCATION); DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get(), true, TEST_LOCATION); + // Check the user interaction enabled and for coverage + DevelTextEditor::SelectWholeText(textEditor); + + // Render and notify + application.SendNotification(); + application.Render(); + + textEditor.SetKeyInputFocus(); + textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false); + application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get(), "D", TEST_LOCATION); + DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get(), false, TEST_LOCATION); + END_TEST; } @@ -5765,6 +5788,55 @@ int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void) END_TEST; } +int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight"); + + TextEditor editor = TextEditor::New(); + editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 10); + editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5"); + editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f); + editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true); + + TextEditor editorSingleLineParagraph = TextEditor::New(); + editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10); + editorSingleLineParagraph.SetProperty(TextEditor::Property::TEXT, "

line 1

line 2

line 3

line 4

line 5"); + editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f); + editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true); + + TextEditor editorMultiLineParagraph = TextEditor::New(); + editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f)); + editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10); + editorMultiLineParagraph.SetProperty(TextEditor::Property::TEXT, "

line 1

line\n2

line 3

line\n4

line 5"); + editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f); + editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false); + editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(editor); + application.GetScene().Add(editorSingleLineParagraph); + application.GetScene().Add(editorMultiLineParagraph); + application.SendNotification(); + application.Render(); + + Vector3 naturalSize = editor.GetNaturalSize(); + Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize(); + Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize(); + + float lineSize = naturalSize.y / 5.0f; //total size/number of lines + + //no effect of relative line size for paragraph with single line + DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + DALI_TEST_EQUALS(lineSize*8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + int UtcDaliToolkitTextEditorRelativeLineHeight(void) { ToolkitTestApplication application; @@ -5788,7 +5860,7 @@ int UtcDaliToolkitTextEditorRelativeLineHeight(void) Vector3 relativeNaturalSize = editor.GetNaturalSize(); - DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y * 2, TEST_LOCATION); + DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION); editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f); @@ -5824,6 +5896,113 @@ int UtcDaliTextEditorCharacterSpacing(void) END_TEST; } +int UtcDaliTextEditorTextSizeNegativeLineSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing"); + + TextEditor editor = TextEditor::New(); + + float lineSpacing = -20.f; + + editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f)); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f); + editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing); + editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Vector positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123); + Vector sizeList = DevelTextEditor::GetTextSize(editor, 0, 123); + + Vector2 lastLinePos = positionsList[positionsList.Size() - 1]; + Vector2 lastLineSize = sizeList[sizeList.Size() - 1]; + + DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; +} + +int UtcDaliTextEditorLineSpacingKeyArrowDown(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + application.GetScene().Add(editor); + + std::string cutText = ""; + std::string copiedText = ""; + + editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4"); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f); + editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f)); + editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::LINE_SPACING, -15); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Tap on the text editor + TestGenerateTap(application, 1.0f, 1.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Move to second line of the text. + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get(), 3, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis"); + + TextEditor editor = TextEditor::New(); + + float lineSpacing = -20.f; + + editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f)); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f); + editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing); + editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); + editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true); + + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Vector sizeList = DevelTextEditor::GetTextSize(editor, 0, 123); + + int lineCount = sizeList.Size(); + DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; +} + int UtcDaliToolkitTexteditorParagraphTag(void) { ToolkitTestApplication application; @@ -5861,4 +6040,83 @@ int UtcDaliToolkitTexteditorParagraphTag(void) application.Render(); END_TEST; +} + +//Handle Emoji clustering for cursor handling +int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey "); + TextEditor textEditor = TextEditor::New(); + DALI_TEST_CHECK(textEditor); + + application.GetScene().Add(textEditor); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY"); + textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Set currsor + textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10); + application.SendNotification(); + application.Render(); + + // Set focus and remove Emoji + textEditor.SetKeyInputFocus(); + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + + //Check the changed text and cursor position + DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get(), "ABCXY", TEST_LOCATION); + DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get(), 3, TEST_LOCATION); + + // Render and notify + application.SendNotification(); + application.Render(); + + END_TEST; +} + +int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey "); + TextEditor textEditor = TextEditor::New(); + DALI_TEST_CHECK(textEditor); + + application.GetScene().Add(textEditor); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY"); + textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Set currsor + textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3); + application.SendNotification(); + application.Render(); + + // Set focus and remove Emoji + textEditor.SetKeyInputFocus(); + application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + + //Check the changed text and cursor position + DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get(), "ABCXY", TEST_LOCATION); + DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get(), 3, TEST_LOCATION); + + // Render and notify + application.SendNotification(); + application.Render(); + + END_TEST; } \ No newline at end of file