/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
#include <dali-toolkit/devel-api/text/rendering-backend.h>
#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
-#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
#include <dali/devel-api/actors/actor-devel.h>
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
+#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/devel-api/adaptor-framework/key-devel.h>
-#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/devel-api/events/pan-gesture-devel.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/public-api/rendering/renderer.h>
const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
+const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
+const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
+
const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
bool& mFinishedCalled;
};
-
// Stores data that is populated in the callback and will be read by the test cases
struct SignalData
{
SignalData& signalData;
};
-
} // namespace
int UtcDaliToolkitTextEditorConstructorP(void)
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
+ DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextEditor::Property::REMOVE_FRONT_INSET);
+ DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextEditor::Property::REMOVE_BACK_INSET);
END_TEST;
}
outlineMapSet["color"] = Color::RED;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
+ outlineMapSet["blurRadius"] = 0.0f;
editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+ // Check Remove Front/Back Inset Property
+ DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
+
+ DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
+ DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
END_TEST;
}
+int utcDaliTextEditorFocusWithInputMethodContext(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorFocusWithInputMethodContext");
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+ editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
+ application.SendNotification();
+ application.Render();
+
+ // get InputMethodContext
+ InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
+ DALI_TEST_CHECK(inputMethodContext);
+
+ // connect StatusChangedSignal
+ editor.SetKeyInputFocus();
+
+ // keyboard shown
+ inputMethodContext.StatusChangedSignal().Emit(true);
+ application.SendNotification();
+ application.Render();
+
+ // keyboard hidden
+ inputMethodContext.StatusChangedSignal().Emit(false);
+ application.SendNotification();
+ application.Render();
+
+ // set focus and keyboard shown
+ editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
+
+ inputMethodContext.StatusChangedSignal().Emit(true);
+ application.SendNotification();
+ application.Render();
+
+ // keyboard hidden, focus should remain
+ inputMethodContext.StatusChangedSignal().Emit(false);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(editor, KeyboardFocusManager::Get().GetCurrentFocusActor(), TEST_LOCATION);
+
+ END_TEST;
+}
+
int utcDaliTextEditorInputStyleChanged01(void)
{
// The text-editor emits signals when the input style changes. These changes of style are
END_TEST;
}
+int utcDaliTextEditorInputStyleChanged03(void)
+{
+ // Test InputStyleCahnged signal emitted even if AddIdle failed.
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorInputStyleChanged03");
+
+ // Load some fonts.
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName(pathNamePtr);
+ free(pathNamePtr);
+
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi(93u, 93u);
+
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ editor.SetProperty(Actor::Property::SIZE, Vector2(300.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, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
+
+ // connect to the text changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
+ bool inputStyleChangedSignal = false;
+ editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
+
+ application.GetScene().Add(editor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 18.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
+
+ const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
+ DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
+
+ const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
+ DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 30.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 43.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
+
+ const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
+ DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Make AddIdle return false.
+ ToolkitApplication::ADD_IDLE_SUCCESS = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 88.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Execute the idle callbacks.
+ // And check whether we didn't change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 115.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Execute the idle callbacks.
+ // And check whether we didn't change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Revert AddIdle return true.
+ ToolkitApplication::ADD_IDLE_SUCCESS = true;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 164.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
+
+ Property::Map fontStyleMapSet;
+ Property::Map fontStyleMapGet;
+
+ fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
+ DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextEditor::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text editor.
+ TestGenerateTap(application, 191.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ END_TEST;
+}
+
int utcDaliTextEditorEvent01(void)
{
ToolkitTestApplication application;
application.Render();
// Send some taps and check text controller with clipboard window
- Dali::TextClipboard clipboard = TextClipboard::Get();
+ Dali::Clipboard clipboard = Clipboard::Get();
clipboard.ShowClipboard();
TestGenerateTap(application, 3.0f, 25.0f, 100);
clipboard.HideClipboard();
TextEditor textEditor = TextEditor::New();
textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
+ textEditor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ textEditor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
application.GetScene().Add(textEditor);
application.SendNotification();
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(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedSizes;
Vector<Vector2> expectedPositions;
- expectedPositions.PushBack(Vector2(37, 0));
- expectedSizes.PushBack(Vector2(20, 25));
+ expectedPositions.PushBack(Vector2(38, 0));
+ expectedSizes.PushBack(Vector2(21, 25));
expectedPositions.PushBack(Vector2(-1, 25));
- expectedSizes.PushBack(Vector2(52, 25));
+ expectedSizes.PushBack(Vector2(53, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
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(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(-1, 0));
- expectedSizes.PushBack(Vector2(25, 25));
+ expectedSizes.PushBack(Vector2(26, 25));
expectedPositions.PushBack(Vector2(-1, 25));
- expectedSizes.PushBack(Vector2(52, 25));
+ expectedSizes.PushBack(Vector2(53, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
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(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(-1, 0));
- expectedSizes.PushBack(Vector2(59, 25));
+ expectedSizes.PushBack(Vector2(60, 25));
expectedPositions.PushBack(Vector2(-1, 25));
- expectedSizes.PushBack(Vector2(38, 25));
+ expectedSizes.PushBack(Vector2(39, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
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::REMOVE_FRONT_INSET, true);
+ editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedSizes;
Vector<Vector2> expectedPositions;
- expectedPositions.PushBack(Vector2(24, 0));
- expectedSizes.PushBack(Vector2(33, 25));
+ expectedPositions.PushBack(Vector2(25, 0));
+ expectedSizes.PushBack(Vector2(34, 25));
expectedPositions.PushBack(Vector2(-1, 25));
- expectedSizes.PushBack(Vector2(52, 25));
+ expectedSizes.PushBack(Vector2(53, 25));
expectedPositions.PushBack(Vector2(-1, 50));
- expectedSizes.PushBack(Vector2(59, 25));
+ expectedSizes.PushBack(Vector2(60, 25));
- expectedPositions.PushBack(Vector2(61, 75));
+ expectedPositions.PushBack(Vector2(63, 75));
expectedSizes.PushBack(Vector2(37, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(6, 0));
- expectedSizes.PushBack(Vector2(124, 25));
+ expectedSizes.PushBack(Vector2(125, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
+ label.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
+ label.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
label.SetProperty(TextEditor::Property::TEXT, "H");
// Avoid a crash when core load gl resources.
END_TEST;
}
-
int utcDaliTextEditorSelectionClearedSignal(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
data.Reset();
-
END_TEST;
}
application.SendNotification();
application.Render();
- unsigned int startIndex = 0;
- unsigned int endIndex = 15;
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 15;
- Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
+ Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
END_TEST;
-}
\ No newline at end of file
+}
+
+int utcDaliTextEditorRemoveFrontInset(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorRemoveFrontInset");
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!DevelTextEditor::IsRemoveFrontInset(editor)); // default value is false.
+ DevelTextEditor::SetRemoveFrontInset(editor, true);
+ DALI_TEST_CHECK(DevelTextEditor::IsRemoveFrontInset(editor));
+
+ END_TEST;
+}
+int utcDaliTextEditorRemoveBackInset(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorRemoveBackInset");
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!DevelTextEditor::IsRemoveBackInset(editor)); // default value is false.
+ DevelTextEditor::SetRemoveBackInset(editor, true);
+ DALI_TEST_CHECK(DevelTextEditor::IsRemoveBackInset(editor));
+
+ END_TEST;
+}