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);
3021 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3023 application.GetScene().Add(editor);
3025 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3026 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3028 tet_infoline("Set strikethrough settings with a map");
3029 // Check the input strikethrough property
3030 Property::Map strikethroughMapSet;
3031 Property::Map strikethroughMapGet;
3032 strikethroughMapSet.Insert("enable", true);
3033 strikethroughMapSet.Insert("color", Color::BLUE);
3034 strikethroughMapSet.Insert("height", 2.0f);
3036 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3037 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3038 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3039 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3041 tet_infoline("Set strikethrough settings with a string");
3042 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3043 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3046 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3048 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3049 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3050 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3051 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3053 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3058 int utcDaliTextEditorShadowPropertyStringP(void)
3060 ToolkitTestApplication application;
3061 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3063 TextEditor editor = TextEditor::New();
3065 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3067 application.GetScene().Add(editor);
3069 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3071 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3075 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3080 int utcDaliTextEditorFontStylePropertyStringP(void)
3082 ToolkitTestApplication application;
3083 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3085 TextEditor editor = TextEditor::New();
3087 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3089 application.GetScene().Add(editor);
3091 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3093 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3097 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3102 int utcDaliTextEditorGetPropertyLinecountP(void)
3104 ToolkitTestApplication application;
3106 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3110 TextEditor editor = TextEditor::New();
3111 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3112 editor.SetProperty(TextEditor::Property::TEXT,
3113 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3115 application.GetScene().Add(editor);
3117 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3118 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3119 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3121 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3122 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3123 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3128 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3130 ToolkitTestApplication application;
3131 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3133 TextEditor editor = TextEditor::New();
3134 DALI_TEST_CHECK(editor);
3136 application.GetScene().Add(editor);
3138 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3139 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3140 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3141 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3142 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3143 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3145 bool startedCalled = false;
3146 bool finishedCalled = false;
3148 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3149 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3151 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3153 // Render and notify
3154 application.SendNotification();
3155 application.Render();
3157 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3158 application.SendNotification();
3159 application.Render(6000);
3161 application.SendNotification();
3162 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3163 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3168 int UtcDaliToolkitTextEditorTextWrapMode(void)
3170 ToolkitTestApplication application;
3171 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3175 TextEditor editor = TextEditor::New();
3176 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3177 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3179 application.GetScene().Add(editor);
3181 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3182 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3184 application.SendNotification();
3185 application.Render();
3187 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3188 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3190 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3191 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3193 application.SendNotification();
3194 application.Render();
3196 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3197 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3199 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3200 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3202 application.SendNotification();
3203 application.Render();
3205 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3206 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3208 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3209 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3211 application.SendNotification();
3212 application.Render();
3214 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3215 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3220 int UtcDaliTextEditorSetPaddingProperty(void)
3222 ToolkitTestApplication application;
3223 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3225 TextEditor editor = TextEditor::New();
3226 DALI_TEST_CHECK(editor);
3227 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3228 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3229 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3230 application.GetScene().Add(editor);
3232 application.SendNotification();
3233 application.Render();
3235 Vector3 originalSize = editor.GetNaturalSize();
3237 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3239 application.SendNotification();
3240 application.Render();
3242 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3244 Vector3 paddingAddedSize = editor.GetNaturalSize();
3246 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3248 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3253 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3255 ToolkitTestApplication application;
3256 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3258 TextEditor editor = TextEditor::New();
3259 DALI_TEST_CHECK(editor);
3260 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3261 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3262 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3263 application.GetScene().Add(editor);
3265 application.SendNotification();
3266 application.Render();
3268 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3269 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3271 // Check the enable shift selection property
3272 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3273 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3275 application.SendNotification();
3276 application.Render();
3281 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3283 ToolkitTestApplication application;
3284 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3286 TextEditor editor = TextEditor::New();
3287 DALI_TEST_CHECK(editor);
3288 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3289 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3290 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3291 application.GetScene().Add(editor);
3293 application.SendNotification();
3294 application.Render();
3296 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3297 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3299 // Check the enable grab handle property
3300 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3301 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3303 application.SendNotification();
3304 application.Render();
3309 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3311 ToolkitTestApplication application;
3312 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3314 TextEditor editor = TextEditor::New();
3315 DALI_TEST_CHECK(editor);
3316 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3317 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3318 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3319 application.GetScene().Add(editor);
3321 application.SendNotification();
3322 application.Render();
3324 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3325 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3327 // Check the disable match system language direction property
3328 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3329 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3331 application.SendNotification();
3332 application.Render();
3337 int UtcDaliTextEditorGetInputMethodContext(void)
3339 ToolkitTestApplication application;
3340 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3342 TextEditor editor = TextEditor::New();
3343 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3348 int utcDaliTextEditorMaxCharactersReached(void)
3350 ToolkitTestApplication application;
3351 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3353 TextEditor editor = TextEditor::New();
3354 DALI_TEST_CHECK(editor);
3356 application.GetScene().Add(editor);
3358 const int maxNumberOfCharacters = 1;
3359 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3360 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3362 editor.SetKeyInputFocus();
3364 // connect to the text changed signal.
3365 ConnectionTracker* testTracker = new ConnectionTracker();
3366 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3367 bool maxLengthReachedSignal = false;
3368 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3370 gMaxCharactersCallBackCalled = false;
3372 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3373 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3375 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3376 DALI_TEST_CHECK(maxLengthReachedSignal);
3381 int utcDaliTextEditorInputFiltered(void)
3383 ToolkitTestApplication application;
3384 tet_infoline(" utcDaliTextEditorInputFiltered");
3385 TextEditor editor = TextEditor::New();
3386 DALI_TEST_CHECK(editor);
3388 application.GetScene().Add(editor);
3390 Property::Map inputFilter;
3392 // Only digit is accepted.
3393 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3395 // Set input filter to TextEditor.
3396 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3398 editor.SetKeyInputFocus();
3400 // connect to the input filtered signal.
3401 ConnectionTracker* testTracker = new ConnectionTracker();
3402 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3403 bool inputFilteredSignal = false;
3404 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3406 gInputFilteredAcceptedCallbackCalled = false;
3408 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3410 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3411 DALI_TEST_CHECK(inputFilteredSignal);
3413 // Word is rejected.
3414 inputFilter[InputFilter::Property::ACCEPTED] = "";
3415 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3417 // Set input filter to TextEditor.
3418 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3420 editor.SetKeyInputFocus();
3422 inputFilteredSignal = false;
3423 gInputFilteredRejectedCallbackCalled = false;
3425 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3427 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3428 DALI_TEST_CHECK(inputFilteredSignal);
3433 int UtcDaliTextEditorSelectWholeText(void)
3435 ToolkitTestApplication application;
3436 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3438 TextEditor textEditor = TextEditor::New();
3440 application.GetScene().Add(textEditor);
3442 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3443 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3444 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3446 // Avoid a crash when core load gl resources.
3447 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3449 application.SendNotification();
3450 application.Render();
3452 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3454 DevelTextEditor::SelectWholeText(textEditor);
3456 application.SendNotification();
3457 application.Render();
3459 // Nothing should have been selected. The number of children is still 1
3460 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3462 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3464 application.SendNotification();
3465 application.Render();
3467 DevelTextEditor::SelectWholeText(textEditor);
3469 application.SendNotification();
3470 application.Render();
3472 // Should be 2 children, the stencil and the layer
3473 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3475 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3476 Actor stencil = textEditor.GetChildAt(0u);
3478 // The highlight actor is drawn first, so is the first actor in the list
3479 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3480 DALI_TEST_CHECK(highlight);
3485 int UtcDaliTextEditorSelectText(void)
3487 ToolkitTestApplication application;
3488 tet_infoline(" UtcDaliTextEditorSelectText ");
3490 TextEditor textEditor = TextEditor::New();
3492 application.GetScene().Add(textEditor);
3494 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3495 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3496 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3498 // Avoid a crash when core load gl resources.
3499 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3501 application.SendNotification();
3502 application.Render();
3504 DevelTextEditor::SelectText(textEditor, 0, 5);
3506 application.SendNotification();
3507 application.Render();
3509 // Nothing is selected
3510 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3511 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3513 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3515 application.SendNotification();
3516 application.Render();
3518 DevelTextEditor::SelectText(textEditor, 0, 5);
3520 application.SendNotification();
3521 application.Render();
3523 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3524 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3526 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3527 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3529 // world is selected
3530 DevelTextEditor::SelectText(textEditor, 6, 11);
3532 application.SendNotification();
3533 application.Render();
3535 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3536 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3538 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3539 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3544 int UtcDaliTextEditorSelectNone(void)
3546 ToolkitTestApplication application;
3547 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3549 TextEditor textEditor = TextEditor::New();
3551 application.GetScene().Add(textEditor);
3553 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3554 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3555 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3557 // Avoid a crash when core load gl resources.
3558 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3560 application.SendNotification();
3561 application.Render();
3563 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3565 application.SendNotification();
3566 application.Render();
3568 // Nothing is selected
3569 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3570 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3572 DevelTextEditor::SelectWholeText(textEditor);
3574 application.SendNotification();
3575 application.Render();
3577 // whole text is selected
3578 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3579 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3581 DevelTextEditor::SelectNone(textEditor);
3583 application.SendNotification();
3584 application.Render();
3586 // Nothing is selected
3587 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3588 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3593 int UtcDaliTextEditorSelectRange(void)
3595 ToolkitTestApplication application;
3596 tet_infoline("utcDaliTextEditorSelectRange");
3598 TextEditor textEditor = TextEditor::New();
3599 DALI_TEST_CHECK(textEditor);
3601 application.GetScene().Add(textEditor);
3603 // Avoid a crash when core load gl resources.
3604 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3606 application.SendNotification();
3607 application.Render();
3609 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3611 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3612 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3614 // Hello is selected
3615 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3616 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3618 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3619 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3624 int UtcDaliTextEditorEnableEditing(void)
3626 ToolkitTestApplication application;
3627 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3629 TextEditor textEditor = TextEditor::New();
3631 application.GetScene().Add(textEditor);
3633 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3634 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3635 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3637 // Avoid a crash when core load gl resources.
3638 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3640 application.SendNotification();
3641 application.Render();
3643 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3644 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3646 textEditor.SetKeyInputFocus();
3647 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3648 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3650 // Render and notify
3651 application.SendNotification();
3652 application.Render();
3654 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3655 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3657 textEditor.SetKeyInputFocus();
3658 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3659 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3661 // Render and notify
3662 application.SendNotification();
3663 application.Render();
3665 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3666 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3668 // Check the user interaction enabled and for coverage
3669 DevelTextEditor::SelectWholeText(textEditor);
3671 // Render and notify
3672 application.SendNotification();
3673 application.Render();
3675 textEditor.SetKeyInputFocus();
3676 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3677 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3679 // Render and notify
3680 application.SendNotification();
3681 application.Render();
3683 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3684 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3689 int UtcDaliTextEditorScrolling(void)
3691 ToolkitTestApplication application;
3692 tet_infoline(" UtcDaliTextEditorScrolling ");
3694 TextEditor textEditor = TextEditor::New();
3695 DALI_TEST_CHECK(textEditor);
3697 application.GetScene().Add(textEditor);
3699 // Avoid a crash when core load gl resources.
3700 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3702 application.SendNotification();
3703 application.Render();
3705 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3706 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3707 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3708 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3710 application.SendNotification();
3711 application.Render();
3713 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3714 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3716 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3718 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
3719 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3721 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3723 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
3724 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3726 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
3727 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
3729 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3730 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3735 int UtcDaliToolkitTextEditorFontSizeScale(void)
3737 ToolkitTestApplication application;
3738 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3740 TextEditor textEditor = TextEditor::New();
3741 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
3742 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3743 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3745 TextEditor textEditorScaled = TextEditor::New();
3746 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
3747 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3748 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3749 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3751 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3753 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
3754 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3755 nonScaledSize = textEditor.GetNaturalSize();
3757 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
3758 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3759 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3760 scaledSize = textEditorScaled.GetNaturalSize();
3762 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3767 int UtcDaliTextEditorPrimaryCursorPosition(void)
3769 ToolkitTestApplication application;
3770 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3772 TextEditor textEditor = TextEditor::New();
3774 application.GetScene().Add(textEditor);
3776 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
3777 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3778 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3779 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3781 // Avoid a crash when core load gl resources.
3782 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3784 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3785 application.SendNotification();
3786 application.Render();
3787 textEditor.SetKeyInputFocus();
3789 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3791 // Render and notify
3792 application.SendNotification();
3793 application.Render();
3795 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3796 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3801 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3803 ToolkitTestApplication application;
3804 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3806 TextEditor textEditor = TextEditor::New();
3807 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3808 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3809 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3810 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3811 application.GetScene().Add(textEditor);
3813 application.SendNotification();
3814 application.Render();
3817 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3818 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3820 textEditor.GetNaturalSize();
3822 // Create a tap event to touch the text editor.
3823 TestGenerateTap(application, 18.0f, 25.0f);
3825 application.SendNotification();
3826 application.Render();
3828 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3829 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3834 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3836 ToolkitTestApplication application;
3838 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3840 int lineCountBefore = 0;
3841 int lineCountAfter = 0;
3843 // Create a text editor
3844 TextEditor textEditor = TextEditor::New();
3845 //Set very large font-size using point-size
3846 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3847 //Specify font-family
3848 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3850 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3851 //Set text longer than width of textEditor
3852 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3854 application.GetScene().Add(textEditor);
3856 application.SendNotification();
3857 application.Render();
3859 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3860 //GetHeightForWidth is a retrieval method which should not modify object
3861 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3862 textEditor.GetHeightForWidth(200.f);
3864 //This is to simulate focus into text editor after calling GetHeightForWidth
3865 //Create a tap event to touch the text editor.
3866 TestGenerateTap(application, 18.0f, 25.0f);
3868 application.SendNotification();
3869 application.Render();
3871 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3873 //The LineCount must not be changed when calling GetHeightForWidth.
3874 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3879 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3881 ToolkitTestApplication application;
3883 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3885 int lineCountBefore = 0;
3886 int lineCountAfter = 0;
3888 // Create a text editor
3889 TextEditor textEditor = TextEditor::New();
3890 //Set very large font-size using point-size
3891 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3892 //Specify font-family
3893 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3895 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3896 //Set text longer than width of textEditor
3897 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3898 //Set line wrap mode Character
3899 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3901 application.GetScene().Add(textEditor);
3903 application.SendNotification();
3904 application.Render();
3906 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3907 //GetHeightForWidth is a retrieval method which should not modify object
3908 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3909 textEditor.GetHeightForWidth(200.f);
3911 //This is to simulate focus into text editor after calling GetHeightForWidth
3912 //Create a tap event to touch the text editor.
3913 TestGenerateTap(application, 18.0f, 25.0f);
3915 application.SendNotification();
3916 application.Render();
3918 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3920 //The LineCount must not be changed when calling GetHeightForWidth.
3921 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3926 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3928 ToolkitTestApplication application;
3930 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3932 int lineCountBefore = 0;
3933 int lineCountAfter = 0;
3935 // Create a text editor
3936 TextEditor textEditor = TextEditor::New();
3937 //Set very large font-size using point-size
3938 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3939 //Specify font-family
3940 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3942 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
3943 //Set text longer than width of textEditor
3944 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
3945 //Set line wrap mode Character
3946 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3948 application.GetScene().Add(textEditor);
3950 application.SendNotification();
3951 application.Render();
3953 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3955 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3956 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3958 // When the text changed, the Line-count should be updated according to new text.
3959 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3960 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
3961 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
3966 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3968 ToolkitTestApplication application;
3970 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3972 int lineCountBefore = 0;
3973 int lineCountAfter = 0;
3975 // Create a text editor
3976 TextEditor textEditor = TextEditor::New();
3977 //Set very large font-size using point-size
3978 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3979 //Specify font-family
3980 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3982 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3983 //Set text longer than width of textEditor
3984 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3986 application.GetScene().Add(textEditor);
3988 application.SendNotification();
3989 application.Render();
3991 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3992 //GetNaturalSize is a retrieval method which should not modify object
3993 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3994 textEditor.GetNaturalSize();
3996 //This is to simulate focus into text editor after calling GetNaturalSize
3997 //Create a tap event to touch the text editor.
3998 TestGenerateTap(application, 18.0f, 25.0f);
4000 application.SendNotification();
4001 application.Render();
4003 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4005 //The LineCount must not be changed when calling GetNaturalSize.
4006 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4011 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4013 ToolkitTestApplication application;
4015 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4017 int lineCountBefore = 0;
4018 int lineCountAfter = 0;
4020 // Create a text editor
4021 TextEditor textEditor = TextEditor::New();
4022 //Set very large font-size using point-size
4023 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4024 //Specify font-family
4025 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4027 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4028 //Set text longer than width of textEditor
4029 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4030 //Set line wrap mode Character
4031 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4033 application.GetScene().Add(textEditor);
4035 application.SendNotification();
4036 application.Render();
4038 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4039 //GetNaturalSize is a retrieval method which should not modify object
4040 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4041 textEditor.GetNaturalSize();
4043 //This is to simulate focus into text editor after calling GetNaturalSize
4044 //Create a tap event to touch the text editor.
4045 TestGenerateTap(application, 18.0f, 25.0f);
4047 application.SendNotification();
4048 application.Render();
4050 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4052 //The LineCount must not be changed when calling GetNaturalSize.
4053 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4058 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4060 ToolkitTestApplication application;
4061 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4063 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4064 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4065 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4067 // Create a text editor
4068 TextEditor textEditor = TextEditor::New();
4070 //Set size to avoid automatic eliding
4071 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4072 //Set very large font-size using point-size
4073 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4074 //Specify font-family
4075 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4076 //Set text to check if appear or not
4077 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4079 application.GetScene().Add(textEditor);
4081 application.SendNotification();
4082 application.Render();
4083 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4084 Vector3 naturalSize = textEditor.GetNaturalSize();
4086 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4087 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4092 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4094 ToolkitTestApplication application;
4095 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4097 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4098 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4099 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4101 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4102 // Create a text editor
4103 TextEditor textEditor = TextEditor::New();
4104 //Set size to avoid automatic eliding
4105 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4106 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4107 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4109 const int numberOfCases = 6;
4110 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4112 for(int index = 0; index < numberOfCases; index++)
4114 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4115 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4116 application.GetScene().Add(textEditor);
4117 application.SendNotification();
4118 application.Render();
4119 naturalSize = textEditor.GetNaturalSize();
4120 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4121 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4127 int UtcDaliTextEditorHyphenWrapMode(void)
4129 ToolkitTestApplication application;
4130 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4133 TextEditor textEditor = TextEditor::New();
4135 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4137 application.GetScene().Add(textEditor);
4138 application.SendNotification();
4139 application.Render();
4141 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4142 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4143 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4145 application.SendNotification();
4146 application.Render();
4148 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4154 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4156 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4157 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4158 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4160 application.SendNotification();
4161 application.Render();
4163 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4170 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4175 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4177 ToolkitTestApplication application;
4178 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4179 TextEditor textEditor = TextEditor::New();
4181 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4182 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4184 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4185 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4186 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4188 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4189 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4190 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4192 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4193 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4194 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4196 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4197 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4198 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4200 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4201 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4202 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4204 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4205 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4206 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4208 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4209 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4210 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4212 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4213 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4214 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4216 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4217 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4218 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4220 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4221 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4222 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4224 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4225 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4226 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4228 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4229 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4230 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4235 int UtcDaliTextEditorCopyText(void)
4237 ToolkitTestApplication application;
4238 tet_infoline(" UtcDaliTextEditorCopyText ");
4240 TextEditor textEditor = TextEditor::New();
4242 std::string selectedText = "";
4243 std::string copiedText = "";
4245 application.GetScene().Add(textEditor);
4247 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4248 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4249 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4251 // Avoid a crash when core load gl resources.
4252 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4254 application.SendNotification();
4255 application.Render();
4257 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4259 application.SendNotification();
4260 application.Render();
4262 // Hello is selected
4263 DevelTextEditor::SelectText(textEditor, 0, 5);
4265 application.SendNotification();
4266 application.Render();
4268 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4269 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4271 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4272 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4275 copiedText = DevelTextEditor::CopyText(textEditor);
4276 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4278 // world is selected
4279 DevelTextEditor::SelectText(textEditor, 6, 11);
4281 application.SendNotification();
4282 application.Render();
4284 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4285 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4287 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4288 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4291 copiedText = DevelTextEditor::CopyText(textEditor);
4292 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4294 // "lo wo" is selected
4295 DevelTextEditor::SelectText(textEditor, 3, 8);
4297 application.SendNotification();
4298 application.Render();
4300 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4301 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4303 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4304 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4306 // "lo wo" is copied
4307 copiedText = DevelTextEditor::CopyText(textEditor);
4308 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4313 int UtcDaliTextEditorCutText(void)
4315 ToolkitTestApplication application;
4316 tet_infoline(" UtcDaliTextEditorCutText ");
4318 TextEditor textEditor = TextEditor::New();
4320 std::string selectedText = "";
4322 application.GetScene().Add(textEditor);
4324 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4325 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4326 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4328 // Avoid a crash when core load gl resources.
4329 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4331 application.SendNotification();
4332 application.Render();
4334 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4336 application.SendNotification();
4337 application.Render();
4339 // Hello is selected
4340 DevelTextEditor::SelectText(textEditor, 0, 5);
4342 application.SendNotification();
4343 application.Render();
4345 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4346 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4348 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4349 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4352 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4354 application.SendNotification();
4355 application.Render();
4357 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4360 DevelTextEditor::SelectText(textEditor, 0, 2);
4362 application.SendNotification();
4363 application.Render();
4365 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4366 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4368 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4369 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4372 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4374 application.SendNotification();
4375 application.Render();
4377 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4379 // Test Cut from the middle
4382 DevelTextEditor::SelectText(textEditor, 1, 3);
4384 application.SendNotification();
4385 application.Render();
4387 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4388 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4390 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4391 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4394 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4396 application.SendNotification();
4397 application.Render();
4399 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4401 // Test Cut from the end
4404 DevelTextEditor::SelectText(textEditor, 1, 2);
4406 application.SendNotification();
4407 application.Render();
4409 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4410 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4412 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4413 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4416 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4418 application.SendNotification();
4419 application.Render();
4421 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4426 int UtcDaliTextEditorPasteText(void)
4428 ToolkitTestApplication application;
4429 tet_infoline(" UtcDaliTextEditorPasteText ");
4431 TextEditor editor = TextEditor::New();
4432 DALI_TEST_CHECK(editor);
4434 application.GetScene().Add(editor);
4436 std::string cutText = "";
4437 std::string copiedText = "";
4439 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4440 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4441 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4442 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4443 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4445 // Avoid a crash when core load gl resources.
4446 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4448 // Render and notify
4449 application.SendNotification();
4450 application.Render();
4452 // Tap on the text editor
4453 TestGenerateTap(application, 3.0f, 25.0f);
4455 // Render and notify
4456 application.SendNotification();
4457 application.Render();
4459 // Move to second line of the text.
4460 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4462 // Render and notify
4463 application.SendNotification();
4464 application.Render();
4466 // Select some text in the right of the current cursor position
4467 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4468 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4469 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4470 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4472 // Render and notify
4473 application.SendNotification();
4474 application.Render();
4476 // Cut the selected text
4477 cutText = DevelTextEditor::CutText(editor);
4479 // Render and notify
4480 application.SendNotification();
4481 application.Render();
4483 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4484 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4486 // Select some text in the left of the current cursor position
4487 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4488 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4489 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4490 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4492 // Render and notify
4493 application.SendNotification();
4494 application.Render();
4496 // Copy the selected text
4497 copiedText = DevelTextEditor::CopyText(editor);
4499 // Render and notify
4500 application.SendNotification();
4501 application.Render();
4503 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4504 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4506 // Move the cursor to the third line
4507 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4508 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4510 // Render and notify
4511 application.SendNotification();
4512 application.Render();
4514 // Paste the selected text at the current cursor position
4515 DevelTextEditor::PasteText(editor);
4517 // Render and notify
4518 application.SendNotification();
4519 application.Render();
4521 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4526 int UtcDaliTextEditorLineSpacing(void)
4528 ToolkitTestApplication application;
4529 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4531 TextEditor textEditor = TextEditor::New();
4532 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4533 application.GetScene().Add(textEditor);
4534 application.SendNotification();
4535 application.Render();
4537 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4538 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4540 Vector3 sizeBefore = textEditor.GetNaturalSize();
4542 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4544 //add 20 for each line 20 * 3
4545 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4550 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4552 //Only for test coverage
4553 ToolkitTestApplication application;
4554 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4556 TextEditor textEditor = TextEditor::New();
4557 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4558 application.GetScene().Add(textEditor);
4559 application.SendNotification();
4560 application.Render();
4562 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4563 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4565 application.SendNotification();
4566 application.Render();
4568 DevelTextEditor::SelectWholeText(textEditor);
4570 application.SendNotification();
4571 application.Render();
4573 DevelTextEditor::SelectNone(textEditor);
4574 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4576 application.SendNotification();
4577 application.Render();
4579 DevelTextEditor::SelectWholeText(textEditor);
4581 application.SendNotification();
4582 application.Render();
4584 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4589 int UtcDaliTextEditorMinLineSize(void)
4591 ToolkitTestApplication application;
4592 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4594 TextEditor textEditor = TextEditor::New();
4595 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4596 application.GetScene().Add(textEditor);
4597 application.SendNotification();
4598 application.Render();
4600 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4601 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4603 Vector3 sizeBefore = textEditor.GetNaturalSize();
4605 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4607 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4610 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4615 int utcDaliTextEditorCursorPositionChangedSignal(void)
4617 ToolkitTestApplication application;
4618 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4620 TextEditor editor = TextEditor::New();
4621 DALI_TEST_CHECK(editor);
4623 application.GetScene().Add(editor);
4625 // connect to the selection changed signal.
4626 ConnectionTracker* testTracker = new ConnectionTracker();
4627 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4628 bool cursorPositionChangedSignal = false;
4629 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4631 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4632 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4633 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4634 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4635 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4637 // Avoid a crash when core load gl resources.
4638 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4640 // Render and notify
4641 application.SendNotification();
4642 application.Render();
4644 editor.SetKeyInputFocus();
4646 // Tap on the text editor
4647 TestGenerateTap(application, 3.0f, 25.0f);
4649 // Render and notify
4650 application.SendNotification();
4651 application.Render();
4653 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4654 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4656 gCursorPositionChangedCallbackCalled = false;
4659 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4661 // Render and notify
4662 application.SendNotification();
4663 application.Render();
4665 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4666 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4668 gCursorPositionChangedCallbackCalled = false;
4671 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4673 // Render and notify
4674 application.SendNotification();
4675 application.Render();
4677 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4678 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4680 gCursorPositionChangedCallbackCalled = false;
4682 //delete one character
4683 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4685 // Render and notify
4686 application.SendNotification();
4687 application.Render();
4689 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4690 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4692 gCursorPositionChangedCallbackCalled = false;
4694 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
4696 // Render and notify
4697 application.SendNotification();
4698 application.Render();
4700 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4701 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4703 gCursorPositionChangedCallbackCalled = false;
4705 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4707 // Render and notify
4708 application.SendNotification();
4709 application.Render();
4711 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4712 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4717 int utcDaliTextEditorGeometryEllipsisStart(void)
4719 ToolkitTestApplication application;
4720 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4722 TextEditor editor = TextEditor::New();
4723 DALI_TEST_CHECK(editor);
4725 application.GetScene().Add(editor);
4727 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4728 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4729 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4730 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4731 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4732 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4733 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4734 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4735 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4737 // Avoid a crash when core load gl resources.
4738 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4740 // Render and notify
4741 application.SendNotification();
4742 application.Render();
4744 unsigned int expectedCount = 2;
4745 unsigned int startIndex = 0;
4746 unsigned int endIndex = 24;
4748 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4749 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4751 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4752 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4754 Vector<Vector2> expectedSizes;
4755 Vector<Vector2> expectedPositions;
4757 expectedPositions.PushBack(Vector2(37, 0));
4758 expectedSizes.PushBack(Vector2(20, 25));
4760 expectedPositions.PushBack(Vector2(-1, 25));
4761 expectedSizes.PushBack(Vector2(52, 25));
4763 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4768 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4770 ToolkitTestApplication application;
4771 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4773 TextEditor editor = TextEditor::New();
4774 DALI_TEST_CHECK(editor);
4776 application.GetScene().Add(editor);
4778 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4779 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4780 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4781 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4782 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4783 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4784 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4785 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4786 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4788 // Avoid a crash when core load gl resources.
4789 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4791 // Render and notify
4792 application.SendNotification();
4793 application.Render();
4795 unsigned int expectedCount = 2;
4796 unsigned int startIndex = 0;
4797 unsigned int endIndex = 24;
4799 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4800 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4802 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4803 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4805 Vector<Vector2> expectedSizes;
4806 Vector<Vector2> expectedPositions;
4808 expectedPositions.PushBack(Vector2(-1, 0));
4809 expectedSizes.PushBack(Vector2(25, 25));
4811 expectedPositions.PushBack(Vector2(-1, 25));
4812 expectedSizes.PushBack(Vector2(52, 25));
4814 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4819 int utcDaliTextEditorGeometryEllipsisEnd(void)
4821 ToolkitTestApplication application;
4822 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4824 TextEditor editor = TextEditor::New();
4825 DALI_TEST_CHECK(editor);
4827 application.GetScene().Add(editor);
4829 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4830 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4831 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4832 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4833 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4834 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4835 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4836 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4837 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4839 // Avoid a crash when core load gl resources.
4840 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4842 // Render and notify
4843 application.SendNotification();
4844 application.Render();
4846 unsigned int expectedCount = 2;
4847 unsigned int startIndex = 0;
4848 unsigned int endIndex = 24;
4850 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4851 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4853 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4854 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4856 Vector<Vector2> expectedSizes;
4857 Vector<Vector2> expectedPositions;
4859 expectedPositions.PushBack(Vector2(-1, 0));
4860 expectedSizes.PushBack(Vector2(59, 25));
4862 expectedPositions.PushBack(Vector2(-1, 25));
4863 expectedSizes.PushBack(Vector2(25, 25));
4865 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4870 int utcDaliTextEditorGeometryRTL(void)
4872 ToolkitTestApplication application;
4873 tet_infoline(" utcDaliTextEditorGeometryRTL");
4875 TextEditor editor = TextEditor::New();
4876 DALI_TEST_CHECK(editor);
4878 application.GetScene().Add(editor);
4880 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4881 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4882 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4883 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4884 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4885 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
4887 // Avoid a crash when core load gl resources.
4888 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4890 // Render and notify
4891 application.SendNotification();
4892 application.Render();
4894 unsigned int expectedCount = 4;
4895 unsigned int startIndex = 3;
4896 unsigned int endIndex = 24;
4898 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4899 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4901 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4902 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4904 Vector<Vector2> expectedSizes;
4905 Vector<Vector2> expectedPositions;
4907 expectedPositions.PushBack(Vector2(24, 0));
4908 expectedSizes.PushBack(Vector2(33, 25));
4910 expectedPositions.PushBack(Vector2(-1, 25));
4911 expectedSizes.PushBack(Vector2(52, 25));
4913 expectedPositions.PushBack(Vector2(-1, 50));
4914 expectedSizes.PushBack(Vector2(59, 25));
4916 expectedPositions.PushBack(Vector2(61, 75));
4917 expectedSizes.PushBack(Vector2(37, 25));
4919 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4924 int utcDaliTextEditorGeometryGlyphMiddle(void)
4926 ToolkitTestApplication application;
4927 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4929 TextEditor editor = TextEditor::New();
4930 DALI_TEST_CHECK(editor);
4932 application.GetScene().Add(editor);
4934 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4935 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4936 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4937 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4938 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4939 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
4941 // Avoid a crash when core load gl resources.
4942 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4944 // Render and notify
4945 application.SendNotification();
4946 application.Render();
4948 unsigned int expectedCount = 1;
4949 unsigned int startIndex = 1;
4950 unsigned int endIndex = 13;
4952 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4953 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4955 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4956 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4958 Vector<Vector2> expectedSizes;
4959 Vector<Vector2> expectedPositions;
4961 expectedPositions.PushBack(Vector2(6, 0));
4962 expectedSizes.PushBack(Vector2(124, 25));
4964 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4969 int utcDaliTextEditorSelectionClearedSignal(void)
4971 ToolkitTestApplication application;
4972 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4974 TextEditor editor = TextEditor::New();
4975 DALI_TEST_CHECK(editor);
4977 application.GetScene().Add(editor);
4979 // connect to the selection changed signal.
4980 ConnectionTracker* testTracker = new ConnectionTracker();
4981 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4982 bool selectionClearedSignal = false;
4983 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4985 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4986 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4987 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4988 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4989 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4991 // Avoid a crash when core load gl resources.
4992 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4994 // Render and notify
4995 application.SendNotification();
4996 application.Render();
4998 // Tap on the text editor
4999 TestGenerateTap(application, 3.0f, 25.0f);
5001 // Render and notify
5002 application.SendNotification();
5003 application.Render();
5005 // Move to second line of the text & Select some text in the right of the current cursor position
5006 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5007 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5010 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5012 // Render and notify
5013 application.SendNotification();
5014 application.Render();
5016 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5018 // Render and notify
5019 application.SendNotification();
5020 application.Render();
5022 // Tap on the text editor
5023 TestGenerateTap(application, 3.0f, 25.0f);
5025 // Render and notify
5026 application.SendNotification();
5027 application.Render();
5029 gSelectionClearedCallbackCalled = false;
5031 // Move to second line of the text & select.
5032 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5033 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5036 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5038 // Render and notify
5039 application.SendNotification();
5040 application.Render();
5042 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5044 gSelectionClearedCallbackCalled = false;
5046 // Render and notify
5047 application.SendNotification();
5048 application.Render();
5050 // Move to second line of the text & select.
5051 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5052 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5054 // replace C with selected text
5055 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5057 // Render and notify
5058 application.SendNotification();
5059 application.Render();
5061 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5063 gSelectionClearedCallbackCalled = false;
5065 // Render and notify
5066 application.SendNotification();
5067 application.Render();
5069 DevelTextEditor::SelectText(editor, 1, 3);
5071 // Render and notify
5072 application.SendNotification();
5073 application.Render();
5075 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5077 // Render and notify
5078 application.SendNotification();
5079 application.Render();
5081 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5083 gSelectionClearedCallbackCalled = false;
5085 DevelTextEditor::SelectText(editor, 1, 3);
5087 // Render and notify
5088 application.SendNotification();
5089 application.Render();
5092 DevelTextEditor::SelectNone(editor);
5094 // Render and notify
5095 application.SendNotification();
5096 application.Render();
5098 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5103 int utcDaliTextEditorSelectionStartedSignal(void)
5105 ToolkitTestApplication application;
5106 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5108 TextEditor editor = TextEditor::New();
5109 DALI_TEST_CHECK(editor);
5111 application.GetScene().Add(editor);
5113 // connect to the selection changed signal.
5114 ConnectionTracker* testTracker = new ConnectionTracker();
5115 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5116 bool selectionStartedSignal = false;
5117 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5119 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5120 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5121 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5122 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5123 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5125 // Avoid a crash when core load gl resources.
5126 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5128 // Render and notify
5129 application.SendNotification();
5130 application.Render();
5132 // Tap on the text editor
5133 TestGenerateTap(application, 3.0f, 25.0f);
5135 // Render and notify
5136 application.SendNotification();
5137 application.Render();
5139 // Move to second line of the text & Select some text in the right of the current cursor position
5140 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5141 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5143 // Render and notify
5144 application.SendNotification();
5145 application.Render();
5147 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5150 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5152 // Render and notify
5153 application.SendNotification();
5154 application.Render();
5156 gSelectionStartedCallbackCalled = false;
5158 DevelTextEditor::SelectText(editor, 1, 3);
5160 // Render and notify
5161 application.SendNotification();
5162 application.Render();
5164 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5169 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5171 ToolkitTestApplication application;
5172 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5174 // Checks if the actor is created.
5176 TextEditor editor = TextEditor::New();
5177 DALI_TEST_CHECK(editor);
5179 application.GetScene().Add(editor);
5181 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5182 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5183 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5184 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5185 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5186 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5187 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5188 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5190 // Avoid a crash when core load gl resources.
5191 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5193 // Render and notify
5194 application.SendNotification();
5195 application.Render();
5197 // Tap on the text editor
5198 TestGenerateTap(application, 3.0f, 25.0f);
5200 // Render and notify
5201 application.SendNotification();
5202 application.Render();
5204 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5205 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5207 application.SendNotification();
5208 application.Render();
5210 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5211 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5216 int utcDaliTextEditorSelectionChangedSignal(void)
5218 ToolkitTestApplication application;
5219 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5221 TextEditor editor = TextEditor::New();
5222 DALI_TEST_CHECK(editor);
5224 application.GetScene().Add(editor);
5226 // connect to the selection changed signal.
5227 ConnectionTracker* testTracker = new ConnectionTracker();
5228 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5229 bool selectionChangedSignal = false;
5230 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5232 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5233 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5234 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5235 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5236 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5238 // Avoid a crash when core load gl resources.
5239 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5241 // Render and notify
5242 application.SendNotification();
5243 application.Render();
5245 // Tap on the text editor
5246 TestGenerateTap(application, 3.0f, 25.0f);
5248 // Render and notify
5249 application.SendNotification();
5250 application.Render();
5252 // Move to second line of the text.
5253 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5255 // Render and notify
5256 application.SendNotification();
5257 application.Render();
5259 // Select some text in the right of the current cursor position
5260 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5261 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5263 // Render and notify
5264 application.SendNotification();
5265 application.Render();
5267 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5268 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5270 gSelectionChangedCallbackCalled = false;
5272 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5274 // Render and notify
5275 application.SendNotification();
5276 application.Render();
5278 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5279 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5280 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5282 gSelectionChangedCallbackCalled = false;
5284 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5286 // Render and notify
5287 application.SendNotification();
5288 application.Render();
5290 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5291 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5292 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5294 gSelectionChangedCallbackCalled = false;
5295 editor.SetKeyInputFocus();
5297 // Render and notify
5298 application.SendNotification();
5299 application.Render();
5301 DevelTextEditor::SelectText(editor, 0, 5);
5303 application.SendNotification();
5304 application.Render();
5306 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5307 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5309 gSelectionChangedCallbackCalled = false;
5311 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5313 // Render and notify
5314 application.SendNotification();
5315 application.Render();
5317 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5318 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5319 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5321 gSelectionChangedCallbackCalled = false;
5324 DevelTextEditor::SelectWholeText(editor);
5326 // Render and notify
5327 application.SendNotification();
5328 application.Render();
5330 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5331 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5333 gSelectionChangedCallbackCalled = false;
5336 DevelTextEditor::SelectNone(editor);
5338 // Render and notify
5339 application.SendNotification();
5340 application.Render();
5342 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5343 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5344 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5349 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5351 ToolkitTestApplication application;
5352 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5354 TextEditor textEditor = TextEditor::New();
5355 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5356 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5357 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5358 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5360 application.GetScene().Add(textEditor);
5361 application.SendNotification();
5362 application.Render();
5364 Property::Map strikethroughMapSet;
5365 Property::Map strikethroughMapGet;
5367 strikethroughMapSet.Insert("enable", true);
5368 strikethroughMapSet.Insert("color", Color::RED);
5369 strikethroughMapSet.Insert("height", 2.0f);
5371 // Check the strikethrough property
5372 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5373 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5374 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5375 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5376 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5378 // Render and notify
5379 application.SendNotification();
5380 application.Render();
5382 strikethroughMapSet.Clear();
5383 strikethroughMapGet.Clear();
5388 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5390 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5391 //DaliException on vector: "Iterator not inside vector"
5393 ToolkitTestApplication application;
5394 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5396 TextEditor editor = TextEditor::New();
5397 DALI_TEST_CHECK(editor);
5399 application.GetScene().Add(editor);
5401 // Avoid a crash when core load gl resources.
5402 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5404 //Set multilines text
5405 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5406 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5407 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5409 //Set ResizePolicy to NaturalSize
5410 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5412 // Render and notify
5413 application.SendNotification();
5414 application.Render();
5416 // Create a tap event to touch the text editor.
5417 TestGenerateTap(application, 5.0f, 5.0f);
5419 // Render and notify
5420 application.SendNotification();
5421 application.Render();
5423 // Set currsor and add character (in first line)
5424 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5425 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5426 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5428 // Render and notify
5429 application.SendNotification();
5430 application.Render();
5432 //Check the changed text and cursor position
5433 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5434 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5436 // Render and notify
5437 application.SendNotification();
5438 application.Render();
5443 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5445 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5446 //DaliException on vector: "Iterator not inside vector"
5448 ToolkitTestApplication application;
5449 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5451 TextEditor editor = TextEditor::New();
5452 DALI_TEST_CHECK(editor);
5454 application.GetScene().Add(editor);
5456 // Avoid a crash when core load gl resources.
5457 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5459 //Set multilines text
5460 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5461 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5462 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5464 //Set ResizePolicy to NaturalSize
5465 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5468 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5469 application.SendNotification();
5470 application.Render();
5472 // Set focus and remove character
5473 editor.SetKeyInputFocus();
5474 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5476 // Render and notify
5477 application.SendNotification();
5478 application.Render();
5480 //Check the changed text and cursor position
5481 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5482 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5484 // Render and notify
5485 application.SendNotification();
5486 application.Render();
5491 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5493 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5494 //DaliException on vector: "Iterator not inside vector"
5496 ToolkitTestApplication application;
5497 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5499 TextEditor editor = TextEditor::New();
5500 DALI_TEST_CHECK(editor);
5502 application.GetScene().Add(editor);
5504 // Avoid a crash when core load gl resources.
5505 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5507 //Set multilines text
5508 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5509 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5510 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5512 //Set ResizePolicy to NaturalSize
5513 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5515 //Select text at initialization (before the first render)
5516 DevelTextEditor::SelectText(editor, 3, 5);
5518 // Render and notify
5519 application.SendNotification();
5520 application.Render();
5523 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5524 application.ProcessEvent(GenerateKey("x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5526 // Render and notify
5527 application.SendNotification();
5528 application.Render();
5530 //Check the changed text and cursor position
5531 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5532 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5534 // Render and notify
5535 application.SendNotification();
5536 application.Render();
5541 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5543 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5544 //DaliException on vector: "Iterator not inside vector"
5546 ToolkitTestApplication application;
5547 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5549 TextEditor editor = TextEditor::New();
5550 DALI_TEST_CHECK(editor);
5552 application.GetScene().Add(editor);
5554 // Avoid a crash when core load gl resources.
5555 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5557 //Set multilines text
5558 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5559 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5560 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5562 //Set ResizePolicy to NaturalSize
5563 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5566 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5567 application.SendNotification();
5568 application.Render();
5570 // Set focus and double enter (new line)
5571 editor.SetKeyInputFocus();
5572 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5573 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5575 // Render and notify
5576 application.SendNotification();
5577 application.Render();
5579 //Check the changed text and cursor position
5580 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5581 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5583 // Render and notify
5584 application.SendNotification();
5585 application.Render();
5590 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5592 ToolkitTestApplication application;
5593 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5594 TextEditor textEditor = TextEditor::New();
5595 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5596 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5597 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5598 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5600 application.GetScene().Add(textEditor);
5601 application.SendNotification();
5602 application.Render();
5604 Property::Map underlineMapSet;
5605 Property::Map underlineMapGet;
5607 underlineMapSet.Insert("enable", true);
5608 underlineMapSet.Insert("color", Color::RED);
5609 underlineMapSet.Insert("height", 1);
5610 underlineMapSet.Insert("type", Text::Underline::SOLID);
5611 underlineMapSet.Insert("dashWidth", 2);
5612 underlineMapSet.Insert("dashGap", 1);
5614 // Check the underline property
5615 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5617 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5618 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5619 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5621 // Render and notify
5622 application.SendNotification();
5623 application.Render();
5625 underlineMapSet.Clear();
5626 underlineMapGet.Clear();
5628 underlineMapSet.Insert("enable", true);
5629 underlineMapSet.Insert("color", Color::BLUE);
5630 underlineMapSet.Insert("height", 1);
5631 underlineMapSet.Insert("type", Text::Underline::DASHED);
5632 underlineMapSet.Insert("dashWidth", 4);
5633 underlineMapSet.Insert("dashGap", 2);
5635 // Check the dashed underline property
5636 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5638 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5639 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5640 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5642 // Render and notify
5643 application.SendNotification();
5644 application.Render();
5646 underlineMapSet.Clear();
5647 underlineMapGet.Clear();
5649 underlineMapSet.Insert("enable", true);
5650 underlineMapSet.Insert("color", Color::BLUE);
5651 underlineMapSet.Insert("height", 1);
5652 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5653 underlineMapSet.Insert("dashWidth", 4);
5654 underlineMapSet.Insert("dashGap", 2);
5656 // Check the dashed underline property
5657 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5659 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5660 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5661 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5663 // Render and notify
5664 application.SendNotification();
5665 application.Render();
5667 underlineMapSet.Clear();
5668 underlineMapGet.Clear();
5673 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
5675 ToolkitTestApplication application;
5676 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
5678 TextEditor textEditor1 = TextEditor::New();
5679 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
5680 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5681 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5682 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5684 Property::Map underlineMapSet1;
5685 Property::Map underlineMapGet1;
5687 underlineMapSet1.Insert("enable", true);
5688 underlineMapSet1.Insert("color", Color::RED);
5689 underlineMapSet1.Insert("height", 1);
5690 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5691 underlineMapSet1.Insert("dashWidth", 2);
5692 underlineMapSet1.Insert("dashGap", 1);
5694 // Check the underline property
5695 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5697 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5698 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5699 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5701 application.GetScene().Add(textEditor1);
5702 application.SendNotification();
5703 application.Render();
5705 TextEditor textEditor2 = TextEditor::New();
5706 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
5707 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5708 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5709 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5711 Property::Map underlineMapSet2;
5712 Property::Map underlineMapGet2;
5714 underlineMapSet2.Insert("enable", true);
5715 underlineMapSet2.Insert("color", Color::BLUE);
5716 underlineMapSet2.Insert("height", 1);
5717 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5718 underlineMapSet2.Insert("dashWidth", 4);
5719 underlineMapSet2.Insert("dashGap", 2);
5721 // Check the dashed underline property
5722 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
5724 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5725 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5726 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5728 application.GetScene().Add(textEditor2);
5729 application.SendNotification();
5730 application.Render();
5732 TextEditor textEditor3 = TextEditor::New();
5733 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
5734 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5735 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5736 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5738 Property::Map underlineMapSet3;
5739 Property::Map underlineMapGet3;
5741 underlineMapSet3.Insert("enable", true);
5742 underlineMapSet3.Insert("color", Color::BLUE);
5743 underlineMapSet3.Insert("height", 1);
5744 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5745 underlineMapSet3.Insert("dashWidth", 4);
5746 underlineMapSet3.Insert("dashGap", 2);
5748 // Check the dashed underline property
5749 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
5751 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5752 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5753 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5755 application.GetScene().Add(textEditor3);
5756 application.SendNotification();
5757 application.Render();
5762 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
5764 ToolkitTestApplication application;
5765 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
5767 TextEditor textEditor1 = TextEditor::New();
5768 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
5769 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5770 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5771 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5773 Property::Map underlineMapSet1;
5774 Property::Map underlineMapGet1;
5776 underlineMapSet1.Insert("enable", true);
5777 underlineMapSet1.Insert("color", Color::RED);
5778 underlineMapSet1.Insert("height", 1);
5779 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5780 underlineMapSet1.Insert("dashWidth", 2);
5781 underlineMapSet1.Insert("dashGap", 1);
5783 // Check the underline property
5784 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5785 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
5787 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5788 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5789 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5791 application.GetScene().Add(textEditor1);
5793 application.SendNotification();
5794 application.Render();
5799 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
5801 ToolkitTestApplication application;
5802 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
5804 TextEditor editor = TextEditor::New();
5805 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5806 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5807 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
5808 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5809 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5810 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5812 TextEditor editorSingleLineParagraph = TextEditor::New();
5813 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5814 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5815 editorSingleLineParagraph.SetProperty(TextEditor::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line 2</p>line 3<p rel-line-height=3>line 4</p>line 5");
5816 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5817 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5818 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5820 TextEditor editorMultiLineParagraph = TextEditor::New();
5821 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5822 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5823 editorMultiLineParagraph.SetProperty(TextEditor::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5");
5824 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5825 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5826 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5828 application.GetScene().Add(editor);
5829 application.GetScene().Add(editorSingleLineParagraph);
5830 application.GetScene().Add(editorMultiLineParagraph);
5831 application.SendNotification();
5832 application.Render();
5834 Vector3 naturalSize = editor.GetNaturalSize();
5835 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
5836 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
5838 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
5840 //no effect of relative line size for paragraph with single line
5841 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5843 DALI_TEST_EQUALS(lineSize*8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5848 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
5850 ToolkitTestApplication application;
5851 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
5853 TextEditor editor = TextEditor::New();
5854 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5855 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5856 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
5858 application.GetScene().Add(editor);
5859 application.SendNotification();
5860 application.Render();
5862 Vector3 naturalSize = editor.GetNaturalSize();
5864 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
5866 application.SendNotification();
5867 application.Render();
5869 Vector3 relativeNaturalSize = editor.GetNaturalSize();
5871 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
5873 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
5875 application.SendNotification();
5876 application.Render();
5878 relativeNaturalSize = editor.GetNaturalSize();
5880 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
5884 int UtcDaliTextEditorCharacterSpacing(void)
5886 ToolkitTestApplication application;
5887 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
5889 TextEditor textEditor = TextEditor::New();
5891 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5893 application.GetScene().Add(textEditor);
5894 application.SendNotification();
5895 application.Render();
5897 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
5898 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
5899 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5901 application.SendNotification();
5902 application.Render();
5907 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
5909 ToolkitTestApplication application;
5910 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
5912 TextEditor editor = TextEditor::New();
5914 float lineSpacing = -20.f;
5916 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
5917 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5918 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
5919 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
5921 application.GetScene().Add(editor);
5922 application.SendNotification();
5923 application.Render();
5925 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
5926 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
5928 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
5929 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
5931 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5932 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5934 application.SendNotification();
5935 application.Render();
5940 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
5942 ToolkitTestApplication application;
5943 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
5945 TextEditor editor = TextEditor::New();
5946 DALI_TEST_CHECK(editor);
5948 application.GetScene().Add(editor);
5950 std::string cutText = "";
5951 std::string copiedText = "";
5953 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
5954 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5955 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
5956 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5957 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5958 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5959 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
5961 // Render and notify
5962 application.SendNotification();
5963 application.Render();
5965 // Tap on the text editor
5966 TestGenerateTap(application, 1.0f, 1.0f);
5968 // Render and notify
5969 application.SendNotification();
5970 application.Render();
5972 // Move to second line of the text.
5973 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5975 // Render and notify
5976 application.SendNotification();
5977 application.Render();
5979 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5984 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
5986 ToolkitTestApplication application;
5987 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
5989 TextEditor editor = TextEditor::New();
5991 float lineSpacing = -20.f;
5993 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
5994 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
5995 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
5996 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
5997 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5999 application.GetScene().Add(editor);
6000 application.SendNotification();
6001 application.Render();
6003 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6005 int lineCount = sizeList.Size();
6006 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6008 application.SendNotification();
6009 application.Render();
6014 int UtcDaliToolkitTexteditorParagraphTag(void)
6016 ToolkitTestApplication application;
6017 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6018 TextEditor editorNewlineSeparator = TextEditor::New();
6019 TextEditor editorParagraphTag = TextEditor::New();
6020 DALI_TEST_CHECK(editorNewlineSeparator);
6021 DALI_TEST_CHECK(editorParagraphTag);
6023 application.GetScene().Add(editorNewlineSeparator);
6024 application.GetScene().Add(editorParagraphTag);
6026 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6027 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6028 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6029 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6030 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6031 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6033 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6034 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6035 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6036 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6037 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6039 application.SendNotification();
6040 application.Render();
6042 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6043 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6045 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6047 application.SendNotification();
6048 application.Render();
6053 //Handle Emoji clustering for cursor handling
6054 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6056 ToolkitTestApplication application;
6057 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6058 TextEditor textEditor = TextEditor::New();
6059 DALI_TEST_CHECK(textEditor);
6061 application.GetScene().Add(textEditor);
6063 // Avoid a crash when core load gl resources.
6064 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6066 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6067 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6069 // Render and notify
6070 application.SendNotification();
6071 application.Render();
6074 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6075 application.SendNotification();
6076 application.Render();
6078 // Set focus and remove Emoji
6079 textEditor.SetKeyInputFocus();
6080 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6082 //Check the changed text and cursor position
6083 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6084 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6086 // Render and notify
6087 application.SendNotification();
6088 application.Render();
6093 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6095 ToolkitTestApplication application;
6096 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6097 TextEditor textEditor = TextEditor::New();
6098 DALI_TEST_CHECK(textEditor);
6100 application.GetScene().Add(textEditor);
6102 // Avoid a crash when core load gl resources.
6103 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6105 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6106 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6108 // Render and notify
6109 application.SendNotification();
6110 application.Render();
6113 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6114 application.SendNotification();
6115 application.Render();
6117 // Set focus and remove Emoji
6118 textEditor.SetKeyInputFocus();
6119 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6121 //Check the changed text and cursor position
6122 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6123 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6125 // Render and notify
6126 application.SendNotification();
6127 application.Render();