/*
- * 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 <unistd.h>
#include <iostream>
-#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>
-
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-field-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/devel-api/actors/actor-devel.h>
#include <dali/devel-api/adaptor-framework/key-devel.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>
#include "test-text-geometry-utils.h"
#include "toolkit-clipboard.h"
const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
+const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
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.
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");
}
/*
return true;
}
+// Stores data that is populated in the callback and will be read by the test cases
+struct SignalData
+{
+ SignalData()
+ : functorCalled(false),
+ voidFunctorCalled(false),
+ receivedGesture()
+ {
+ }
+
+ void Reset()
+ {
+ functorCalled = false;
+ voidFunctorCalled = false;
+
+ receivedGesture.Reset();
+
+ pannedActor.Reset();
+ }
+
+ bool functorCalled;
+ bool voidFunctorCalled;
+ PanGesture receivedGesture;
+ Actor pannedActor;
+};
+
+// Functor that sets the data when called
+struct GestureReceivedFunctor
+{
+ GestureReceivedFunctor(SignalData& data)
+ : signalData(data)
+ {
+ }
+
+ void operator()(Actor actor, const PanGesture& pan)
+ {
+ signalData.functorCalled = true;
+ signalData.receivedGesture = pan;
+ signalData.pannedActor = actor;
+ }
+
+ void operator()()
+ {
+ signalData.voidFunctorCalled = true;
+ }
+
+ SignalData& signalData;
+};
+
} // namespace
int UtcDaliToolkitTextFieldConstructorP(void)
TextField copy(textField);
DALI_TEST_CHECK(copy);
- DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
+ DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
END_TEST;
}
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
+ DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
+ DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextField::Property::REMOVE_FRONT_INSET);
+ DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextField::Property::REMOVE_BACK_INSET);
END_TEST;
}
DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
+ // Check the selection popup style
+ const Vector2 popupMaxSize(200.0f, 300.0f);
+ const Vector2 optionDividerSize(30.0f, 5.0f);
+ const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
+ const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
+
+ Property::Map selectionPopupStyle;
+ selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
+ selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
+ selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
+ selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
+
+ field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
+
+ Property::Map selectionPopupStyleGet;
+ selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
+
+ Property::Value* popupValue;
+ popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
+ DALI_TEST_CHECK(NULL != popupValue);
+ if(popupValue)
+ {
+ Vector2 popupMaxSizeGet;
+ popupValue->Get(popupMaxSizeGet);
+ DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
+ }
+
+ popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
+ DALI_TEST_CHECK(NULL != popupValue);
+ if(popupValue)
+ {
+ Vector2 optionDividerSizeGet;
+ popupValue->Get(optionDividerSizeGet);
+ DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
+ }
+
+ popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
+ DALI_TEST_CHECK(NULL != popupValue);
+ if(popupValue)
+ {
+ Vector4 optionDividerPaddingGet;
+ popupValue->Get(optionDividerPaddingGet);
+ DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
+ }
+
+ popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
+ DALI_TEST_CHECK(NULL != popupValue);
+ if(popupValue)
+ {
+ Vector4 labelPaddingGet;
+ popupValue->Get(labelPaddingGet);
+ DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
+ }
+
+ // Reset selection popup style
+ selectionPopupStyle.Clear();
+ field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
+
// Check the highlight color
field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
outlineMapSet["color"] = Color::RED;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
+ outlineMapSet["blurRadius"] = 0.0f;
field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
application.SendNotification();
application.Render();
+ // Check Remove Front/Back Inset Property
+ DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
+ field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, true);
+ DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
+
+ DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
+ field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, true);
+ DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
+
+ application.SendNotification();
+ application.Render();
+
+
END_TEST;
}
END_TEST;
}
+int utcDaliTextFieldSelectionWithInputMethodContext(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ field.SetProperty(TextField::Property::TEXT, "Hello world");
+
+ application.GetScene().Add(field);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
+ bool selectionChangedSignal = false;
+ field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
+
+ // get InputMethodContext
+ std::string text;
+ InputMethodContext::EventData imfEvent;
+ InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
+
+ field.SetKeyInputFocus();
+ field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
+
+ // input text
+ gSelectionChangedCallbackCalled = false;
+ imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
+ inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+
+ DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldPositionWithInputMethodContext(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ field.SetProperty(TextField::Property::TEXT, "Hello world");
+
+ application.GetScene().Add(field);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
+ bool cursorPositionChangedSignal = false;
+ field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
+
+ // get InputMethodContext
+ std::string text;
+ InputMethodContext::EventData imfEvent;
+ InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
+
+ field.SetKeyInputFocus();
+ field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
+
+ // input text
+ gCursorPositionChangedCallbackCalled = false;
+ imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
+ inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+
+ DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
+
+ 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<std::string>(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<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldFocusWithInputMethodContext(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldFocusWithInputMethodContext");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+ field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
+ application.SendNotification();
+ application.Render();
+
+ // get InputMethodContext
+ InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
+ DALI_TEST_CHECK(inputMethodContext);
+
+ // connect StatusChangedSignal
+ field.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
+ field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ KeyboardFocusManager::Get().SetCurrentFocusActor(field);
+
+ inputMethodContext.StatusChangedSignal().Emit(true);
+ application.SendNotification();
+ application.Render();
+
+ // keyboard hidden, focus should remain
+ inputMethodContext.StatusChangedSignal().Emit(false);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field, KeyboardFocusManager::Get().GetCurrentFocusActor(), TEST_LOCATION);
+
+ END_TEST;
+}
+
// Negative test for the textChanged signal.
int utcDaliTextFieldTextChangedN(void)
{
END_TEST;
}
-int utcDaliTextFieldEvent01(void)
+int utcDaliTextFieldInputStyleChanged03(void)
{
+ // Test InputStyleCahnged signal emitted even if AddIdle failed.
ToolkitTestApplication application;
- tet_infoline(" utcDaliTextFieldEvent01");
+ tet_infoline(" utcDaliTextFieldInputStyleChanged03");
- // Creates a tap event. After creating a tap event the text field should
- // have the focus and add text with key events should be possible.
+ // 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);
TextField field = TextField::New();
DALI_TEST_CHECK(field);
- application.GetScene().Add(field);
-
field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- // Render and notify
- application.SendNotification();
- application.Render();
-
- // Avoid a crash when core load gl resources.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
- // Render and notify
- application.SendNotification();
- application.Render();
+ // connect to the text changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
+ bool inputStyleChangedSignal = false;
+ field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
- // Add a key event but as the text field has not the focus it should do nothing.
- application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.GetScene().Add(field);
// Render and notify
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
- // Create a tap event to touch the text field.
- TestGenerateTap(application, 150.0f, 25.0f);
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
- // Render and notify
- application.SendNotification();
- application.Render();
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 18.0f, 25.0f);
- // Pressing delete key should be fine even if there is no text in TextField.
- application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
// Render and notify
application.SendNotification();
application.Render();
- // Now the text field has the focus, so it can handle the key events.
- application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
- application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
- // Render and notify
- application.SendNotification();
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
+
+ const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
+ DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
+
+ const float pointSize = field.GetProperty(TextField::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 = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ 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 = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ 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>(TextField::InputStyle::COLOR), TEST_LOCATION);
+
+ const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
+ DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Make AddIdle return false.
+ ToolkitApplication::ADD_IDLE_SUCCESS = false;
+
+ // Create a tap event to touch the text field.
+ 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 = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ 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 = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Revert AddIdle return true.
+ ToolkitApplication::ADD_IDLE_SUCCESS = true;
+
+ // Create a tap event to touch the text field.
+ 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>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
+
+ const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
+ DALI_TEST_CHECK(style.empty());
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ 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 utcDaliTextFieldEvent01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent01");
+
+ // Creates a tap event. After creating a tap event the text field should
+ // have the focus and add text with key events should be possible.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Add a key event but as the text field has not the focus it should do nothing.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Pressing delete key should be fine even if there is no text in TextField.
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Now the text field has the focus, so it can handle the key events.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
application.Render();
DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
application.SendNotification();
application.Render();
- Actor layer = field.GetChildAt(1u);
+ Actor layer = field.GetChildAt(2u);
DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
// Checks the cursor and the renderer have been created.
DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
- DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION); // The renderer
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
Control cursor = Control::DownCast(layer.GetChildAt(0u));
DALI_TEST_CHECK(cursor);
DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
- // Should not be a renderer.
- DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
+ // Should not be a renderer, there is only a clipped cursor.
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
// Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
application.Render();
// Tap first to get the focus.
- TestGenerateTap(application, 3.0f, 25.0f);
+ TestGenerateTap(application, 3.0f, 25.0f, 100);
// Render and notify
application.SendNotification();
application.Render();
// Double tap to select a word.
- TestGenerateTap(application, 3.0f, 25.0f);
+ TestGenerateTap(application, 3.0f, 25.0f, 200);
// Render and notify
application.SendNotification();
// Tap grab handle
TestGenerateTap(application, 0.0f, 40.0f);
+
+ field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
+ DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
END_TEST;
}
ToolkitTestApplication application;
tet_infoline(" utcDaliTextFieldEvent08");
- Dali::Clipboard clipboard = Clipboard::Get();
- clipboard.SetItem("testTextFieldEvent");
+ Dali::Clipboard clipboard = Clipboard::Get();
+ Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
+ clipboard.SetData(data);
// Checks Longpress when only place holder text
event.AddPoint(GetPointUpInside(position));
application.ProcessEvent(event);
}
- DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
+
+ Dali::Clipboard::ClipData htmlData("application/xhtml+xml", "testTextFieldEventHtml");
+ clipboard.SetData(htmlData);
+
+ field.SetProperty(TextField::Property::TEXT, "");
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f, 20);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Wait(application, 500);
+
+ TestEndLongPress(application, 1.0f, 25.0f, 520);
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f, 600);
+
+ // Render and notify
+ application.Render();
+
+ Wait(application, 500);
+
+ stage = application.GetScene();
+ layer = stage.GetRootLayer();
+ actor = layer.FindChildByName("optionPaste");
+
+ if(actor)
+ {
+ Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
+ Vector2 halfStageSize = stage.GetSize() / 2.0f;
+ Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
+
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint(GetPointDownInside(position));
+ application.ProcessEvent(event);
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint(GetPointUpInside(position));
+ application.ProcessEvent(event);
+ }
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEventHtml"), TEST_LOCATION);
END_TEST;
}
application.Render();
field.SetProperty(TextField::Property::TEXT, "Hello");
+ field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
application.SendNotification();
application.Render();
+ for(unsigned int index = 0u; index < 6u; ++index)
+ {
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+ }
map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
application.SendNotification();
application.Render();
+ // Generate a Back key event. Nothing happens to the text field.
+ application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
// The text shouldn't be deleted.
DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
application.SendNotification();
application.Render();
+ textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
+ DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
+
textField.SetKeyInputFocus();
textField.SetProperty(DevelTextField::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));
DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliToolkitTextFieldFontSizeScale(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
+ // Check the user interaction enabled and for coverage
+ DevelTextField::SelectWholeText(textField);
- TextField textField = TextField::New();
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ textField.SetKeyInputFocus();
+ textField.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(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
+ DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextFieldFontSizeScale(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
+
+ TextField textField = TextField::New();
textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
textField.SetProperty(TextField::Property::TEXT, "Test");
Vector3 nonScaledSize = textField.GetNaturalSize();
field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
+ field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, true);
+ field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, true);
field.SetProperty(TextField::Property::TEXT, "Hello World");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(14, 0));
- expectedSizes.PushBack(Vector2(106, 25));
+ expectedSizes.PushBack(Vector2(107, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
+ field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, true);
+ field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, true);
field.SetProperty(TextField::Property::TEXT, "Hello World");
// Avoid a crash when core load gl resources.
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(-2, 0));
- expectedSizes.PushBack(Vector2(122, 25));
+ expectedSizes.PushBack(Vector2(123, 25));
TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
Vector<Vector2> expectedPositions;
expectedPositions.PushBack(Vector2(38, 0));
- expectedSizes.PushBack(Vector2(73, 25));
+ expectedSizes.PushBack(Vector2(75, 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);
END_TEST;
}
+int utcDaliTextFieldGeometryNullPtr(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("utcDaliTextFieldGeometryNullPtr");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
+ field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(TextField::Property::TEXT, "");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ unsigned int expectedCount = 0;
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 0;
+
+ Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
+ Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+ DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+ END_TEST;
+}
+
int utcDaliTextFieldSelectionClearedSignal(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
application.GetScene().Add(field3);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldCharacterSpacing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
+
+ TextField textField = TextField::New();
+
+ textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
+
+ application.GetScene().Add(textField);
+ application.SendNotification();
+ application.Render();
+
+ textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
+ textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
+ DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
application.SendNotification();
application.Render();
application.Render();
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliToolkitTextfieldParagraphTag(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
+ TextField fieldNewlineSeparator = TextField::New();
+ TextField fieldParagraphTag = TextField::New();
+ DALI_TEST_CHECK(fieldNewlineSeparator);
+ DALI_TEST_CHECK(fieldParagraphTag);
+
+ application.GetScene().Add(fieldNewlineSeparator);
+ application.GetScene().Add(fieldParagraphTag);
+
+ //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
+ fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
+
+ fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
+ Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
+
+ DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+//Handle Emoji clustering for cursor handling
+int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
+ TextField textField = TextField::New();
+ DALI_TEST_CHECK(textField);
+
+ application.GetScene().Add(textField);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
+ textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set currsor
+ textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
+ application.SendNotification();
+ application.Render();
+
+ // Set focus and remove Emoji
+ textField.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(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
+ DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
+ TextField textField = TextField::New();
+ DALI_TEST_CHECK(textField);
+
+ application.GetScene().Add(textField);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
+ textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set currsor
+ textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+ application.SendNotification();
+ application.Render();
+
+ // Set focus and remove Emoji
+ textField.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(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
+ DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldPanGesturePropagation(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldPanGesturePropagation");
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+
+ field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ actor.Add(field);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ PanGestureDetector detector = PanGestureDetector::New();
+ detector.Attach(actor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 3.0f, 25.0f, 100);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Pan the text field
+ uint32_t time = 100;
+ TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
+ TestMovePan(application, Vector2(10.0f, 50.0f), time);
+ TestEndPan(application, Vector2(40.0f, 50.0f), time);
+ application.SendNotification();
+ application.Render();
+
+ // The text scrolls because there is text that is scrolling.
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ // Set the size large enough to prevent scrolling.
+ field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ time = 200;
+ TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
+ TestMovePan(application, Vector2(10.0f, 50.0f), time);
+ TestEndPan(application, Vector2(40.0f, 50.0f), time);
+
+ // Because scrolling is not possible, the pan gesture is propagated.
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldGetTextBoundingRectangle(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ unsigned int startIndex = 0;
+ unsigned int endIndex = 15;
+
+ Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
+ Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
+
+ TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
+
+ END_TEST;
+}
+
+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<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
+
+ textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
+ DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
+
+ textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
+ DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
+
+ textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
+ DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
+
+ textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
+ DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldRemoveFrontInset(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldRemoveFrontInset");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!DevelTextField::IsRemoveFrontInset(field)); // default value is false.
+ DevelTextField::SetRemoveFrontInset(field, true);
+ DALI_TEST_CHECK(DevelTextField::IsRemoveFrontInset(field));
+
+ END_TEST;
+}
+
+int utcDaliTextFieldRemoveBackInset(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldRemoveBackInset");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!DevelTextField::IsRemoveBackInset(field)); // default value is false.
+ DevelTextField::SetRemoveBackInset(field, true);
+ DALI_TEST_CHECK(DevelTextField::IsRemoveBackInset(field));
+
+ END_TEST;
+}