+}
+
+int UtcDaliTextEditorPasteText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorPasteText ");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ std::string cutText = "";
+ std::string copiedText = "";
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.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();
+
+ // Select some text in the right of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Cut the selected text
+ cutText = DevelTextEditor::CutText(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
+ DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
+
+ // Select some text in the left of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Copy the selected text
+ copiedText = DevelTextEditor::CopyText(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
+ DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
+
+ // Move the cursor to the third line
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ 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();
+
+ // Paste the selected text at the current cursor position
+ DevelTextEditor::PasteText(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextEditorLineSpacing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorLineSpacing ");
+
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
+ application.GetScene().Add(textEditor);
+ application.SendNotification();
+ application.Render();
+
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
+ textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
+
+ Vector3 sizeBefore = textEditor.GetNaturalSize();
+
+ textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
+
+ //add 20 for each line 20 * 3
+ DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextEditorMinLineSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorMinLineSize ");
+
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
+ application.GetScene().Add(textEditor);
+ application.SendNotification();
+ application.Render();
+
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
+ textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
+
+ Vector3 sizeBefore = textEditor.GetNaturalSize();
+
+ textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
+
+ DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
+
+ //60 * 3 lines
+ DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorCursorPositionChangedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
+ bool cursorPositionChangedSignal = false;
+ editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ editor.SetKeyInputFocus();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ // Move to left.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ // Insert C
+ application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ //delete one character
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello");
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGeometryEllipsisStart(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.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(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
+ editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int expectedCount = 2;
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 24;
+
+ Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ Vector<Vector2> expectedSizes;
+ Vector<Vector2> expectedPositions;
+
+ expectedPositions.PushBack(Vector2(37, 0));
+ expectedSizes.PushBack(Vector2(20, 25));
+
+ expectedPositions.PushBack(Vector2(-1, 25));
+ expectedSizes.PushBack(Vector2(52, 25));
+
+ TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGeometryEllipsisMiddle(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.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(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
+ editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int expectedCount = 2;
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 24;
+
+ Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ Vector<Vector2> expectedSizes;
+ Vector<Vector2> expectedPositions;
+
+ expectedPositions.PushBack(Vector2(-1, 0));
+ expectedSizes.PushBack(Vector2(25, 25));
+
+ expectedPositions.PushBack(Vector2(-1, 25));
+ expectedSizes.PushBack(Vector2(52, 25));
+
+ TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGeometryEllipsisEnd(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.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(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
+ editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
+ editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int expectedCount = 2;
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 24;
+
+ Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ Vector<Vector2> expectedSizes;
+ Vector<Vector2> expectedPositions;
+
+ expectedPositions.PushBack(Vector2(-1, 0));
+ expectedSizes.PushBack(Vector2(59, 25));
+
+ expectedPositions.PushBack(Vector2(-1, 25));
+ expectedSizes.PushBack(Vector2(25, 25));
+
+ TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGeometryRTL(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorGeometryRTL");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.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::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int expectedCount = 4;
+ unsigned int startIndex = 3;
+ unsigned int endIndex = 24;
+
+ Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ Vector<Vector2> expectedSizes;
+ Vector<Vector2> expectedPositions;
+
+ expectedPositions.PushBack(Vector2(24, 0));
+ expectedSizes.PushBack(Vector2(33, 25));
+
+ expectedPositions.PushBack(Vector2(-1, 25));
+ expectedSizes.PushBack(Vector2(52, 25));
+
+ expectedPositions.PushBack(Vector2(-1, 50));
+ expectedSizes.PushBack(Vector2(59, 25));
+
+ expectedPositions.PushBack(Vector2(61, 75));
+ expectedSizes.PushBack(Vector2(37, 25));
+
+ TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGeometryGlyphMiddle(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(150.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::TEXT, "لا تحتوي على لا");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int expectedCount = 1;
+ unsigned int startIndex = 1;
+ unsigned int endIndex = 13;
+
+ Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ Vector<Vector2> expectedSizes;
+ Vector<Vector2> expectedPositions;
+
+ expectedPositions.PushBack(Vector2(6, 0));
+ expectedSizes.PushBack(Vector2(124, 25));
+
+ TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorSelectionClearedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
+ bool selectionClearedSignal = false;
+ editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move to second line of the text & Select some text in the right of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // remove selection
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ gSelectionClearedCallbackCalled = false;
+
+ // Move to second line of the text & select.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ //remove selection
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
+
+ gSelectionClearedCallbackCalled = false;
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move to second line of the text & select.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // replace C with selected text
+ application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
+
+ gSelectionClearedCallbackCalled = false;
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DevelTextEditor::SelectText(editor, 1, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
+
+ gSelectionClearedCallbackCalled = false;
+
+ DevelTextEditor::SelectText(editor, 1, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // select none
+ DevelTextEditor::SelectNone(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorSelectionStartedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
+ bool selectionStartedSignal = false;
+ editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move to second line of the text & Select some text in the right of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
+
+ // remove selection
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ gSelectionStartedCallbackCalled = false;
+
+ DevelTextEditor::SelectText(editor, 1, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorSelectionWithSecondaryCursor(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
+
+ // Checks if the actor is created.
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
+ editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
+ editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
+ DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
+
+ application.SendNotification();
+ application.Render();
+
+ std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
+ DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextEditorSelectionChangedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
+ bool selectionChangedSignal = false;
+ editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
+
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
+ editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
+ editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ TestGenerateTap(application, 3.0f, 25.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();
+
+ // Select some text in the right of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+ editor.SetKeyInputFocus();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DevelTextEditor::SelectText(editor, 0, 5);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ // select all text
+ DevelTextEditor::SelectWholeText(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ // select none
+ DevelTextEditor::SelectNone(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
+
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ application.GetScene().Add(textEditor);
+ application.SendNotification();
+ application.Render();
+
+ Property::Map strikethroughMapSet;
+ Property::Map strikethroughMapGet;
+
+ strikethroughMapSet.Insert("enable", true);
+ strikethroughMapSet.Insert("color", Color::RED);
+ strikethroughMapSet.Insert("height", 2.0f);
+
+ // Check the strikethrough property
+ textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
+ strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
+ DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ strikethroughMapSet.Clear();
+ strikethroughMapGet.Clear();
+
+ END_TEST;
+}
+
+int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
+{
+ //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+ //DaliException on vector: "Iterator not inside vector"
+
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ //Set multilines text
+ editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ //Set ResizePolicy to NaturalSize
+ editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 5.0f, 5.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set currsor and add character (in first line)
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Check the changed text and cursor position
+ DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
+ DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
+{
+ //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+ //DaliException on vector: "Iterator not inside vector"
+
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ //Set multilines text
+ editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ //Set ResizePolicy to NaturalSize
+ editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+ // Set currsor
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ // Set focus and remove character
+ editor.SetKeyInputFocus();
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Check the changed text and cursor position
+ DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
+ DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
+{
+ //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+ //DaliException on vector: "Iterator not inside vector"
+
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ //Set multilines text
+ editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ //Set ResizePolicy to NaturalSize
+ editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+ //Select text at initialization (before the first render)
+ DevelTextEditor::SelectText(editor, 3, 5);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Cut text
+ application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Check the changed text and cursor position
+ DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
+ DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
+{
+ //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+ //DaliException on vector: "Iterator not inside vector"
+
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ //Set multilines text
+ editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+ editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ //Set ResizePolicy to NaturalSize
+ editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+ // Set currsor
+ editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ // Set focus and double enter (new line)
+ editor.SetKeyInputFocus();
+ application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ //Check the changed text and cursor position
+ DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
+ DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ application.GetScene().Add(textEditor);
+ application.SendNotification();
+ application.Render();
+
+ Property::Map underlineMapSet;
+ Property::Map underlineMapGet;
+
+ underlineMapSet.Insert("enable", true);
+ underlineMapSet.Insert("color", Color::RED);
+ underlineMapSet.Insert("height", 1);
+ underlineMapSet.Insert("type", Text::Underline::SOLID);
+ underlineMapSet.Insert("dashWidth", 2);
+ underlineMapSet.Insert("dashGap", 1);
+
+ // Check the underline property
+ textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
+
+ underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ underlineMapSet.Clear();
+ underlineMapGet.Clear();
+
+ underlineMapSet.Insert("enable", true);
+ underlineMapSet.Insert("color", Color::BLUE);
+ underlineMapSet.Insert("height", 1);
+ underlineMapSet.Insert("type", Text::Underline::DASHED);
+ underlineMapSet.Insert("dashWidth", 4);
+ underlineMapSet.Insert("dashGap", 2);
+
+ // Check the dashed underline property
+ textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
+
+ underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ underlineMapSet.Clear();
+ underlineMapGet.Clear();
+
+ underlineMapSet.Insert("enable", true);
+ underlineMapSet.Insert("color", Color::BLUE);
+ underlineMapSet.Insert("height", 1);
+ underlineMapSet.Insert("type", Text::Underline::DOUBLE);
+ underlineMapSet.Insert("dashWidth", 4);
+ underlineMapSet.Insert("dashGap", 2);
+
+ // Check the dashed underline property
+ textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
+
+ underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ underlineMapSet.Clear();
+ underlineMapGet.Clear();
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
+
+ TextEditor textEditor1 = TextEditor::New();
+ textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
+ textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ Property::Map underlineMapSet1;
+ Property::Map underlineMapGet1;
+
+ underlineMapSet1.Insert("enable", true);
+ underlineMapSet1.Insert("color", Color::RED);
+ underlineMapSet1.Insert("height", 1);
+ underlineMapSet1.Insert("type", Text::Underline::SOLID);
+ underlineMapSet1.Insert("dashWidth", 2);
+ underlineMapSet1.Insert("dashGap", 1);
+
+ // Check the underline property
+ textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
+
+ underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
+
+ application.GetScene().Add(textEditor1);
+ application.SendNotification();
+ application.Render();
+
+ TextEditor textEditor2 = TextEditor::New();
+ textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
+ textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ Property::Map underlineMapSet2;
+ Property::Map underlineMapGet2;
+
+ underlineMapSet2.Insert("enable", true);
+ underlineMapSet2.Insert("color", Color::BLUE);
+ underlineMapSet2.Insert("height", 1);
+ underlineMapSet2.Insert("type", Text::Underline::DASHED);
+ underlineMapSet2.Insert("dashWidth", 4);
+ underlineMapSet2.Insert("dashGap", 2);
+
+ // Check the dashed underline property
+ textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
+
+ underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
+
+ application.GetScene().Add(textEditor2);
+ application.SendNotification();
+ application.Render();
+
+ TextEditor textEditor3 = TextEditor::New();
+ textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
+ textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ Property::Map underlineMapSet3;
+ Property::Map underlineMapGet3;
+
+ underlineMapSet3.Insert("enable", true);
+ underlineMapSet3.Insert("color", Color::BLUE);
+ underlineMapSet3.Insert("height", 1);
+ underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
+ underlineMapSet3.Insert("dashWidth", 4);
+ underlineMapSet3.Insert("dashGap", 2);
+
+ // Check the dashed underline property
+ textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
+
+ underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
+
+ application.GetScene().Add(textEditor3);
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
+
+ TextEditor textEditor1 = TextEditor::New();
+ textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
+ textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
+ textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
+ textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+
+ Property::Map underlineMapSet1;
+ Property::Map underlineMapGet1;
+
+ underlineMapSet1.Insert("enable", true);
+ underlineMapSet1.Insert("color", Color::RED);
+ underlineMapSet1.Insert("height", 1);
+ underlineMapSet1.Insert("type", Text::Underline::SOLID);
+ underlineMapSet1.Insert("dashWidth", 2);
+ underlineMapSet1.Insert("dashGap", 1);
+
+ // Check the underline property
+ textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
+ //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
+
+ underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
+ DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
+
+ application.GetScene().Add(textEditor1);
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}