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>
23 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/devel-api/adaptor-framework/clipboard.h>
27 #include <dali/devel-api/adaptor-framework/key-devel.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/integration-api/events/key-event-integ.h>
30 #include <dali/integration-api/events/touch-event-integ.h>
31 #include <dali/public-api/rendering/renderer.h>
35 #include "test-text-geometry-utils.h"
38 using namespace Toolkit;
40 void dali_texteditor_startup(void)
42 test_return_value = TET_UNDEF;
45 void dali_texteditor_cleanup(void)
47 test_return_value = TET_PASS;
52 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT = "text";
54 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
59 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
60 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
61 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
62 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
63 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
64 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
66 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
67 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
69 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
77 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
78 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
79 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
80 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
81 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
82 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
84 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
85 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
86 const char* const PROPERTY_NAME_UNDERLINE = "underline";
87 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
88 const char* const PROPERTY_NAME_SHADOW = "shadow";
89 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
90 const char* const PROPERTY_NAME_EMBOSS = "emboss";
91 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
92 const char* const PROPERTY_NAME_OUTLINE = "outline";
93 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
94 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
95 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
97 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
98 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
99 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
100 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
101 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
102 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
103 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
104 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
105 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
106 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
107 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
112 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
113 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
114 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
115 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
116 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
117 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
119 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
120 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
122 const float RENDER_FRAME_INTERVAL = 16.66f;
124 const unsigned int DEFAULT_FONT_SIZE = 1152u;
125 const std::string DEFAULT_FONT_DIR("/resources/fonts");
127 const int KEY_A_CODE = 38;
128 const int KEY_D_CODE = 40;
129 const int KEY_C_CODE = 54;
130 const int KEY_V_CODE = 55;
131 const int KEY_X_CODE = 53;
132 const int KEY_WHITE_SPACE_CODE = 65;
134 const int KEY_SHIFT_MODIFIER = 257;
135 const int KEY_CONTROL_MODIFIER = 258;
137 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
138 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
139 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
141 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
143 static bool gSelectionChangedCallbackCalled;
144 static uint32_t oldSelectionStart;
145 static uint32_t oldSelectionEnd;
146 static bool gSelectionClearedCallbackCalled;
147 static bool gSelectionStartedCallbackCalled;
148 static bool gAnchorClickedCallBackCalled;
149 static bool gAnchorClickedCallBackNotCalled;
150 static bool gTextChangedCallBackCalled;
151 static bool gInputFilteredAcceptedCallbackCalled;
152 static bool gInputFilteredRejectedCallbackCalled;
153 static bool gInputStyleChangedCallbackCalled;
154 static bool gMaxCharactersCallBackCalled;
155 static bool gCursorPositionChangedCallbackCalled;
156 static uint32_t oldCursorPos;
157 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
159 struct CallbackFunctor
161 CallbackFunctor(bool* callbackFlag)
162 : mCallbackFlag(callbackFlag)
168 *mCallbackFlag = true;
173 static void TestSelectionStartedCallback(TextEditor control)
175 tet_infoline(" TestSelectionStartedCallback");
177 gSelectionStartedCallbackCalled = true;
180 static void TestSelectionClearedCallback(TextEditor control)
182 tet_infoline(" TestSelectionClearedCallback");
184 gSelectionClearedCallbackCalled = true;
187 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
189 tet_infoline(" TestSelectionChangedCallback");
191 gSelectionChangedCallbackCalled = true;
192 oldSelectionStart = oldStart;
193 oldSelectionEnd = oldEnd;
196 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
198 tet_infoline(" TestAnchorClickedCallback");
200 gAnchorClickedCallBackNotCalled = false;
202 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
204 gAnchorClickedCallBackCalled = true;
208 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
210 tet_infoline(" TestCursorPositionChangedCallback");
212 gCursorPositionChangedCallbackCalled = true;
213 oldCursorPos = oldPos;
216 static void TestTextChangedCallback(TextEditor control)
218 tet_infoline(" TestTextChangedCallback");
220 gTextChangedCallBackCalled = true;
223 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
225 tet_infoline(" TestInputStyleChangedCallback");
227 gInputStyleChangedCallbackCalled = true;
228 gInputStyleMask = mask;
231 static void TestMaxLengthReachedCallback(TextEditor control)
233 tet_infoline(" TestMaxLengthReachedCallback");
235 gMaxCharactersCallBackCalled = true;
238 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
240 tet_infoline(" TestInputFilteredCallback");
242 if(type == Toolkit::InputFilter::Property::ACCEPTED)
244 gInputFilteredAcceptedCallbackCalled = true;
246 else if(type == Toolkit::InputFilter::Property::REJECTED)
248 gInputFilteredRejectedCallbackCalled = true;
252 // Generate a KeyEvent to send to Core.
253 Integration::KeyEvent GenerateKey(const std::string& keyName,
254 const std::string& logicalKey,
255 const std::string& keyString,
258 unsigned long timeStamp,
259 const Integration::KeyEvent::State& keyState,
260 const std::string& compose = "",
261 const std::string& deviceName = DEFAULT_DEVICE_NAME,
262 const Device::Class::Type& deviceClass = Device::Class::NONE,
263 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
265 return Integration::KeyEvent(keyName,
278 Dali::Integration::Point GetPointDownInside(Vector2& pos)
280 Dali::Integration::Point point;
281 point.SetState(PointState::DOWN);
282 point.SetScreenPosition(pos);
286 Dali::Integration::Point GetPointUpInside(Vector2& pos)
288 Dali::Integration::Point point;
289 point.SetState(PointState::UP);
290 point.SetScreenPosition(pos);
294 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
296 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
298 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
300 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
302 Property::Value* valueSet = NULL;
303 if(valueGet.first.type == Property::Key::INDEX)
305 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
309 // Get Key is a string so searching Set Map for a string key
310 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
315 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
317 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
320 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
322 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
325 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
327 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
330 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
332 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
335 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
337 Vector2 vector2Get = valueGet.second.Get<Vector2>();
338 Vector2 vector2Set = valueSet->Get<Vector2>();
339 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
342 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
344 Vector4 vector4Get = valueGet.second.Get<Vector4>();
345 Vector4 vector4Set = valueSet->Get<Vector4>();
346 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);
352 if(valueGet.first.type == Property::Key::INDEX)
354 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
358 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
368 class ScrollStateChangeCallback : public Dali::ConnectionTracker
371 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
372 : mStartedCalled(startedCalled),
373 mFinishedCalled(finishedCalled)
377 void Callback(TextEditor editor, TextEditor::Scroll::Type type)
379 if(type == TextEditor::Scroll::STARTED)
381 mStartedCalled = true;
383 else if(type == TextEditor::Scroll::FINISHED)
385 mFinishedCalled = true;
389 bool& mStartedCalled;
390 bool& mFinishedCalled;
395 int UtcDaliToolkitTextEditorConstructorP(void)
397 ToolkitTestApplication application;
398 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
399 TextEditor textEditor;
400 DALI_TEST_CHECK(!textEditor);
404 int UtcDaliToolkitTextEditorNewP(void)
406 ToolkitTestApplication application;
407 tet_infoline(" UtcDaliToolkitTextEditorNewP");
408 TextEditor textEditor = TextEditor::New();
409 DALI_TEST_CHECK(textEditor);
413 int UtcDaliToolkitTextEditorDownCastP(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
417 TextEditor textEditor1 = TextEditor::New();
418 BaseHandle object(textEditor1);
420 TextEditor textEditor2 = TextEditor::DownCast(object);
421 DALI_TEST_CHECK(textEditor2);
423 TextEditor textEditor3 = DownCast<TextEditor>(object);
424 DALI_TEST_CHECK(textEditor3);
428 int UtcDaliToolkitTextEditorDownCastN(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
432 BaseHandle uninitializedObject;
433 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
434 DALI_TEST_CHECK(!textEditor1);
436 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
437 DALI_TEST_CHECK(!textEditor2);
441 int UtcDaliToolkitTextEditorCopyConstructorP(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
445 TextEditor textEditor = TextEditor::New();
446 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
448 TextEditor copy(textEditor);
449 DALI_TEST_CHECK(copy);
450 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
454 int UtcDaliTextEditorMoveConstructor(void)
456 ToolkitTestApplication application;
458 TextEditor textEditor = TextEditor::New();
459 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
460 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
462 TextEditor moved = std::move(textEditor);
463 DALI_TEST_CHECK(moved);
464 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
465 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
466 DALI_TEST_CHECK(!textEditor);
471 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
475 TextEditor textEditor = TextEditor::New();
476 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
478 TextEditor copy = textEditor;
479 DALI_TEST_CHECK(copy);
480 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
484 int UtcDaliTextEditorMoveAssignment(void)
486 ToolkitTestApplication application;
488 TextEditor textEditor = TextEditor::New();
489 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
490 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
493 moved = std::move(textEditor);
494 DALI_TEST_CHECK(moved);
495 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
496 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
497 DALI_TEST_CHECK(!textEditor);
502 int UtcDaliTextEditorNewP(void)
504 ToolkitTestApplication application;
505 tet_infoline(" UtcDaliToolkitTextEditorNewP");
506 TextEditor textEditor = TextEditor::New();
507 DALI_TEST_CHECK(textEditor);
511 // Positive test case for a method
512 int UtcDaliTextEditorGetPropertyP(void)
514 ToolkitTestApplication application;
515 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
516 TextEditor editor = TextEditor::New();
517 DALI_TEST_CHECK(editor);
519 // Check Property Indices are correct
520 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
521 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
522 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
523 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
524 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
525 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
526 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
527 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
528 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
529 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
530 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
531 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
532 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
533 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
534 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
535 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
536 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
537 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
538 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
539 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
540 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
541 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
542 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
543 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
544 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
545 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
546 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
547 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
548 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
549 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
551 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
552 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
553 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
554 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
555 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
556 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
557 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
558 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
559 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
560 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
561 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
562 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
563 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
564 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
565 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
566 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
567 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
568 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
569 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
570 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
571 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
572 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
574 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
575 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
576 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
577 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
578 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
579 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
580 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
581 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
582 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
583 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
584 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
585 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
586 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
591 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
594 Property::Map imageMap;
595 imageMap[mapKey] = mapValue;
597 editor.SetProperty(property, imageMap);
598 Property::Value propValue = editor.GetProperty(property);
599 Property::Map* resultMap = propValue.GetMap();
601 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
609 // Positive test case for a method
610 int UtcDaliTextEditorSetPropertyP(void)
612 ToolkitTestApplication application;
613 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
614 TextEditor editor = TextEditor::New();
615 DALI_TEST_CHECK(editor);
616 application.GetScene().Add(editor);
618 // Note - we can't check the defaults since the stylesheets are platform-specific
620 // Check the render backend property.
621 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
622 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
624 // Check text property.
625 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
626 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
628 // Check text's color property
629 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
630 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
632 // Check font properties.
633 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
634 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
636 Property::Map fontStyleMapSet;
637 Property::Map fontStyleMapGet;
638 Property::Value* slantValue = NULL;
640 fontStyleMapSet.Insert("weight", "bold");
641 fontStyleMapSet.Insert("width", "condensed");
642 fontStyleMapSet.Insert("slant", "italic");
644 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
645 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
646 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
647 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
649 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
650 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
652 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
653 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
654 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
656 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
657 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
658 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
661 fontStyleMapSet.Clear();
662 fontStyleMapSet.Insert("weight", "normal");
663 fontStyleMapSet.Insert("slant", "oblique");
664 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
665 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
666 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
667 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
669 fontStyleMapSet.Clear();
670 fontStyleMapSet.Insert("slant", "roman");
671 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
672 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
674 // Replace 'roman' for 'normal'.
675 slantValue = fontStyleMapGet.Find("slant");
676 if(NULL != slantValue)
678 if("normal" == slantValue->Get<std::string>())
680 fontStyleMapGet["slant"] = "roman";
683 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
684 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
686 fontStyleMapSet.Clear();
688 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
689 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
690 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
691 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
693 // Check that the Alignment properties can be correctly set
694 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
695 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
697 // Check that the Alignment properties can be correctly set
698 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
699 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
700 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
701 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
702 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
703 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
705 // Check scroll properties.
706 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
707 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
708 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
709 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
711 // Check cursor properties
712 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
713 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
714 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
715 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
717 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
718 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
719 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
720 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
721 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
722 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
723 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
724 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
726 // Check handle images
727 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
728 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
729 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
730 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
731 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
733 // Check handle images
734 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
735 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
736 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
737 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
738 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
739 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
741 // Check the selection popup style
742 const Vector2 popupMaxSize(200.0f, 300.0f);
743 const Vector2 optionDividerSize(30.0f, 5.0f);
744 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
745 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
747 Property::Map selectionPopupStyle;
748 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
749 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
750 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
751 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
753 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
755 Property::Map selectionPopupStyleGet;
756 selectionPopupStyleGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::SELECTION_POPUP_STYLE);
758 Property::Value* popupValue;
759 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
760 DALI_TEST_CHECK(NULL != popupValue);
763 Vector2 popupMaxSizeGet;
764 popupValue->Get(popupMaxSizeGet);
765 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
768 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
769 DALI_TEST_CHECK(NULL != popupValue);
772 Vector2 optionDividerSizeGet;
773 popupValue->Get(optionDividerSizeGet);
774 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
777 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
778 DALI_TEST_CHECK(NULL != popupValue);
781 Vector4 optionDividerPaddingGet;
782 popupValue->Get(optionDividerPaddingGet);
783 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
786 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
787 DALI_TEST_CHECK(NULL != popupValue);
790 Vector4 labelPaddingGet;
791 popupValue->Get(labelPaddingGet);
792 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
795 // Reset selection popup style
796 selectionPopupStyle.Clear();
797 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
799 // Check the highlight color
800 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
801 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
803 // Decoration bounding box
804 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
805 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
807 // Check the enable markup property.
808 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
809 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
810 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
812 // Check input color property.
813 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
814 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
816 // Check input font properties.
817 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
818 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
820 fontStyleMapSet.Clear();
821 fontStyleMapSet.Insert("weight", "bold");
822 fontStyleMapSet.Insert("width", "condensed");
823 fontStyleMapSet.Insert("slant", "italic");
825 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
826 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
827 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
828 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
830 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
831 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
833 // Reset input font style.
834 fontStyleMapSet.Clear();
835 fontStyleMapSet.Insert("weight", "normal");
836 fontStyleMapSet.Insert("slant", "oblique");
838 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
839 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
840 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
841 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
843 fontStyleMapSet.Clear();
844 fontStyleMapSet.Insert("slant", "roman");
846 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
847 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
849 // Replace 'roman' for 'normal'.
850 slantValue = fontStyleMapGet.Find("slant");
851 if(NULL != slantValue)
853 if("normal" == slantValue->Get<std::string>())
855 fontStyleMapGet["slant"] = "roman";
858 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
859 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
861 fontStyleMapSet.Clear();
863 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
864 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
865 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
866 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
868 // Check the line spacing property
869 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
870 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
871 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
873 // Check the input line spacing property
874 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
875 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
876 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
878 // Check the underline property
880 Property::Map underlineMapSet;
881 Property::Map underlineMapGet;
883 underlineMapSet.Insert("enable", true);
884 underlineMapSet.Insert("color", Color::RED);
885 underlineMapSet.Insert("height", 1);
886 underlineMapSet.Insert("type", Text::Underline::SOLID);
887 underlineMapSet.Insert("dashWidth", 5);
888 underlineMapSet.Insert("dashGap", 3);
890 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
892 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
893 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
894 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
896 application.SendNotification();
897 application.Render();
899 // Check the dashed underline property
901 underlineMapSet.Clear();
902 underlineMapGet.Clear();
904 underlineMapSet.Insert("enable", true);
905 underlineMapSet.Insert("color", Color::RED);
906 underlineMapSet.Insert("height", 1);
907 underlineMapSet.Insert("type", Text::Underline::DASHED);
908 underlineMapSet.Insert("dashWidth", 5);
909 underlineMapSet.Insert("dashGap", 3);
911 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
913 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
914 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
915 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
917 application.SendNotification();
918 application.Render();
920 underlineMapSet.Clear();
921 underlineMapGet.Clear();
923 // Check the double underline property
925 underlineMapSet.Clear();
926 underlineMapGet.Clear();
928 underlineMapSet.Insert("enable", true);
929 underlineMapSet.Insert("color", Color::RED);
930 underlineMapSet.Insert("height", 1);
931 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
932 underlineMapSet.Insert("dashWidth", 5);
933 underlineMapSet.Insert("dashGap", 3);
935 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
937 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
938 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
939 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
941 application.SendNotification();
942 application.Render();
944 underlineMapSet.Clear();
945 underlineMapGet.Clear();
947 // Check the input underline property
948 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
949 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
951 // Check the shadow property
952 Property::Map shadowMapSet;
953 Property::Map shadowMapGet;
955 shadowMapSet.Insert("color", Color::GREEN);
956 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
957 shadowMapSet.Insert("blurRadius", 3.0f);
959 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
961 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
962 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
963 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
965 // Check the input shadow property
966 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
967 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
969 // Check the emboss property
970 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
971 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
973 // Check the input emboss property
974 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
975 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
977 // Check the outline property
979 // Test string type first
980 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
981 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
982 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
984 // Then test the property map type
985 Property::Map outlineMapSet;
986 Property::Map outlineMapGet;
988 outlineMapSet["color"] = Color::RED;
989 outlineMapSet["width"] = 2.0f;
991 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
993 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
994 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
995 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
997 // Check the input outline property
998 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
999 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1001 // Check the smooth scroll property
1002 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1003 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1004 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1006 // Check the smooth scroll duration property
1007 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1008 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1010 // Check the scroll bar property
1011 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1012 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1013 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1015 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1016 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1017 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1018 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1020 // Check the pixel size of font
1021 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1022 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1024 // Check placeholder text properties.
1025 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1026 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1028 // Check placeholder text's color property.
1029 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1030 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1032 // Check the enable selection property
1033 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1034 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1036 // Check the placeholder property with pixel size
1037 Property::Map placeholderPixelSizeMapSet;
1038 Property::Map placeholderPixelSizeMapGet;
1039 Property::Map placeholderFontstyleMap;
1040 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1041 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1042 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1043 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1044 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1046 placeholderFontstyleMap.Insert("weight", "bold");
1047 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1048 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1050 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1051 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1053 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1054 Property::Map placeholderConversionMap;
1055 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1056 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1057 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1058 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1059 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1060 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1062 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1064 // Check the placeholder property with point size
1065 Property::Map placeholderMapSet;
1066 Property::Map placeholderMapGet;
1067 placeholderMapSet["text"] = "Setting Placeholder Text";
1068 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1069 placeholderMapSet["color"] = Color::RED;
1070 placeholderMapSet["fontFamily"] = "Arial";
1071 placeholderMapSet["pointSize"] = 12.0f;
1072 // Check the placeholder font style property
1073 placeholderFontstyleMap.Clear();
1075 placeholderFontstyleMap.Insert("weight", "bold");
1076 placeholderFontstyleMap.Insert("width", "condensed");
1077 placeholderFontstyleMap.Insert("slant", "italic");
1078 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1079 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1081 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1082 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1084 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1085 placeholderConversionMap.Clear();
1086 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1087 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1088 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1089 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1090 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1091 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1092 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1094 // Reset font style.
1095 placeholderFontstyleMap.Clear();
1096 placeholderFontstyleMap.Insert("weight", "normal");
1097 placeholderFontstyleMap.Insert("slant", "oblique");
1098 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1099 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1101 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1102 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1103 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1104 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1106 placeholderFontstyleMap.Clear();
1107 placeholderFontstyleMap.Insert("slant", "roman");
1108 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1109 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1111 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1113 placeholderFontstyleMap.Clear();
1114 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1116 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1117 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1118 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1119 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1120 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1122 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1123 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1125 // Check handle color
1126 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1127 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1129 // Test the ENABLE_GRAB_HANDLE_POPUP property
1130 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1131 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1133 // Check the input method setting
1134 Property::Map propertyMap;
1135 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1136 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1137 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1138 int inputVariation = 1;
1139 propertyMap["PANEL_LAYOUT"] = panelLayout;
1140 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1141 propertyMap["BUTTON_ACTION"] = buttonAction;
1142 propertyMap["VARIATION"] = inputVariation;
1143 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1145 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1147 DALI_TEST_CHECK(value.Get(map));
1150 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1151 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1154 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1155 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1158 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1159 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1162 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1163 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1165 // Check the input filter property
1166 Property::Map inputFilterMapSet;
1167 Property::Map inputFilterMapGet;
1168 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1169 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1171 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1173 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1174 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1177 inputFilterMapSet.Clear();
1178 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1180 // Check the strikethrough property
1182 Property::Map strikethroughMapSet;
1183 Property::Map strikethroughMapGet;
1185 application.SendNotification();
1186 application.Render();
1188 // Check the input strikethrough property
1190 strikethroughMapSet.Clear();
1191 strikethroughMapGet.Clear();
1192 strikethroughMapSet.Insert("enable", true);
1193 strikethroughMapSet.Insert("color", Color::BLUE);
1194 strikethroughMapSet.Insert("height", 2.0f);
1196 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1198 application.SendNotification();
1199 application.Render();
1201 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1203 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1204 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1206 // Check the input strikethrough property
1207 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1208 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1210 application.SendNotification();
1211 application.Render();
1213 // Check the line size property
1214 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1215 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1216 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1221 // Positive Atlas Text Renderer test
1222 int utcDaliTextEditorAtlasRenderP(void)
1224 ToolkitTestApplication application;
1225 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1226 StyleManager styleManager = StyleManager::Get();
1227 styleManager.ApplyDefaultTheme();
1228 TextEditor editor = TextEditor::New();
1229 DALI_TEST_CHECK(editor);
1231 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1233 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1235 application.GetScene().Add(editor);
1239 // Render some text with the shared atlas backend
1240 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1241 application.SendNotification();
1242 application.Render();
1246 tet_result(TET_FAIL);
1251 // Positive test for the anchorClicked signal.
1252 int utcDaliTextEditorAnchorClickedP(void)
1254 ToolkitTestApplication application;
1255 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1256 TextEditor editor = TextEditor::New();
1257 DALI_TEST_CHECK(editor);
1259 application.GetScene().Add(editor);
1261 // connect to the anchor clicked signal.
1262 ConnectionTracker* testTracker = new ConnectionTracker();
1263 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1264 bool anchorClickedSignal = false;
1265 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1267 gAnchorClickedCallBackCalled = false;
1268 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1269 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1270 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1271 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1272 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1274 application.SendNotification();
1275 application.Render();
1276 editor.SetKeyInputFocus();
1278 // Create a tap event to touch the text editor.
1279 TestGenerateTap(application, 5.0f, 5.0f);
1280 application.SendNotification();
1281 application.Render();
1283 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1284 DALI_TEST_CHECK(anchorClickedSignal);
1286 gAnchorClickedCallBackNotCalled = true;
1287 // Tap the outside of anchor, callback should not be called.
1288 TestGenerateTap(application, 150.f, 100.f);
1289 application.SendNotification();
1290 application.Render();
1292 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1297 // Positive test for the textChanged signal.
1298 int utcDaliTextEditorTextChangedP(void)
1300 ToolkitTestApplication application;
1301 tet_infoline(" utcDaliTextEditorTextChangedP");
1302 TextEditor editor = TextEditor::New();
1303 DALI_TEST_CHECK(editor);
1305 application.GetScene().Add(editor);
1307 // connect to the text changed signal.
1308 ConnectionTracker* testTracker = new ConnectionTracker();
1309 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1310 bool textChangedSignal = false;
1311 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1313 gTextChangedCallBackCalled = false;
1314 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1315 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1316 DALI_TEST_CHECK(textChangedSignal);
1318 application.SendNotification();
1319 editor.SetKeyInputFocus();
1321 gTextChangedCallBackCalled = false;
1322 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1323 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1326 editor.SetProperty(TextField::Property::TEXT, "");
1328 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1329 gTextChangedCallBackCalled = false;
1330 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1331 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1333 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1334 gTextChangedCallBackCalled = false;
1335 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1336 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1341 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1343 ToolkitTestApplication application;
1344 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1345 TextEditor editor = TextEditor::New();
1346 DALI_TEST_CHECK(editor);
1348 application.GetScene().Add(editor);
1350 // connect to the text changed signal.
1351 ConnectionTracker* testTracker = new ConnectionTracker();
1352 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1353 bool textChangedSignal = false;
1354 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1356 // get InputMethodContext
1358 InputMethodContext::EventData imfEvent;
1359 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1361 editor.SetKeyInputFocus();
1362 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1365 gTextChangedCallBackCalled = false;
1366 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1367 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1368 application.SendNotification();
1369 application.Render();
1370 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1371 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1373 gTextChangedCallBackCalled = false;
1374 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1375 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1376 application.SendNotification();
1377 application.Render();
1378 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1379 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1381 gTextChangedCallBackCalled = false;
1382 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1383 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1384 application.SendNotification();
1385 application.Render();
1386 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1387 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1389 gTextChangedCallBackCalled = false;
1390 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1391 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1392 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1394 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1395 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1396 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1398 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1399 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1400 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1402 application.SendNotification();
1403 application.Render();
1404 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1405 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1410 int utcDaliTextEditorInputStyleChanged01(void)
1412 // The text-editor emits signals when the input style changes. These changes of style are
1413 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1414 // can't be emitted during the size negotiation as the callbacks may update the UI.
1415 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1416 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1417 ToolkitTestApplication application;
1418 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1422 char* pathNamePtr = get_current_dir_name();
1423 const std::string pathName(pathNamePtr);
1426 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1427 fontClient.SetDpi(93u, 93u);
1429 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1430 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1432 TextEditor editor = TextEditor::New();
1433 DALI_TEST_CHECK(editor);
1435 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1436 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1437 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1439 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1440 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1442 // connect to the text changed signal.
1443 ConnectionTracker* testTracker = new ConnectionTracker();
1444 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1445 bool inputStyleChangedSignal = false;
1446 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1448 application.GetScene().Add(editor);
1450 // Render and notify
1451 application.SendNotification();
1452 application.Render();
1454 // Executes the idle callbacks added by the text control on the change of input style.
1455 application.RunIdles();
1457 gInputStyleChangedCallbackCalled = false;
1458 gInputStyleMask = TextEditor::InputStyle::NONE;
1459 inputStyleChangedSignal = false;
1461 // Create a tap event to touch the text editor.
1462 TestGenerateTap(application, 18.0f, 25.0f);
1464 // Render and notify
1465 application.SendNotification();
1466 application.Render();
1468 // Executes the idle callbacks added by the text control on the change of input style.
1469 application.RunIdles();
1471 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1472 if(gInputStyleChangedCallbackCalled)
1474 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1476 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1477 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1479 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1480 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1482 DALI_TEST_CHECK(inputStyleChangedSignal);
1484 gInputStyleChangedCallbackCalled = false;
1485 gInputStyleMask = TextEditor::InputStyle::NONE;
1486 inputStyleChangedSignal = false;
1488 // Create a tap event to touch the text editor.
1489 TestGenerateTap(application, 30.0f, 25.0f);
1491 // Render and notify
1492 application.SendNotification();
1493 application.Render();
1495 // Executes the idle callbacks added by the text control on the change of input style.
1496 application.RunIdles();
1498 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1499 DALI_TEST_CHECK(!inputStyleChangedSignal);
1501 gInputStyleChangedCallbackCalled = false;
1502 gInputStyleMask = TextEditor::InputStyle::NONE;
1503 inputStyleChangedSignal = false;
1505 // Create a tap event to touch the text editor.
1506 TestGenerateTap(application, 43.0f, 25.0f);
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Executes the idle callbacks added by the text control on the change of input style.
1513 application.RunIdles();
1515 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1516 if(gInputStyleChangedCallbackCalled)
1518 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1520 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1521 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1523 DALI_TEST_CHECK(inputStyleChangedSignal);
1525 gInputStyleChangedCallbackCalled = false;
1526 gInputStyleMask = TextEditor::InputStyle::NONE;
1527 inputStyleChangedSignal = false;
1529 // Create a tap event to touch the text editor.
1530 TestGenerateTap(application, 88.0f, 25.0f);
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Executes the idle callbacks added by the text control on the change of input style.
1537 application.RunIdles();
1539 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1540 if(gInputStyleChangedCallbackCalled)
1542 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1544 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1545 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1547 Property::Map fontStyleMapSet;
1548 Property::Map fontStyleMapGet;
1550 fontStyleMapSet.Insert("weight", "bold");
1552 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1553 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1554 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1556 DALI_TEST_CHECK(inputStyleChangedSignal);
1558 gInputStyleChangedCallbackCalled = false;
1559 gInputStyleMask = TextEditor::InputStyle::NONE;
1560 inputStyleChangedSignal = false;
1562 // Create a tap event to touch the text editor.
1563 TestGenerateTap(application, 115.0f, 25.0f);
1565 // Render and notify
1566 application.SendNotification();
1567 application.Render();
1569 // Executes the idle callbacks added by the text control on the change of input style.
1570 application.RunIdles();
1572 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1573 DALI_TEST_CHECK(!inputStyleChangedSignal);
1575 gInputStyleChangedCallbackCalled = false;
1576 gInputStyleMask = TextEditor::InputStyle::NONE;
1577 inputStyleChangedSignal = false;
1579 // Create a tap event to touch the text editor.
1580 TestGenerateTap(application, 164.0f, 25.0f);
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Executes the idle callbacks added by the text control on the change of input style.
1587 application.RunIdles();
1589 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1590 if(gInputStyleChangedCallbackCalled)
1592 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1594 Property::Map fontStyleMapSet;
1595 Property::Map fontStyleMapGet;
1597 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1598 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1599 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1601 DALI_TEST_CHECK(inputStyleChangedSignal);
1603 gInputStyleChangedCallbackCalled = false;
1604 gInputStyleMask = TextEditor::InputStyle::NONE;
1605 inputStyleChangedSignal = false;
1607 // Create a tap event to touch the text editor.
1608 TestGenerateTap(application, 191.0f, 25.0f);
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 // Executes the idle callbacks added by the text control on the change of input style.
1615 application.RunIdles();
1617 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1618 DALI_TEST_CHECK(!inputStyleChangedSignal);
1623 int utcDaliTextEditorInputStyleChanged02(void)
1625 // The text-editor emits signals when the input style changes. These changes of style are
1626 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1627 // can't be emitted during the size negotiation as the callbacks may update the UI.
1628 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1629 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1630 ToolkitTestApplication application;
1631 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1635 char* pathNamePtr = get_current_dir_name();
1636 const std::string pathName(pathNamePtr);
1639 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1640 fontClient.SetDpi(93u, 93u);
1642 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1643 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1645 TextEditor editor = TextEditor::New();
1646 DALI_TEST_CHECK(editor);
1648 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1649 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1650 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1652 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1653 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>");
1655 // connect to the text changed signal.
1656 ConnectionTracker* testTracker = new ConnectionTracker();
1657 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1658 bool inputStyleChangedSignal = false;
1659 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1661 application.GetScene().Add(editor);
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Executes the idle callbacks added by the text control on the change of input style.
1668 application.RunIdles();
1670 gInputStyleChangedCallbackCalled = false;
1671 gInputStyleMask = TextEditor::InputStyle::NONE;
1672 inputStyleChangedSignal = false;
1674 // Create a tap event to touch the text editor.
1675 TestGenerateTap(application, 53.0f, 25.0f, 100);
1676 TestGenerateTap(application, 53.0f, 25.0f, 200);
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // Executes the idle callbacks added by the text control on the change of input style.
1683 application.RunIdles();
1685 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1686 if(gInputStyleChangedCallbackCalled)
1688 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1689 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1690 TextEditor::InputStyle::POINT_SIZE |
1691 TextEditor::InputStyle::COLOR),
1694 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1695 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1697 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1698 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1700 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1701 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1703 DALI_TEST_CHECK(inputStyleChangedSignal);
1705 gInputStyleChangedCallbackCalled = false;
1706 gInputStyleMask = TextEditor::InputStyle::NONE;
1707 inputStyleChangedSignal = false;
1709 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 // Executes the idle callbacks added by the text control on the change of input style.
1716 application.RunIdles();
1718 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1719 if(gInputStyleChangedCallbackCalled)
1721 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1722 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1725 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1726 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1728 DALI_TEST_CHECK(inputStyleChangedSignal);
1730 gInputStyleChangedCallbackCalled = false;
1731 gInputStyleMask = TextEditor::InputStyle::NONE;
1732 inputStyleChangedSignal = false;
1734 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 // Executes the idle callbacks added by the text control on the change of input style.
1741 application.RunIdles();
1743 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1744 DALI_TEST_CHECK(!inputStyleChangedSignal);
1746 gInputStyleChangedCallbackCalled = false;
1747 gInputStyleMask = TextEditor::InputStyle::NONE;
1748 inputStyleChangedSignal = false;
1750 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1752 // Render and notify
1753 application.SendNotification();
1754 application.Render();
1756 // Executes the idle callbacks added by the text control on the change of input style.
1757 application.RunIdles();
1759 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1760 if(gInputStyleChangedCallbackCalled)
1762 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1763 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1766 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1767 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1769 DALI_TEST_CHECK(inputStyleChangedSignal);
1771 gInputStyleChangedCallbackCalled = false;
1772 gInputStyleMask = TextEditor::InputStyle::NONE;
1773 inputStyleChangedSignal = false;
1775 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1777 Property::Map fontStyleMapSet;
1778 fontStyleMapSet.Insert("weight", "thin");
1779 fontStyleMapSet.Insert("width", "condensed");
1780 fontStyleMapSet.Insert("slant", "italic");
1782 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1783 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1784 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1786 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1787 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1788 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1789 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1790 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1792 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Executes the idle callbacks added by the text control on the change of input style.
1799 application.RunIdles();
1801 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1802 DALI_TEST_CHECK(!inputStyleChangedSignal);
1804 // Create a tap event to touch the text editor.
1805 TestGenerateTap(application, 63.0f, 25.0f, 900);
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // Executes the idle callbacks added by the text control on the change of input style.
1812 application.RunIdles();
1814 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1815 if(gInputStyleChangedCallbackCalled)
1817 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1818 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1819 TextEditor::InputStyle::POINT_SIZE |
1820 TextEditor::InputStyle::FONT_STYLE |
1821 TextEditor::InputStyle::LINE_SPACING |
1822 TextEditor::InputStyle::UNDERLINE |
1823 TextEditor::InputStyle::SHADOW |
1824 TextEditor::InputStyle::EMBOSS |
1825 TextEditor::InputStyle::OUTLINE),
1828 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1829 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1831 DALI_TEST_CHECK(inputStyleChangedSignal);
1833 gInputStyleChangedCallbackCalled = false;
1834 gInputStyleMask = TextEditor::InputStyle::NONE;
1835 inputStyleChangedSignal = false;
1837 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1839 fontStyleMapSet.Clear();
1840 fontStyleMapSet.Insert("weight", "black");
1841 fontStyleMapSet.Insert("width", "expanded");
1842 fontStyleMapSet.Insert("slant", "oblique");
1844 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1846 // Create a tap event to touch the text editor.
1847 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Executes the idle callbacks added by the text control on the change of input style.
1854 application.RunIdles();
1856 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1857 if(gInputStyleChangedCallbackCalled)
1859 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1860 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1861 TextEditor::InputStyle::POINT_SIZE |
1862 TextEditor::InputStyle::FONT_STYLE),
1865 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1866 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1868 DALI_TEST_CHECK(inputStyleChangedSignal);
1873 int utcDaliTextEditorEvent01(void)
1875 ToolkitTestApplication application;
1876 tet_infoline(" utcDaliTextEditorEvent01");
1878 // Creates a tap event. After creating a tap event the text editor should
1879 // have the focus and add text with key events should be possible.
1881 TextEditor editor = TextEditor::New();
1882 DALI_TEST_CHECK(editor);
1884 application.GetScene().Add(editor);
1886 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1887 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1888 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1890 // Avoid a crash when core load gl resources.
1891 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 // Add a key event but as the text editor has not the focus it should do nothing.
1898 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1906 // Create a tap event to touch the text editor.
1907 TestGenerateTap(application, 150.0f, 25.0f);
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 // Now the text editor has the focus, so it can handle the key events.
1914 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1915 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1923 // Create a second text editor and send key events to it.
1924 TextEditor editor2 = TextEditor::New();
1926 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1927 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1928 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1929 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1931 application.GetScene().Add(editor2);
1933 // Render and notify
1934 application.SendNotification();
1935 application.Render();
1937 // Create a tap event on the second text editor.
1938 TestGenerateTap(application, 150.0f, 125.0f);
1940 // Render and notify
1941 application.SendNotification();
1942 application.Render();
1944 // The second text editor has the focus. It should handle the key events.
1945 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1946 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Check the text has been added to the second text editor.
1953 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1958 int utcDaliTextEditorEvent02(void)
1960 ToolkitTestApplication application;
1961 tet_infoline(" utcDaliTextEditorEvent02");
1963 // Checks if the right number of actors are created.
1965 TextEditor editor = TextEditor::New();
1966 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
1967 DALI_TEST_CHECK(editor);
1969 application.GetScene().Add(editor);
1971 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1972 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1973 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1975 // Avoid a crash when core load gl resources.
1976 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 // Check there are the expected number of children (the stencil).
1983 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
1985 Actor stencil = editor.GetChildAt(0u);
1987 // Create a tap event to touch the text editor.
1988 TestGenerateTap(application, 150.0f, 25.0f, 100);
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1994 Actor layer = editor.GetChildAt(2u);
1995 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1996 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
1998 // Now the text editor has the focus, so it can handle the key events.
1999 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Checks the cursor and the renderer have been created.
2007 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2008 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2010 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2011 DALI_TEST_CHECK(cursor);
2013 // The stencil actor has a container with all the actors which contain the text renderers.
2014 Actor container = stencil.GetChildAt(0u);
2015 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2017 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2018 DALI_TEST_CHECK(renderer);
2021 // Move the cursor and check the position changes.
2022 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2024 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2025 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2027 // Render and notify
2028 application.SendNotification();
2029 application.Render();
2031 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2033 DALI_TEST_CHECK(position2.x < position1.x);
2035 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2036 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2044 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2046 // Send some taps and check the cursor positions.
2048 // Try to tap at the beginning.
2049 TestGenerateTap(application, 1.0f, 25.0f, 700);
2051 // Render and notify
2052 application.SendNotification();
2053 application.Render();
2055 // Cursor position should be the same than position1.
2056 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2058 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2060 // Tap away from the start position.
2061 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2069 DALI_TEST_CHECK(position5.x > position4.x);
2071 // Remove all the text.
2072 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2073 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2074 editor.SetProperty(TextEditor::Property::TEXT, "");
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2080 // Cursor position should be the same than position2.
2081 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2083 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2085 // Should not be a renderer, there is only a clipped cursor.
2086 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2091 int utcDaliTextEditorEvent03(void)
2093 ToolkitTestApplication application;
2094 tet_infoline(" utcDaliTextEditorEvent03");
2096 // Checks if the highlight actor is created.
2098 TextEditor editor = TextEditor::New();
2099 DALI_TEST_CHECK(editor);
2101 application.GetScene().Add(editor);
2103 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2104 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2105 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2106 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2107 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2109 // Avoid a crash when core load gl resources.
2110 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Send some taps and check text controller with clipboard window
2117 Dali::Clipboard clipboard = Clipboard::Get();
2118 clipboard.ShowClipboard();
2119 TestGenerateTap(application, 3.0f, 25.0f, 100);
2120 clipboard.HideClipboard();
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Tap first to get the focus.
2127 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Double tap to select a word.
2134 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // The stencil actor should have two actors: the renderer and the highlight actor.
2141 Actor stencil = editor.GetChildAt(0u);
2143 // Highlight needs to be drawn before text, so should come first in child order
2144 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2145 DALI_TEST_CHECK(highlight);
2147 // The stencil actor has a container with all the actors which contain the text renderers.
2148 Actor container = stencil.GetChildAt(1u);
2149 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2151 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2152 DALI_TEST_CHECK(renderer);
2155 // Double tap out of bounds
2156 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2157 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // The stencil actor should have one actors: the renderer actor.
2164 stencil = editor.GetChildAt(0u);
2166 // The stencil actor has a container with all the actors which contain the text renderers.
2167 container = stencil.GetChildAt(0u);
2168 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2170 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2171 DALI_TEST_CHECK(renderer);
2175 TestGenerateLongPress(application, 1.0f, 25.0f);
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2182 TestGenerateMiniPan(application);
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2191 int utcDaliTextEditorEvent04(void)
2193 ToolkitTestApplication application;
2194 tet_infoline(" utcDaliTextEditorEvent04");
2196 // Checks if the highlight actor is created.
2198 TextEditor editor = TextEditor::New();
2199 DALI_TEST_CHECK(editor);
2201 application.GetScene().Add(editor);
2203 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2204 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2205 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2206 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2207 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2209 // Avoid a crash when core load gl resources.
2210 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Tap on the text editor
2217 TestGenerateTap(application, 3.0f, 25.0f);
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Move at the end of the text.
2224 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2225 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 for(unsigned int index = 0u; index < 10u; ++index)
2233 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2234 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2242 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2250 // Add some key events
2251 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2252 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 for(unsigned int index = 0u; index < 10u; ++index)
2260 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2261 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2263 // Render and notify
2264 application.SendNotification();
2265 application.Render();
2269 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2271 // Render and notify
2272 application.SendNotification();
2273 application.Render();
2275 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2280 int utcDaliTextEditorEvent05(void)
2282 ToolkitTestApplication application;
2283 tet_infoline(" utcDaliTextEditorEvent05");
2285 // Checks if the highlight actor is created.
2287 TextEditor editor = TextEditor::New();
2288 DALI_TEST_CHECK(editor);
2290 application.GetScene().Add(editor);
2292 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2293 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2294 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2295 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2296 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2297 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2298 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2299 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2300 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2301 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2303 // Avoid a crash when core load gl resources.
2304 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 // Tap on the text editor
2311 TestGenerateTap(application, 3.0f, 25.0f);
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 // Move at the end of the text.
2318 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2319 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 for(unsigned int index = 0u; index < 10u; ++index)
2328 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2334 // Modify duration after scroll is enabled
2335 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2337 // Continuous scroll left to increase coverage
2338 for(unsigned int index = 0u; index < 10u; ++index)
2340 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2347 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2348 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2349 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2350 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2352 // Press Escape to increase coverage
2353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2354 application.SendNotification();
2355 application.Render();
2357 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2362 int utcDaliTextEditorEvent06(void)
2364 ToolkitTestApplication application;
2365 tet_infoline(" utcDaliTextEditorEvent06");
2367 // Checks if the highlight actor is created.
2369 TextEditor editor = TextEditor::New();
2370 DALI_TEST_CHECK(editor);
2372 application.GetScene().Add(editor);
2374 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2375 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2376 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2377 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2378 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2380 // Avoid a crash when core load gl resources.
2381 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 // Tap on the text editor
2388 TestGenerateTap(application, 3.0f, 25.0f);
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Move to seconds line of the text.
2395 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 float layoutHeight = editor.GetHeightForWidth(100.f);
2403 // Add another script characters ( glyph height is defferent )
2404 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2405 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2407 // Delete characters
2408 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2409 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2411 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2413 // Render and notify
2414 application.SendNotification();
2415 application.Render();
2417 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2420 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2421 application.SendNotification();
2422 application.Render();
2424 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2425 application.SendNotification();
2426 application.Render();
2428 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2429 application.SendNotification();
2430 application.Render();
2432 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433 application.SendNotification();
2434 application.Render();
2436 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2437 application.SendNotification();
2438 application.Render();
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.SendNotification();
2442 application.Render();
2444 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2445 application.SendNotification();
2446 application.Render();
2451 int utcDaliTextEditorEvent07(void)
2453 ToolkitTestApplication application;
2454 tet_infoline(" utcDaliTextEditorEvent07");
2456 // Checks if the highlight actor is created.
2458 TextEditor editor = TextEditor::New();
2459 DALI_TEST_CHECK(editor);
2461 application.GetScene().Add(editor);
2463 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2464 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2465 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2466 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2467 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2469 // Avoid a crash when core load gl resources.
2470 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 // Tap on the text editor
2477 TestGenerateTap(application, 3.0f, 25.0f);
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 // Move to second line of the text.
2484 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 // Select some text in the right of the current cursor position
2491 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2493 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2494 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 // Cut the selected text
2501 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502 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));
2504 // Render and notify
2505 application.SendNotification();
2506 application.Render();
2508 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2510 // Select some text in the left of the current cursor position
2511 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2514 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // Copy the selected text
2521 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522 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));
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 // Move the cursor to the third line
2529 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2530 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2532 // Render and notify
2533 application.SendNotification();
2534 application.Render();
2536 // Paste the selected text at the current cursor position
2537 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2538 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));
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2546 // Disable Shift Selection
2547 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2549 // Test to select some text in the right of the current cursor position
2550 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2551 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2552 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2553 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2555 // Render and notify
2556 application.SendNotification();
2557 application.Render();
2559 // Cut the selected text
2560 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2561 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));
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2567 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2568 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2570 // Test to select some text in the left of the current cursor position
2571 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2572 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2573 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2574 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Copy the selected text
2581 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2582 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));
2584 // Render and notify
2585 application.SendNotification();
2586 application.Render();
2588 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2589 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2592 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));
2594 // Render and notify
2595 application.SendNotification();
2596 application.Render();
2598 // replace text with "c"
2599 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2601 // Render and notify
2602 application.SendNotification();
2603 application.Render();
2606 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2609 DevelTextEditor::SelectWholeText(editor);
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2615 // Copy the selected text using logical keys
2616 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2617 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2624 DevelTextEditor::SelectNone(editor);
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 // Paste the selected using logical keys
2631 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2632 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2635 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2637 // select all using logical keys
2638 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2639 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2641 // Render and notify
2642 application.SendNotification();
2643 application.Render();
2645 // cut text using logical keys
2646 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2649 // Render and notify
2650 application.SendNotification();
2651 application.Render();
2654 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2659 int utcDaliTextEditorEvent08(void)
2661 ToolkitTestApplication application;
2662 tet_infoline(" utcDaliTextEditorEvent08");
2664 // Checks if the highlight actor is released correctly.
2666 TextEditor editor = TextEditor::New();
2667 DALI_TEST_CHECK(editor);
2669 application.GetScene().Add(editor);
2671 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2672 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2673 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2674 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2675 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2677 // Avoid a crash when core load gl resources.
2678 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2680 // Render and notify
2681 application.SendNotification();
2682 application.Render();
2684 // Tap on the text editor
2685 TestGenerateTap(application, 3.0f, 25.0f);
2687 // Render and notify
2688 application.SendNotification();
2689 application.Render();
2691 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2692 // Test to select some text in the left of the current cursor position
2693 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2694 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2695 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2696 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2698 // Render and notify
2699 application.SendNotification();
2700 application.Render();
2702 // Test to the left selection handle position and the right selection handle position
2703 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2704 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2705 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2706 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2708 // Render and notify
2709 application.SendNotification();
2710 application.Render();
2712 // Test to select full 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));
2718 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Test to release the current full text selection
2725 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2726 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2728 // Render and notify
2729 application.SendNotification();
2730 application.Render();
2732 // Test to move the current cursor position correctly
2733 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2735 // Render and notify
2736 application.SendNotification();
2737 application.Render();
2740 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2742 // Render and notify
2743 application.SendNotification();
2744 application.Render();
2746 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2748 // Test to select some text in the right of the current cursor position
2749 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2751 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2753 // Render and notify
2754 application.SendNotification();
2755 application.Render();
2757 // Test the cursor position with right arrow key
2758 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2760 // Render and notify
2761 application.SendNotification();
2762 application.Render();
2765 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2767 // Render and notify
2768 application.SendNotification();
2769 application.Render();
2771 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2773 // Test to select some text in the left of the current cursor position
2774 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2775 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2776 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2777 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2778 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2780 // Render and notify
2781 application.SendNotification();
2782 application.Render();
2784 // Test the cursor position with left arrow key
2785 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2787 // Render and notify
2788 application.SendNotification();
2789 application.Render();
2792 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2800 // Test to select some text in the right of the current cursor position
2801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2803 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2804 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2806 // Render and notify
2807 application.SendNotification();
2808 application.Render();
2810 // Test the cursor position with left arrow key
2811 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2813 // Render and notify
2814 application.SendNotification();
2815 application.Render();
2818 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2820 // Render and notify
2821 application.SendNotification();
2822 application.Render();
2824 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2826 // Test to select some text in the left of the current cursor position
2827 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2828 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2829 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2830 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2832 // Render and notify
2833 application.SendNotification();
2834 application.Render();
2836 // Test the cursor position with right arrow key
2837 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2844 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2855 int utcDaliTextEditorHandles(void)
2857 ToolkitTestApplication application;
2858 tet_infoline(" utcDaliTextEditorHandles");
2860 TextEditor editor = TextEditor::New();
2861 DALI_TEST_CHECK(editor);
2863 application.GetScene().Add(editor);
2865 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2866 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2867 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2868 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2870 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2871 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2872 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2873 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2875 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2876 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2877 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2879 // Avoid a crash when core load gl resources.
2880 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2882 // Render and notify
2883 application.SendNotification();
2884 application.Render();
2886 // Tap first to get the focus.
2887 TestGenerateTap(application, 3.0f, 25.0f, 100);
2889 // Render and notify
2890 application.SendNotification();
2891 application.Render();
2893 // Tap to create the grab handle.
2894 TestGenerateTap(application, 3.0f, 25.0f, 700);
2896 // Render and notify
2897 application.SendNotification();
2898 application.Render();
2900 // Get the active layer where the text's decoration is added.
2901 Actor activeLayer = editor.GetChildAt(1u);
2903 // Get the handle's actor.
2904 Actor handle = activeLayer.GetChildAt(0u);
2905 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2907 // Render and notify
2908 application.SendNotification();
2909 application.Render();
2911 // Touch the grab handle to set it as pressed.
2912 Vector2 touchPos(10.0f, 50.0f);
2913 Dali::Integration::TouchEvent event;
2914 event = Dali::Integration::TouchEvent();
2915 event.AddPoint(GetPointDownInside(touchPos));
2916 application.ProcessEvent(event);
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 // Pan the grab handle
2923 uint32_t time = 100;
2924 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2925 TestMovePan(application, Vector2(10.0f, 30.0f), time);
2926 TestEndPan(application, Vector2(10.0f, 50.0f), time);
2927 application.SendNotification();
2928 application.Render();
2930 // Release the grab handle.
2931 event = Dali::Integration::TouchEvent();
2932 event.AddPoint(GetPointUpInside(touchPos));
2933 application.ProcessEvent(event);
2935 // Render and notify
2936 application.SendNotification();
2937 application.Render();
2939 // Tap first to get the focus.
2940 TestGenerateTap(application, 3.0f, 25.0f, 1400);
2942 // Render and notify
2943 application.SendNotification();
2944 application.Render();
2946 // Double tap to select a word and create the selection handles.
2947 TestGenerateTap(application, 3.0f, 25.0f, 1500);
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 touchPos = Vector2(10.0f, 50.0f);
2955 // Touch the left selection handle to set it as pressed.
2956 event = Dali::Integration::TouchEvent();
2957 event.AddPoint(GetPointDownInside(touchPos));
2958 application.ProcessEvent(event);
2960 // Render and notify
2961 application.SendNotification();
2962 application.Render();
2964 // Release the left selection handle.
2965 event = Dali::Integration::TouchEvent();
2966 event.AddPoint(GetPointUpInside(touchPos));
2967 application.ProcessEvent(event);
2969 // Render and notify
2970 application.SendNotification();
2971 application.Render();
2976 int utcDaliTextEditorUnderPropertyStringP(void)
2978 ToolkitTestApplication application;
2979 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2980 TextEditor editor = TextEditor::New();
2981 DALI_TEST_CHECK(editor);
2983 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
2985 application.GetScene().Add(editor);
2987 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2988 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
2990 tet_infoline("Set underline settings with a map");
2991 // Check the input underline property
2992 Property::Map underlineMapSet;
2993 Property::Map underlineMapGet;
2994 underlineMapSet.Insert("enable", true);
2995 underlineMapSet.Insert("color", Color::BLUE);
2996 underlineMapSet.Insert("height", 1);
2997 underlineMapSet.Insert("type", Text::Underline::SOLID);
2998 underlineMapSet.Insert("dashWidth", 2);
2999 underlineMapSet.Insert("dashGap", 1);
3001 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3002 editor.SetProperty(TextEditor::Property::TEXT, "text");
3003 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3004 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3005 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3007 application.SendNotification();
3008 application.Render();
3010 underlineMapSet.Clear();
3011 underlineMapGet.Clear();
3013 tet_infoline("Set dashed underline settings with a map");
3014 // Check the input underline property
3015 underlineMapSet.Clear();
3016 underlineMapGet.Clear();
3017 underlineMapSet.Insert("enable", true);
3018 underlineMapSet.Insert("color", Color::BLUE);
3019 underlineMapSet.Insert("height", 1);
3020 underlineMapSet.Insert("type", Text::Underline::DASHED);
3021 underlineMapSet.Insert("dashWidth", 5);
3022 underlineMapSet.Insert("dashGap", 3);
3024 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3025 editor.SetProperty(TextEditor::Property::TEXT, "text");
3026 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3027 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3028 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3030 // Check the input underline property
3031 underlineMapSet.Clear();
3032 underlineMapGet.Clear();
3033 underlineMapSet.Insert("enable", true);
3034 underlineMapSet.Insert("color", Color::BLUE);
3035 underlineMapSet.Insert("height", 1);
3036 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3037 underlineMapSet.Insert("dashWidth", 5);
3038 underlineMapSet.Insert("dashGap", 3);
3040 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3041 editor.SetProperty(TextEditor::Property::TEXT, "text");
3042 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3043 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3044 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3046 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3047 editor.SetProperty(TextEditor::Property::TEXT, "text");
3048 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3049 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3050 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3052 application.SendNotification();
3053 application.Render();
3055 underlineMapSet.Clear();
3056 underlineMapGet.Clear();
3058 tet_infoline("Set underline settings with a string");
3059 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3060 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3063 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3065 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3066 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3067 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3068 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3070 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3075 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3077 ToolkitTestApplication application;
3078 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3079 TextEditor editor = TextEditor::New();
3080 DALI_TEST_CHECK(editor);
3082 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3084 application.GetScene().Add(editor);
3086 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3087 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3089 tet_infoline("Set strikethrough settings with a map");
3090 // Check the input strikethrough property
3091 Property::Map strikethroughMapSet;
3092 Property::Map strikethroughMapGet;
3093 strikethroughMapSet.Insert("enable", true);
3094 strikethroughMapSet.Insert("color", Color::BLUE);
3095 strikethroughMapSet.Insert("height", 2.0f);
3097 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3098 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3099 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3100 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3102 tet_infoline("Set strikethrough settings with a string");
3103 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3104 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3107 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3109 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3110 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3111 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3112 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3114 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3119 int utcDaliTextEditorShadowPropertyStringP(void)
3121 ToolkitTestApplication application;
3122 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3124 TextEditor editor = TextEditor::New();
3126 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3128 application.GetScene().Add(editor);
3130 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3132 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3136 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3141 int utcDaliTextEditorFontStylePropertyStringP(void)
3143 ToolkitTestApplication application;
3144 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3146 TextEditor editor = TextEditor::New();
3148 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3150 application.GetScene().Add(editor);
3152 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3154 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3158 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3163 int utcDaliTextEditorGetPropertyLinecountP(void)
3165 ToolkitTestApplication application;
3167 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3171 TextEditor editor = TextEditor::New();
3172 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3173 editor.SetProperty(TextEditor::Property::TEXT,
3174 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3176 application.GetScene().Add(editor);
3178 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3179 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3180 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3182 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3183 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3184 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3189 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3191 ToolkitTestApplication application;
3192 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3194 TextEditor editor = TextEditor::New();
3195 DALI_TEST_CHECK(editor);
3197 application.GetScene().Add(editor);
3199 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3200 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3201 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3202 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3203 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3204 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3206 bool startedCalled = false;
3207 bool finishedCalled = false;
3209 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3210 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3212 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3214 // Render and notify
3215 application.SendNotification();
3216 application.Render();
3218 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3219 application.SendNotification();
3220 application.Render(6000);
3222 application.SendNotification();
3223 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3224 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3229 int UtcDaliToolkitTextEditorTextWrapMode(void)
3231 ToolkitTestApplication application;
3232 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3236 TextEditor editor = TextEditor::New();
3237 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3238 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3240 application.GetScene().Add(editor);
3242 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3243 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3245 application.SendNotification();
3246 application.Render();
3248 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3249 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3251 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3252 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3254 application.SendNotification();
3255 application.Render();
3257 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3258 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3260 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3261 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3263 application.SendNotification();
3264 application.Render();
3266 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3267 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3269 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3270 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3272 application.SendNotification();
3273 application.Render();
3275 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3276 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3281 int UtcDaliTextEditorSetPaddingProperty(void)
3283 ToolkitTestApplication application;
3284 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
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 Vector3 originalSize = editor.GetNaturalSize();
3298 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3300 application.SendNotification();
3301 application.Render();
3303 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3305 Vector3 paddingAddedSize = editor.GetNaturalSize();
3307 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3309 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3314 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3316 ToolkitTestApplication application;
3317 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3319 TextEditor editor = TextEditor::New();
3320 DALI_TEST_CHECK(editor);
3321 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3322 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3323 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3324 application.GetScene().Add(editor);
3326 application.SendNotification();
3327 application.Render();
3329 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3330 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3332 // Check the enable shift selection property
3333 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3334 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3336 application.SendNotification();
3337 application.Render();
3342 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3344 ToolkitTestApplication application;
3345 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3347 TextEditor editor = TextEditor::New();
3348 DALI_TEST_CHECK(editor);
3349 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3350 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3351 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3352 application.GetScene().Add(editor);
3354 application.SendNotification();
3355 application.Render();
3357 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3358 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3360 // Check the enable grab handle property
3361 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3362 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3364 application.SendNotification();
3365 application.Render();
3370 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3372 ToolkitTestApplication application;
3373 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3375 TextEditor editor = TextEditor::New();
3376 DALI_TEST_CHECK(editor);
3377 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3378 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3379 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3380 application.GetScene().Add(editor);
3382 application.SendNotification();
3383 application.Render();
3385 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3386 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3388 // Check the disable match system language direction property
3389 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3390 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3392 application.SendNotification();
3393 application.Render();
3398 int UtcDaliTextEditorGetInputMethodContext(void)
3400 ToolkitTestApplication application;
3401 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3403 TextEditor editor = TextEditor::New();
3404 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3409 int utcDaliTextEditorMaxCharactersReached(void)
3411 ToolkitTestApplication application;
3412 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3414 TextEditor editor = TextEditor::New();
3415 DALI_TEST_CHECK(editor);
3417 application.GetScene().Add(editor);
3419 const int maxNumberOfCharacters = 1;
3420 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3421 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3423 editor.SetKeyInputFocus();
3425 // connect to the text changed signal.
3426 ConnectionTracker* testTracker = new ConnectionTracker();
3427 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3428 bool maxLengthReachedSignal = false;
3429 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3431 gMaxCharactersCallBackCalled = false;
3433 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3434 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3436 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3437 DALI_TEST_CHECK(maxLengthReachedSignal);
3442 int utcDaliTextEditorInputFiltered(void)
3444 ToolkitTestApplication application;
3445 tet_infoline(" utcDaliTextEditorInputFiltered");
3446 TextEditor editor = TextEditor::New();
3447 DALI_TEST_CHECK(editor);
3449 application.GetScene().Add(editor);
3451 Property::Map inputFilter;
3453 // Only digit is accepted.
3454 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3456 // Set input filter to TextEditor.
3457 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3459 editor.SetKeyInputFocus();
3461 // connect to the input filtered signal.
3462 ConnectionTracker* testTracker = new ConnectionTracker();
3463 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3464 bool inputFilteredSignal = false;
3465 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3467 gInputFilteredAcceptedCallbackCalled = false;
3469 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3471 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3472 DALI_TEST_CHECK(inputFilteredSignal);
3474 // Word is rejected.
3475 inputFilter[InputFilter::Property::ACCEPTED] = "";
3476 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3478 // Set input filter to TextEditor.
3479 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3481 editor.SetKeyInputFocus();
3483 inputFilteredSignal = false;
3484 gInputFilteredRejectedCallbackCalled = false;
3486 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3488 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3489 DALI_TEST_CHECK(inputFilteredSignal);
3494 int UtcDaliTextEditorSelectWholeText(void)
3496 ToolkitTestApplication application;
3497 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3499 TextEditor textEditor = TextEditor::New();
3501 application.GetScene().Add(textEditor);
3503 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3504 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3505 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3507 // Avoid a crash when core load gl resources.
3508 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3510 application.SendNotification();
3511 application.Render();
3513 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3515 DevelTextEditor::SelectWholeText(textEditor);
3517 application.SendNotification();
3518 application.Render();
3520 // Nothing should have been selected. The number of children is still 1
3521 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3523 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3525 application.SendNotification();
3526 application.Render();
3528 DevelTextEditor::SelectWholeText(textEditor);
3530 application.SendNotification();
3531 application.Render();
3533 // Should be 2 children, the stencil and the layer
3534 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3536 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3537 Actor stencil = textEditor.GetChildAt(0u);
3539 // The highlight actor is drawn first, so is the first actor in the list
3540 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3541 DALI_TEST_CHECK(highlight);
3546 int UtcDaliTextEditorSelectText(void)
3548 ToolkitTestApplication application;
3549 tet_infoline(" UtcDaliTextEditorSelectText ");
3551 TextEditor textEditor = TextEditor::New();
3553 application.GetScene().Add(textEditor);
3555 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3556 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3557 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3559 // Avoid a crash when core load gl resources.
3560 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3562 application.SendNotification();
3563 application.Render();
3565 DevelTextEditor::SelectText(textEditor, 0, 5);
3567 application.SendNotification();
3568 application.Render();
3570 // Nothing is selected
3571 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3572 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3574 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3576 application.SendNotification();
3577 application.Render();
3579 DevelTextEditor::SelectText(textEditor, 0, 5);
3581 application.SendNotification();
3582 application.Render();
3584 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3585 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3587 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3588 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3590 // world is selected
3591 DevelTextEditor::SelectText(textEditor, 6, 11);
3593 application.SendNotification();
3594 application.Render();
3596 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3597 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3599 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3600 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3605 int UtcDaliTextEditorSelectNone(void)
3607 ToolkitTestApplication application;
3608 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3610 TextEditor textEditor = TextEditor::New();
3612 application.GetScene().Add(textEditor);
3614 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3615 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3616 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3618 // Avoid a crash when core load gl resources.
3619 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3621 application.SendNotification();
3622 application.Render();
3624 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3626 application.SendNotification();
3627 application.Render();
3629 // Nothing is selected
3630 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3631 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3633 DevelTextEditor::SelectWholeText(textEditor);
3635 application.SendNotification();
3636 application.Render();
3638 // whole text is selected
3639 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3640 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3642 DevelTextEditor::SelectNone(textEditor);
3644 application.SendNotification();
3645 application.Render();
3647 // Nothing is selected
3648 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3649 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3654 int UtcDaliTextEditorSelectRange(void)
3656 ToolkitTestApplication application;
3657 tet_infoline("utcDaliTextEditorSelectRange");
3659 TextEditor textEditor = TextEditor::New();
3660 DALI_TEST_CHECK(textEditor);
3662 application.GetScene().Add(textEditor);
3664 // Avoid a crash when core load gl resources.
3665 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3667 application.SendNotification();
3668 application.Render();
3670 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3672 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3673 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3675 // Hello is selected
3676 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3677 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3679 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3680 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3685 int UtcDaliTextEditorEnableEditing(void)
3687 ToolkitTestApplication application;
3688 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3690 TextEditor textEditor = TextEditor::New();
3692 application.GetScene().Add(textEditor);
3694 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3695 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3696 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3698 // Avoid a crash when core load gl resources.
3699 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3701 application.SendNotification();
3702 application.Render();
3704 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3705 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3707 textEditor.SetKeyInputFocus();
3708 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3709 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3711 // Render and notify
3712 application.SendNotification();
3713 application.Render();
3715 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3716 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3718 textEditor.SetKeyInputFocus();
3719 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3720 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3722 // Render and notify
3723 application.SendNotification();
3724 application.Render();
3726 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3727 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3729 // Check the user interaction enabled and for coverage
3730 DevelTextEditor::SelectWholeText(textEditor);
3732 // Render and notify
3733 application.SendNotification();
3734 application.Render();
3736 textEditor.SetKeyInputFocus();
3737 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3738 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3740 // Render and notify
3741 application.SendNotification();
3742 application.Render();
3744 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3745 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3750 int UtcDaliTextEditorScrolling(void)
3752 ToolkitTestApplication application;
3753 tet_infoline(" UtcDaliTextEditorScrolling ");
3755 TextEditor textEditor = TextEditor::New();
3756 DALI_TEST_CHECK(textEditor);
3758 application.GetScene().Add(textEditor);
3760 // Avoid a crash when core load gl resources.
3761 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3763 application.SendNotification();
3764 application.Render();
3766 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3767 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3768 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3769 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3771 application.SendNotification();
3772 application.Render();
3774 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3775 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3777 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3779 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
3780 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3782 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3784 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
3785 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3787 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
3788 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
3790 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3791 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3796 int UtcDaliToolkitTextEditorFontSizeScale(void)
3798 ToolkitTestApplication application;
3799 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3801 TextEditor textEditor = TextEditor::New();
3802 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
3803 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3804 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3806 TextEditor textEditorScaled = TextEditor::New();
3807 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
3808 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3809 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3810 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3812 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3814 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
3815 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3816 nonScaledSize = textEditor.GetNaturalSize();
3818 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
3819 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3820 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3821 scaledSize = textEditorScaled.GetNaturalSize();
3823 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3828 int UtcDaliTextEditorPrimaryCursorPosition(void)
3830 ToolkitTestApplication application;
3831 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3833 TextEditor textEditor = TextEditor::New();
3835 application.GetScene().Add(textEditor);
3837 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
3838 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3839 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3840 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3842 // Avoid a crash when core load gl resources.
3843 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3845 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3846 application.SendNotification();
3847 application.Render();
3848 textEditor.SetKeyInputFocus();
3850 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3852 // Render and notify
3853 application.SendNotification();
3854 application.Render();
3856 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3857 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3862 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3864 ToolkitTestApplication application;
3865 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3867 TextEditor textEditor = TextEditor::New();
3868 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3869 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3870 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3871 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3872 application.GetScene().Add(textEditor);
3874 application.SendNotification();
3875 application.Render();
3878 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3879 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3881 textEditor.GetNaturalSize();
3883 // Create a tap event to touch the text editor.
3884 TestGenerateTap(application, 18.0f, 25.0f);
3886 application.SendNotification();
3887 application.Render();
3889 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3890 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3895 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3897 ToolkitTestApplication application;
3899 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3901 int lineCountBefore = 0;
3902 int lineCountAfter = 0;
3904 // Create a text editor
3905 TextEditor textEditor = TextEditor::New();
3906 //Set very large font-size using point-size
3907 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3908 //Specify font-family
3909 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3911 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3912 //Set text longer than width of textEditor
3913 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3915 application.GetScene().Add(textEditor);
3917 application.SendNotification();
3918 application.Render();
3920 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3921 //GetHeightForWidth is a retrieval method which should not modify object
3922 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3923 textEditor.GetHeightForWidth(200.f);
3925 //This is to simulate focus into text editor after calling GetHeightForWidth
3926 //Create a tap event to touch the text editor.
3927 TestGenerateTap(application, 18.0f, 25.0f);
3929 application.SendNotification();
3930 application.Render();
3932 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3934 //The LineCount must not be changed when calling GetHeightForWidth.
3935 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3940 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3942 ToolkitTestApplication application;
3944 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3946 int lineCountBefore = 0;
3947 int lineCountAfter = 0;
3949 // Create a text editor
3950 TextEditor textEditor = TextEditor::New();
3951 //Set very large font-size using point-size
3952 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3953 //Specify font-family
3954 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3956 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3957 //Set text longer than width of textEditor
3958 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3959 //Set line wrap mode Character
3960 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3962 application.GetScene().Add(textEditor);
3964 application.SendNotification();
3965 application.Render();
3967 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3968 //GetHeightForWidth is a retrieval method which should not modify object
3969 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3970 textEditor.GetHeightForWidth(200.f);
3972 //This is to simulate focus into text editor after calling GetHeightForWidth
3973 //Create a tap event to touch the text editor.
3974 TestGenerateTap(application, 18.0f, 25.0f);
3976 application.SendNotification();
3977 application.Render();
3979 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3981 //The LineCount must not be changed when calling GetHeightForWidth.
3982 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3987 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3989 ToolkitTestApplication application;
3991 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3993 int lineCountBefore = 0;
3994 int lineCountAfter = 0;
3996 // Create a text editor
3997 TextEditor textEditor = TextEditor::New();
3998 //Set very large font-size using point-size
3999 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4000 //Specify font-family
4001 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4003 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4004 //Set text longer than width of textEditor
4005 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4006 //Set line wrap mode Character
4007 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4009 application.GetScene().Add(textEditor);
4011 application.SendNotification();
4012 application.Render();
4014 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4016 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4017 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4019 // When the text changed, the Line-count should be updated according to new text.
4020 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4021 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4022 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4027 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4029 ToolkitTestApplication application;
4031 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4033 int lineCountBefore = 0;
4034 int lineCountAfter = 0;
4036 // Create a text editor
4037 TextEditor textEditor = TextEditor::New();
4038 //Set very large font-size using point-size
4039 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4040 //Specify font-family
4041 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4043 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4044 //Set text longer than width of textEditor
4045 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4047 application.GetScene().Add(textEditor);
4049 application.SendNotification();
4050 application.Render();
4052 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4053 //GetNaturalSize is a retrieval method which should not modify object
4054 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4055 textEditor.GetNaturalSize();
4057 //This is to simulate focus into text editor after calling GetNaturalSize
4058 //Create a tap event to touch the text editor.
4059 TestGenerateTap(application, 18.0f, 25.0f);
4061 application.SendNotification();
4062 application.Render();
4064 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4066 //The LineCount must not be changed when calling GetNaturalSize.
4067 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4072 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4074 ToolkitTestApplication application;
4076 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4078 int lineCountBefore = 0;
4079 int lineCountAfter = 0;
4081 // Create a text editor
4082 TextEditor textEditor = TextEditor::New();
4083 //Set very large font-size using point-size
4084 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4085 //Specify font-family
4086 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4088 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4089 //Set text longer than width of textEditor
4090 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4091 //Set line wrap mode Character
4092 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4094 application.GetScene().Add(textEditor);
4096 application.SendNotification();
4097 application.Render();
4099 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4100 //GetNaturalSize is a retrieval method which should not modify object
4101 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4102 textEditor.GetNaturalSize();
4104 //This is to simulate focus into text editor after calling GetNaturalSize
4105 //Create a tap event to touch the text editor.
4106 TestGenerateTap(application, 18.0f, 25.0f);
4108 application.SendNotification();
4109 application.Render();
4111 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4113 //The LineCount must not be changed when calling GetNaturalSize.
4114 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4119 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4121 ToolkitTestApplication application;
4122 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4124 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4125 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4126 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4128 // Create a text editor
4129 TextEditor textEditor = TextEditor::New();
4131 //Set size to avoid automatic eliding
4132 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4133 //Set very large font-size using point-size
4134 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4135 //Specify font-family
4136 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4137 //Set text to check if appear or not
4138 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4140 application.GetScene().Add(textEditor);
4142 application.SendNotification();
4143 application.Render();
4144 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4145 Vector3 naturalSize = textEditor.GetNaturalSize();
4147 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4148 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4153 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4155 ToolkitTestApplication application;
4156 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4158 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4159 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4160 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4162 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4163 // Create a text editor
4164 TextEditor textEditor = TextEditor::New();
4165 //Set size to avoid automatic eliding
4166 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4167 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4168 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4170 const int numberOfCases = 6;
4171 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4173 for(int index = 0; index < numberOfCases; index++)
4175 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4176 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4177 application.GetScene().Add(textEditor);
4178 application.SendNotification();
4179 application.Render();
4180 naturalSize = textEditor.GetNaturalSize();
4181 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4182 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4188 int UtcDaliTextEditorHyphenWrapMode(void)
4190 ToolkitTestApplication application;
4191 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4194 TextEditor textEditor = TextEditor::New();
4196 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4198 application.GetScene().Add(textEditor);
4199 application.SendNotification();
4200 application.Render();
4202 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4203 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4204 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4206 application.SendNotification();
4207 application.Render();
4209 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4215 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4217 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4218 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4219 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4221 application.SendNotification();
4222 application.Render();
4224 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4231 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4236 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4238 ToolkitTestApplication application;
4239 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4240 TextEditor textEditor = TextEditor::New();
4242 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4243 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4245 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4246 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4247 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4249 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4250 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4251 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4253 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4254 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4255 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4257 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4258 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4259 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4261 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4262 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4263 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4265 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4266 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4267 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4269 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4270 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4271 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4273 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4274 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4275 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4277 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4278 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4279 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4281 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4282 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4283 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4285 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4286 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4287 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4289 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4290 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4291 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4296 int UtcDaliTextEditorCopyText(void)
4298 ToolkitTestApplication application;
4299 tet_infoline(" UtcDaliTextEditorCopyText ");
4301 TextEditor textEditor = TextEditor::New();
4303 std::string selectedText = "";
4304 std::string copiedText = "";
4306 application.GetScene().Add(textEditor);
4308 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4309 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4310 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4312 // Avoid a crash when core load gl resources.
4313 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4315 application.SendNotification();
4316 application.Render();
4318 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4320 application.SendNotification();
4321 application.Render();
4323 // Hello is selected
4324 DevelTextEditor::SelectText(textEditor, 0, 5);
4326 application.SendNotification();
4327 application.Render();
4329 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4330 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4332 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4333 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4336 copiedText = DevelTextEditor::CopyText(textEditor);
4337 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4339 // world is selected
4340 DevelTextEditor::SelectText(textEditor, 6, 11);
4342 application.SendNotification();
4343 application.Render();
4345 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4346 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4348 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4349 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4352 copiedText = DevelTextEditor::CopyText(textEditor);
4353 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4355 // "lo wo" is selected
4356 DevelTextEditor::SelectText(textEditor, 3, 8);
4358 application.SendNotification();
4359 application.Render();
4361 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4362 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4364 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4365 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4367 // "lo wo" is copied
4368 copiedText = DevelTextEditor::CopyText(textEditor);
4369 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4374 int UtcDaliTextEditorCutText(void)
4376 ToolkitTestApplication application;
4377 tet_infoline(" UtcDaliTextEditorCutText ");
4379 TextEditor textEditor = TextEditor::New();
4381 std::string selectedText = "";
4383 application.GetScene().Add(textEditor);
4385 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4386 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4387 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4389 // Avoid a crash when core load gl resources.
4390 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4392 application.SendNotification();
4393 application.Render();
4395 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4397 application.SendNotification();
4398 application.Render();
4400 // Hello is selected
4401 DevelTextEditor::SelectText(textEditor, 0, 5);
4403 application.SendNotification();
4404 application.Render();
4406 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4407 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4409 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4410 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4413 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4415 application.SendNotification();
4416 application.Render();
4418 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4421 DevelTextEditor::SelectText(textEditor, 0, 2);
4423 application.SendNotification();
4424 application.Render();
4426 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4427 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4429 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4430 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4433 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4435 application.SendNotification();
4436 application.Render();
4438 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4440 // Test Cut from the middle
4443 DevelTextEditor::SelectText(textEditor, 1, 3);
4445 application.SendNotification();
4446 application.Render();
4448 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4449 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4451 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4452 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4455 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4457 application.SendNotification();
4458 application.Render();
4460 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4462 // Test Cut from the end
4465 DevelTextEditor::SelectText(textEditor, 1, 2);
4467 application.SendNotification();
4468 application.Render();
4470 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4471 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4473 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4474 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4477 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4479 application.SendNotification();
4480 application.Render();
4482 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4487 int UtcDaliTextEditorPasteText(void)
4489 ToolkitTestApplication application;
4490 tet_infoline(" UtcDaliTextEditorPasteText ");
4492 TextEditor editor = TextEditor::New();
4493 DALI_TEST_CHECK(editor);
4495 application.GetScene().Add(editor);
4497 std::string cutText = "";
4498 std::string copiedText = "";
4500 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4501 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4502 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4503 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4504 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4506 // Avoid a crash when core load gl resources.
4507 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4509 // Render and notify
4510 application.SendNotification();
4511 application.Render();
4513 // Tap on the text editor
4514 TestGenerateTap(application, 3.0f, 25.0f);
4516 // Render and notify
4517 application.SendNotification();
4518 application.Render();
4520 // Move to second line of the text.
4521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4523 // Render and notify
4524 application.SendNotification();
4525 application.Render();
4527 // Select some text in the right of the current cursor position
4528 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4529 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4530 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4531 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4533 // Render and notify
4534 application.SendNotification();
4535 application.Render();
4537 // Cut the selected text
4538 cutText = DevelTextEditor::CutText(editor);
4540 // Render and notify
4541 application.SendNotification();
4542 application.Render();
4544 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4545 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4547 // Select some text in the left of the current cursor position
4548 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4549 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4550 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4551 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4553 // Render and notify
4554 application.SendNotification();
4555 application.Render();
4557 // Copy the selected text
4558 copiedText = DevelTextEditor::CopyText(editor);
4560 // Render and notify
4561 application.SendNotification();
4562 application.Render();
4564 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4565 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4567 // Move the cursor to the third line
4568 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4569 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4571 // Render and notify
4572 application.SendNotification();
4573 application.Render();
4575 // Paste the selected text at the current cursor position
4576 DevelTextEditor::PasteText(editor);
4578 // Render and notify
4579 application.SendNotification();
4580 application.Render();
4582 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4587 int UtcDaliTextEditorLineSpacing(void)
4589 ToolkitTestApplication application;
4590 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4592 TextEditor textEditor = TextEditor::New();
4593 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4594 application.GetScene().Add(textEditor);
4595 application.SendNotification();
4596 application.Render();
4598 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4599 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4601 Vector3 sizeBefore = textEditor.GetNaturalSize();
4603 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4605 //add 20 for each line 20 * 3
4606 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4611 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4613 //Only for test coverage
4614 ToolkitTestApplication application;
4615 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4617 TextEditor textEditor = TextEditor::New();
4618 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4619 application.GetScene().Add(textEditor);
4620 application.SendNotification();
4621 application.Render();
4623 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4624 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4626 application.SendNotification();
4627 application.Render();
4629 DevelTextEditor::SelectWholeText(textEditor);
4631 application.SendNotification();
4632 application.Render();
4634 DevelTextEditor::SelectNone(textEditor);
4635 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4637 application.SendNotification();
4638 application.Render();
4640 DevelTextEditor::SelectWholeText(textEditor);
4642 application.SendNotification();
4643 application.Render();
4645 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4650 int UtcDaliTextEditorMinLineSize(void)
4652 ToolkitTestApplication application;
4653 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4655 TextEditor textEditor = TextEditor::New();
4656 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4657 application.GetScene().Add(textEditor);
4658 application.SendNotification();
4659 application.Render();
4661 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4662 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4664 Vector3 sizeBefore = textEditor.GetNaturalSize();
4666 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4668 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4671 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4676 int utcDaliTextEditorCursorPositionChangedSignal(void)
4678 ToolkitTestApplication application;
4679 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4681 TextEditor editor = TextEditor::New();
4682 DALI_TEST_CHECK(editor);
4684 application.GetScene().Add(editor);
4686 // connect to the selection changed signal.
4687 ConnectionTracker* testTracker = new ConnectionTracker();
4688 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4689 bool cursorPositionChangedSignal = false;
4690 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4692 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4693 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4694 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4695 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4696 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4698 // Avoid a crash when core load gl resources.
4699 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4701 // Render and notify
4702 application.SendNotification();
4703 application.Render();
4705 editor.SetKeyInputFocus();
4707 // Tap on the text editor
4708 TestGenerateTap(application, 3.0f, 25.0f);
4710 // Render and notify
4711 application.SendNotification();
4712 application.Render();
4714 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4715 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4717 gCursorPositionChangedCallbackCalled = false;
4720 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4722 // Render and notify
4723 application.SendNotification();
4724 application.Render();
4726 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4727 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4729 gCursorPositionChangedCallbackCalled = false;
4732 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4734 // Render and notify
4735 application.SendNotification();
4736 application.Render();
4738 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4739 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4741 gCursorPositionChangedCallbackCalled = false;
4743 //delete one character
4744 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4746 // Render and notify
4747 application.SendNotification();
4748 application.Render();
4750 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4751 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4753 gCursorPositionChangedCallbackCalled = false;
4755 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
4757 // Render and notify
4758 application.SendNotification();
4759 application.Render();
4761 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4762 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4764 gCursorPositionChangedCallbackCalled = false;
4766 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4768 // Render and notify
4769 application.SendNotification();
4770 application.Render();
4772 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4773 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4778 int utcDaliTextEditorGeometryEllipsisStart(void)
4780 ToolkitTestApplication application;
4781 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4783 TextEditor editor = TextEditor::New();
4784 DALI_TEST_CHECK(editor);
4786 application.GetScene().Add(editor);
4788 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4789 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4790 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4791 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4792 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4793 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4794 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4795 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4796 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4798 // Avoid a crash when core load gl resources.
4799 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4801 // Render and notify
4802 application.SendNotification();
4803 application.Render();
4805 unsigned int expectedCount = 2;
4806 unsigned int startIndex = 0;
4807 unsigned int endIndex = 24;
4809 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4810 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4812 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4813 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4815 Vector<Vector2> expectedSizes;
4816 Vector<Vector2> expectedPositions;
4818 expectedPositions.PushBack(Vector2(37, 0));
4819 expectedSizes.PushBack(Vector2(20, 25));
4821 expectedPositions.PushBack(Vector2(-1, 25));
4822 expectedSizes.PushBack(Vector2(52, 25));
4824 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4829 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4831 ToolkitTestApplication application;
4832 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4834 TextEditor editor = TextEditor::New();
4835 DALI_TEST_CHECK(editor);
4837 application.GetScene().Add(editor);
4839 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4840 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4841 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4842 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4843 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4844 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4845 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4846 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4847 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4849 // Avoid a crash when core load gl resources.
4850 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4852 // Render and notify
4853 application.SendNotification();
4854 application.Render();
4856 unsigned int expectedCount = 2;
4857 unsigned int startIndex = 0;
4858 unsigned int endIndex = 24;
4860 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4861 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4863 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4864 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4866 Vector<Vector2> expectedSizes;
4867 Vector<Vector2> expectedPositions;
4869 expectedPositions.PushBack(Vector2(-1, 0));
4870 expectedSizes.PushBack(Vector2(25, 25));
4872 expectedPositions.PushBack(Vector2(-1, 25));
4873 expectedSizes.PushBack(Vector2(52, 25));
4875 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4880 int utcDaliTextEditorGeometryEllipsisEnd(void)
4882 ToolkitTestApplication application;
4883 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4885 TextEditor editor = TextEditor::New();
4886 DALI_TEST_CHECK(editor);
4888 application.GetScene().Add(editor);
4890 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4891 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4892 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4893 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4894 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4895 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4896 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4897 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4898 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4900 // Avoid a crash when core load gl resources.
4901 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4903 // Render and notify
4904 application.SendNotification();
4905 application.Render();
4907 unsigned int expectedCount = 2;
4908 unsigned int startIndex = 0;
4909 unsigned int endIndex = 24;
4911 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4912 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4914 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4915 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4917 Vector<Vector2> expectedSizes;
4918 Vector<Vector2> expectedPositions;
4920 expectedPositions.PushBack(Vector2(-1, 0));
4921 expectedSizes.PushBack(Vector2(59, 25));
4923 expectedPositions.PushBack(Vector2(-1, 25));
4924 expectedSizes.PushBack(Vector2(38, 25));
4926 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4931 int utcDaliTextEditorGeometryRTL(void)
4933 ToolkitTestApplication application;
4934 tet_infoline(" utcDaliTextEditorGeometryRTL");
4936 TextEditor editor = TextEditor::New();
4937 DALI_TEST_CHECK(editor);
4939 application.GetScene().Add(editor);
4941 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4942 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4943 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4944 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4945 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4946 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
4948 // Avoid a crash when core load gl resources.
4949 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4951 // Render and notify
4952 application.SendNotification();
4953 application.Render();
4955 unsigned int expectedCount = 4;
4956 unsigned int startIndex = 3;
4957 unsigned int endIndex = 24;
4959 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4960 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4962 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4963 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4965 Vector<Vector2> expectedSizes;
4966 Vector<Vector2> expectedPositions;
4968 expectedPositions.PushBack(Vector2(24, 0));
4969 expectedSizes.PushBack(Vector2(33, 25));
4971 expectedPositions.PushBack(Vector2(-1, 25));
4972 expectedSizes.PushBack(Vector2(52, 25));
4974 expectedPositions.PushBack(Vector2(-1, 50));
4975 expectedSizes.PushBack(Vector2(59, 25));
4977 expectedPositions.PushBack(Vector2(61, 75));
4978 expectedSizes.PushBack(Vector2(37, 25));
4980 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4985 int utcDaliTextEditorGeometryGlyphMiddle(void)
4987 ToolkitTestApplication application;
4988 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4990 TextEditor editor = TextEditor::New();
4991 DALI_TEST_CHECK(editor);
4993 application.GetScene().Add(editor);
4995 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4996 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4997 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4998 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4999 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5000 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5002 // Avoid a crash when core load gl resources.
5003 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5005 // Render and notify
5006 application.SendNotification();
5007 application.Render();
5009 unsigned int expectedCount = 1;
5010 unsigned int startIndex = 1;
5011 unsigned int endIndex = 13;
5013 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5014 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5016 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5017 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5019 Vector<Vector2> expectedSizes;
5020 Vector<Vector2> expectedPositions;
5022 expectedPositions.PushBack(Vector2(6, 0));
5023 expectedSizes.PushBack(Vector2(124, 25));
5025 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5030 int utcDaliTextEditorGeometryOneGlyph(void)
5032 ToolkitTestApplication application;
5033 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5035 TextEditor label = TextEditor::New();
5036 DALI_TEST_CHECK(label);
5038 application.GetScene().Add(label);
5040 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5041 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5042 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5043 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5044 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5045 label.SetProperty(TextEditor::Property::TEXT, "H");
5047 // Avoid a crash when core load gl resources.
5048 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5050 // Render and notify
5051 application.SendNotification();
5052 application.Render();
5054 unsigned int expectedCount = 1;
5055 unsigned int startIndex = 0;
5056 unsigned int endIndex = 0;
5058 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5059 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5061 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5062 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5064 Vector<Vector2> expectedSizes;
5065 Vector<Vector2> expectedPositions;
5067 expectedPositions.PushBack(Vector2(-2, 0));
5068 expectedSizes.PushBack(Vector2(16, 25));
5070 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5075 int utcDaliTextEditorSelectionClearedSignal(void)
5077 ToolkitTestApplication application;
5078 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5080 TextEditor editor = TextEditor::New();
5081 DALI_TEST_CHECK(editor);
5083 application.GetScene().Add(editor);
5085 // connect to the selection changed signal.
5086 ConnectionTracker* testTracker = new ConnectionTracker();
5087 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5088 bool selectionClearedSignal = false;
5089 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5091 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5092 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5093 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5094 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5095 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5097 // Avoid a crash when core load gl resources.
5098 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5100 // Render and notify
5101 application.SendNotification();
5102 application.Render();
5104 // Tap on the text editor
5105 TestGenerateTap(application, 3.0f, 25.0f);
5107 // Render and notify
5108 application.SendNotification();
5109 application.Render();
5111 // Move to second line of the text & Select some text in the right of the current cursor position
5112 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5113 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5116 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5118 // Render and notify
5119 application.SendNotification();
5120 application.Render();
5122 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5124 // Render and notify
5125 application.SendNotification();
5126 application.Render();
5128 // Tap on the text editor
5129 TestGenerateTap(application, 3.0f, 25.0f);
5131 // Render and notify
5132 application.SendNotification();
5133 application.Render();
5135 gSelectionClearedCallbackCalled = false;
5137 // Move to second line of the text & select.
5138 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5139 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5142 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5144 // Render and notify
5145 application.SendNotification();
5146 application.Render();
5148 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5150 gSelectionClearedCallbackCalled = false;
5152 // Render and notify
5153 application.SendNotification();
5154 application.Render();
5156 // Move to second line of the text & select.
5157 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5158 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5160 // replace C with selected text
5161 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5163 // Render and notify
5164 application.SendNotification();
5165 application.Render();
5167 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5169 gSelectionClearedCallbackCalled = false;
5171 // Render and notify
5172 application.SendNotification();
5173 application.Render();
5175 DevelTextEditor::SelectText(editor, 1, 3);
5177 // Render and notify
5178 application.SendNotification();
5179 application.Render();
5181 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5183 // Render and notify
5184 application.SendNotification();
5185 application.Render();
5187 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5189 gSelectionClearedCallbackCalled = false;
5191 DevelTextEditor::SelectText(editor, 1, 3);
5193 // Render and notify
5194 application.SendNotification();
5195 application.Render();
5198 DevelTextEditor::SelectNone(editor);
5200 // Render and notify
5201 application.SendNotification();
5202 application.Render();
5204 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5209 int utcDaliTextEditorSelectionStartedSignal(void)
5211 ToolkitTestApplication application;
5212 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5214 TextEditor editor = TextEditor::New();
5215 DALI_TEST_CHECK(editor);
5217 application.GetScene().Add(editor);
5219 // connect to the selection changed signal.
5220 ConnectionTracker* testTracker = new ConnectionTracker();
5221 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5222 bool selectionStartedSignal = false;
5223 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5225 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5226 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5227 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5228 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5229 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5231 // Avoid a crash when core load gl resources.
5232 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5234 // Render and notify
5235 application.SendNotification();
5236 application.Render();
5238 // Tap on the text editor
5239 TestGenerateTap(application, 3.0f, 25.0f);
5241 // Render and notify
5242 application.SendNotification();
5243 application.Render();
5245 // Move to second line of the text & Select some text in the right of the current cursor position
5246 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5247 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5249 // Render and notify
5250 application.SendNotification();
5251 application.Render();
5253 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5256 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5258 // Render and notify
5259 application.SendNotification();
5260 application.Render();
5262 gSelectionStartedCallbackCalled = false;
5264 DevelTextEditor::SelectText(editor, 1, 3);
5266 // Render and notify
5267 application.SendNotification();
5268 application.Render();
5270 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5275 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5277 ToolkitTestApplication application;
5278 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5280 // Checks if the actor is created.
5282 TextEditor editor = TextEditor::New();
5283 DALI_TEST_CHECK(editor);
5285 application.GetScene().Add(editor);
5287 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5288 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5289 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5290 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5291 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5292 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5293 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5294 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5296 // Avoid a crash when core load gl resources.
5297 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5299 // Render and notify
5300 application.SendNotification();
5301 application.Render();
5303 // Tap on the text editor
5304 TestGenerateTap(application, 3.0f, 25.0f);
5306 // Render and notify
5307 application.SendNotification();
5308 application.Render();
5310 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5311 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5313 application.SendNotification();
5314 application.Render();
5316 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5317 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5322 int utcDaliTextEditorSelectionChangedSignal(void)
5324 ToolkitTestApplication application;
5325 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5327 TextEditor editor = TextEditor::New();
5328 DALI_TEST_CHECK(editor);
5330 application.GetScene().Add(editor);
5332 // connect to the selection changed signal.
5333 ConnectionTracker* testTracker = new ConnectionTracker();
5334 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5335 bool selectionChangedSignal = false;
5336 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5338 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5339 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5340 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5341 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5342 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5344 // Avoid a crash when core load gl resources.
5345 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5347 // Render and notify
5348 application.SendNotification();
5349 application.Render();
5351 // Tap on the text editor
5352 TestGenerateTap(application, 3.0f, 25.0f);
5354 // Render and notify
5355 application.SendNotification();
5356 application.Render();
5358 // Move to second line of the text.
5359 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5361 // Render and notify
5362 application.SendNotification();
5363 application.Render();
5365 // Select some text in the right of the current cursor position
5366 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5367 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5369 // Render and notify
5370 application.SendNotification();
5371 application.Render();
5373 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5374 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5376 gSelectionChangedCallbackCalled = false;
5378 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5380 // Render and notify
5381 application.SendNotification();
5382 application.Render();
5384 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5385 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5386 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5388 gSelectionChangedCallbackCalled = false;
5390 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5392 // Render and notify
5393 application.SendNotification();
5394 application.Render();
5396 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5397 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5398 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5400 gSelectionChangedCallbackCalled = false;
5401 editor.SetKeyInputFocus();
5403 // Render and notify
5404 application.SendNotification();
5405 application.Render();
5407 DevelTextEditor::SelectText(editor, 0, 5);
5409 application.SendNotification();
5410 application.Render();
5412 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5413 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5415 gSelectionChangedCallbackCalled = false;
5417 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5419 // Render and notify
5420 application.SendNotification();
5421 application.Render();
5423 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5424 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5425 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5427 gSelectionChangedCallbackCalled = false;
5430 DevelTextEditor::SelectWholeText(editor);
5432 // Render and notify
5433 application.SendNotification();
5434 application.Render();
5436 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5437 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5439 gSelectionChangedCallbackCalled = false;
5442 DevelTextEditor::SelectNone(editor);
5444 // Render and notify
5445 application.SendNotification();
5446 application.Render();
5448 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5449 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5450 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5455 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5457 ToolkitTestApplication application;
5458 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5460 TextEditor textEditor = TextEditor::New();
5461 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5462 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5463 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5464 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5466 application.GetScene().Add(textEditor);
5467 application.SendNotification();
5468 application.Render();
5470 Property::Map strikethroughMapSet;
5471 Property::Map strikethroughMapGet;
5473 strikethroughMapSet.Insert("enable", true);
5474 strikethroughMapSet.Insert("color", Color::RED);
5475 strikethroughMapSet.Insert("height", 2.0f);
5477 // Check the strikethrough property
5478 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5479 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5480 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5481 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5482 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5484 // Render and notify
5485 application.SendNotification();
5486 application.Render();
5488 strikethroughMapSet.Clear();
5489 strikethroughMapGet.Clear();
5494 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5496 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5497 //DaliException on vector: "Iterator not inside vector"
5499 ToolkitTestApplication application;
5500 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5502 TextEditor editor = TextEditor::New();
5503 DALI_TEST_CHECK(editor);
5505 application.GetScene().Add(editor);
5507 // Avoid a crash when core load gl resources.
5508 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5510 //Set multilines text
5511 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5512 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5513 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5515 //Set ResizePolicy to NaturalSize
5516 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5518 // Render and notify
5519 application.SendNotification();
5520 application.Render();
5522 // Create a tap event to touch the text editor.
5523 TestGenerateTap(application, 5.0f, 5.0f);
5525 // Render and notify
5526 application.SendNotification();
5527 application.Render();
5529 // Set currsor and add character (in first line)
5530 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5531 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5532 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5534 // Render and notify
5535 application.SendNotification();
5536 application.Render();
5538 //Check the changed text and cursor position
5539 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5540 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5542 // Render and notify
5543 application.SendNotification();
5544 application.Render();
5549 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5551 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5552 //DaliException on vector: "Iterator not inside vector"
5554 ToolkitTestApplication application;
5555 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5557 TextEditor editor = TextEditor::New();
5558 DALI_TEST_CHECK(editor);
5560 application.GetScene().Add(editor);
5562 // Avoid a crash when core load gl resources.
5563 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5565 //Set multilines text
5566 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5567 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5568 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5570 //Set ResizePolicy to NaturalSize
5571 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5574 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5575 application.SendNotification();
5576 application.Render();
5578 // Set focus and remove character
5579 editor.SetKeyInputFocus();
5580 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5582 // Render and notify
5583 application.SendNotification();
5584 application.Render();
5586 //Check the changed text and cursor position
5587 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5588 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5590 // Render and notify
5591 application.SendNotification();
5592 application.Render();
5597 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5599 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5600 //DaliException on vector: "Iterator not inside vector"
5602 ToolkitTestApplication application;
5603 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5605 TextEditor editor = TextEditor::New();
5606 DALI_TEST_CHECK(editor);
5608 application.GetScene().Add(editor);
5610 // Avoid a crash when core load gl resources.
5611 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5613 //Set multilines text
5614 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5615 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5616 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5618 //Set ResizePolicy to NaturalSize
5619 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5621 //Select text at initialization (before the first render)
5622 DevelTextEditor::SelectText(editor, 3, 5);
5624 // Render and notify
5625 application.SendNotification();
5626 application.Render();
5629 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5630 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));
5632 // Render and notify
5633 application.SendNotification();
5634 application.Render();
5636 //Check the changed text and cursor position
5637 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5638 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5640 // Render and notify
5641 application.SendNotification();
5642 application.Render();
5647 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5649 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5650 //DaliException on vector: "Iterator not inside vector"
5652 ToolkitTestApplication application;
5653 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5655 TextEditor editor = TextEditor::New();
5656 DALI_TEST_CHECK(editor);
5658 application.GetScene().Add(editor);
5660 // Avoid a crash when core load gl resources.
5661 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5663 //Set multilines text
5664 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5665 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5666 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5668 //Set ResizePolicy to NaturalSize
5669 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5672 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5673 application.SendNotification();
5674 application.Render();
5676 // Set focus and double enter (new line)
5677 editor.SetKeyInputFocus();
5678 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5679 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5681 // Render and notify
5682 application.SendNotification();
5683 application.Render();
5685 //Check the changed text and cursor position
5686 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5687 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5689 // Render and notify
5690 application.SendNotification();
5691 application.Render();
5696 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5698 ToolkitTestApplication application;
5699 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5700 TextEditor textEditor = TextEditor::New();
5701 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5702 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5703 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5704 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5706 application.GetScene().Add(textEditor);
5707 application.SendNotification();
5708 application.Render();
5710 Property::Map underlineMapSet;
5711 Property::Map underlineMapGet;
5713 underlineMapSet.Insert("enable", true);
5714 underlineMapSet.Insert("color", Color::RED);
5715 underlineMapSet.Insert("height", 1);
5716 underlineMapSet.Insert("type", Text::Underline::SOLID);
5717 underlineMapSet.Insert("dashWidth", 2);
5718 underlineMapSet.Insert("dashGap", 1);
5720 // Check the underline property
5721 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5723 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5724 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5725 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5727 // Render and notify
5728 application.SendNotification();
5729 application.Render();
5731 underlineMapSet.Clear();
5732 underlineMapGet.Clear();
5734 underlineMapSet.Insert("enable", true);
5735 underlineMapSet.Insert("color", Color::BLUE);
5736 underlineMapSet.Insert("height", 1);
5737 underlineMapSet.Insert("type", Text::Underline::DASHED);
5738 underlineMapSet.Insert("dashWidth", 4);
5739 underlineMapSet.Insert("dashGap", 2);
5741 // Check the dashed underline property
5742 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5744 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5745 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5746 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5748 // Render and notify
5749 application.SendNotification();
5750 application.Render();
5752 underlineMapSet.Clear();
5753 underlineMapGet.Clear();
5755 underlineMapSet.Insert("enable", true);
5756 underlineMapSet.Insert("color", Color::BLUE);
5757 underlineMapSet.Insert("height", 1);
5758 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5759 underlineMapSet.Insert("dashWidth", 4);
5760 underlineMapSet.Insert("dashGap", 2);
5762 // Check the dashed underline property
5763 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5765 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5766 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5767 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5769 // Render and notify
5770 application.SendNotification();
5771 application.Render();
5773 underlineMapSet.Clear();
5774 underlineMapGet.Clear();
5779 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
5781 ToolkitTestApplication application;
5782 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
5784 TextEditor textEditor1 = TextEditor::New();
5785 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
5786 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5787 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5788 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5790 Property::Map underlineMapSet1;
5791 Property::Map underlineMapGet1;
5793 underlineMapSet1.Insert("enable", true);
5794 underlineMapSet1.Insert("color", Color::RED);
5795 underlineMapSet1.Insert("height", 1);
5796 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5797 underlineMapSet1.Insert("dashWidth", 2);
5798 underlineMapSet1.Insert("dashGap", 1);
5800 // Check the underline property
5801 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5803 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5804 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5805 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5807 application.GetScene().Add(textEditor1);
5808 application.SendNotification();
5809 application.Render();
5811 TextEditor textEditor2 = TextEditor::New();
5812 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
5813 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5814 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5815 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5817 Property::Map underlineMapSet2;
5818 Property::Map underlineMapGet2;
5820 underlineMapSet2.Insert("enable", true);
5821 underlineMapSet2.Insert("color", Color::BLUE);
5822 underlineMapSet2.Insert("height", 1);
5823 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5824 underlineMapSet2.Insert("dashWidth", 4);
5825 underlineMapSet2.Insert("dashGap", 2);
5827 // Check the dashed underline property
5828 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
5830 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5831 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5832 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5834 application.GetScene().Add(textEditor2);
5835 application.SendNotification();
5836 application.Render();
5838 TextEditor textEditor3 = TextEditor::New();
5839 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
5840 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5841 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5842 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5844 Property::Map underlineMapSet3;
5845 Property::Map underlineMapGet3;
5847 underlineMapSet3.Insert("enable", true);
5848 underlineMapSet3.Insert("color", Color::BLUE);
5849 underlineMapSet3.Insert("height", 1);
5850 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5851 underlineMapSet3.Insert("dashWidth", 4);
5852 underlineMapSet3.Insert("dashGap", 2);
5854 // Check the dashed underline property
5855 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
5857 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5858 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5859 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5861 application.GetScene().Add(textEditor3);
5862 application.SendNotification();
5863 application.Render();
5868 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
5870 ToolkitTestApplication application;
5871 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
5873 TextEditor textEditor1 = TextEditor::New();
5874 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
5875 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5876 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5877 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5879 Property::Map underlineMapSet1;
5880 Property::Map underlineMapGet1;
5882 underlineMapSet1.Insert("enable", true);
5883 underlineMapSet1.Insert("color", Color::RED);
5884 underlineMapSet1.Insert("height", 1);
5885 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5886 underlineMapSet1.Insert("dashWidth", 2);
5887 underlineMapSet1.Insert("dashGap", 1);
5889 // Check the underline property
5890 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5891 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
5893 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5894 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5895 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5897 application.GetScene().Add(textEditor1);
5899 application.SendNotification();
5900 application.Render();
5905 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
5907 ToolkitTestApplication application;
5908 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
5910 TextEditor editor = TextEditor::New();
5911 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5912 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5913 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
5914 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5915 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5916 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5918 TextEditor editorSingleLineParagraph = TextEditor::New();
5919 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5920 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5921 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");
5922 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5923 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5924 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5926 TextEditor editorMultiLineParagraph = TextEditor::New();
5927 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5928 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5929 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");
5930 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
5931 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
5932 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5934 application.GetScene().Add(editor);
5935 application.GetScene().Add(editorSingleLineParagraph);
5936 application.GetScene().Add(editorMultiLineParagraph);
5937 application.SendNotification();
5938 application.Render();
5940 Vector3 naturalSize = editor.GetNaturalSize();
5941 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
5942 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
5944 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
5946 //no effect of relative line size for paragraph with single line
5947 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5949 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5954 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
5956 ToolkitTestApplication application;
5957 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
5959 TextEditor editor = TextEditor::New();
5960 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
5961 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5962 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
5964 application.GetScene().Add(editor);
5965 application.SendNotification();
5966 application.Render();
5968 Vector3 naturalSize = editor.GetNaturalSize();
5970 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
5972 application.SendNotification();
5973 application.Render();
5975 Vector3 relativeNaturalSize = editor.GetNaturalSize();
5977 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
5979 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
5981 application.SendNotification();
5982 application.Render();
5984 relativeNaturalSize = editor.GetNaturalSize();
5986 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
5990 int UtcDaliTextEditorCharacterSpacing(void)
5992 ToolkitTestApplication application;
5993 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
5995 TextEditor textEditor = TextEditor::New();
5997 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5999 application.GetScene().Add(textEditor);
6000 application.SendNotification();
6001 application.Render();
6003 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6004 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6005 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6007 application.SendNotification();
6008 application.Render();
6013 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6015 ToolkitTestApplication application;
6016 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6018 TextEditor editor = TextEditor::New();
6020 float lineSpacing = -20.f;
6022 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6023 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6024 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6025 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6027 application.GetScene().Add(editor);
6028 application.SendNotification();
6029 application.Render();
6031 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6032 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6034 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6035 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6037 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6038 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6040 application.SendNotification();
6041 application.Render();
6046 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6048 ToolkitTestApplication application;
6049 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6051 TextEditor editor = TextEditor::New();
6052 DALI_TEST_CHECK(editor);
6054 application.GetScene().Add(editor);
6056 std::string cutText = "";
6057 std::string copiedText = "";
6059 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6060 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6061 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6062 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6063 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6064 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6065 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6067 // Render and notify
6068 application.SendNotification();
6069 application.Render();
6071 // Tap on the text editor
6072 TestGenerateTap(application, 1.0f, 1.0f);
6074 // Render and notify
6075 application.SendNotification();
6076 application.Render();
6078 // Move to second line of the text.
6079 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6081 // Render and notify
6082 application.SendNotification();
6083 application.Render();
6085 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6090 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6092 ToolkitTestApplication application;
6093 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6095 TextEditor editor = TextEditor::New();
6097 float lineSpacing = -20.f;
6099 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6100 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6101 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6102 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6103 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6105 application.GetScene().Add(editor);
6106 application.SendNotification();
6107 application.Render();
6109 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6111 int lineCount = sizeList.Size();
6112 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6114 application.SendNotification();
6115 application.Render();
6120 int UtcDaliToolkitTexteditorParagraphTag(void)
6122 ToolkitTestApplication application;
6123 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6124 TextEditor editorNewlineSeparator = TextEditor::New();
6125 TextEditor editorParagraphTag = TextEditor::New();
6126 DALI_TEST_CHECK(editorNewlineSeparator);
6127 DALI_TEST_CHECK(editorParagraphTag);
6129 application.GetScene().Add(editorNewlineSeparator);
6130 application.GetScene().Add(editorParagraphTag);
6132 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6133 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6134 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6135 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6136 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6137 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6139 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6140 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6141 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6142 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6143 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6145 application.SendNotification();
6146 application.Render();
6148 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6149 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6151 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6153 application.SendNotification();
6154 application.Render();
6159 //Handle Emoji clustering for cursor handling
6160 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6162 ToolkitTestApplication application;
6163 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6164 TextEditor textEditor = TextEditor::New();
6165 DALI_TEST_CHECK(textEditor);
6167 application.GetScene().Add(textEditor);
6169 // Avoid a crash when core load gl resources.
6170 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6172 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6173 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6175 // Render and notify
6176 application.SendNotification();
6177 application.Render();
6180 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6181 application.SendNotification();
6182 application.Render();
6184 // Set focus and remove Emoji
6185 textEditor.SetKeyInputFocus();
6186 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6188 //Check the changed text and cursor position
6189 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6190 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6192 // Render and notify
6193 application.SendNotification();
6194 application.Render();
6199 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6201 ToolkitTestApplication application;
6202 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6203 TextEditor textEditor = TextEditor::New();
6204 DALI_TEST_CHECK(textEditor);
6206 application.GetScene().Add(textEditor);
6208 // Avoid a crash when core load gl resources.
6209 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6211 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6212 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6214 // Render and notify
6215 application.SendNotification();
6216 application.Render();
6219 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6220 application.SendNotification();
6221 application.Render();
6223 // Set focus and remove Emoji
6224 textEditor.SetKeyInputFocus();
6225 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6227 //Check the changed text and cursor position
6228 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6229 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6231 // Render and notify
6232 application.SendNotification();
6233 application.Render();