2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/public-api/rendering/renderer.h>
25 #include <dali/devel-api/actors/actor-devel.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
33 #include <dali/devel-api/adaptor-framework/key-devel.h>
34 #include <dali/devel-api/text-abstraction/font-client.h>
35 #include "test-text-geometry-utils.h"
36 #include "toolkit-clipboard.h"
39 using namespace Toolkit;
41 void dali_textfield_startup(void)
43 test_return_value = TET_UNDEF;
46 void dali_textfield_cleanup(void)
48 test_return_value = TET_PASS;
53 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT = "text";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
57 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
58 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
59 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
60 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
61 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
62 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
63 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
64 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
65 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
66 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
67 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
68 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
71 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
74 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
75 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
76 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
83 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
84 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
85 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
86 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
87 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
88 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
89 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
90 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
92 const char* const PROPERTY_NAME_UNDERLINE = "underline";
93 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
94 const char* const PROPERTY_NAME_SHADOW = "shadow";
95 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
96 const char* const PROPERTY_NAME_EMBOSS = "emboss";
97 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
98 const char* const PROPERTY_NAME_OUTLINE = "outline";
99 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
100 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
101 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
103 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
104 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
105 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
106 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
107 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
116 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
118 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
119 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
121 const float RENDER_FRAME_INTERVAL = 16.66f;
123 const unsigned int DEFAULT_FONT_SIZE = 1152u;
124 const std::string DEFAULT_FONT_DIR("/resources/fonts");
126 const int KEY_RETURN_CODE = 36;
127 const int KEY_A_CODE = 38;
128 const int KEY_D_CODE = 40;
129 const int KEY_SHIFT_MODIFIER = 257;
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
133 static bool gSelectionChangedCallbackCalled;
134 static uint32_t oldSelectionStart;
135 static uint32_t oldSelectionEnd;
136 static bool gSelectionClearedCallbackCalled;
137 static bool gSelectionStartedCallbackCalled;
138 static bool gAnchorClickedCallBackCalled;
139 static bool gAnchorClickedCallBackNotCalled;
140 static bool gTextChangedCallBackCalled;
141 static bool gMaxCharactersCallBackCalled;
142 static bool gInputFilteredAcceptedCallbackCalled;
143 static bool gInputFilteredRejectedCallbackCalled;
144 static bool gInputStyleChangedCallbackCalled;
145 static bool gCursorPositionChangedCallbackCalled;
146 static uint32_t oldCursorPos;
147 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
149 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
151 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
152 Integration::ResourcePointer resource(bitmap);
153 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
156 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
160 LoadBitmapResource(app.GetPlatform(), width, height);
162 Property::Map propertyMap;
163 propertyMap["filename"] = "image.png";
164 propertyMap["width"] = width;
165 propertyMap["height"] = height;
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
173 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
177 * Simulate time passed by.
179 * @note this will always process at least 1 frame (1/60 sec)
181 * @param application Test application instance
182 * @param duration Time to pass in milliseconds.
183 * @return The actual time passed in milliseconds
185 static int Wait(ToolkitTestApplication& application, int duration = 0)
189 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
191 application.SendNotification();
192 application.Render(RENDER_FRAME_INTERVAL);
193 time += RENDER_FRAME_INTERVAL;
199 Dali::Integration::Point GetPointDownInside(Vector2& pos)
201 Dali::Integration::Point point;
202 point.SetState(PointState::DOWN);
203 point.SetScreenPosition(pos);
207 Dali::Integration::Point GetPointUpInside(Vector2& pos)
209 Dali::Integration::Point point;
210 point.SetState(PointState::UP);
211 point.SetScreenPosition(pos);
215 struct CallbackFunctor
217 CallbackFunctor(bool* callbackFlag)
218 : mCallbackFlag(callbackFlag)
224 *mCallbackFlag = true;
229 static void TestSelectionClearedCallback(TextField control)
231 tet_infoline(" TestSelectionClearedCallback");
233 gSelectionClearedCallbackCalled = true;
236 static void TestSelectionStartedCallback(TextField control)
238 tet_infoline(" TestSelectionStartedCallback");
240 gSelectionStartedCallbackCalled = true;
243 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
245 tet_infoline(" TestSelectionChangedCallback");
247 gSelectionChangedCallbackCalled = true;
248 oldSelectionStart = oldStart;
249 oldSelectionEnd = oldEnd;
252 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
254 tet_infoline(" TestAnchorClickedCallback");
256 gAnchorClickedCallBackNotCalled = false;
258 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
260 gAnchorClickedCallBackCalled = true;
264 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
266 tet_infoline(" TestCursorPositionChangedCallback");
268 gCursorPositionChangedCallbackCalled = true;
269 oldCursorPos = oldPos;
272 static void TestTextChangedCallback(TextField control)
274 tet_infoline(" TestTextChangedCallback");
276 gTextChangedCallBackCalled = true;
279 static void TestMaxLengthReachedCallback(TextField control)
281 tet_infoline(" TestMaxLengthReachedCallback");
283 gMaxCharactersCallBackCalled = true;
286 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
288 tet_infoline(" TestInputFilteredCallback");
290 if(type == Toolkit::InputFilter::Property::ACCEPTED)
292 gInputFilteredAcceptedCallbackCalled = true;
294 else if(type == Toolkit::InputFilter::Property::REJECTED)
296 gInputFilteredRejectedCallbackCalled = true;
300 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
302 tet_infoline(" TestInputStyleChangedCallback");
304 gInputStyleChangedCallbackCalled = true;
305 gInputStyleMask = mask;
308 // Generate a KeyEvent to send to Core.
309 Integration::KeyEvent GenerateKey(const std::string& keyName,
310 const std::string& logicalKey,
311 const std::string& keyString,
314 unsigned long timeStamp,
315 const Integration::KeyEvent::State& keyState,
316 const std::string& compose = "",
317 const std::string& deviceName = DEFAULT_DEVICE_NAME,
318 const Device::Class::Type& deviceClass = Device::Class::NONE,
319 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
321 return Integration::KeyEvent(keyName,
334 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
336 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
338 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
340 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
342 Property::Value* valueSet = NULL;
343 if(valueGet.first.type == Property::Key::INDEX)
345 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
349 // Get Key is a string so searching Set Map for a string key
350 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
355 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
357 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
360 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
362 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
365 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
367 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
370 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
372 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
375 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
377 Vector2 vector2Get = valueGet.second.Get<Vector2>();
378 Vector2 vector2Set = valueSet->Get<Vector2>();
379 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
382 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
384 Vector4 vector4Get = valueGet.second.Get<Vector4>();
385 Vector4 vector4Set = valueSet->Get<Vector4>();
386 tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
392 if(valueGet.first.type == Property::Key::INDEX)
394 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
398 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
410 int UtcDaliToolkitTextFieldConstructorP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
415 DALI_TEST_CHECK(!textField);
419 int UtcDaliToolkitTextFieldNewP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextFieldNewP");
423 TextField textField = TextField::New();
424 DALI_TEST_CHECK(textField);
428 int UtcDaliToolkitTextFieldDownCastP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
432 TextField textField1 = TextField::New();
433 BaseHandle object(textField1);
435 TextField textField2 = TextField::DownCast(object);
436 DALI_TEST_CHECK(textField2);
438 TextField textField3 = DownCast<TextField>(object);
439 DALI_TEST_CHECK(textField3);
443 int UtcDaliToolkitTextFieldDownCastN(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
447 BaseHandle uninitializedObject;
448 TextField textField1 = TextField::DownCast(uninitializedObject);
449 DALI_TEST_CHECK(!textField1);
451 TextField textField2 = DownCast<TextField>(uninitializedObject);
452 DALI_TEST_CHECK(!textField2);
456 int UtcDaliToolkitTextFieldCopyConstructorP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
460 TextField textField = TextField::New();
461 textField.SetProperty(TextField::Property::TEXT, "Test");
463 TextField copy(textField);
464 DALI_TEST_CHECK(copy);
465 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
469 int UtcDaliTextFieldMoveConstructor(void)
471 ToolkitTestApplication application;
473 TextField textField = TextField::New();
474 textField.SetProperty(TextEditor::Property::TEXT, "Test");
475 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
477 TextField moved = std::move(textField);
478 DALI_TEST_CHECK(moved);
479 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
480 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
481 DALI_TEST_CHECK(!textField);
486 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
488 ToolkitTestApplication application;
489 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
490 TextField textField = TextField::New();
491 textField.SetProperty(TextField::Property::TEXT, "Test");
493 TextField copy = textField;
494 DALI_TEST_CHECK(copy);
495 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
499 int UtcDaliTextFieldMoveAssignment(void)
501 ToolkitTestApplication application;
503 TextField textField = TextField::New();
504 textField.SetProperty(TextEditor::Property::TEXT, "Test");
505 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
508 moved = std::move(textField);
509 DALI_TEST_CHECK(moved);
510 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
511 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
512 DALI_TEST_CHECK(!textField);
517 int UtcDaliTextFieldNewP(void)
519 ToolkitTestApplication application;
520 tet_infoline(" UtcDaliToolkitTextFieldNewP");
521 TextField textField = TextField::New();
522 DALI_TEST_CHECK(textField);
526 // Positive test case for a method
527 int UtcDaliTextFieldGetPropertyP(void)
529 ToolkitTestApplication application;
530 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
531 TextField field = TextField::New();
532 DALI_TEST_CHECK(field);
534 // Check Property Indices are correct
535 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
536 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
537 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
538 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
539 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
540 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
541 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
542 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
543 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
544 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
545 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
546 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
547 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
548 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
549 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
550 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
551 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
552 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
553 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
554 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
555 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
556 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
557 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
558 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
559 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
560 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
561 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
562 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
563 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
564 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
565 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
566 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
567 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
568 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
569 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
570 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
571 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
572 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
573 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
574 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
575 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
576 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
577 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
578 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
579 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
580 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
581 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
582 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
583 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
585 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
601 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
604 Property::Map imageMap;
605 imageMap[mapKey] = mapValue;
607 field.SetProperty(property, imageMap);
608 Property::Value propValue = field.GetProperty(property);
609 Property::Map* resultMap = propValue.GetMap();
611 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
619 // Positive test case for a method
620 int UtcDaliTextFieldSetPropertyP(void)
622 ToolkitTestApplication application;
623 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
624 TextField field = TextField::New();
625 DALI_TEST_CHECK(field);
626 application.GetScene().Add(field);
628 // Note - we can't check the defaults since the stylesheets are platform-specific
630 // Check the render backend property.
631 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
632 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
634 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
635 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
637 // Check text property.
638 field.SetProperty(TextField::Property::TEXT, "Setting Text");
639 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
641 // Check placeholder text properties.
642 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
643 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
645 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
646 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
648 // Check font properties.
649 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
650 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
652 Property::Map fontStyleMapSet;
653 Property::Map fontStyleMapGet;
654 Property::Value* slantValue = NULL;
656 fontStyleMapSet.Insert("weight", "bold");
657 fontStyleMapSet.Insert("width", "condensed");
658 fontStyleMapSet.Insert("slant", "italic");
659 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
661 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
662 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
663 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
665 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
666 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
668 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
669 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
670 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
672 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
673 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
674 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
677 fontStyleMapSet.Clear();
678 fontStyleMapSet.Insert("weight", "normal");
679 fontStyleMapSet.Insert("slant", "oblique");
680 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
682 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
683 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
684 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
686 fontStyleMapSet.Clear();
687 fontStyleMapSet.Insert("slant", "roman");
688 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
689 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
691 // Replace 'roman' for 'normal'.
692 slantValue = fontStyleMapGet.Find("slant");
693 if(NULL != slantValue)
695 if("normal" == slantValue->Get<std::string>())
697 fontStyleMapGet["slant"] = "roman";
700 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
701 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
703 fontStyleMapSet.Clear();
705 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
706 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
707 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
708 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
710 // Check that the MAX_LENGTH property can be correctly set
711 const int maxNumberOfCharacters = 20;
712 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
713 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
715 // Check exceed policy
716 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
717 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
718 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
719 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
721 // Check that the Alignment properties can be correctly set
722 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
723 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
724 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
725 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
727 // Check text's color property
728 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
729 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
731 // Check placeholder text's color property.
732 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
733 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
735 // Check cursor properties
736 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
737 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
738 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
739 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
741 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
742 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
743 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
744 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
745 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
746 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
747 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
748 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
750 // Check scroll properties.
751 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
752 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
753 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
754 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
756 // Check handle images
757 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
758 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
759 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
760 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
761 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
763 // Check handle images
764 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
765 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
766 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
767 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
768 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
769 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
771 // Check the selection popup style
772 const Vector2 popupMaxSize(200.0f, 300.0f);
773 const Vector2 optionDividerSize(30.0f, 5.0f);
774 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
775 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
777 Property::Map selectionPopupStyle;
778 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
779 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
780 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
781 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
783 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
785 Property::Map selectionPopupStyleGet;
786 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
788 Property::Value* popupValue;
789 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
790 DALI_TEST_CHECK(NULL != popupValue);
793 Vector2 popupMaxSizeGet;
794 popupValue->Get(popupMaxSizeGet);
795 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
798 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
799 DALI_TEST_CHECK(NULL != popupValue);
802 Vector2 optionDividerSizeGet;
803 popupValue->Get(optionDividerSizeGet);
804 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
807 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
808 DALI_TEST_CHECK(NULL != popupValue);
811 Vector4 optionDividerPaddingGet;
812 popupValue->Get(optionDividerPaddingGet);
813 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
816 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
817 DALI_TEST_CHECK(NULL != popupValue);
820 Vector4 labelPaddingGet;
821 popupValue->Get(labelPaddingGet);
822 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
825 // Reset selection popup style
826 selectionPopupStyle.Clear();
827 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
829 // Check the highlight color
830 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
831 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
833 // Decoration bounding box
834 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
835 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
837 // Check the input method setting
838 Property::Map propertyMap;
839 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
840 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
841 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
842 int inputVariation = 1;
843 propertyMap["PANEL_LAYOUT"] = panelLayout;
844 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
845 propertyMap["BUTTON_ACTION"] = buttonAction;
846 propertyMap["VARIATION"] = inputVariation;
847 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
849 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
851 DALI_TEST_CHECK(value.Get(map));
854 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
855 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
858 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
859 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
862 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
863 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
866 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
867 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
869 // Check input color property.
870 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
871 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
873 // Check the enable markup property.
874 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
875 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
876 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
878 // Check input font properties.
879 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
880 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
882 fontStyleMapSet.Clear();
883 fontStyleMapSet.Insert("weight", "bold");
884 fontStyleMapSet.Insert("width", "condensed");
885 fontStyleMapSet.Insert("slant", "italic");
887 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
888 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
889 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
890 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
892 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
893 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
895 // Reset input font style.
896 fontStyleMapSet.Clear();
897 fontStyleMapSet.Insert("weight", "normal");
898 fontStyleMapSet.Insert("slant", "oblique");
900 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
901 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
902 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
903 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
905 fontStyleMapSet.Clear();
906 fontStyleMapSet.Insert("slant", "roman");
908 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
909 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
911 // Replace 'roman' for 'normal'.
912 slantValue = fontStyleMapGet.Find("slant");
913 if(NULL != slantValue)
915 if("normal" == slantValue->Get<std::string>())
917 fontStyleMapGet["slant"] = "roman";
920 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
921 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
923 fontStyleMapSet.Clear();
925 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
926 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
927 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
928 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
930 Property::Map strikethroughMapSet;
931 Property::Map strikethroughMapGet;
933 strikethroughMapSet.Insert("enable", true);
934 strikethroughMapSet.Insert("color", Color::RED);
935 strikethroughMapSet.Insert("height", 2.0f);
937 // Check the strikethrough property
938 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
940 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
941 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
942 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
944 // Check the input strikethrough property
945 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
946 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
948 Property::Map underlineMapSet;
949 Property::Map underlineMapGet;
951 underlineMapSet.Insert("enable", true);
952 underlineMapSet.Insert("color", Color::RED);
953 underlineMapSet.Insert("height", 1);
954 underlineMapSet.Insert("type", Text::Underline::SOLID);
955 underlineMapSet.Insert("dashWidth", 2);
956 underlineMapSet.Insert("dashGap", 1);
958 // Check the underline property
959 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
961 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
962 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
963 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
966 application.SendNotification();
967 application.Render();
969 underlineMapSet.Clear();
970 underlineMapGet.Clear();
972 underlineMapSet.Insert("enable", true);
973 underlineMapSet.Insert("color", Color::BLUE);
974 underlineMapSet.Insert("height", 1);
975 underlineMapSet.Insert("type", Text::Underline::DASHED);
976 underlineMapSet.Insert("dashWidth", 4);
977 underlineMapSet.Insert("dashGap", 2);
979 // Check the dashed underline property
980 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
982 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
983 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
984 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
987 application.SendNotification();
988 application.Render();
990 underlineMapSet.Clear();
991 underlineMapGet.Clear();
993 underlineMapSet.Insert("enable", true);
994 underlineMapSet.Insert("color", Color::BLUE);
995 underlineMapSet.Insert("height", 4);
996 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
997 underlineMapSet.Insert("dashWidth", 4);
998 underlineMapSet.Insert("dashGap", 2);
1000 // Check the dashed underline property
1001 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1003 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1004 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1005 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1007 // Render and notify
1008 application.SendNotification();
1009 application.Render();
1011 underlineMapSet.Clear();
1012 underlineMapGet.Clear();
1014 // Check the input underline property
1015 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1016 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1018 // Check the shadow property
1019 Property::Map shadowMapSet;
1020 Property::Map shadowMapGet;
1022 shadowMapSet.Insert("color", Color::GREEN);
1023 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1024 shadowMapSet.Insert("blurRadius", 3.0f);
1026 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1028 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1029 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1030 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1032 // Check the input shadow property
1033 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1034 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1036 // Check the emboss property
1037 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1038 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1040 // Check the input emboss property
1041 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1042 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1044 // Check the outline property
1046 // Test string type first
1047 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1048 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1049 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1051 // Then test the property map type
1052 Property::Map outlineMapSet;
1053 Property::Map outlineMapGet;
1055 outlineMapSet["color"] = Color::RED;
1056 outlineMapSet["width"] = 2.0f;
1058 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1060 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1061 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1062 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1064 // Check the input outline property
1065 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1066 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1068 // Check the hidden input settings property
1069 Property::Map hiddenMapSet;
1070 Property::Map hiddenMapGet;
1071 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1072 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1073 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1074 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1075 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1077 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1078 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1079 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1081 // Check the pixel size of font
1082 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1083 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1085 // Check the enable selection property
1086 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1087 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1089 // Check the placeholder property with pixel size
1090 Property::Map placeholderPixelSizeMapSet;
1091 Property::Map placeholderPixelSizeMapGet;
1092 Property::Map placeholderFontstyleMap;
1093 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1094 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1095 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1096 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1097 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1098 placeholderPixelSizeMapSet["ellipsis"] = true;
1100 placeholderFontstyleMap.Insert("weight", "bold");
1101 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1102 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1104 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1105 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1107 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1108 Property::Map placeholderConversionMap;
1109 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1110 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1111 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1112 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1113 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1114 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1116 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1118 // Check the placeholder property with point size
1119 Property::Map placeholderMapSet;
1120 Property::Map placeholderMapGet;
1121 placeholderMapSet["text"] = "Setting Placeholder Text";
1122 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1123 placeholderMapSet["color"] = Color::RED;
1124 placeholderMapSet["fontFamily"] = "Arial";
1125 placeholderMapSet["pointSize"] = 12.0f;
1126 placeholderMapSet["ellipsis"] = false;
1128 // Check the placeholder font style property
1129 placeholderFontstyleMap.Clear();
1131 placeholderFontstyleMap.Insert("weight", "bold");
1132 placeholderFontstyleMap.Insert("width", "condensed");
1133 placeholderFontstyleMap.Insert("slant", "italic");
1134 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1135 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1137 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1138 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1140 placeholderConversionMap.Clear();
1141 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1142 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1143 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1144 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1145 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1146 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1148 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1150 // Reset font style.
1151 placeholderFontstyleMap.Clear();
1152 placeholderFontstyleMap.Insert("weight", "normal");
1153 placeholderFontstyleMap.Insert("slant", "oblique");
1154 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1155 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1157 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1158 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1160 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1161 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1163 placeholderFontstyleMap.Clear();
1164 placeholderFontstyleMap.Insert("slant", "roman");
1165 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1166 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1168 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1170 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1172 placeholderFontstyleMap.Clear();
1173 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1174 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1176 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1177 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1178 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1180 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1182 // Check the ellipsis property
1183 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1184 field.SetProperty(TextField::Property::ELLIPSIS, true);
1185 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1187 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1188 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1190 // Test the ENABLE_GRAB_HANDLE_POPUP property
1191 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1192 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1193 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1195 // Check the background property
1196 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1197 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1199 //Check handle color
1200 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1201 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1203 // Check the input filter property
1204 Property::Map inputFilterMapSet;
1205 Property::Map inputFilterMapGet;
1206 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1207 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1209 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1211 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1212 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1215 inputFilterMapSet.Clear();
1216 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1218 application.SendNotification();
1219 application.Render();
1224 // Positive Atlas Text Renderer test
1225 int utcDaliTextFieldAtlasRenderP(void)
1227 ToolkitTestApplication application;
1228 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1229 StyleManager styleManager = StyleManager::Get();
1230 styleManager.ApplyDefaultTheme();
1231 TextField field = TextField::New();
1232 DALI_TEST_CHECK(field);
1234 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1236 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1238 application.GetScene().Add(field);
1242 // Render some text with the shared atlas backend
1243 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1244 application.SendNotification();
1245 application.Render();
1249 tet_result(TET_FAIL);
1254 // Positive test for the anchorClicked signal.
1255 int utcDaliTextFieldAnchorClicked01(void)
1257 ToolkitTestApplication application;
1258 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1259 TextField field = TextField::New();
1260 DALI_TEST_CHECK(field);
1262 application.GetScene().Add(field);
1264 // connect to the anchor clicked signal.
1265 ConnectionTracker* testTracker = new ConnectionTracker();
1266 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1267 bool anchorClickedSignal = false;
1268 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1270 gAnchorClickedCallBackCalled = false;
1271 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1272 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1273 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1274 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1275 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1277 application.SendNotification();
1278 application.Render();
1279 field.SetKeyInputFocus();
1281 // Create a tap event to touch the text field.
1282 TestGenerateTap(application, 5.0f, 25.0f);
1283 application.SendNotification();
1284 application.Render();
1286 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1287 DALI_TEST_CHECK(anchorClickedSignal);
1289 gAnchorClickedCallBackNotCalled = true;
1290 // Tap the outside of anchor, callback should not be called.
1291 TestGenerateTap(application, 150.f, 100.f);
1292 application.SendNotification();
1293 application.Render();
1295 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1300 // Positive test for the anchorClicked signal.
1301 int utcDaliTextFieldAnchorClicked02(void)
1303 ToolkitTestApplication application;
1304 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1305 TextField field = TextField::New();
1306 DALI_TEST_CHECK(field);
1308 application.GetScene().Add(field);
1310 // connect to the anchor clicked signal.
1311 ConnectionTracker* testTracker = new ConnectionTracker();
1312 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1313 bool anchorClickedSignal = false;
1314 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1316 gAnchorClickedCallBackCalled = false;
1317 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1318 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1319 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1320 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1321 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1323 application.SendNotification();
1324 application.Render();
1325 field.SetKeyInputFocus();
1327 // Avoid a crash when core load gl resources.
1328 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1330 // Create a tap event to touch the text field.
1331 TestGenerateTap(application, 30.0f, 25.0f, 100);
1332 application.SendNotification();
1333 application.Render();
1335 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1336 DALI_TEST_CHECK(anchorClickedSignal);
1338 // For coverage InsertTextAnchor, RemoveTextAnchor
1339 // first index insert
1340 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1341 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1342 application.SendNotification();
1343 application.Render();
1345 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1346 application.SendNotification();
1347 application.Render();
1349 gAnchorClickedCallBackCalled = false;
1350 // Create a tap event to touch the text field.
1351 TestGenerateTap(application, 30.0f, 25.0f, 700);
1352 application.SendNotification();
1353 field.SetKeyInputFocus();
1355 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1357 // last index insert
1358 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1359 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1360 application.SendNotification();
1361 application.Render();
1363 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1364 application.SendNotification();
1365 application.Render();
1367 gAnchorClickedCallBackCalled = false;
1368 // Create a tap event to touch the text field.
1369 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1370 application.SendNotification();
1371 field.SetKeyInputFocus();
1373 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1376 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1377 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1378 application.SendNotification();
1379 application.Render();
1381 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1382 application.SendNotification();
1383 application.Render();
1385 gAnchorClickedCallBackCalled = false;
1386 // Create a tap event to touch the text field.
1387 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1388 application.SendNotification();
1389 field.SetKeyInputFocus();
1391 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1393 // first index remove
1394 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1395 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1396 application.SendNotification();
1397 application.Render();
1399 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1400 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));
1401 application.SendNotification();
1402 application.Render();
1404 gAnchorClickedCallBackCalled = false;
1405 // Create a tap event to touch the text field.
1406 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1407 application.SendNotification();
1408 field.SetKeyInputFocus();
1410 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1412 // last index remove
1413 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1414 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1415 application.SendNotification();
1416 application.Render();
1418 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1419 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));
1420 application.SendNotification();
1421 application.Render();
1423 gAnchorClickedCallBackCalled = false;
1424 // Create a tap event to touch the text field.
1425 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1426 application.SendNotification();
1427 application.Render();
1429 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1432 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1433 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1434 application.SendNotification();
1435 application.Render();
1437 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1438 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));
1439 application.SendNotification();
1440 application.Render();
1442 gAnchorClickedCallBackCalled = false;
1443 // Create a tap event to touch the text field.
1444 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1450 // 0 ~ 1 index remove
1451 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1452 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1453 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1454 application.SendNotification();
1455 application.Render();
1457 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1458 application.SendNotification();
1459 application.Render();
1461 gAnchorClickedCallBackCalled = false;
1462 // Create a tap event to touch the text field.
1463 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1469 // 1 ~ 3 index remove
1470 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1471 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1472 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1473 application.SendNotification();
1474 application.Render();
1476 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1477 application.SendNotification();
1478 application.Render();
1480 gAnchorClickedCallBackCalled = false;
1481 // Create a tap event to touch the text field.
1482 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1483 application.SendNotification();
1484 application.Render();
1486 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1488 // 3 ~ 4 index remove
1489 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1490 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1491 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1492 application.SendNotification();
1493 application.Render();
1495 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1496 application.SendNotification();
1497 application.Render();
1499 gAnchorClickedCallBackCalled = false;
1500 // Create a tap event to touch the text field.
1501 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1502 application.SendNotification();
1503 application.Render();
1505 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1507 // Remove front of anchor
1508 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1509 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1510 application.SendNotification();
1511 application.Render();
1513 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1514 application.SendNotification();
1515 application.Render();
1517 // Remove whole text
1518 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1519 DevelTextField::SelectWholeText(field);
1520 application.SendNotification();
1521 application.Render();
1523 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1524 application.SendNotification();
1525 application.Render();
1527 // Remove all with backspace
1528 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1529 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1530 application.SendNotification();
1531 application.Render();
1533 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1534 application.SendNotification();
1535 application.Render();
1537 // Remove all with delete
1538 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1539 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1540 application.SendNotification();
1541 application.Render();
1543 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));
1544 application.SendNotification();
1545 application.Render();
1550 // Positive test for the textChanged signal.
1551 int utcDaliTextFieldTextChangedP(void)
1553 ToolkitTestApplication application;
1554 tet_infoline(" utcDaliTextFieldTextChangedP");
1555 TextField field = TextField::New();
1556 DALI_TEST_CHECK(field);
1558 application.GetScene().Add(field);
1560 // connect to the text changed signal.
1561 ConnectionTracker* testTracker = new ConnectionTracker();
1562 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1563 bool textChangedSignal = false;
1564 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1566 gTextChangedCallBackCalled = false;
1567 field.SetProperty(TextField::Property::TEXT, "ABC");
1568 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1569 DALI_TEST_CHECK(textChangedSignal);
1571 application.SendNotification();
1572 field.SetKeyInputFocus();
1574 gTextChangedCallBackCalled = false;
1575 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1576 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1579 field.SetProperty(TextField::Property::TEXT, "");
1581 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1582 gTextChangedCallBackCalled = false;
1583 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1584 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1586 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1587 gTextChangedCallBackCalled = false;
1588 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1589 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1594 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1596 ToolkitTestApplication application;
1597 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1598 TextField field = TextField::New();
1599 DALI_TEST_CHECK(field);
1601 application.GetScene().Add(field);
1603 // connect to the text changed signal.
1604 ConnectionTracker* testTracker = new ConnectionTracker();
1605 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1606 bool textChangedSignal = false;
1607 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1609 // get InputMethodContext
1611 InputMethodContext::EventData imfEvent;
1612 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1614 field.SetKeyInputFocus();
1615 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1618 gTextChangedCallBackCalled = false;
1619 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1620 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1621 application.SendNotification();
1622 application.Render();
1623 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1624 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1626 gTextChangedCallBackCalled = false;
1627 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1628 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1629 application.SendNotification();
1630 application.Render();
1631 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1632 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1634 gTextChangedCallBackCalled = false;
1635 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1636 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1637 application.SendNotification();
1638 application.Render();
1639 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1640 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1642 gTextChangedCallBackCalled = false;
1643 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1644 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1645 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1647 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1648 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1649 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1651 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1652 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1653 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1655 application.SendNotification();
1656 application.Render();
1657 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1658 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1663 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1665 ToolkitTestApplication application;
1666 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1667 TextField field = TextField::New();
1668 DALI_TEST_CHECK(field);
1670 field.SetProperty(TextField::Property::TEXT, "Hello world");
1672 application.GetScene().Add(field);
1674 // connect to the selection changed signal.
1675 ConnectionTracker* testTracker = new ConnectionTracker();
1676 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1677 bool selectionChangedSignal = false;
1678 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1680 // get InputMethodContext
1682 InputMethodContext::EventData imfEvent;
1683 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1685 field.SetKeyInputFocus();
1686 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1689 gSelectionChangedCallbackCalled = false;
1690 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1691 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1692 application.SendNotification();
1693 application.Render();
1694 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1696 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1697 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1702 int utcDaliTextFieldPositionWithInputMethodContext(void)
1704 ToolkitTestApplication application;
1705 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1706 TextField field = TextField::New();
1707 DALI_TEST_CHECK(field);
1709 field.SetProperty(TextField::Property::TEXT, "Hello world");
1711 application.GetScene().Add(field);
1713 // connect to the selection changed signal.
1714 ConnectionTracker* testTracker = new ConnectionTracker();
1715 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1716 bool cursorPositionChangedSignal = false;
1717 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1719 // get InputMethodContext
1721 InputMethodContext::EventData imfEvent;
1722 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1724 field.SetKeyInputFocus();
1725 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1728 gCursorPositionChangedCallbackCalled = false;
1729 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1730 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1731 application.SendNotification();
1732 application.Render();
1733 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1735 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1740 // Negative test for the textChanged signal.
1741 int utcDaliTextFieldTextChangedN(void)
1743 ToolkitTestApplication application;
1744 tet_infoline(" utcDaliTextFieldTextChangedN");
1745 TextField field = TextField::New();
1746 DALI_TEST_CHECK(field);
1748 application.GetScene().Add(field);
1750 // connect to the text changed signal.
1751 ConnectionTracker* testTracker = new ConnectionTracker();
1752 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1753 bool textChangedSignal = false;
1754 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1756 gTextChangedCallBackCalled = false;
1757 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1758 application.SendNotification();
1759 application.Render();
1760 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1761 DALI_TEST_CHECK(!textChangedSignal);
1766 // Positive test for Max Characters reached signal.
1767 int utcDaliTextFieldMaxCharactersReachedP(void)
1769 ToolkitTestApplication application;
1770 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1771 TextField field = TextField::New();
1772 DALI_TEST_CHECK(field);
1774 application.GetScene().Add(field);
1776 const int maxNumberOfCharacters = 1;
1777 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1779 field.SetKeyInputFocus();
1781 // connect to the text changed signal.
1782 ConnectionTracker* testTracker = new ConnectionTracker();
1783 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1784 bool maxLengthReachedSignal = false;
1785 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1787 gMaxCharactersCallBackCalled = false;
1789 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1790 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1792 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1793 DALI_TEST_CHECK(maxLengthReachedSignal);
1798 // Negative test for Max Characters reached signal.
1799 int utcDaliTextFieldMaxCharactersReachedN(void)
1801 ToolkitTestApplication application;
1802 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1803 TextField field = TextField::New();
1804 DALI_TEST_CHECK(field);
1806 application.GetScene().Add(field);
1808 const int maxNumberOfCharacters = 3;
1809 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1811 field.SetKeyInputFocus();
1813 // connect to the text changed signal.
1814 ConnectionTracker* testTracker = new ConnectionTracker();
1815 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1816 bool maxLengthReachedSignal = false;
1817 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1819 gMaxCharactersCallBackCalled = false;
1821 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1822 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1824 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1825 DALI_TEST_CHECK(!maxLengthReachedSignal);
1827 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1829 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1830 DALI_TEST_CHECK(!maxLengthReachedSignal);
1835 // Positive test for Input Filtered signal.
1836 int utcDaliTextFieldInputFilteredP(void)
1838 ToolkitTestApplication application;
1839 tet_infoline(" utcDaliTextFieldInputFilteredP");
1840 TextField field = TextField::New();
1841 DALI_TEST_CHECK(field);
1843 application.GetScene().Add(field);
1845 Property::Map inputFilter;
1847 // Only digit is accepted.
1848 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1850 // Set input filter to TextField.
1851 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1853 field.SetKeyInputFocus();
1855 // connect to the input filtered signal.
1856 ConnectionTracker* testTracker = new ConnectionTracker();
1857 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1858 bool inputFilteredSignal = false;
1859 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1861 gInputFilteredAcceptedCallbackCalled = false;
1863 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1865 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1866 DALI_TEST_CHECK(inputFilteredSignal);
1868 // Word is rejected.
1869 inputFilter[InputFilter::Property::ACCEPTED] = "";
1870 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1872 // Set input filter to TextField.
1873 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1875 field.SetKeyInputFocus();
1877 inputFilteredSignal = false;
1878 gInputFilteredRejectedCallbackCalled = false;
1880 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1882 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1883 DALI_TEST_CHECK(inputFilteredSignal);
1888 // Negative test for Input Filtered signal.
1889 int utcDaliTextFieldInputFilteredN(void)
1891 ToolkitTestApplication application;
1892 tet_infoline(" utcDaliTextFieldInputFilteredP");
1893 TextField field = TextField::New();
1894 DALI_TEST_CHECK(field);
1896 application.GetScene().Add(field);
1898 Property::Map inputFilter;
1900 // Only word is accepted.
1901 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1903 // Set input filter to TextField.
1904 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1906 field.SetKeyInputFocus();
1908 // connect to the input filtered signal.
1909 ConnectionTracker* testTracker = new ConnectionTracker();
1910 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1911 bool inputFilteredSignal = false;
1912 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1914 gInputFilteredAcceptedCallbackCalled = false;
1916 // Key a, d should not be filtered.
1917 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1918 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1919 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1920 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1922 // Backspace, Delete should not be filtered.
1923 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1924 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));
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1931 DALI_TEST_CHECK(!inputFilteredSignal);
1933 // Digit is rejected.
1934 inputFilter[InputFilter::Property::ACCEPTED] = "";
1935 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1937 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1939 field.SetKeyInputFocus();
1941 inputFilteredSignal = false;
1942 gInputFilteredRejectedCallbackCalled = false;
1944 // Key a, d should not be filtered.
1945 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1946 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1947 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1948 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1950 // Backspace, Delete should not be filtered.
1951 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1952 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));
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1958 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1959 DALI_TEST_CHECK(!inputFilteredSignal);
1964 int utcDaliTextFieldInputStyleChanged01(void)
1966 // The text-field emits signals when the input style changes. These changes of style are
1967 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1968 // can't be emitted during the size negotiation as the callbacks may update the UI.
1969 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1970 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1971 ToolkitTestApplication application;
1972 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1976 char* pathNamePtr = get_current_dir_name();
1977 const std::string pathName(pathNamePtr);
1980 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1981 fontClient.SetDpi(93u, 93u);
1983 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1984 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1986 TextField field = TextField::New();
1987 DALI_TEST_CHECK(field);
1989 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1990 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1991 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1993 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1994 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1996 // connect to the text changed signal.
1997 ConnectionTracker* testTracker = new ConnectionTracker();
1998 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1999 bool inputStyleChangedSignal = false;
2000 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2002 application.GetScene().Add(field);
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2008 // Executes the idle callbacks added by the text control on the change of input style.
2009 application.RunIdles();
2011 gInputStyleChangedCallbackCalled = false;
2012 gInputStyleMask = TextField::InputStyle::NONE;
2013 inputStyleChangedSignal = false;
2015 // Create a tap event to touch the text field.
2016 TestGenerateTap(application, 18.0f, 25.0f);
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Executes the idle callbacks added by the text control on the change of input style.
2023 application.RunIdles();
2025 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2026 if(gInputStyleChangedCallbackCalled)
2028 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2030 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2031 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2033 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2034 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2036 DALI_TEST_CHECK(inputStyleChangedSignal);
2038 gInputStyleChangedCallbackCalled = false;
2039 gInputStyleMask = TextField::InputStyle::NONE;
2040 inputStyleChangedSignal = false;
2042 // Create a tap event to touch the text field.
2043 TestGenerateTap(application, 30.0f, 25.0f);
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Executes the idle callbacks added by the text control on the change of input style.
2050 application.RunIdles();
2052 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2053 DALI_TEST_CHECK(!inputStyleChangedSignal);
2055 gInputStyleChangedCallbackCalled = false;
2056 gInputStyleMask = TextField::InputStyle::NONE;
2057 inputStyleChangedSignal = false;
2059 // Create a tap event to touch the text field.
2060 TestGenerateTap(application, 43.0f, 25.0f);
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 // Executes the idle callbacks added by the text control on the change of input style.
2067 application.RunIdles();
2069 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2070 if(gInputStyleChangedCallbackCalled)
2072 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2074 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2075 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2077 DALI_TEST_CHECK(inputStyleChangedSignal);
2079 gInputStyleChangedCallbackCalled = false;
2080 gInputStyleMask = TextField::InputStyle::NONE;
2081 inputStyleChangedSignal = false;
2083 // Create a tap event to touch the text field.
2084 TestGenerateTap(application, 88.0f, 25.0f);
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2090 // Executes the idle callbacks added by the text control on the change of input style.
2091 application.RunIdles();
2093 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2094 if(gInputStyleChangedCallbackCalled)
2096 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2098 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2099 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2101 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2103 Property::Map fontStyleMapSet;
2104 fontStyleMapSet.Insert("weight", "bold");
2106 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2107 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2109 DALI_TEST_CHECK(inputStyleChangedSignal);
2111 gInputStyleChangedCallbackCalled = false;
2112 gInputStyleMask = TextField::InputStyle::NONE;
2113 inputStyleChangedSignal = false;
2115 // Create a tap event to touch the text field.
2116 TestGenerateTap(application, 115.0f, 25.0f);
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Executes the idle callbacks added by the text control on the change of input style.
2123 application.RunIdles();
2125 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2126 DALI_TEST_CHECK(!inputStyleChangedSignal);
2128 gInputStyleChangedCallbackCalled = false;
2129 gInputStyleMask = TextField::InputStyle::NONE;
2130 inputStyleChangedSignal = false;
2132 // Create a tap event to touch the text field.
2133 TestGenerateTap(application, 164.0f, 25.0f);
2135 // Render and notify
2136 application.SendNotification();
2137 application.Render();
2139 // Executes the idle callbacks added by the text control on the change of input style.
2140 application.RunIdles();
2142 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2143 if(gInputStyleChangedCallbackCalled)
2145 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2147 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2148 DALI_TEST_CHECK(style.empty());
2150 DALI_TEST_CHECK(inputStyleChangedSignal);
2152 gInputStyleChangedCallbackCalled = false;
2153 gInputStyleMask = TextField::InputStyle::NONE;
2154 inputStyleChangedSignal = false;
2156 // Create a tap event to touch the text field.
2157 TestGenerateTap(application, 191.0f, 25.0f);
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // Executes the idle callbacks added by the text control on the change of input style.
2164 application.RunIdles();
2166 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2167 DALI_TEST_CHECK(!inputStyleChangedSignal);
2172 int utcDaliTextFieldInputStyleChanged02(void)
2174 // The text-field emits signals when the input style changes. These changes of style are
2175 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2176 // can't be emitted during the size negotiation as the callbacks may update the UI.
2177 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2178 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2179 ToolkitTestApplication application;
2180 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2184 char* pathNamePtr = get_current_dir_name();
2185 const std::string pathName(pathNamePtr);
2188 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2189 fontClient.SetDpi(93u, 93u);
2191 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2192 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2194 TextField field = TextField::New();
2195 DALI_TEST_CHECK(field);
2197 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2198 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2199 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2201 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2202 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>");
2204 // connect to the text changed signal.
2205 ConnectionTracker* testTracker = new ConnectionTracker();
2206 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2207 bool inputStyleChangedSignal = false;
2208 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2210 application.GetScene().Add(field);
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Executes the idle callbacks added by the text control on the change of input style.
2217 application.RunIdles();
2219 gInputStyleChangedCallbackCalled = false;
2220 gInputStyleMask = TextField::InputStyle::NONE;
2221 inputStyleChangedSignal = false;
2223 // Create a tap event to touch the text field.
2224 TestGenerateTap(application, 53.0f, 25.0f, 100);
2225 TestGenerateTap(application, 53.0f, 25.0f, 200);
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 // Executes the idle callbacks added by the text control on the change of input style.
2232 application.RunIdles();
2234 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2235 if(gInputStyleChangedCallbackCalled)
2237 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2238 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2239 TextField::InputStyle::POINT_SIZE |
2240 TextField::InputStyle::COLOR),
2243 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2244 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2246 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2247 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2249 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2250 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2252 DALI_TEST_CHECK(inputStyleChangedSignal);
2254 gInputStyleChangedCallbackCalled = false;
2255 gInputStyleMask = TextField::InputStyle::NONE;
2256 inputStyleChangedSignal = false;
2258 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2264 // Executes the idle callbacks added by the text control on the change of input style.
2265 application.RunIdles();
2267 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2268 if(gInputStyleChangedCallbackCalled)
2270 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2271 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2274 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2275 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2277 DALI_TEST_CHECK(inputStyleChangedSignal);
2279 gInputStyleChangedCallbackCalled = false;
2280 gInputStyleMask = TextField::InputStyle::NONE;
2281 inputStyleChangedSignal = false;
2283 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2285 // Render and notify
2286 application.SendNotification();
2287 application.Render();
2289 // Executes the idle callbacks added by the text control on the change of input style.
2290 application.RunIdles();
2292 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2293 DALI_TEST_CHECK(!inputStyleChangedSignal);
2295 gInputStyleChangedCallbackCalled = false;
2296 gInputStyleMask = TextField::InputStyle::NONE;
2297 inputStyleChangedSignal = false;
2299 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Executes the idle callbacks added by the text control on the change of input style.
2306 application.RunIdles();
2308 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2309 if(gInputStyleChangedCallbackCalled)
2311 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2312 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2315 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2316 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2318 DALI_TEST_CHECK(inputStyleChangedSignal);
2320 gInputStyleChangedCallbackCalled = false;
2321 gInputStyleMask = TextField::InputStyle::NONE;
2322 inputStyleChangedSignal = false;
2324 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2326 Property::Map fontStyleMapSet;
2327 fontStyleMapSet.Insert("weight", "thin");
2328 fontStyleMapSet.Insert("width", "condensed");
2329 fontStyleMapSet.Insert("slant", "italic");
2331 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2332 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2334 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2335 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2336 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2337 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2338 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 // Executes the idle callbacks added by the text control on the change of input style.
2345 application.RunIdles();
2347 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2348 DALI_TEST_CHECK(!inputStyleChangedSignal);
2350 // Create a tap event to touch the text field.
2351 TestGenerateTap(application, 63.0f, 25.0f, 700);
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Executes the idle callbacks added by the text control on the change of input style.
2358 application.RunIdles();
2360 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2361 if(gInputStyleChangedCallbackCalled)
2363 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2364 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2365 TextField::InputStyle::POINT_SIZE |
2366 TextField::InputStyle::FONT_STYLE |
2367 TextField::InputStyle::UNDERLINE |
2368 TextField::InputStyle::SHADOW |
2369 TextField::InputStyle::EMBOSS |
2370 TextField::InputStyle::OUTLINE),
2373 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2374 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2376 DALI_TEST_CHECK(inputStyleChangedSignal);
2381 int utcDaliTextFieldEvent01(void)
2383 ToolkitTestApplication application;
2384 tet_infoline(" utcDaliTextFieldEvent01");
2386 // Creates a tap event. After creating a tap event the text field should
2387 // have the focus and add text with key events should be possible.
2389 TextField field = TextField::New();
2390 DALI_TEST_CHECK(field);
2392 application.GetScene().Add(field);
2394 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2395 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2396 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 // Avoid a crash when core load gl resources.
2403 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Add a key event but as the text field has not the focus it should do nothing.
2410 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2418 // Create a tap event to touch the text field.
2419 TestGenerateTap(application, 150.0f, 25.0f);
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Pressing delete key should be fine even if there is no text in TextField.
2426 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));
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Now the text field has the focus, so it can handle the key events.
2432 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2441 // Create a second text field and send key events to it.
2442 TextField field2 = TextField::New();
2444 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2445 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2446 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2447 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2449 application.GetScene().Add(field2);
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2455 // Create a tap event on the second text field.
2456 TestGenerateTap(application, 150.0f, 125.0f);
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // The second text field has the focus. It should handle the key events.
2463 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2464 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2466 // Render and notify
2467 application.SendNotification();
2468 application.Render();
2470 // Check the text has been added to the second text field.
2471 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2476 int utcDaliTextFieldEvent02(void)
2478 ToolkitTestApplication application;
2479 tet_infoline(" utcDaliTextFieldEvent02");
2481 // Checks if the right number of actors are created.
2483 TextField field = TextField::New();
2484 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2485 DALI_TEST_CHECK(field);
2486 LoadMarkerImages(application, field);
2488 application.GetScene().Add(field);
2490 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2491 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2492 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2494 // Avoid a crash when core load gl resources.
2495 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2497 // Render and notify
2498 application.SendNotification();
2499 application.Render();
2501 // Check there are the expected number of children ( stencil ).
2502 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2504 Actor stencil = field.GetChildAt(0u);
2505 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2507 // Create a tap event to touch the text field.
2508 TestGenerateTap(application, 150.0f, 25.0f, 300);
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 Actor layer = field.GetChildAt(2u);
2515 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2516 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2518 // Now the text field has the focus, so it can handle the key events.
2519 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2520 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 // Checks the cursor and the renderer have been created.
2527 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2528 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2530 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2531 DALI_TEST_CHECK(cursor);
2533 // The offscreen root actor has a container with all the actors which contain the text renderers.
2534 Actor container = stencil.GetChildAt(0u);
2535 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2537 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2538 DALI_TEST_CHECK(renderer);
2541 // Move the cursor and check the position changes.
2542 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2543 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2550 DALI_TEST_CHECK(position2.x < position1.x);
2552 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2554 // Render and notify
2555 application.SendNotification();
2556 application.Render();
2558 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2559 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2561 // Move the cursor to the first position.
2562 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2563 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2571 // Send some taps and check the cursor positions.
2573 // Try to tap at the beginning.
2574 TestGenerateTap(application, 1.0f, 25.0f, 900);
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Cursor position should be the same than position1.
2581 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2583 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2585 // Tap away from the start position.
2586 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2592 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2594 DALI_TEST_CHECK(position6.x > position5.x);
2596 // Remove all the text.
2597 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2598 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2599 field.SetProperty(TextField::Property::TEXT, "");
2601 // Render and notify
2602 application.SendNotification();
2603 application.Render();
2605 // Cursor position should be the same than position2.
2606 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2608 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2610 // Should not be a renderer, there is only a clipped cursor.
2611 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2613 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2614 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2615 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2617 application.SendNotification();
2618 application.Render();
2620 // There are renderer and decorator layer
2621 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2626 int utcDaliTextFieldEvent03(void)
2628 ToolkitTestApplication application;
2629 tet_infoline(" utcDaliTextFieldEvent03");
2631 // Checks if the highlight actor is created.
2633 TextField field = TextField::New();
2634 DALI_TEST_CHECK(field);
2636 application.GetScene().Add(field);
2638 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2639 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2640 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2641 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2642 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2644 // Avoid a crash when core load gl resources.
2645 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2646 LoadMarkerImages(application, field);
2648 // Render and notify
2649 application.SendNotification();
2650 application.Render();
2652 // Tap first to get the focus.
2653 TestGenerateTap(application, 3.0f, 25.0f);
2655 // Render and notify
2656 application.SendNotification();
2657 application.Render();
2659 // Double tap to select a word.
2660 TestGenerateTap(application, 3.0f, 25.0f);
2662 // Render and notify
2663 application.SendNotification();
2664 application.Render();
2666 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2667 Actor stencil = field.GetChildAt(0u);
2669 // The highlight actor is drawn first, so is the first actor in the list
2670 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2671 DALI_TEST_CHECK(highlight);
2673 // The offscreen root actor has a container with all the actors which contain the text renderers.
2674 Actor container = stencil.GetChildAt(1u);
2675 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2677 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2678 DALI_TEST_CHECK(renderer);
2684 int utcDaliTextFieldEvent04(void)
2686 ToolkitTestApplication application;
2687 tet_infoline(" utcDaliTextFieldEvent04");
2689 // Checks if the highlight actor is created.
2691 TextField field = TextField::New();
2692 DALI_TEST_CHECK(field);
2693 application.GetScene().Add(field);
2694 LoadMarkerImages(application, field);
2695 // Render and notify
2696 application.SendNotification();
2697 application.Render();
2699 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2700 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2701 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2702 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2703 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2705 // Avoid a crash when core load gl resources.
2706 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2711 // Create a tap event to touch the text field.
2712 TestGenerateTap(application, 150.0f, 25.0f);
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 // Tap first to get the focus.
2718 TestGenerateTap(application, 1.0f, 25.0f);
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Double tap to select a word.
2725 TestGenerateTap(application, 1.0f, 25.0f);
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2732 TestGenerateTap(application, 0.0f, 40.0f);
2736 int utcDaliTextFieldEvent05(void)
2738 ToolkitTestApplication application;
2739 tet_infoline(" utcDaliTextFieldEvent05");
2741 // Checks dragging of cursor/grab handle
2743 TextField field = TextField::New();
2744 DALI_TEST_CHECK(field);
2745 application.GetScene().Add(field);
2746 LoadMarkerImages(application, field);
2747 // Render and notify
2748 application.SendNotification();
2749 application.Render();
2751 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2752 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2753 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2754 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2755 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2757 // Avoid a crash when core load gl resources.
2758 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2759 // Render and notify
2760 application.SendNotification();
2761 application.Render();
2763 // Create a tap event to touch the text field.
2764 TestGenerateTap(application, 150.0f, 25.0f);
2765 // Render and notify
2766 application.SendNotification();
2767 application.Render();
2769 // Tap first to get the focus.
2770 TestGenerateTap(application, 1.0f, 25.0f);
2772 // Render and notify
2773 application.SendNotification();
2774 application.Render();
2776 // Double tap to select a word.
2777 TestGenerateTap(application, 1.0f, 25.0f);
2779 // Render and notify
2780 application.SendNotification();
2781 application.Render();
2783 Actor stencil = field.GetChildAt(1u);
2787 int utcDaliTextFieldEvent06(void)
2789 ToolkitTestApplication application;
2790 tet_infoline(" utcDaliTextFieldEvent06");
2792 // Checks Longpress when in edit mode
2794 TextField field = TextField::New();
2795 DALI_TEST_CHECK(field);
2796 application.GetScene().Add(field);
2797 LoadMarkerImages(application, field);
2798 // Render and notify
2799 application.SendNotification();
2800 application.Render();
2802 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2803 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2804 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2805 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2806 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2808 // Avoid a crash when core load gl resources.
2809 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2810 // Render and notify
2811 application.SendNotification();
2812 application.Render();
2814 // Create a tap event to touch the text field.
2815 TestGenerateTap(application, 150.0f, 25.0f);
2816 // Render and notify
2817 application.SendNotification();
2818 application.Render();
2820 // Tap first to get the focus.
2821 TestGenerateTap(application, 1.0f, 25.0f);
2823 // Render and notify
2824 application.SendNotification();
2825 application.Render();
2828 TestGenerateLongPress(application, 1.0f, 25.0f);
2830 // Render and notify
2831 application.SendNotification();
2832 application.Render();
2837 int utcDaliTextFieldEvent07(void)
2839 ToolkitTestApplication application;
2840 tet_infoline(" utcDaliTextFieldEvent07");
2842 // Checks Longpress to start edit mode
2844 TextField field = TextField::New();
2845 DALI_TEST_CHECK(field);
2846 application.GetScene().Add(field);
2847 LoadMarkerImages(application, field);
2848 // Render and notify
2849 application.SendNotification();
2850 application.Render();
2852 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2853 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2854 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2855 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2856 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2857 Property::Map propertyMap;
2858 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2859 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2861 // Avoid a crash when core load gl resources.
2862 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2863 // Render and notify
2864 application.SendNotification();
2865 application.Render();
2868 TestGenerateLongPress(application, 1.0f, 25.0f);
2870 // Render and notify
2871 application.SendNotification();
2872 application.Render();
2877 int utcDaliTextFieldEvent08(void)
2879 ToolkitTestApplication application;
2880 tet_infoline(" utcDaliTextFieldEvent08");
2882 Dali::Clipboard clipboard = Clipboard::Get();
2883 clipboard.SetItem("testTextFieldEvent");
2885 // Checks Longpress when only place holder text
2887 TextField field = TextField::New();
2888 DALI_TEST_CHECK(field);
2889 application.GetScene().Add(field);
2890 LoadMarkerImages(application, field);
2891 // Render and notify
2892 application.SendNotification();
2893 application.Render();
2895 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2896 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2897 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2898 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2899 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2901 // Avoid a crash when core load gl resources.
2902 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2903 // Render and notify
2904 application.SendNotification();
2905 application.Render();
2908 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2910 // Render and notify
2911 application.SendNotification();
2912 application.Render();
2914 Wait(application, 500);
2916 TestEndLongPress(application, 1.0f, 25.0f, 520);
2919 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2921 // Render and notify
2922 application.Render();
2924 Wait(application, 500);
2926 Integration::Scene stage = application.GetScene();
2927 Layer layer = stage.GetRootLayer();
2928 Actor actor = layer.FindChildByName("optionPaste");
2932 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2933 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2934 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2936 Dali::Integration::TouchEvent event;
2937 event = Dali::Integration::TouchEvent();
2938 event.AddPoint(GetPointDownInside(position));
2939 application.ProcessEvent(event);
2941 event = Dali::Integration::TouchEvent();
2942 event.AddPoint(GetPointUpInside(position));
2943 application.ProcessEvent(event);
2945 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2950 int utcDaliTextFieldEvent09(void)
2952 ToolkitTestApplication application;
2953 tet_infoline(" utcDaliTextFieldEvent09");
2955 TextField field = TextField::New();
2956 DALI_TEST_CHECK(field);
2957 application.GetScene().Add(field);
2958 LoadMarkerImages(application, field);
2959 // Render and notify
2960 application.SendNotification();
2961 application.Render();
2963 field.SetProperty(TextField::Property::TEXT, "Hello");
2964 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2965 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2966 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2967 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2969 // Avoid a crash when core load gl resources.
2970 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2972 // Create a tap event to touch the text field.
2973 TestGenerateTap(application, 150.0f, 25.0f);
2974 application.SendNotification();
2975 application.Render();
2978 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2979 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2980 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2981 application.SendNotification();
2982 application.Render();
2984 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2985 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2986 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2987 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2988 application.SendNotification();
2989 application.Render();
2991 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2992 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2993 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2994 for(unsigned int index = 0u; index < 5u; ++index)
2996 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2997 application.SendNotification();
2998 application.Render();
3001 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3002 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3003 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3004 for(unsigned int index = 0u; index < 5u; ++index)
3006 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3007 application.SendNotification();
3008 application.Render();
3011 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3012 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3013 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3014 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3015 application.SendNotification();
3016 application.Render();
3017 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3018 application.SendNotification();
3019 application.Render();
3021 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3022 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3023 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3024 application.SendNotification();
3025 application.Render();
3027 Property::Map mapGet;
3028 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3029 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3030 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3034 int utcDaliTextFieldStyleWhilstSelected(void)
3036 ToolkitTestApplication application;
3037 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3039 // Change font and styles whilst text is selected whilst word selected
3041 TextField field = TextField::New();
3042 DALI_TEST_CHECK(field);
3043 application.GetScene().Add(field);
3044 LoadMarkerImages(application, field);
3045 // Render and notify
3046 application.SendNotification();
3047 application.Render();
3049 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3050 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3051 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3052 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3053 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3055 // Avoid a crash when core load gl resources.
3056 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3057 // Render and notify
3058 application.SendNotification();
3059 application.Render();
3061 // Create a tap event to touch the text field.
3062 TestGenerateTap(application, 150.0f, 25.0f);
3063 // Render and notify
3064 application.SendNotification();
3065 application.Render();
3067 // Tap first to get the focus.
3068 TestGenerateTap(application, 1.0f, 25.0f);
3070 // Render and notify
3071 application.SendNotification();
3072 application.Render();
3074 // Double tap to select a word.
3075 TestGenerateTap(application, 1.0f, 25.0f);
3077 // Render and notify
3078 application.SendNotification();
3079 application.Render();
3081 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3082 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3084 Property::Map fontStyleMapSet;
3085 Property::Map fontStyleMapGet;
3087 fontStyleMapSet.Insert("weight", "bold");
3088 fontStyleMapSet.Insert("slant", "italic");
3089 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3091 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3092 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3093 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3095 fontStyleMapSet.Clear();
3096 fontStyleMapSet.Insert("width", "expanded");
3097 fontStyleMapSet.Insert("slant", "italic");
3098 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3100 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3101 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3102 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3104 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3105 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3107 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3108 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3110 fontStyleMapSet.Clear();
3111 fontStyleMapSet.Insert("weight", "bold");
3112 fontStyleMapSet.Insert("slant", "italic");
3114 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3116 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3117 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3118 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3120 fontStyleMapSet.Clear();
3121 fontStyleMapSet.Insert("width", "expanded");
3123 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3125 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3126 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3127 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3129 // Press Escape to increase coverage
3130 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3131 application.SendNotification();
3132 application.Render();
3134 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3139 int utcDaliTextFieldEscKeyLoseFocus(void)
3141 ToolkitTestApplication application;
3142 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3144 // Creates a tap event. After creating a tap event the text field should
3145 // have the focus and add text with key events should be possible.
3147 TextField field = TextField::New();
3148 DALI_TEST_CHECK(field);
3150 application.GetScene().Add(field);
3152 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3153 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3154 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3156 // Avoid a crash when core load gl resources.
3157 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3159 // Render and notify
3160 application.SendNotification();
3161 application.Render();
3163 // Add a key event but as the text field has not the focus it should do nothing.
3164 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3165 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3167 // Render and notify
3168 application.SendNotification();
3169 application.Render();
3171 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3173 // Create a tap event to touch the text field.
3174 TestGenerateTap(application, 150.0f, 25.0f);
3176 // Render and notify
3177 application.SendNotification();
3178 application.Render();
3180 // Now the text field has the focus, so it can handle the key events.
3181 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3182 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3183 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3184 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3186 // Render and notify
3187 application.SendNotification();
3188 application.Render();
3190 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3192 // Generate a Esc key event. The text field should lose the focus.
3193 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3194 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3196 // Render and notify
3197 application.SendNotification();
3198 application.Render();
3200 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3202 // No more text should be introduced
3203 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3204 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3206 // Render and notify
3207 application.SendNotification();
3208 application.Render();
3210 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3215 int utcDaliTextFieldSomeSpecialKeys(void)
3217 ToolkitTestApplication application;
3218 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3220 // Checks some special keys when the text is selected.
3222 TextField field = TextField::New();
3223 DALI_TEST_CHECK(field);
3224 application.GetScene().Add(field);
3225 LoadMarkerImages(application, field);
3226 // Render and notify
3227 application.SendNotification();
3228 application.Render();
3230 const std::string longText("This is a long text for the size of the text-field.");
3232 field.SetProperty(TextField::Property::TEXT, longText);
3233 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3234 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3235 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3236 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3238 // Avoid a crash when core load gl resources.
3239 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3240 // Render and notify
3241 application.SendNotification();
3242 application.Render();
3244 // Create a tap event to touch the text field.
3245 TestGenerateTap(application, 150.0f, 25.0f);
3247 // Render and notify
3248 application.SendNotification();
3249 application.Render();
3251 // Tap first to get the focus.
3252 TestGenerateTap(application, 1.0f, 25.0f);
3254 // Render and notify
3255 application.SendNotification();
3256 application.Render();
3258 // Double tap to select a word.
3259 TestGenerateTap(application, 1.0f, 25.0f);
3261 // Render and notify
3262 application.SendNotification();
3263 application.Render();
3265 // Generate a Esc key event. The text field should lose the focus.
3266 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3267 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3269 // Render and notify
3270 application.SendNotification();
3271 application.Render();
3273 // Generate a Esc key event. The text field should lose the focus.
3274 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3275 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3277 // Render and notify
3278 application.SendNotification();
3279 application.Render();
3281 // Generate a Esc key event. The text field should lose the focus.
3282 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3283 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3285 // Render and notify
3286 application.SendNotification();
3287 application.Render();
3289 // Generate a Back key event. Nothing happens to the text field.
3290 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3291 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3293 // Render and notify
3294 application.SendNotification();
3295 application.Render();
3297 // The text shouldn't be deleted.
3298 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3303 int utcDaliTextFieldSizeUpdate(void)
3305 ToolkitTestApplication application;
3306 tet_infoline("utcDaliTextFieldSizeUpdate");
3308 // Checks some special keys when the text is selected.
3309 TextField field = TextField::New();
3310 DALI_TEST_CHECK(field);
3311 application.GetScene().Add(field);
3313 float previousHeight = 0.0f;
3314 float currentHeight = 0.0f;
3315 const float fieldWidth = 1920.0f;
3317 // "ㅁ" is bigger then "ኢ"
3318 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3319 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3320 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3322 field.SetProperty(TextField::Property::TEXT, "ኢ");
3323 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3324 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3326 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3327 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3329 application.SendNotification();
3330 application.Render();
3332 previousHeight = field.GetHeightForWidth(fieldWidth);
3333 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3335 // Add another script characters ( glyph height is defferent )
3336 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3337 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3339 application.SendNotification();
3340 application.Render();
3342 currentHeight = field.GetHeightForWidth(fieldWidth);
3343 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3344 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3349 int utcDaliTextFieldExtremlyLargePointSize(void)
3351 ToolkitTestApplication application;
3352 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3354 TextField field = TextField::New();
3356 field.SetProperty(TextField::Property::TEXT, "Text");
3357 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3358 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3359 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3360 application.GetScene().Add(field);
3364 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3365 application.SendNotification();
3366 DALI_TEST_CHECK(field);
3370 tet_result(TET_FAIL);
3375 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3377 ToolkitTestApplication application;
3378 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3379 TextField field = TextField::New();
3380 DALI_TEST_CHECK(field);
3381 application.GetScene().Add(field);
3383 Property::Map fontStyleMapGet;
3385 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3387 Property::Value* weightValue = NULL;
3388 Property::Value* widthValue = NULL;
3389 Property::Value* slantValue = NULL;
3390 weightValue = fontStyleMapGet.Find("weight");
3391 widthValue = fontStyleMapGet.Find("width");
3392 slantValue = fontStyleMapGet.Find("slant");
3393 DALI_TEST_CHECK(!weightValue);
3394 DALI_TEST_CHECK(!widthValue);
3395 DALI_TEST_CHECK(!slantValue);
3400 int UtcDaliTextFieldSettingPlaceholder(void)
3402 ToolkitTestApplication application;
3403 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3405 TextField field = TextField::New();
3406 DALI_TEST_CHECK(field);
3407 application.GetScene().Add(field);
3409 // Check the placeholder property with pixel size
3410 Property::Map placeholderPixelSizeMapSet;
3411 Property::Map placeholderPixelSizeMapGet;
3412 Property::Map placeholderFontstyleMap;
3413 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3414 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3415 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3416 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3417 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3418 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3420 placeholderFontstyleMap.Insert("weight", "bold");
3421 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3422 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3424 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3425 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3426 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3428 // Check the placeholder property with point size
3429 Property::Map placeholderMapSet;
3430 Property::Map placeholderMapGet;
3431 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3432 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3433 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3434 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3435 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3436 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3438 // Check the placeholder font style property
3439 placeholderFontstyleMap.Clear();
3441 placeholderFontstyleMap.Insert("weight", "bold");
3442 placeholderFontstyleMap.Insert("width", "condensed");
3443 placeholderFontstyleMap.Insert("slant", "italic");
3444 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3445 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3447 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3448 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3449 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3451 // Reset font style.
3452 placeholderFontstyleMap.Clear();
3453 placeholderFontstyleMap.Insert("weight", "normal");
3454 placeholderFontstyleMap.Insert("slant", "oblique");
3455 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3456 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3458 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3459 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3460 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3462 placeholderFontstyleMap.Clear();
3463 placeholderFontstyleMap.Insert("slant", "roman");
3464 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3465 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3467 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3469 placeholderFontstyleMap.Clear();
3470 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3472 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3473 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3474 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3475 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3480 int UtcDaliTextFieldPlaceholderCoverage(void)
3482 ToolkitTestApplication application;
3483 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3485 // mPlaceholderFont is created only once, so create a new control for coverage.
3486 TextField fieldForCoverage = TextField::New();
3487 DALI_TEST_CHECK(fieldForCoverage);
3488 application.GetScene().Add(fieldForCoverage);
3490 // for SetPlaceholderFontFamily() coverage.
3491 Property::Map fontFamilyMap;
3492 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3493 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3495 // mPlaceholderFont is created only once, so create a new control for coverage.
3496 fieldForCoverage = TextField::New();
3497 DALI_TEST_CHECK(fieldForCoverage);
3498 application.GetScene().Add(fieldForCoverage);
3500 // for SetPlaceholderTextFontSize coverage.
3501 Property::Map fontSizeMap;
3502 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3503 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3505 // mPlaceholderFont is created only once, so create a new control for coverage.
3506 fieldForCoverage = TextField::New();
3507 DALI_TEST_CHECK(fieldForCoverage);
3508 application.GetScene().Add(fieldForCoverage);
3510 // for SetPlaceholderTextFontWeight coverage.
3511 Property::Map fontStyleWeightMap;
3512 Property::Map fontStyleWeightPropertyMap;
3513 fontStyleWeightPropertyMap.Insert("weight", "bold");
3514 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3515 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3517 // mPlaceholderFont is created only once, so create a new control for coverage.
3518 fieldForCoverage = TextField::New();
3519 DALI_TEST_CHECK(fieldForCoverage);
3520 application.GetScene().Add(fieldForCoverage);
3522 // for SetPlaceholderTextFontWidth coverage.
3523 Property::Map fontStyleWidthMap;
3524 Property::Map fontStyleWidthPropertyMap;
3525 fontStyleWidthPropertyMap.Insert("width", "expanded");
3526 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3527 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3529 // mPlaceholderFont is created only once, so create a new control for coverage.
3530 fieldForCoverage = TextField::New();
3531 DALI_TEST_CHECK(fieldForCoverage);
3532 application.GetScene().Add(fieldForCoverage);
3534 // for SetPlaceholderTextFontSlant coverage.
3535 Property::Map fontStyleSlantMap;
3536 Property::Map fontStyleSlantPropertyMap;
3537 fontStyleSlantPropertyMap.Insert("slant", "italic");
3538 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3539 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3544 int UtcDaliTextFieldSetPaddingProperty(void)
3546 ToolkitTestApplication application;
3547 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3549 TextField field = TextField::New();
3550 DALI_TEST_CHECK(field);
3551 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3552 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3553 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3554 application.GetScene().Add(field);
3556 application.SendNotification();
3557 application.Render();
3559 Vector3 originalSize = field.GetNaturalSize();
3561 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3563 application.SendNotification();
3564 application.Render();
3566 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3568 Vector3 paddingAddedSize = field.GetNaturalSize();
3570 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3572 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3577 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3579 ToolkitTestApplication application;
3580 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3582 TextField field = TextField::New();
3583 DALI_TEST_CHECK(field);
3584 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3585 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3586 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3587 application.GetScene().Add(field);
3589 application.SendNotification();
3590 application.Render();
3592 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3593 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3595 // Check the enable shift selection property
3596 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3597 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3599 application.SendNotification();
3600 application.Render();
3605 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3607 ToolkitTestApplication application;
3608 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3610 TextField field = TextField::New();
3611 DALI_TEST_CHECK(field);
3612 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3613 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3614 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3615 application.GetScene().Add(field);
3617 application.SendNotification();
3618 application.Render();
3620 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3621 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3623 // Check the enable grab handle property
3624 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3625 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3627 application.SendNotification();
3628 application.Render();
3633 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3635 ToolkitTestApplication application;
3636 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3638 TextField field = TextField::New();
3639 DALI_TEST_CHECK(field);
3640 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3641 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3642 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3643 application.GetScene().Add(field);
3645 application.SendNotification();
3646 application.Render();
3648 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3649 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3651 // Check the match system language direction property
3652 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3653 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3655 application.SendNotification();
3656 application.Render();
3661 int utcDaliTextFieldLayoutDirectionCoverage(void)
3663 ToolkitTestApplication application;
3664 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3666 // Creates a tap event. After creating a tap event the text field should
3667 // have the focus and add text with key events should be possible.
3668 TextField field = TextField::New();
3669 DALI_TEST_CHECK(field);
3671 application.GetScene().Add(field);
3673 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3674 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3675 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3677 // Avoid a crash when core load gl resources.
3678 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3680 // Render and notify
3681 application.SendNotification();
3682 application.Render();
3684 // init direction for coverage
3685 // Set horizontal alignment END
3686 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3688 // Create a tap event to touch the text field.
3689 TestGenerateTap(application, 150.0f, 25.0f);
3691 // Render and notify
3692 application.SendNotification();
3693 application.Render();
3695 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3696 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3697 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3699 // Set horizontal alignment BEGIN
3700 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3702 // Create a tap event to touch the text field.
3703 TestGenerateTap(application, 150.0f, 25.0f);
3705 // Render and notify
3706 application.SendNotification();
3707 application.Render();
3709 // Set horizontal alignment CENTER
3710 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3712 // Create a tap event to touch the text field.
3713 TestGenerateTap(application, 150.0f, 25.0f);
3715 // Render and notify
3716 application.SendNotification();
3717 application.Render();
3719 // Set horizontal alignment END
3720 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3722 // Create a tap event to touch the text field.
3723 TestGenerateTap(application, 150.0f, 25.0f);
3725 // Render and notify
3726 application.SendNotification();
3727 application.Render();
3729 // Generate a Esc key event. The text field should lose the focus.
3730 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3731 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3733 // Render and notify
3734 application.SendNotification();
3735 application.Render();
3737 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3742 int UtcDaliTextFieldGetInputMethodContext(void)
3744 ToolkitTestApplication application;
3745 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3747 TextField field = TextField::New();
3748 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3753 int UtcDaliTextFieldSelectWholeText(void)
3755 ToolkitTestApplication application;
3756 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3758 TextField textField = TextField::New();
3760 application.GetScene().Add(textField);
3762 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3763 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3764 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3766 // Avoid a crash when core load gl resources.
3767 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3769 application.SendNotification();
3770 application.Render();
3772 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3774 DevelTextField::SelectWholeText(textField);
3776 application.SendNotification();
3777 application.Render();
3779 // Nothing should have been selected. The number of children is still 1
3780 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3782 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3784 application.SendNotification();
3785 application.Render();
3787 DevelTextField::SelectWholeText(textField);
3789 application.SendNotification();
3790 application.Render();
3792 // Even if resize, selection should remain.
3793 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3795 application.SendNotification();
3796 application.Render();
3798 // Should be 2 children, the stencil and the layer
3799 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3801 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3802 Actor stencil = textField.GetChildAt(0u);
3804 // The highlight actor is drawn first, so is the first actor in the list
3805 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3806 DALI_TEST_CHECK(highlight);
3811 int UtcDaliTextFieldSelectText(void)
3813 ToolkitTestApplication application;
3814 tet_infoline(" UtcDaliTextFieldSelectText ");
3816 TextField textField = TextField::New();
3818 application.GetScene().Add(textField);
3820 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3821 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3822 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3824 // Avoid a crash when core load gl resources.
3825 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3827 application.SendNotification();
3828 application.Render();
3830 DevelTextField::SelectText(textField, 0, 5);
3832 application.SendNotification();
3833 application.Render();
3835 // Nothing is selected
3836 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3837 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3839 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3841 application.SendNotification();
3842 application.Render();
3844 // Hello is selected
3845 DevelTextField::SelectText(textField, 0, 5);
3847 application.SendNotification();
3848 application.Render();
3850 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3851 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3853 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3854 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3856 // world is selected
3857 DevelTextField::SelectText(textField, 6, 11);
3859 application.SendNotification();
3860 application.Render();
3862 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3863 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3865 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3866 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3871 int UtcDaliTextFieldSelectNone(void)
3873 ToolkitTestApplication application;
3874 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3876 TextField textField = TextField::New();
3878 application.GetScene().Add(textField);
3880 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3881 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3882 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3884 // Avoid a crash when core load gl resources.
3885 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3887 application.SendNotification();
3888 application.Render();
3890 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3892 application.SendNotification();
3893 application.Render();
3895 // Nothing is selected
3896 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3897 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3899 DevelTextField::SelectWholeText(textField);
3901 application.SendNotification();
3902 application.Render();
3904 // whole text is selected
3905 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3906 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3908 DevelTextField::SelectNone(textField);
3910 application.SendNotification();
3911 application.Render();
3913 // Nothing is selected
3914 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3915 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3920 int UtcDaliTextFieldSelectRange(void)
3922 ToolkitTestApplication application;
3923 tet_infoline(" UtcDaliTextFieldSelectRange ");
3925 TextField textField = TextField::New();
3927 application.GetScene().Add(textField);
3929 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3930 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3931 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3933 // Avoid a crash when core load gl resources.
3934 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3936 application.SendNotification();
3937 application.Render();
3939 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3941 application.SendNotification();
3942 application.Render();
3944 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3945 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3947 // Hello is selected
3948 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3949 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3951 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3952 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3954 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3955 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3957 // world is selected
3958 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3959 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3961 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3962 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3967 int UtcDaliTextFieldEnableEditing(void)
3969 ToolkitTestApplication application;
3970 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3972 TextField textField = TextField::New();
3974 application.GetScene().Add(textField);
3976 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3977 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3978 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3980 // Avoid a crash when core load gl resources.
3981 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3983 application.SendNotification();
3984 application.Render();
3986 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3987 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3989 textField.SetKeyInputFocus();
3990 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3991 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3993 // Render and notify
3994 application.SendNotification();
3995 application.Render();
3997 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3998 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4000 textField.SetKeyInputFocus();
4001 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4002 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4004 // Render and notify
4005 application.SendNotification();
4006 application.Render();
4008 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4009 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4011 // Check the user interaction enabled and for coverage
4012 DevelTextField::SelectWholeText(textField);
4014 // Render and notify
4015 application.SendNotification();
4016 application.Render();
4018 textField.SetKeyInputFocus();
4019 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4020 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4022 // Render and notify
4023 application.SendNotification();
4024 application.Render();
4026 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4027 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4032 int UtcDaliToolkitTextFieldFontSizeScale(void)
4034 ToolkitTestApplication application;
4035 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4037 TextField textField = TextField::New();
4038 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4039 textField.SetProperty(TextField::Property::TEXT, "Test");
4040 Vector3 nonScaledSize = textField.GetNaturalSize();
4042 TextField textFieldScaled = TextField::New();
4043 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4044 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4045 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4046 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4048 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4050 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4051 textField.SetProperty(TextField::Property::TEXT, "Test");
4052 nonScaledSize = textField.GetNaturalSize();
4054 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4055 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4056 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4057 scaledSize = textFieldScaled.GetNaturalSize();
4059 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4064 int UtcDaliTextFieldPrimaryCursorPosition(void)
4066 ToolkitTestApplication application;
4067 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4069 TextField textField = TextField::New();
4071 application.GetScene().Add(textField);
4073 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4074 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4075 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4076 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4078 // Avoid a crash when core load gl resources.
4079 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4081 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4082 application.SendNotification();
4083 application.Render();
4084 textField.SetKeyInputFocus();
4086 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4088 // Render and notify
4089 application.SendNotification();
4090 application.Render();
4092 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4093 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4098 // test max length when set after setting long text
4099 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4101 ToolkitTestApplication application;
4102 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4103 TextField field = TextField::New();
4104 DALI_TEST_CHECK(field);
4106 application.GetScene().Add(field);
4108 field.SetProperty(TextField::Property::TEXT, "123456789");
4110 const int maxNumberOfCharacters = 3;
4111 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4113 field.SetKeyInputFocus();
4115 // connect to the text max lengh reached signal.
4116 ConnectionTracker* testTracker = new ConnectionTracker();
4117 bool maxLengthReachedSignal = false;
4118 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4120 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4121 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4123 DALI_TEST_CHECK(maxLengthReachedSignal);
4125 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4130 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4132 ToolkitTestApplication application;
4133 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4135 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4136 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4137 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4139 // Create a text field
4140 TextField textField = TextField::New();
4142 //Set size to avoid automatic eliding
4143 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4144 //Set very large font-size using point-size
4145 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4146 //Specify font-family
4147 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4148 //Set text to check if appear or not
4149 textField.SetProperty(TextField::Property::TEXT, "A");
4151 application.GetScene().Add(textField);
4153 application.SendNotification();
4154 application.Render();
4155 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4156 Vector3 naturalSize = textField.GetNaturalSize();
4158 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4159 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4164 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4166 ToolkitTestApplication application;
4167 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4169 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4170 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4171 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4173 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4174 // Create a text editor
4175 TextField textField = TextField::New();
4177 //Set size to avoid automatic eliding
4178 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4179 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4180 textField.SetProperty(TextField::Property::TEXT, "A");
4182 const int numberOfCases = 6;
4183 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4185 for(int index = 0; index < numberOfCases; index++)
4187 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4188 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4189 application.GetScene().Add(textField);
4190 application.SendNotification();
4191 application.Render();
4192 naturalSize = textField.GetNaturalSize();
4193 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4194 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4200 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4202 ToolkitTestApplication application;
4203 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4204 TextField textField = TextField::New();
4206 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4207 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4209 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4210 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4211 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4213 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4214 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4215 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4217 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4218 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4219 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4221 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4222 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4223 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4225 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4226 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4227 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4229 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4230 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4231 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4233 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4234 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4235 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4237 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4238 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4239 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4241 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4242 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4243 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4245 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4246 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4247 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4249 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4250 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4251 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4253 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4254 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4255 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4260 int UtcDaliTextFieldCopyText(void)
4262 ToolkitTestApplication application;
4263 tet_infoline(" UtcDaliTextFieldCopyText ");
4265 TextField textField = TextField::New();
4267 std::string selectedText = "";
4268 std::string copiedText = "";
4270 application.GetScene().Add(textField);
4272 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4273 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4274 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4276 // Avoid a crash when core load gl resources.
4277 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4279 application.SendNotification();
4280 application.Render();
4282 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4284 application.SendNotification();
4285 application.Render();
4287 // Hello is selected
4288 DevelTextField::SelectText(textField, 0, 5);
4290 application.SendNotification();
4291 application.Render();
4293 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4294 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4296 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4297 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4300 copiedText = DevelTextField::CopyText(textField);
4301 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4303 // world is selected
4304 DevelTextField::SelectText(textField, 6, 11);
4306 application.SendNotification();
4307 application.Render();
4309 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4310 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4312 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4313 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4316 copiedText = DevelTextField::CopyText(textField);
4317 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4319 // "lo wo" is selected
4320 DevelTextField::SelectText(textField, 3, 8);
4322 application.SendNotification();
4323 application.Render();
4325 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4326 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4328 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4329 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4331 // "lo wo" is copied
4332 copiedText = DevelTextField::CopyText(textField);
4333 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4338 int UtcDaliTextFieldCutText(void)
4340 ToolkitTestApplication application;
4341 tet_infoline(" UtcDaliTextFieldCutText ");
4343 TextField textField = TextField::New();
4345 std::string selectedText = "";
4347 application.GetScene().Add(textField);
4349 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4350 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4351 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4353 // Avoid a crash when core load gl resources.
4354 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4356 application.SendNotification();
4357 application.Render();
4359 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4361 application.SendNotification();
4362 application.Render();
4364 // Hello is selected
4365 DevelTextField::SelectText(textField, 0, 5);
4367 application.SendNotification();
4368 application.Render();
4370 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4371 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4373 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4374 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4377 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4379 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4382 DevelTextField::SelectText(textField, 0, 2);
4384 application.SendNotification();
4385 application.Render();
4387 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4388 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4390 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4391 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4394 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4396 application.SendNotification();
4397 application.Render();
4399 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4401 // Test Cut from the middle
4404 DevelTextField::SelectText(textField, 1, 3);
4406 application.SendNotification();
4407 application.Render();
4409 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4410 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4412 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4413 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4416 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4418 application.SendNotification();
4419 application.Render();
4421 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4423 // Test Cut from the end
4426 DevelTextField::SelectText(textField, 1, 2);
4428 application.SendNotification();
4429 application.Render();
4431 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4432 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4434 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4435 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4438 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4440 application.SendNotification();
4441 application.Render();
4443 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4448 int UtcDaliTextFieldPasteText(void)
4450 ToolkitTestApplication application;
4451 tet_infoline(" UtcDaliTextFieldPasteText ");
4453 TextField textField = TextField::New();
4455 application.GetScene().Add(textField);
4457 std::string cutText = "";
4458 std::string copiedText = "";
4460 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4461 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4462 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4464 // Avoid a crash when core load gl resources.
4465 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4467 application.SendNotification();
4468 application.Render();
4470 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4472 application.SendNotification();
4473 application.Render();
4475 // Tap on the text editor
4476 TestGenerateTap(application, 3.0f, 25.0f);
4478 // Render and notify
4479 application.SendNotification();
4480 application.Render();
4482 // Select some text in the right of the current cursor position
4483 DevelTextField::SelectText(textField, 0, 3);
4485 // Render and notify
4486 application.SendNotification();
4487 application.Render();
4489 // Cut the selected text
4490 cutText = DevelTextField::CutText(textField);
4492 // Render and notify
4493 application.SendNotification();
4494 application.Render();
4496 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4497 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4499 DevelTextField::SelectText(textField, 0, 3);
4501 // Render and notify
4502 application.SendNotification();
4503 application.Render();
4505 // Copy the selected text
4506 copiedText = DevelTextField::CopyText(textField);
4508 // Render and notify
4509 application.SendNotification();
4510 application.Render();
4512 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4513 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4515 // Move the cursor to the end of the line
4516 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4517 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4518 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4519 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4520 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4522 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4523 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4525 // Render and notify
4526 application.SendNotification();
4527 application.Render();
4529 // Paste the selected text at the current cursor position
4530 DevelTextField::PasteText(textField);
4532 // Render and notify
4533 application.SendNotification();
4534 application.Render();
4536 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4541 int utcDaliTextFieldCursorPositionChangedSignal(void)
4543 ToolkitTestApplication application;
4544 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4546 TextField field = TextField::New();
4547 DALI_TEST_CHECK(field);
4549 application.GetScene().Add(field);
4551 // connect to the selection changed signal.
4552 ConnectionTracker* testTracker = new ConnectionTracker();
4553 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4554 bool cursorPositionChangedSignal = false;
4555 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4557 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4558 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4559 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4560 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4561 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4563 // Avoid a crash when core load gl resources.
4564 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4566 // Render and notify
4567 application.SendNotification();
4568 application.Render();
4570 field.SetKeyInputFocus();
4572 // Tap on the text field
4573 TestGenerateTap(application, 3.0f, 25.0f);
4575 // Render and notify
4576 application.SendNotification();
4577 application.Render();
4579 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4580 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4582 gCursorPositionChangedCallbackCalled = false;
4585 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4587 // Render and notify
4588 application.SendNotification();
4589 application.Render();
4591 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4592 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4594 gCursorPositionChangedCallbackCalled = false;
4597 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4599 // Render and notify
4600 application.SendNotification();
4601 application.Render();
4603 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4604 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4606 gCursorPositionChangedCallbackCalled = false;
4608 //delete one character
4609 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4611 // Render and notify
4612 application.SendNotification();
4613 application.Render();
4615 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4616 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4618 gCursorPositionChangedCallbackCalled = false;
4620 field.SetProperty(TextField::Property::TEXT, "Hello");
4622 // Render and notify
4623 application.SendNotification();
4624 application.Render();
4626 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4627 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4629 gCursorPositionChangedCallbackCalled = false;
4631 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4633 // Render and notify
4634 application.SendNotification();
4635 application.Render();
4637 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4638 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4643 int utcDaliTextFieldGeometryEllipsisStart(void)
4645 ToolkitTestApplication application;
4646 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4648 TextField field = TextField::New();
4649 DALI_TEST_CHECK(field);
4651 application.GetScene().Add(field);
4653 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4654 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4655 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4656 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4657 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4658 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4659 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4660 field.SetProperty(TextField::Property::TEXT, "Hello World");
4662 // Avoid a crash when core load gl resources.
4663 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4665 // Render and notify
4666 application.SendNotification();
4667 application.Render();
4669 unsigned int expectedCount = 1;
4670 unsigned int startIndex = 0;
4671 unsigned int endIndex = 10;
4673 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4674 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4676 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4677 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4679 Vector<Vector2> expectedSizes;
4680 Vector<Vector2> expectedPositions;
4682 expectedPositions.PushBack(Vector2(14, 0));
4683 expectedSizes.PushBack(Vector2(106, 25));
4685 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4690 int utcDaliTextFieldGeometryEllipsisEnd(void)
4692 ToolkitTestApplication application;
4693 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4695 TextField field = TextField::New();
4696 DALI_TEST_CHECK(field);
4698 application.GetScene().Add(field);
4700 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4701 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4702 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4703 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4704 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4705 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4706 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4707 field.SetProperty(TextField::Property::TEXT, "Hello World");
4709 // Avoid a crash when core load gl resources.
4710 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4712 // Render and notify
4713 application.SendNotification();
4714 application.Render();
4716 unsigned int expectedCount = 1;
4717 unsigned int startIndex = 0;
4718 unsigned int endIndex = 10;
4720 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4721 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4723 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4724 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4726 Vector<Vector2> expectedSizes;
4727 Vector<Vector2> expectedPositions;
4729 expectedPositions.PushBack(Vector2(-2, 0));
4730 expectedSizes.PushBack(Vector2(122, 25));
4732 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4737 int utcDaliTextFieldGeometryRTL(void)
4739 ToolkitTestApplication application;
4740 tet_infoline(" utcDaliTextFieldGeometryRTL");
4742 TextField field = TextField::New();
4743 DALI_TEST_CHECK(field);
4745 application.GetScene().Add(field);
4747 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4748 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4749 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4750 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4751 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4752 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4754 // Avoid a crash when core load gl resources.
4755 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4757 // Render and notify
4758 application.SendNotification();
4759 application.Render();
4761 unsigned int expectedCount = 1;
4762 unsigned int startIndex = 1;
4763 unsigned int endIndex = 7;
4765 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4766 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4768 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4769 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4771 Vector<Vector2> expectedSizes;
4772 Vector<Vector2> expectedPositions;
4774 expectedPositions.PushBack(Vector2(38, 0));
4775 expectedSizes.PushBack(Vector2(73, 25));
4777 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4782 int utcDaliTextFieldGeometryGlyphMiddle(void)
4784 ToolkitTestApplication application;
4785 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4787 TextField field = TextField::New();
4788 DALI_TEST_CHECK(field);
4790 application.GetScene().Add(field);
4792 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4793 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4794 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4795 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4796 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4797 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4799 // Avoid a crash when core load gl resources.
4800 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4802 // Render and notify
4803 application.SendNotification();
4804 application.Render();
4806 unsigned int expectedCount = 1;
4807 unsigned int startIndex = 1;
4808 unsigned int endIndex = 13;
4810 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4811 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4813 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4814 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4816 Vector<Vector2> expectedSizes;
4817 Vector<Vector2> expectedPositions;
4819 expectedPositions.PushBack(Vector2(6, 0));
4820 expectedSizes.PushBack(Vector2(124, 25));
4822 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4827 int utcDaliTextFieldSelectionClearedSignal(void)
4829 ToolkitTestApplication application;
4830 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4832 TextField field = TextField::New();
4833 DALI_TEST_CHECK(field);
4835 application.GetScene().Add(field);
4837 // connect to the selection changed signal.
4838 ConnectionTracker* testTracker = new ConnectionTracker();
4839 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4840 bool selectionClearedSignal = false;
4841 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4843 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4844 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4845 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4846 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4847 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4849 // Avoid a crash when core load gl resources.
4850 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4852 // Render and notify
4853 application.SendNotification();
4854 application.Render();
4856 // Tap on the text editor
4857 TestGenerateTap(application, 3.0f, 25.0f);
4859 // Render and notify
4860 application.SendNotification();
4861 application.Render();
4863 // Move to second line of the text & Select some text in the right of the current cursor position
4864 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4865 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4868 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4870 // Render and notify
4871 application.SendNotification();
4872 application.Render();
4874 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4876 // Render and notify
4877 application.SendNotification();
4878 application.Render();
4880 // Tap on the text editor
4881 TestGenerateTap(application, 3.0f, 25.0f);
4883 // Render and notify
4884 application.SendNotification();
4885 application.Render();
4887 gSelectionClearedCallbackCalled = false;
4889 // Move to second line of the text & select.
4890 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4891 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4894 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4896 // Render and notify
4897 application.SendNotification();
4898 application.Render();
4900 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4902 gSelectionClearedCallbackCalled = false;
4904 // Render and notify
4905 application.SendNotification();
4906 application.Render();
4908 // Move to second line of the text & select.
4909 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4910 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4912 // replace D with selected text
4913 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4915 // Render and notify
4916 application.SendNotification();
4917 application.Render();
4919 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4921 gSelectionClearedCallbackCalled = false;
4923 // Render and notify
4924 application.SendNotification();
4925 application.Render();
4927 DevelTextField::SelectText(field, 1, 3);
4929 // Render and notify
4930 application.SendNotification();
4931 application.Render();
4933 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4935 // Render and notify
4936 application.SendNotification();
4937 application.Render();
4939 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4941 gSelectionClearedCallbackCalled = false;
4943 DevelTextField::SelectText(field, 1, 3);
4945 // Render and notify
4946 application.SendNotification();
4947 application.Render();
4950 DevelTextField::SelectNone(field);
4952 // Render and notify
4953 application.SendNotification();
4954 application.Render();
4956 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4961 int utcDaliTextFieldSelectionStartedSignal(void)
4963 ToolkitTestApplication application;
4964 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4966 TextField field = TextField::New();
4967 DALI_TEST_CHECK(field);
4969 application.GetScene().Add(field);
4971 // connect to the selection changed signal.
4972 ConnectionTracker* testTracker = new ConnectionTracker();
4973 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4974 bool selectionStartedSignal = false;
4975 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4977 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4978 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4979 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4980 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4981 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4983 // Avoid a crash when core load gl resources.
4984 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4986 // Render and notify
4987 application.SendNotification();
4988 application.Render();
4990 // Tap on the text field
4991 TestGenerateTap(application, 3.0f, 25.0f);
4993 // Render and notify
4994 application.SendNotification();
4995 application.Render();
4997 // Move to second line of the text & Select some text in the right of the current cursor position
4998 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4999 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5001 // Render and notify
5002 application.SendNotification();
5003 application.Render();
5005 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5008 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5010 // Render and notify
5011 application.SendNotification();
5012 application.Render();
5014 gSelectionStartedCallbackCalled = false;
5016 DevelTextField::SelectText(field, 1, 3);
5018 // Render and notify
5019 application.SendNotification();
5020 application.Render();
5022 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5027 int utcDaliTextFieldSelectionChangedSignal(void)
5029 ToolkitTestApplication application;
5030 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5032 TextField field = TextField::New();
5033 DALI_TEST_CHECK(field);
5035 application.GetScene().Add(field);
5037 // connect to the selection changed signal.
5038 ConnectionTracker* testTracker = new ConnectionTracker();
5039 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5040 bool selectionChangedSignal = false;
5041 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5043 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5044 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5045 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5046 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5047 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5049 // Avoid a crash when core load gl resources.
5050 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5052 // Render and notify
5053 application.SendNotification();
5054 application.Render();
5056 // Tap on the text field
5057 TestGenerateTap(application, 3.0f, 25.0f);
5059 // Render and notify
5060 application.SendNotification();
5061 application.Render();
5063 // Select some text in the right of the current cursor position
5064 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5065 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5067 // Render and notify
5068 application.SendNotification();
5069 application.Render();
5071 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5072 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5074 gSelectionChangedCallbackCalled = false;
5076 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5078 // Render and notify
5079 application.SendNotification();
5080 application.Render();
5082 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5083 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5084 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5086 gSelectionChangedCallbackCalled = false;
5088 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5090 // Render and notify
5091 application.SendNotification();
5092 application.Render();
5094 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5095 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5096 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5098 gSelectionChangedCallbackCalled = false;
5099 field.SetKeyInputFocus();
5101 // Render and notify
5102 application.SendNotification();
5103 application.Render();
5105 DevelTextField::SelectText(field, 0, 5);
5107 application.SendNotification();
5108 application.Render();
5110 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5111 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5113 gSelectionChangedCallbackCalled = false;
5115 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5117 // Render and notify
5118 application.SendNotification();
5119 application.Render();
5121 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5122 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5123 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5125 gSelectionChangedCallbackCalled = false;
5128 DevelTextField::SelectWholeText(field);
5130 // Render and notify
5131 application.SendNotification();
5132 application.Render();
5134 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5135 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5137 gSelectionChangedCallbackCalled = false;
5140 DevelTextField::SelectNone(field);
5142 // Render and notify
5143 application.SendNotification();
5144 application.Render();
5146 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5147 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5148 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5153 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5155 ToolkitTestApplication application;
5156 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5158 TextField textField = TextField::New();
5159 textField.SetProperty(TextField::Property::TEXT, "Test");
5160 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5161 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5162 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5164 application.GetScene().Add(textField);
5165 application.SendNotification();
5166 application.Render();
5168 Property::Map strikethroughMapSet;
5169 Property::Map strikethroughMapGet;
5171 strikethroughMapSet.Insert("enable", true);
5172 strikethroughMapSet.Insert("color", Color::RED);
5173 strikethroughMapSet.Insert("height", 2.0f);
5175 // Check the strikethrough property
5176 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5177 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5178 textField.SetProperty(TextField::Property::TEXT, "Test1");
5179 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5180 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5182 // Render and notify
5183 application.SendNotification();
5184 application.Render();
5186 strikethroughMapSet.Clear();
5187 strikethroughMapGet.Clear();
5192 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5194 ToolkitTestApplication application;
5195 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5197 TextField textField = TextField::New();
5198 textField.SetProperty(TextField::Property::TEXT, "Test");
5199 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5200 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5201 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5203 application.GetScene().Add(textField);
5204 application.SendNotification();
5205 application.Render();
5207 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5209 // Check the strikethrough property
5210 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5211 textField.SetProperty(TextField::Property::TEXT, "Test1");
5212 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5214 // Render and notify
5215 application.SendNotification();
5216 application.Render();
5221 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5223 ToolkitTestApplication application;
5224 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5225 TextField field = TextField::New();
5226 field.SetProperty(TextField::Property::TEXT, "Test");
5227 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5228 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5229 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5231 application.GetScene().Add(field);
5232 application.SendNotification();
5233 application.Render();
5235 Property::Map underlineMapSet;
5236 Property::Map underlineMapGet;
5238 underlineMapSet.Insert("enable", true);
5239 underlineMapSet.Insert("color", Color::RED);
5240 underlineMapSet.Insert("height", 1);
5241 underlineMapSet.Insert("type", Text::Underline::SOLID);
5242 underlineMapSet.Insert("dashWidth", 2);
5243 underlineMapSet.Insert("dashGap", 1);
5245 // Check the underline property
5246 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5248 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5249 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5250 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5252 // Render and notify
5253 application.SendNotification();
5254 application.Render();
5256 underlineMapSet.Clear();
5257 underlineMapGet.Clear();
5259 underlineMapSet.Insert("enable", true);
5260 underlineMapSet.Insert("color", Color::BLUE);
5261 underlineMapSet.Insert("height", 1);
5262 underlineMapSet.Insert("type", Text::Underline::DASHED);
5263 underlineMapSet.Insert("dashWidth", 4);
5264 underlineMapSet.Insert("dashGap", 2);
5266 // Check the dashed underline property
5267 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5269 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5270 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5271 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5273 // Render and notify
5274 application.SendNotification();
5275 application.Render();
5277 underlineMapSet.Clear();
5278 underlineMapGet.Clear();
5280 underlineMapSet.Insert("enable", true);
5281 underlineMapSet.Insert("color", Color::BLUE);
5282 underlineMapSet.Insert("height", 1);
5283 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5284 underlineMapSet.Insert("dashWidth", 4);
5285 underlineMapSet.Insert("dashGap", 2);
5287 // Check the dashed underline property
5288 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5290 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5291 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5292 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5294 // Render and notify
5295 application.SendNotification();
5296 application.Render();
5298 underlineMapSet.Clear();
5299 underlineMapGet.Clear();
5304 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5306 ToolkitTestApplication application;
5307 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5309 TextField field1 = TextField::New();
5310 field1.SetProperty(TextField::Property::TEXT, "Test");
5311 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5312 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5313 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5315 Property::Map underlineMapSet1;
5316 Property::Map underlineMapGet1;
5318 underlineMapSet1.Insert("enable", true);
5319 underlineMapSet1.Insert("color", Color::RED);
5320 underlineMapSet1.Insert("height", 1);
5321 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5322 underlineMapSet1.Insert("dashWidth", 2);
5323 underlineMapSet1.Insert("dashGap", 1);
5325 // Check the underline property
5326 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5328 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5329 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5330 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5332 application.GetScene().Add(field1);
5333 application.SendNotification();
5334 application.Render();
5336 TextField field2 = TextField::New();
5337 field2.SetProperty(TextField::Property::TEXT, "Test");
5338 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5339 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5340 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5342 Property::Map underlineMapSet2;
5343 Property::Map underlineMapGet2;
5345 underlineMapSet2.Insert("enable", true);
5346 underlineMapSet2.Insert("color", Color::BLUE);
5347 underlineMapSet2.Insert("height", 1);
5348 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5349 underlineMapSet2.Insert("dashWidth", 4);
5350 underlineMapSet2.Insert("dashGap", 2);
5352 // Check the dashed underline property
5353 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5355 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5356 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5357 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5359 application.GetScene().Add(field2);
5360 application.SendNotification();
5361 application.Render();
5363 TextField field3 = TextField::New();
5364 field3.SetProperty(TextField::Property::TEXT, "Test");
5365 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5366 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5367 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5369 Property::Map underlineMapSet3;
5370 Property::Map underlineMapGet3;
5372 underlineMapSet3.Insert("enable", true);
5373 underlineMapSet3.Insert("color", Color::BLUE);
5374 underlineMapSet3.Insert("height", 1);
5375 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5376 underlineMapSet3.Insert("dashWidth", 4);
5377 underlineMapSet3.Insert("dashGap", 2);
5379 // Check the dashed underline property
5380 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5382 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5383 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5384 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5386 application.GetScene().Add(field3);
5388 application.SendNotification();
5389 application.Render();
5394 int UtcDaliTextFieldCharacterSpacing(void)
5396 ToolkitTestApplication application;
5397 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5399 TextField textField = TextField::New();
5401 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5403 application.GetScene().Add(textField);
5404 application.SendNotification();
5405 application.Render();
5407 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5408 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5409 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5411 application.SendNotification();
5412 application.Render();
5417 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5419 ToolkitTestApplication application;
5420 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5422 TextField field1 = TextField::New();
5423 field1.SetProperty(TextField::Property::TEXT, "Test1");
5424 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5425 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5426 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5428 Property::Map underlineMapSet1;
5429 Property::Map underlineMapGet1;
5431 underlineMapSet1.Insert("enable", true);
5432 underlineMapSet1.Insert("color", Color::RED);
5433 underlineMapSet1.Insert("height", 1);
5434 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5435 underlineMapSet1.Insert("dashWidth", 2);
5436 underlineMapSet1.Insert("dashGap", 1);
5438 // Check the underline property
5439 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5440 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5442 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5443 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5444 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5446 application.GetScene().Add(field1);
5447 application.SendNotification();
5448 application.Render();
5453 int UtcDaliToolkitTextfieldParagraphTag(void)
5455 ToolkitTestApplication application;
5456 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5457 TextField fieldNewlineSeparator = TextField::New();
5458 TextField fieldParagraphTag = TextField::New();
5459 DALI_TEST_CHECK(fieldNewlineSeparator);
5460 DALI_TEST_CHECK(fieldParagraphTag);
5462 application.GetScene().Add(fieldNewlineSeparator);
5463 application.GetScene().Add(fieldParagraphTag);
5465 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5466 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5467 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5468 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5469 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5470 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5472 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5473 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5474 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5475 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5476 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5478 application.SendNotification();
5479 application.Render();
5481 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5482 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5484 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5486 application.SendNotification();
5487 application.Render();
5492 //Handle Emoji clustering for cursor handling
5493 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5495 ToolkitTestApplication application;
5496 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5497 TextField textField = TextField::New();
5498 DALI_TEST_CHECK(textField);
5500 application.GetScene().Add(textField);
5502 // Avoid a crash when core load gl resources.
5503 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5505 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5506 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5508 // Render and notify
5509 application.SendNotification();
5510 application.Render();
5513 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5514 application.SendNotification();
5515 application.Render();
5517 // Set focus and remove Emoji
5518 textField.SetKeyInputFocus();
5519 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5521 //Check the changed text and cursor position
5522 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5523 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5525 // Render and notify
5526 application.SendNotification();
5527 application.Render();
5532 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5534 ToolkitTestApplication application;
5535 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5536 TextField textField = TextField::New();
5537 DALI_TEST_CHECK(textField);
5539 application.GetScene().Add(textField);
5541 // Avoid a crash when core load gl resources.
5542 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5544 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5545 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5547 // Render and notify
5548 application.SendNotification();
5549 application.Render();
5552 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5553 application.SendNotification();
5554 application.Render();
5556 // Set focus and remove Emoji
5557 textField.SetKeyInputFocus();
5558 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5560 //Check the changed text and cursor position
5561 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5562 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5564 // Render and notify
5565 application.SendNotification();
5566 application.Render();