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.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
21 #include <dali-toolkit/devel-api/text/rendering-backend.h>
22 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
24 #include <dali/devel-api/actors/actor-devel.h>
25 #include <dali/devel-api/adaptor-framework/clipboard.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali/integration-api/events/key-event-integ.h>
29 #include <dali/integration-api/events/touch-event-integ.h>
30 #include <dali/public-api/rendering/renderer.h>
34 #include "test-text-geometry-utils.h"
37 using namespace Toolkit;
39 void dali_texteditor_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_texteditor_cleanup(void)
46 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
59 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
60 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
61 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
62 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
64 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
65 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
67 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
75 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
76 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
77 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
78 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
79 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
80 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
82 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
83 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
84 const char* const PROPERTY_NAME_UNDERLINE = "underline";
85 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
86 const char* const PROPERTY_NAME_SHADOW = "shadow";
87 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
88 const char* const PROPERTY_NAME_EMBOSS = "emboss";
89 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
90 const char* const PROPERTY_NAME_OUTLINE = "outline";
91 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
92 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
93 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
95 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
96 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
97 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
98 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
99 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
102 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
103 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
104 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
105 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
110 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
111 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
112 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
113 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
114 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
115 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
117 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
118 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
120 const float RENDER_FRAME_INTERVAL = 16.66f;
122 const unsigned int DEFAULT_FONT_SIZE = 1152u;
123 const std::string DEFAULT_FONT_DIR("/resources/fonts");
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
127 const int KEY_C_CODE = 54;
128 const int KEY_V_CODE = 55;
129 const int KEY_X_CODE = 53;
130 const int KEY_WHITE_SPACE_CODE = 65;
132 const int KEY_SHIFT_MODIFIER = 257;
133 const int KEY_CONTROL_MODIFIER = 258;
135 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
136 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
137 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
139 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
141 static bool gSelectionChangedCallbackCalled;
142 static uint32_t oldSelectionStart;
143 static uint32_t oldSelectionEnd;
144 static bool gSelectionClearedCallbackCalled;
145 static bool gSelectionStartedCallbackCalled;
146 static bool gAnchorClickedCallBackCalled;
147 static bool gAnchorClickedCallBackNotCalled;
148 static bool gTextChangedCallBackCalled;
149 static bool gInputFilteredAcceptedCallbackCalled;
150 static bool gInputFilteredRejectedCallbackCalled;
151 static bool gInputStyleChangedCallbackCalled;
152 static bool gMaxCharactersCallBackCalled;
153 static bool gCursorPositionChangedCallbackCalled;
154 static uint32_t oldCursorPos;
155 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
157 struct CallbackFunctor
159 CallbackFunctor(bool* callbackFlag)
160 : mCallbackFlag(callbackFlag)
166 *mCallbackFlag = true;
171 static void TestSelectionStartedCallback(TextEditor control)
173 tet_infoline(" TestSelectionStartedCallback");
175 gSelectionStartedCallbackCalled = true;
178 static void TestSelectionClearedCallback(TextEditor control)
180 tet_infoline(" TestSelectionClearedCallback");
182 gSelectionClearedCallbackCalled = true;
185 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
187 tet_infoline(" TestSelectionChangedCallback");
189 gSelectionChangedCallbackCalled = true;
190 oldSelectionStart = oldStart;
191 oldSelectionEnd = oldEnd;
194 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
196 tet_infoline(" TestAnchorClickedCallback");
198 gAnchorClickedCallBackNotCalled = false;
200 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
202 gAnchorClickedCallBackCalled = true;
206 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
208 tet_infoline(" TestCursorPositionChangedCallback");
210 gCursorPositionChangedCallbackCalled = true;
211 oldCursorPos = oldPos;
214 static void TestTextChangedCallback(TextEditor control)
216 tet_infoline(" TestTextChangedCallback");
218 gTextChangedCallBackCalled = true;
221 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
223 tet_infoline(" TestInputStyleChangedCallback");
225 gInputStyleChangedCallbackCalled = true;
226 gInputStyleMask = mask;
229 static void TestMaxLengthReachedCallback(TextEditor control)
231 tet_infoline(" TestMaxLengthReachedCallback");
233 gMaxCharactersCallBackCalled = true;
236 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
238 tet_infoline(" TestInputFilteredCallback");
240 if(type == Toolkit::InputFilter::Property::ACCEPTED)
242 gInputFilteredAcceptedCallbackCalled = true;
244 else if(type == Toolkit::InputFilter::Property::REJECTED)
246 gInputFilteredRejectedCallbackCalled = true;
250 // Generate a KeyEvent to send to Core.
251 Integration::KeyEvent GenerateKey(const std::string& keyName,
252 const std::string& logicalKey,
253 const std::string& keyString,
256 unsigned long timeStamp,
257 const Integration::KeyEvent::State& keyState,
258 const std::string& compose = "",
259 const std::string& deviceName = DEFAULT_DEVICE_NAME,
260 const Device::Class::Type& deviceClass = Device::Class::NONE,
261 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
263 return Integration::KeyEvent(keyName,
276 Dali::Integration::Point GetPointDownInside(Vector2& pos)
278 Dali::Integration::Point point;
279 point.SetState(PointState::DOWN);
280 point.SetScreenPosition(pos);
284 Dali::Integration::Point GetPointUpInside(Vector2& pos)
286 Dali::Integration::Point point;
287 point.SetState(PointState::UP);
288 point.SetScreenPosition(pos);
292 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
294 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
296 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
298 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
300 Property::Value* valueSet = NULL;
301 if(valueGet.first.type == Property::Key::INDEX)
303 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
307 // Get Key is a string so searching Set Map for a string key
308 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
313 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
315 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
318 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
320 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
323 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
325 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
328 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
330 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
333 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
335 Vector2 vector2Get = valueGet.second.Get<Vector2>();
336 Vector2 vector2Set = valueSet->Get<Vector2>();
337 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
340 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
342 Vector4 vector4Get = valueGet.second.Get<Vector4>();
343 Vector4 vector4Set = valueSet->Get<Vector4>();
344 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);
350 if(valueGet.first.type == Property::Key::INDEX)
352 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
356 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
366 class ScrollStateChangeCallback : public Dali::ConnectionTracker
369 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
370 : mStartedCalled(startedCalled),
371 mFinishedCalled(finishedCalled)
375 void Callback(TextEditor editor, TextEditor::Scroll::Type type)
377 if(type == TextEditor::Scroll::STARTED)
379 mStartedCalled = true;
381 else if(type == TextEditor::Scroll::FINISHED)
383 mFinishedCalled = true;
387 bool& mStartedCalled;
388 bool& mFinishedCalled;
393 int UtcDaliToolkitTextEditorConstructorP(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
397 TextEditor textEditor;
398 DALI_TEST_CHECK(!textEditor);
402 int UtcDaliToolkitTextEditorNewP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextEditorNewP");
406 TextEditor textEditor = TextEditor::New();
407 DALI_TEST_CHECK(textEditor);
411 int UtcDaliToolkitTextEditorDownCastP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
415 TextEditor textEditor1 = TextEditor::New();
416 BaseHandle object(textEditor1);
418 TextEditor textEditor2 = TextEditor::DownCast(object);
419 DALI_TEST_CHECK(textEditor2);
421 TextEditor textEditor3 = DownCast<TextEditor>(object);
422 DALI_TEST_CHECK(textEditor3);
426 int UtcDaliToolkitTextEditorDownCastN(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
430 BaseHandle uninitializedObject;
431 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
432 DALI_TEST_CHECK(!textEditor1);
434 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
435 DALI_TEST_CHECK(!textEditor2);
439 int UtcDaliToolkitTextEditorCopyConstructorP(void)
441 ToolkitTestApplication application;
442 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
443 TextEditor textEditor = TextEditor::New();
444 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
446 TextEditor copy(textEditor);
447 DALI_TEST_CHECK(copy);
448 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
452 int UtcDaliTextEditorMoveConstructor(void)
454 ToolkitTestApplication application;
456 TextEditor textEditor = TextEditor::New();
457 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
458 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
460 TextEditor moved = std::move(textEditor);
461 DALI_TEST_CHECK(moved);
462 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
463 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
464 DALI_TEST_CHECK(!textEditor);
469 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
473 TextEditor textEditor = TextEditor::New();
474 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
476 TextEditor copy = textEditor;
477 DALI_TEST_CHECK(copy);
478 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
482 int UtcDaliTextEditorMoveAssignment(void)
484 ToolkitTestApplication application;
486 TextEditor textEditor = TextEditor::New();
487 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
488 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
491 moved = std::move(textEditor);
492 DALI_TEST_CHECK(moved);
493 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
494 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
495 DALI_TEST_CHECK(!textEditor);
500 int UtcDaliTextEditorNewP(void)
502 ToolkitTestApplication application;
503 tet_infoline(" UtcDaliToolkitTextEditorNewP");
504 TextEditor textEditor = TextEditor::New();
505 DALI_TEST_CHECK(textEditor);
509 // Positive test case for a method
510 int UtcDaliTextEditorGetPropertyP(void)
512 ToolkitTestApplication application;
513 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
514 TextEditor editor = TextEditor::New();
515 DALI_TEST_CHECK(editor);
517 // Check Property Indices are correct
518 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
519 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
520 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
521 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
522 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
523 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
524 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
525 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
526 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
527 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
528 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
529 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
530 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
531 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
532 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
533 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
534 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
535 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
536 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
537 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
538 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
539 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
540 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
541 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
542 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
543 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
544 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
545 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
546 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
547 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
549 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
550 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
551 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
552 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
553 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
554 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
555 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
556 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
557 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
558 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
559 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
560 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
561 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
562 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
563 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
564 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
565 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
566 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
567 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
568 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
569 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
570 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
571 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
572 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
574 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
575 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
576 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
577 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
578 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
579 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
580 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
581 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
582 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
583 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
588 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
591 Property::Map imageMap;
592 imageMap[mapKey] = mapValue;
594 editor.SetProperty(property, imageMap);
595 Property::Value propValue = editor.GetProperty(property);
596 Property::Map* resultMap = propValue.GetMap();
598 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
606 // Positive test case for a method
607 int UtcDaliTextEditorSetPropertyP(void)
609 ToolkitTestApplication application;
610 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
611 TextEditor editor = TextEditor::New();
612 DALI_TEST_CHECK(editor);
613 application.GetScene().Add(editor);
615 // Note - we can't check the defaults since the stylesheets are platform-specific
617 // Check the render backend property.
618 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
619 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
621 // Check text property.
622 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
623 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
625 // Check text's color property
626 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
627 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
629 // Check font properties.
630 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
631 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
633 Property::Map fontStyleMapSet;
634 Property::Map fontStyleMapGet;
635 Property::Value* slantValue = NULL;
637 fontStyleMapSet.Insert("weight", "bold");
638 fontStyleMapSet.Insert("width", "condensed");
639 fontStyleMapSet.Insert("slant", "italic");
641 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
642 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
643 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
644 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
646 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
647 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
649 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
650 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
651 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
653 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
654 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
655 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
658 fontStyleMapSet.Clear();
659 fontStyleMapSet.Insert("weight", "normal");
660 fontStyleMapSet.Insert("slant", "oblique");
661 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
662 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
663 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
664 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
666 fontStyleMapSet.Clear();
667 fontStyleMapSet.Insert("slant", "roman");
668 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
669 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
671 // Replace 'roman' for 'normal'.
672 slantValue = fontStyleMapGet.Find("slant");
673 if(NULL != slantValue)
675 if("normal" == slantValue->Get<std::string>())
677 fontStyleMapGet["slant"] = "roman";
680 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
681 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
683 fontStyleMapSet.Clear();
685 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
686 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
687 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
688 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
690 // Check that the Alignment properties can be correctly set
691 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
692 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
694 // Check that the Alignment properties can be correctly set
695 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
696 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
697 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
698 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
699 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
700 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
702 // Check scroll properties.
703 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
704 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
705 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
706 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
708 // Check cursor properties
709 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
710 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
711 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
712 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
714 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
715 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
716 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
717 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
718 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
719 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
720 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
721 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
723 // Check handle images
724 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
725 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
726 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
727 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
728 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
730 // Check handle images
731 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
732 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
733 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
734 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
735 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
736 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
738 // Check the highlight color
739 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
740 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
742 // Decoration bounding box
743 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
744 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
746 // Check the enable markup property.
747 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
748 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
749 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
751 // Check input color property.
752 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
753 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
755 // Check input font properties.
756 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
757 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
759 fontStyleMapSet.Clear();
760 fontStyleMapSet.Insert("weight", "bold");
761 fontStyleMapSet.Insert("width", "condensed");
762 fontStyleMapSet.Insert("slant", "italic");
764 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
765 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
766 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
767 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
769 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
770 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
772 // Reset input font style.
773 fontStyleMapSet.Clear();
774 fontStyleMapSet.Insert("weight", "normal");
775 fontStyleMapSet.Insert("slant", "oblique");
777 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
778 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
779 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
780 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
782 fontStyleMapSet.Clear();
783 fontStyleMapSet.Insert("slant", "roman");
785 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
786 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
788 // Replace 'roman' for 'normal'.
789 slantValue = fontStyleMapGet.Find("slant");
790 if(NULL != slantValue)
792 if("normal" == slantValue->Get<std::string>())
794 fontStyleMapGet["slant"] = "roman";
797 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
798 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
800 fontStyleMapSet.Clear();
802 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
803 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
804 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
805 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
807 // Check the line spacing property
808 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
809 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
810 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
812 // Check the input line spacing property
813 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
814 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
815 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
817 // Check the underline property
819 Property::Map underlineMapSet;
820 Property::Map underlineMapGet;
822 underlineMapSet.Insert("enable", true);
823 underlineMapSet.Insert("color", Color::RED);
824 underlineMapSet.Insert("height", 1);
825 underlineMapSet.Insert("type", Text::Underline::SOLID);
826 underlineMapSet.Insert("dashWidth", 5);
827 underlineMapSet.Insert("dashGap", 3);
829 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
831 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
832 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
833 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
835 application.SendNotification();
836 application.Render();
838 // Check the dashed underline property
840 underlineMapSet.Clear();
841 underlineMapGet.Clear();
843 underlineMapSet.Insert("enable", true);
844 underlineMapSet.Insert("color", Color::RED);
845 underlineMapSet.Insert("height", 1);
846 underlineMapSet.Insert("type", Text::Underline::DASHED);
847 underlineMapSet.Insert("dashWidth", 5);
848 underlineMapSet.Insert("dashGap", 3);
850 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
852 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
853 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
854 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
856 application.SendNotification();
857 application.Render();
859 underlineMapSet.Clear();
860 underlineMapGet.Clear();
862 // Check the double underline property
864 underlineMapSet.Clear();
865 underlineMapGet.Clear();
867 underlineMapSet.Insert("enable", true);
868 underlineMapSet.Insert("color", Color::RED);
869 underlineMapSet.Insert("height", 1);
870 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
871 underlineMapSet.Insert("dashWidth", 5);
872 underlineMapSet.Insert("dashGap", 3);
874 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
876 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
877 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
878 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
880 application.SendNotification();
881 application.Render();
883 underlineMapSet.Clear();
884 underlineMapGet.Clear();
886 // Check the input underline property
887 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
888 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
890 // Check the shadow property
891 Property::Map shadowMapSet;
892 Property::Map shadowMapGet;
894 shadowMapSet.Insert("color", Color::GREEN);
895 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
896 shadowMapSet.Insert("blurRadius", 3.0f);
898 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
900 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
901 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
902 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
904 // Check the input shadow property
905 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
906 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
908 // Check the emboss property
909 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
910 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
912 // Check the input emboss property
913 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
914 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
916 // Check the outline property
918 // Test string type first
919 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
920 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
921 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
923 // Then test the property map type
924 Property::Map outlineMapSet;
925 Property::Map outlineMapGet;
927 outlineMapSet["color"] = Color::RED;
928 outlineMapSet["width"] = 2.0f;
930 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
932 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
933 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
934 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
936 // Check the input outline property
937 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
938 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
940 // Check the smooth scroll property
941 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
942 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
943 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
945 // Check the smooth scroll duration property
946 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
947 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
949 // Check the scroll bar property
950 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
951 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
952 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
954 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
955 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
956 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
957 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
959 // Check the pixel size of font
960 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
961 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
963 // Check placeholder text properties.
964 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
965 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
967 // Check placeholder text's color property.
968 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
969 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
971 // Check the enable selection property
972 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
973 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
975 // Check the placeholder property with pixel size
976 Property::Map placeholderPixelSizeMapSet;
977 Property::Map placeholderPixelSizeMapGet;
978 Property::Map placeholderFontstyleMap;
979 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
980 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
981 placeholderPixelSizeMapSet["color"] = Color::BLUE;
982 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
983 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
985 placeholderFontstyleMap.Insert("weight", "bold");
986 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
987 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
989 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
990 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
992 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
993 Property::Map placeholderConversionMap;
994 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
995 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
996 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
997 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
998 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
999 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1001 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1003 // Check the placeholder property with point size
1004 Property::Map placeholderMapSet;
1005 Property::Map placeholderMapGet;
1006 placeholderMapSet["text"] = "Setting Placeholder Text";
1007 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1008 placeholderMapSet["color"] = Color::RED;
1009 placeholderMapSet["fontFamily"] = "Arial";
1010 placeholderMapSet["pointSize"] = 12.0f;
1011 // Check the placeholder font style property
1012 placeholderFontstyleMap.Clear();
1014 placeholderFontstyleMap.Insert("weight", "bold");
1015 placeholderFontstyleMap.Insert("width", "condensed");
1016 placeholderFontstyleMap.Insert("slant", "italic");
1017 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1018 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1020 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1021 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1023 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1024 placeholderConversionMap.Clear();
1025 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1026 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1027 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1028 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1029 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1030 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1031 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1033 // Reset font style.
1034 placeholderFontstyleMap.Clear();
1035 placeholderFontstyleMap.Insert("weight", "normal");
1036 placeholderFontstyleMap.Insert("slant", "oblique");
1037 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1038 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1040 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1041 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1042 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1043 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1045 placeholderFontstyleMap.Clear();
1046 placeholderFontstyleMap.Insert("slant", "roman");
1047 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1048 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1050 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1052 placeholderFontstyleMap.Clear();
1053 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1055 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1056 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1057 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1058 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1059 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1061 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1062 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1064 // Check handle color
1065 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1066 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1068 // Test the ENABLE_GRAB_HANDLE_POPUP property
1069 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1070 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1072 // Check the input method setting
1073 Property::Map propertyMap;
1074 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1075 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1076 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1077 int inputVariation = 1;
1078 propertyMap["PANEL_LAYOUT"] = panelLayout;
1079 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1080 propertyMap["BUTTON_ACTION"] = buttonAction;
1081 propertyMap["VARIATION"] = inputVariation;
1082 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1084 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1086 DALI_TEST_CHECK(value.Get(map));
1089 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1090 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1093 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1094 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1097 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1098 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1101 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1102 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1104 // Check the input filter property
1105 Property::Map inputFilterMapSet;
1106 Property::Map inputFilterMapGet;
1107 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1108 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1110 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1112 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1113 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1116 inputFilterMapSet.Clear();
1117 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1119 // Check the strikethrough property
1121 Property::Map strikethroughMapSet;
1122 Property::Map strikethroughMapGet;
1124 application.SendNotification();
1125 application.Render();
1127 // Check the input strikethrough property
1129 strikethroughMapSet.Clear();
1130 strikethroughMapGet.Clear();
1131 strikethroughMapSet.Insert("enable", true);
1132 strikethroughMapSet.Insert("color", Color::BLUE);
1133 strikethroughMapSet.Insert("height", 2.0f);
1135 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1137 application.SendNotification();
1138 application.Render();
1140 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1142 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1143 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1145 // Check the input strikethrough property
1146 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1147 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1149 application.SendNotification();
1150 application.Render();
1152 // Check the line size property
1153 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1154 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1155 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1160 // Positive Atlas Text Renderer test
1161 int utcDaliTextEditorAtlasRenderP(void)
1163 ToolkitTestApplication application;
1164 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1165 StyleManager styleManager = StyleManager::Get();
1166 styleManager.ApplyDefaultTheme();
1167 TextEditor editor = TextEditor::New();
1168 DALI_TEST_CHECK(editor);
1170 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1172 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1174 application.GetScene().Add(editor);
1178 // Render some text with the shared atlas backend
1179 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1180 application.SendNotification();
1181 application.Render();
1185 tet_result(TET_FAIL);
1190 // Positive test for the anchorClicked signal.
1191 int utcDaliTextEditorAnchorClickedP(void)
1193 ToolkitTestApplication application;
1194 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1195 TextEditor editor = TextEditor::New();
1196 DALI_TEST_CHECK(editor);
1198 application.GetScene().Add(editor);
1200 // connect to the anchor clicked signal.
1201 ConnectionTracker* testTracker = new ConnectionTracker();
1202 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1203 bool anchorClickedSignal = false;
1204 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1206 gAnchorClickedCallBackCalled = false;
1207 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1208 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1209 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1210 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1211 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1213 application.SendNotification();
1214 application.Render();
1215 editor.SetKeyInputFocus();
1217 // Create a tap event to touch the text editor.
1218 TestGenerateTap(application, 5.0f, 5.0f);
1219 application.SendNotification();
1220 application.Render();
1222 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1223 DALI_TEST_CHECK(anchorClickedSignal);
1225 gAnchorClickedCallBackNotCalled = true;
1226 // Tap the outside of anchor, callback should not be called.
1227 TestGenerateTap(application, 150.f, 100.f);
1228 application.SendNotification();
1229 application.Render();
1231 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1236 // Positive test for the textChanged signal.
1237 int utcDaliTextEditorTextChangedP(void)
1239 ToolkitTestApplication application;
1240 tet_infoline(" utcDaliTextEditorTextChangedP");
1241 TextEditor editor = TextEditor::New();
1242 DALI_TEST_CHECK(editor);
1244 application.GetScene().Add(editor);
1246 // connect to the text changed signal.
1247 ConnectionTracker* testTracker = new ConnectionTracker();
1248 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1249 bool textChangedSignal = false;
1250 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1252 gTextChangedCallBackCalled = false;
1253 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1254 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1255 DALI_TEST_CHECK(textChangedSignal);
1257 application.SendNotification();
1258 editor.SetKeyInputFocus();
1260 gTextChangedCallBackCalled = false;
1261 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1262 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1265 editor.SetProperty(TextField::Property::TEXT, "");
1267 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1268 gTextChangedCallBackCalled = false;
1269 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1270 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1272 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1273 gTextChangedCallBackCalled = false;
1274 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1275 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1280 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1282 ToolkitTestApplication application;
1283 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1284 TextEditor editor = TextEditor::New();
1285 DALI_TEST_CHECK(editor);
1287 application.GetScene().Add(editor);
1289 // connect to the text changed signal.
1290 ConnectionTracker* testTracker = new ConnectionTracker();
1291 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1292 bool textChangedSignal = false;
1293 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1295 // get InputMethodContext
1297 InputMethodContext::EventData imfEvent;
1298 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1300 editor.SetKeyInputFocus();
1301 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1304 gTextChangedCallBackCalled = false;
1305 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1306 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1307 application.SendNotification();
1308 application.Render();
1309 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1310 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1312 gTextChangedCallBackCalled = false;
1313 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1314 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1315 application.SendNotification();
1316 application.Render();
1317 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1318 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1320 gTextChangedCallBackCalled = false;
1321 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1322 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1323 application.SendNotification();
1324 application.Render();
1325 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1326 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1328 gTextChangedCallBackCalled = false;
1329 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1330 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1331 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1333 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1334 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1335 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1337 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1338 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1339 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1341 application.SendNotification();
1342 application.Render();
1343 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1344 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1349 int utcDaliTextEditorInputStyleChanged01(void)
1351 // The text-editor emits signals when the input style changes. These changes of style are
1352 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1353 // can't be emitted during the size negotiation as the callbacks may update the UI.
1354 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1355 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1356 ToolkitTestApplication application;
1357 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1361 char* pathNamePtr = get_current_dir_name();
1362 const std::string pathName(pathNamePtr);
1365 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1366 fontClient.SetDpi(93u, 93u);
1368 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1369 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1371 TextEditor editor = TextEditor::New();
1372 DALI_TEST_CHECK(editor);
1374 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1375 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1376 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1378 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1379 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1381 // connect to the text changed signal.
1382 ConnectionTracker* testTracker = new ConnectionTracker();
1383 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1384 bool inputStyleChangedSignal = false;
1385 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1387 application.GetScene().Add(editor);
1389 // Render and notify
1390 application.SendNotification();
1391 application.Render();
1393 // Executes the idle callbacks added by the text control on the change of input style.
1394 application.RunIdles();
1396 gInputStyleChangedCallbackCalled = false;
1397 gInputStyleMask = TextEditor::InputStyle::NONE;
1398 inputStyleChangedSignal = false;
1400 // Create a tap event to touch the text editor.
1401 TestGenerateTap(application, 18.0f, 25.0f);
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Executes the idle callbacks added by the text control on the change of input style.
1408 application.RunIdles();
1410 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1411 if(gInputStyleChangedCallbackCalled)
1413 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1415 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1416 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1418 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1419 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1421 DALI_TEST_CHECK(inputStyleChangedSignal);
1423 gInputStyleChangedCallbackCalled = false;
1424 gInputStyleMask = TextEditor::InputStyle::NONE;
1425 inputStyleChangedSignal = false;
1427 // Create a tap event to touch the text editor.
1428 TestGenerateTap(application, 30.0f, 25.0f);
1430 // Render and notify
1431 application.SendNotification();
1432 application.Render();
1434 // Executes the idle callbacks added by the text control on the change of input style.
1435 application.RunIdles();
1437 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1438 DALI_TEST_CHECK(!inputStyleChangedSignal);
1440 gInputStyleChangedCallbackCalled = false;
1441 gInputStyleMask = TextEditor::InputStyle::NONE;
1442 inputStyleChangedSignal = false;
1444 // Create a tap event to touch the text editor.
1445 TestGenerateTap(application, 43.0f, 25.0f);
1447 // Render and notify
1448 application.SendNotification();
1449 application.Render();
1451 // Executes the idle callbacks added by the text control on the change of input style.
1452 application.RunIdles();
1454 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1455 if(gInputStyleChangedCallbackCalled)
1457 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1459 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1460 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1462 DALI_TEST_CHECK(inputStyleChangedSignal);
1464 gInputStyleChangedCallbackCalled = false;
1465 gInputStyleMask = TextEditor::InputStyle::NONE;
1466 inputStyleChangedSignal = false;
1468 // Create a tap event to touch the text editor.
1469 TestGenerateTap(application, 88.0f, 25.0f);
1471 // Render and notify
1472 application.SendNotification();
1473 application.Render();
1475 // Executes the idle callbacks added by the text control on the change of input style.
1476 application.RunIdles();
1478 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1479 if(gInputStyleChangedCallbackCalled)
1481 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1483 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1484 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1486 Property::Map fontStyleMapSet;
1487 Property::Map fontStyleMapGet;
1489 fontStyleMapSet.Insert("weight", "bold");
1491 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1492 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1493 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1495 DALI_TEST_CHECK(inputStyleChangedSignal);
1497 gInputStyleChangedCallbackCalled = false;
1498 gInputStyleMask = TextEditor::InputStyle::NONE;
1499 inputStyleChangedSignal = false;
1501 // Create a tap event to touch the text editor.
1502 TestGenerateTap(application, 115.0f, 25.0f);
1504 // Render and notify
1505 application.SendNotification();
1506 application.Render();
1508 // Executes the idle callbacks added by the text control on the change of input style.
1509 application.RunIdles();
1511 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1512 DALI_TEST_CHECK(!inputStyleChangedSignal);
1514 gInputStyleChangedCallbackCalled = false;
1515 gInputStyleMask = TextEditor::InputStyle::NONE;
1516 inputStyleChangedSignal = false;
1518 // Create a tap event to touch the text editor.
1519 TestGenerateTap(application, 164.0f, 25.0f);
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Executes the idle callbacks added by the text control on the change of input style.
1526 application.RunIdles();
1528 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1529 if(gInputStyleChangedCallbackCalled)
1531 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1533 Property::Map fontStyleMapSet;
1534 Property::Map fontStyleMapGet;
1536 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1537 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1538 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1540 DALI_TEST_CHECK(inputStyleChangedSignal);
1542 gInputStyleChangedCallbackCalled = false;
1543 gInputStyleMask = TextEditor::InputStyle::NONE;
1544 inputStyleChangedSignal = false;
1546 // Create a tap event to touch the text editor.
1547 TestGenerateTap(application, 191.0f, 25.0f);
1549 // Render and notify
1550 application.SendNotification();
1551 application.Render();
1553 // Executes the idle callbacks added by the text control on the change of input style.
1554 application.RunIdles();
1556 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1557 DALI_TEST_CHECK(!inputStyleChangedSignal);
1562 int utcDaliTextEditorInputStyleChanged02(void)
1564 // The text-editor emits signals when the input style changes. These changes of style are
1565 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1566 // can't be emitted during the size negotiation as the callbacks may update the UI.
1567 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1568 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1569 ToolkitTestApplication application;
1570 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1574 char* pathNamePtr = get_current_dir_name();
1575 const std::string pathName(pathNamePtr);
1578 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1579 fontClient.SetDpi(93u, 93u);
1581 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1582 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1584 TextEditor editor = TextEditor::New();
1585 DALI_TEST_CHECK(editor);
1587 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1588 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1589 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1591 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1592 editor.SetProperty(TextEditor::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>");
1594 // connect to the text changed signal.
1595 ConnectionTracker* testTracker = new ConnectionTracker();
1596 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1597 bool inputStyleChangedSignal = false;
1598 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1600 application.GetScene().Add(editor);
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 // Executes the idle callbacks added by the text control on the change of input style.
1607 application.RunIdles();
1609 gInputStyleChangedCallbackCalled = false;
1610 gInputStyleMask = TextEditor::InputStyle::NONE;
1611 inputStyleChangedSignal = false;
1613 // Create a tap event to touch the text editor.
1614 TestGenerateTap(application, 53.0f, 25.0f, 100);
1615 TestGenerateTap(application, 53.0f, 25.0f, 200);
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // Executes the idle callbacks added by the text control on the change of input style.
1622 application.RunIdles();
1624 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1625 if(gInputStyleChangedCallbackCalled)
1627 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1628 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1629 TextEditor::InputStyle::POINT_SIZE |
1630 TextEditor::InputStyle::COLOR),
1633 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1634 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1636 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1637 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1639 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1640 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1642 DALI_TEST_CHECK(inputStyleChangedSignal);
1644 gInputStyleChangedCallbackCalled = false;
1645 gInputStyleMask = TextEditor::InputStyle::NONE;
1646 inputStyleChangedSignal = false;
1648 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1650 // Render and notify
1651 application.SendNotification();
1652 application.Render();
1654 // Executes the idle callbacks added by the text control on the change of input style.
1655 application.RunIdles();
1657 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1658 if(gInputStyleChangedCallbackCalled)
1660 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1661 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1664 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1665 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1667 DALI_TEST_CHECK(inputStyleChangedSignal);
1669 gInputStyleChangedCallbackCalled = false;
1670 gInputStyleMask = TextEditor::InputStyle::NONE;
1671 inputStyleChangedSignal = false;
1673 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1675 // Render and notify
1676 application.SendNotification();
1677 application.Render();
1679 // Executes the idle callbacks added by the text control on the change of input style.
1680 application.RunIdles();
1682 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1683 DALI_TEST_CHECK(!inputStyleChangedSignal);
1685 gInputStyleChangedCallbackCalled = false;
1686 gInputStyleMask = TextEditor::InputStyle::NONE;
1687 inputStyleChangedSignal = false;
1689 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // Executes the idle callbacks added by the text control on the change of input style.
1696 application.RunIdles();
1698 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1699 if(gInputStyleChangedCallbackCalled)
1701 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1702 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1705 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1706 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1708 DALI_TEST_CHECK(inputStyleChangedSignal);
1710 gInputStyleChangedCallbackCalled = false;
1711 gInputStyleMask = TextEditor::InputStyle::NONE;
1712 inputStyleChangedSignal = false;
1714 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1716 Property::Map fontStyleMapSet;
1717 fontStyleMapSet.Insert("weight", "thin");
1718 fontStyleMapSet.Insert("width", "condensed");
1719 fontStyleMapSet.Insert("slant", "italic");
1721 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1722 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1723 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1725 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1726 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1727 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1728 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1729 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1731 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // Executes the idle callbacks added by the text control on the change of input style.
1738 application.RunIdles();
1740 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1741 DALI_TEST_CHECK(!inputStyleChangedSignal);
1743 // Create a tap event to touch the text editor.
1744 TestGenerateTap(application, 63.0f, 25.0f, 900);
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Executes the idle callbacks added by the text control on the change of input style.
1751 application.RunIdles();
1753 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1754 if(gInputStyleChangedCallbackCalled)
1756 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1757 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1758 TextEditor::InputStyle::POINT_SIZE |
1759 TextEditor::InputStyle::FONT_STYLE |
1760 TextEditor::InputStyle::LINE_SPACING |
1761 TextEditor::InputStyle::UNDERLINE |
1762 TextEditor::InputStyle::SHADOW |
1763 TextEditor::InputStyle::EMBOSS |
1764 TextEditor::InputStyle::OUTLINE),
1767 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1768 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1770 DALI_TEST_CHECK(inputStyleChangedSignal);
1772 gInputStyleChangedCallbackCalled = false;
1773 gInputStyleMask = TextEditor::InputStyle::NONE;
1774 inputStyleChangedSignal = false;
1776 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1778 fontStyleMapSet.Clear();
1779 fontStyleMapSet.Insert("weight", "black");
1780 fontStyleMapSet.Insert("width", "expanded");
1781 fontStyleMapSet.Insert("slant", "oblique");
1783 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1785 // Create a tap event to touch the text editor.
1786 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Executes the idle callbacks added by the text control on the change of input style.
1793 application.RunIdles();
1795 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1796 if(gInputStyleChangedCallbackCalled)
1798 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1799 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1800 TextEditor::InputStyle::POINT_SIZE |
1801 TextEditor::InputStyle::FONT_STYLE),
1804 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1805 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1807 DALI_TEST_CHECK(inputStyleChangedSignal);
1812 int utcDaliTextEditorEvent01(void)
1814 ToolkitTestApplication application;
1815 tet_infoline(" utcDaliTextEditorEvent01");
1817 // Creates a tap event. After creating a tap event the text editor should
1818 // have the focus and add text with key events should be possible.
1820 TextEditor editor = TextEditor::New();
1821 DALI_TEST_CHECK(editor);
1823 application.GetScene().Add(editor);
1825 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1826 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1827 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1829 // Avoid a crash when core load gl resources.
1830 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 // Add a key event but as the text editor has not the focus it should do nothing.
1837 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1845 // Create a tap event to touch the text editor.
1846 TestGenerateTap(application, 150.0f, 25.0f);
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1852 // Now the text editor has the focus, so it can handle the key events.
1853 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1854 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1862 // Create a second text editor and send key events to it.
1863 TextEditor editor2 = TextEditor::New();
1865 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1866 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1867 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1868 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1870 application.GetScene().Add(editor2);
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 // Create a tap event on the second text editor.
1877 TestGenerateTap(application, 150.0f, 125.0f);
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 // The second text editor has the focus. It should handle the key events.
1884 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1885 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1891 // Check the text has been added to the second text editor.
1892 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1897 int utcDaliTextEditorEvent02(void)
1899 ToolkitTestApplication application;
1900 tet_infoline(" utcDaliTextEditorEvent02");
1902 // Checks if the right number of actors are created.
1904 TextEditor editor = TextEditor::New();
1905 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
1906 DALI_TEST_CHECK(editor);
1908 application.GetScene().Add(editor);
1910 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1911 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1912 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1914 // Avoid a crash when core load gl resources.
1915 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 // Check there are the expected number of children (the stencil).
1922 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
1924 Actor stencil = editor.GetChildAt(0u);
1926 // Create a tap event to touch the text editor.
1927 TestGenerateTap(application, 150.0f, 25.0f, 100);
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 Actor layer = editor.GetChildAt(2u);
1934 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1935 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
1937 // Now the text editor has the focus, so it can handle the key events.
1938 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1939 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Checks the cursor and the renderer have been created.
1946 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1947 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
1949 Control cursor = Control::DownCast(layer.GetChildAt(0u));
1950 DALI_TEST_CHECK(cursor);
1952 // The stencil actor has a container with all the actors which contain the text renderers.
1953 Actor container = stencil.GetChildAt(0u);
1954 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
1956 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
1957 DALI_TEST_CHECK(renderer);
1960 // Move the cursor and check the position changes.
1961 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1963 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1964 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1972 DALI_TEST_CHECK(position2.x < position1.x);
1974 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1975 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1983 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
1985 // Send some taps and check the cursor positions.
1987 // Try to tap at the beginning.
1988 TestGenerateTap(application, 1.0f, 25.0f, 700);
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1994 // Cursor position should be the same than position1.
1995 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1997 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
1999 // Tap away from the start position.
2000 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2008 DALI_TEST_CHECK(position5.x > position4.x);
2010 // Remove all the text.
2011 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2012 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2013 editor.SetProperty(TextEditor::Property::TEXT, "");
2015 // Render and notify
2016 application.SendNotification();
2017 application.Render();
2019 // Cursor position should be the same than position2.
2020 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2022 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2024 // Should not be a renderer, there is only a clipped cursor.
2025 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2030 int utcDaliTextEditorEvent03(void)
2032 ToolkitTestApplication application;
2033 tet_infoline(" utcDaliTextEditorEvent03");
2035 // Checks if the highlight actor is created.
2037 TextEditor editor = TextEditor::New();
2038 DALI_TEST_CHECK(editor);
2040 application.GetScene().Add(editor);
2042 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2043 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2044 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2045 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2046 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2048 // Avoid a crash when core load gl resources.
2049 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2051 // Render and notify
2052 application.SendNotification();
2053 application.Render();
2055 // Send some taps and check text controller with clipboard window
2056 Dali::Clipboard clipboard = Clipboard::Get();
2057 clipboard.ShowClipboard();
2058 TestGenerateTap(application, 3.0f, 25.0f, 100);
2059 clipboard.HideClipboard();
2061 // Render and notify
2062 application.SendNotification();
2063 application.Render();
2065 // Tap first to get the focus.
2066 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2068 // Render and notify
2069 application.SendNotification();
2070 application.Render();
2072 // Double tap to select a word.
2073 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2075 // Render and notify
2076 application.SendNotification();
2077 application.Render();
2079 // The stencil actor should have two actors: the renderer and the highlight actor.
2080 Actor stencil = editor.GetChildAt(0u);
2082 // Highlight needs to be drawn before text, so should come first in child order
2083 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2084 DALI_TEST_CHECK(highlight);
2086 // The stencil actor has a container with all the actors which contain the text renderers.
2087 Actor container = stencil.GetChildAt(1u);
2088 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2090 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2091 DALI_TEST_CHECK(renderer);
2094 // Double tap out of bounds
2095 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2096 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 // The stencil actor should have one actors: the renderer actor.
2103 stencil = editor.GetChildAt(0u);
2105 // The stencil actor has a container with all the actors which contain the text renderers.
2106 container = stencil.GetChildAt(0u);
2107 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2109 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2110 DALI_TEST_CHECK(renderer);
2114 TestGenerateLongPress(application, 1.0f, 25.0f);
2116 // Render and notify
2117 application.SendNotification();
2118 application.Render();
2121 TestGenerateMiniPan(application);
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2130 int utcDaliTextEditorEvent04(void)
2132 ToolkitTestApplication application;
2133 tet_infoline(" utcDaliTextEditorEvent04");
2135 // Checks if the highlight actor is created.
2137 TextEditor editor = TextEditor::New();
2138 DALI_TEST_CHECK(editor);
2140 application.GetScene().Add(editor);
2142 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2143 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2144 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2145 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2146 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2148 // Avoid a crash when core load gl resources.
2149 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Tap on the text editor
2156 TestGenerateTap(application, 3.0f, 25.0f);
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // Move at the end of the text.
2163 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2164 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 for(unsigned int index = 0u; index < 10u; ++index)
2172 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2173 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2181 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2189 // Add some key events
2190 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2191 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2197 for(unsigned int index = 0u; index < 10u; ++index)
2199 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2200 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2208 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2219 int utcDaliTextEditorEvent05(void)
2221 ToolkitTestApplication application;
2222 tet_infoline(" utcDaliTextEditorEvent05");
2224 // Checks if the highlight actor is created.
2226 TextEditor editor = TextEditor::New();
2227 DALI_TEST_CHECK(editor);
2229 application.GetScene().Add(editor);
2231 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2232 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2233 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2234 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2235 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2236 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2237 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2238 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2239 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2240 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2242 // Avoid a crash when core load gl resources.
2243 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2245 // Render and notify
2246 application.SendNotification();
2247 application.Render();
2249 // Tap on the text editor
2250 TestGenerateTap(application, 3.0f, 25.0f);
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 // Move at the end of the text.
2257 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2258 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 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 for(unsigned int index = 0u; index < 10u; ++index)
2267 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2269 // Render and notify
2270 application.SendNotification();
2271 application.Render();
2273 // Modify duration after scroll is enabled
2274 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2276 // Continuous scroll left to increase coverage
2277 for(unsigned int index = 0u; index < 10u; ++index)
2279 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2286 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2287 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2288 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2289 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2291 // Press Escape to increase coverage
2292 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2293 application.SendNotification();
2294 application.Render();
2296 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2301 int utcDaliTextEditorEvent06(void)
2303 ToolkitTestApplication application;
2304 tet_infoline(" utcDaliTextEditorEvent06");
2306 // Checks if the highlight actor is created.
2308 TextEditor editor = TextEditor::New();
2309 DALI_TEST_CHECK(editor);
2311 application.GetScene().Add(editor);
2313 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2314 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2315 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2316 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2317 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2319 // Avoid a crash when core load gl resources.
2320 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 // Tap on the text editor
2327 TestGenerateTap(application, 3.0f, 25.0f);
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 // Move to seconds line of the text.
2334 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 float layoutHeight = editor.GetHeightForWidth(100.f);
2342 // Add another script characters ( glyph height is defferent )
2343 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2344 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2346 // Delete characters
2347 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2348 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2350 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2359 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2360 application.SendNotification();
2361 application.Render();
2363 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2364 application.SendNotification();
2365 application.Render();
2367 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2368 application.SendNotification();
2369 application.Render();
2371 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2372 application.SendNotification();
2373 application.Render();
2375 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2376 application.SendNotification();
2377 application.Render();
2379 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2380 application.SendNotification();
2381 application.Render();
2383 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2384 application.SendNotification();
2385 application.Render();
2390 int utcDaliTextEditorEvent07(void)
2392 ToolkitTestApplication application;
2393 tet_infoline(" utcDaliTextEditorEvent07");
2395 // Checks if the highlight actor is created.
2397 TextEditor editor = TextEditor::New();
2398 DALI_TEST_CHECK(editor);
2400 application.GetScene().Add(editor);
2402 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2403 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2404 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2405 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2406 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2408 // Avoid a crash when core load gl resources.
2409 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // Tap on the text editor
2416 TestGenerateTap(application, 3.0f, 25.0f);
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Move to second line of the text.
2423 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 // Select some text in the right of the current cursor position
2430 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2431 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2432 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // Cut the selected text
2440 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2441 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2443 // Render and notify
2444 application.SendNotification();
2445 application.Render();
2447 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2449 // Select some text in the left of the current cursor position
2450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2452 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2453 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2455 // Render and notify
2456 application.SendNotification();
2457 application.Render();
2459 // Copy the selected text
2460 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2461 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // Move the cursor to the third line
2468 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2469 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 // Paste the selected text at the current cursor position
2476 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2477 application.ProcessEvent(GenerateKey("v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2485 // Disable Shift Selection
2486 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2488 // Test to select some text in the right of the current cursor position
2489 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2490 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2491 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2492 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 // Cut the selected text
2499 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2500 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502 // Render and notify
2503 application.SendNotification();
2504 application.Render();
2506 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2507 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2509 // Test to select some text in the left of the current cursor position
2510 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2511 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2512 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2513 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // Copy the selected text
2520 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2521 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2528 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2531 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // replace text with "c"
2538 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2545 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2548 DevelTextEditor::SelectWholeText(editor);
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2554 // Copy the selected text using logical keys
2555 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2556 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2563 DevelTextEditor::SelectNone(editor);
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 // Paste the selected using logical keys
2570 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2574 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2576 // select all using logical keys
2577 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2578 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2584 // cut text using logical keys
2585 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2586 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2593 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2598 int utcDaliTextEditorEvent08(void)
2600 ToolkitTestApplication application;
2601 tet_infoline(" utcDaliTextEditorEvent08");
2603 // Checks if the highlight actor is released correctly.
2605 TextEditor editor = TextEditor::New();
2606 DALI_TEST_CHECK(editor);
2608 application.GetScene().Add(editor);
2610 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2611 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2612 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2613 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2614 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2616 // Avoid a crash when core load gl resources.
2617 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2623 // Tap on the text editor
2624 TestGenerateTap(application, 3.0f, 25.0f);
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2631 // Test to select some text in the left of the current cursor position
2632 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2633 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2634 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2635 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2637 // Render and notify
2638 application.SendNotification();
2639 application.Render();
2641 // Test to the left selection handle position and the right selection handle position
2642 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2643 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2644 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2645 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 // Test to select full text in the left of the current cursor position
2652 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2653 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2654 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2655 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2656 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2657 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Test to release the current full text selection
2664 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2665 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2667 // Render and notify
2668 application.SendNotification();
2669 application.Render();
2671 // Test to move the current cursor position correctly
2672 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2674 // Render and notify
2675 application.SendNotification();
2676 application.Render();
2679 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2681 // Render and notify
2682 application.SendNotification();
2683 application.Render();
2685 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2687 // Test to select some text in the right of the current cursor position
2688 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2689 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2690 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2692 // Render and notify
2693 application.SendNotification();
2694 application.Render();
2696 // Test the cursor position with right arrow key
2697 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2699 // Render and notify
2700 application.SendNotification();
2701 application.Render();
2704 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2706 // Render and notify
2707 application.SendNotification();
2708 application.Render();
2710 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2712 // Test to select some text in the left of the current cursor position
2713 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2714 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2715 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2716 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2717 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2719 // Render and notify
2720 application.SendNotification();
2721 application.Render();
2723 // Test the cursor position with left arrow key
2724 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2726 // Render and notify
2727 application.SendNotification();
2728 application.Render();
2731 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2733 // Render and notify
2734 application.SendNotification();
2735 application.Render();
2737 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2739 // Test to select some text in the right of the current cursor position
2740 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2741 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2742 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2743 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2745 // Render and notify
2746 application.SendNotification();
2747 application.Render();
2749 // Test the cursor position with left arrow key
2750 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2752 // Render and notify
2753 application.SendNotification();
2754 application.Render();
2757 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2759 // Render and notify
2760 application.SendNotification();
2761 application.Render();
2763 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2765 // Test to select some text in the left of the current cursor position
2766 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2767 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2768 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2769 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2775 // Test the cursor position with right arrow key
2776 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2778 // Render and notify
2779 application.SendNotification();
2780 application.Render();
2783 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2785 // Render and notify
2786 application.SendNotification();
2787 application.Render();
2789 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2794 int utcDaliTextEditorHandles(void)
2796 ToolkitTestApplication application;
2797 tet_infoline(" utcDaliTextEditorHandles");
2799 TextEditor editor = TextEditor::New();
2800 DALI_TEST_CHECK(editor);
2802 application.GetScene().Add(editor);
2804 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2805 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2806 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2807 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2809 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2810 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2811 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2812 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2814 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2815 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2816 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2818 // Avoid a crash when core load gl resources.
2819 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2821 // Render and notify
2822 application.SendNotification();
2823 application.Render();
2825 // Tap first to get the focus.
2826 TestGenerateTap(application, 3.0f, 25.0f, 100);
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 // Tap to create the grab handle.
2833 TestGenerateTap(application, 3.0f, 25.0f, 700);
2835 // Render and notify
2836 application.SendNotification();
2837 application.Render();
2839 // Get the active layer where the text's decoration is added.
2840 Actor activeLayer = editor.GetChildAt(1u);
2842 // Get the handle's actor.
2843 Actor handle = activeLayer.GetChildAt(0u);
2844 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 // Touch the grab handle to set it as pressed.
2851 Vector2 touchPos(10.0f, 50.0f);
2852 Dali::Integration::TouchEvent event;
2853 event = Dali::Integration::TouchEvent();
2854 event.AddPoint(GetPointDownInside(touchPos));
2855 application.ProcessEvent(event);
2857 // Render and notify
2858 application.SendNotification();
2859 application.Render();
2861 // Pan the grab handle
2862 uint32_t time = 100;
2863 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2864 TestMovePan(application, Vector2(10.0f, 30.0f), time);
2865 TestEndPan(application, Vector2(10.0f, 50.0f), time);
2866 application.SendNotification();
2867 application.Render();
2869 // Release the grab handle.
2870 event = Dali::Integration::TouchEvent();
2871 event.AddPoint(GetPointUpInside(touchPos));
2872 application.ProcessEvent(event);
2874 // Render and notify
2875 application.SendNotification();
2876 application.Render();
2878 // Tap first to get the focus.
2879 TestGenerateTap(application, 3.0f, 25.0f, 1400);
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2885 // Double tap to select a word and create the selection handles.
2886 TestGenerateTap(application, 3.0f, 25.0f, 1500);
2888 // Render and notify
2889 application.SendNotification();
2890 application.Render();
2892 touchPos = Vector2(10.0f, 50.0f);
2894 // Touch the left selection handle to set it as pressed.
2895 event = Dali::Integration::TouchEvent();
2896 event.AddPoint(GetPointDownInside(touchPos));
2897 application.ProcessEvent(event);
2899 // Render and notify
2900 application.SendNotification();
2901 application.Render();
2903 // Release the left selection handle.
2904 event = Dali::Integration::TouchEvent();
2905 event.AddPoint(GetPointUpInside(touchPos));
2906 application.ProcessEvent(event);
2908 // Render and notify
2909 application.SendNotification();
2910 application.Render();
2915 int utcDaliTextEditorUnderPropertyStringP(void)
2917 ToolkitTestApplication application;
2918 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2919 TextEditor editor = TextEditor::New();
2920 DALI_TEST_CHECK(editor);
2922 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
2924 application.GetScene().Add(editor);
2926 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2927 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
2929 tet_infoline("Set underline settings with a map");
2930 // Check the input underline property
2931 Property::Map underlineMapSet;
2932 Property::Map underlineMapGet;
2933 underlineMapSet.Insert("enable", true);
2934 underlineMapSet.Insert("color", Color::BLUE);
2935 underlineMapSet.Insert("height", 1);
2936 underlineMapSet.Insert("type", Text::Underline::SOLID);
2937 underlineMapSet.Insert("dashWidth", 2);
2938 underlineMapSet.Insert("dashGap", 1);
2940 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2941 editor.SetProperty(TextEditor::Property::TEXT, "text");
2942 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2943 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2944 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2946 application.SendNotification();
2947 application.Render();
2949 underlineMapSet.Clear();
2950 underlineMapGet.Clear();
2952 tet_infoline("Set dashed underline settings with a map");
2953 // Check the input underline property
2954 underlineMapSet.Clear();
2955 underlineMapGet.Clear();
2956 underlineMapSet.Insert("enable", true);
2957 underlineMapSet.Insert("color", Color::BLUE);
2958 underlineMapSet.Insert("height", 1);
2959 underlineMapSet.Insert("type", Text::Underline::DASHED);
2960 underlineMapSet.Insert("dashWidth", 5);
2961 underlineMapSet.Insert("dashGap", 3);
2963 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2964 editor.SetProperty(TextEditor::Property::TEXT, "text");
2965 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2966 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2967 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2969 // Check the input underline property
2970 underlineMapSet.Clear();
2971 underlineMapGet.Clear();
2972 underlineMapSet.Insert("enable", true);
2973 underlineMapSet.Insert("color", Color::BLUE);
2974 underlineMapSet.Insert("height", 1);
2975 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2976 underlineMapSet.Insert("dashWidth", 5);
2977 underlineMapSet.Insert("dashGap", 3);
2979 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2980 editor.SetProperty(TextEditor::Property::TEXT, "text");
2981 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2982 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2983 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2985 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2986 editor.SetProperty(TextEditor::Property::TEXT, "text");
2987 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2988 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2989 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2991 application.SendNotification();
2992 application.Render();
2994 underlineMapSet.Clear();
2995 underlineMapGet.Clear();
2997 tet_infoline("Set underline settings with a string");
2998 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2999 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3002 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3004 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3005 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3006 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3007 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3009 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3014 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3016 ToolkitTestApplication application;
3017 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3018 TextEditor editor = TextEditor::New();
3019 DALI_TEST_CHECK(editor);