2 * Copyright (c) 2021 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/devel-api/adaptor-framework/clipboard.h>
24 #include <dali/devel-api/adaptor-framework/key-devel.h>
25 #include <dali/devel-api/text-abstraction/font-client.h>
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/public-api/rendering/renderer.h>
32 #include "test-text-geometry-utils.h"
35 using namespace Toolkit;
37 void dali_texteditor_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_texteditor_cleanup(void)
44 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
91 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
93 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
94 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
95 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
96 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
97 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
100 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
101 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
102 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
103 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
104 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
106 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
107 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
108 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
109 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
110 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
113 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
115 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
116 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
118 const float RENDER_FRAME_INTERVAL = 16.66f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR("/resources/fonts");
123 const int KEY_A_CODE = 38;
124 const int KEY_D_CODE = 40;
125 const int KEY_C_CODE = 54;
126 const int KEY_V_CODE = 55;
127 const int KEY_X_CODE = 53;
128 const int KEY_WHITE_SPACE_CODE = 65;
130 const int KEY_SHIFT_MODIFIER = 257;
131 const int KEY_CONTROL_MODIFIER = 258;
133 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
134 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
135 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
137 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
139 static bool gSelectionChangedCallbackCalled;
140 static uint32_t oldSelectionStart;
141 static uint32_t oldSelectionEnd;
142 static bool gSelectionClearedCallbackCalled;
143 static bool gAnchorClickedCallBackCalled;
144 static bool gAnchorClickedCallBackNotCalled;
145 static bool gTextChangedCallBackCalled;
146 static bool gInputFilteredAcceptedCallbackCalled;
147 static bool gInputFilteredRejectedCallbackCalled;
148 static bool gInputStyleChangedCallbackCalled;
149 static bool gMaxCharactersCallBackCalled;
150 static bool gCursorPositionChangedCallbackCalled;
151 static uint32_t oldCursorPos;
152 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
154 struct CallbackFunctor
156 CallbackFunctor(bool* callbackFlag)
157 : mCallbackFlag(callbackFlag)
163 *mCallbackFlag = true;
168 static void TestSelectionClearedCallback(TextEditor control)
170 tet_infoline(" TestSelectionClearedCallback");
172 gSelectionClearedCallbackCalled = true;
175 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
177 tet_infoline(" TestSelectionChangedCallback");
179 gSelectionChangedCallbackCalled = true;
180 oldSelectionStart = oldStart;
181 oldSelectionEnd = oldEnd;
184 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
186 tet_infoline(" TestAnchorClickedCallback");
188 gAnchorClickedCallBackNotCalled = false;
190 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
192 gAnchorClickedCallBackCalled = true;
196 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
198 tet_infoline(" TestCursorPositionChangedCallback");
200 gCursorPositionChangedCallbackCalled = true;
201 oldCursorPos = oldPos;
204 static void TestTextChangedCallback(TextEditor control)
206 tet_infoline(" TestTextChangedCallback");
208 gTextChangedCallBackCalled = true;
211 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
213 tet_infoline(" TestInputStyleChangedCallback");
215 gInputStyleChangedCallbackCalled = true;
216 gInputStyleMask = mask;
219 static void TestMaxLengthReachedCallback(TextEditor control)
221 tet_infoline(" TestMaxLengthReachedCallback");
223 gMaxCharactersCallBackCalled = true;
226 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
228 tet_infoline(" TestInputFilteredCallback");
230 if(type == Toolkit::InputFilter::Property::ACCEPTED)
232 gInputFilteredAcceptedCallbackCalled = true;
234 else if(type == Toolkit::InputFilter::Property::REJECTED)
236 gInputFilteredRejectedCallbackCalled = true;
240 // Generate a KeyEvent to send to Core.
241 Integration::KeyEvent GenerateKey(const std::string& keyName,
242 const std::string& logicalKey,
243 const std::string& keyString,
246 unsigned long timeStamp,
247 const Integration::KeyEvent::State& keyState,
248 const std::string& compose = "",
249 const std::string& deviceName = DEFAULT_DEVICE_NAME,
250 const Device::Class::Type& deviceClass = Device::Class::NONE,
251 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
253 return Integration::KeyEvent(keyName,
266 Dali::Integration::Point GetPointDownInside(Vector2& pos)
268 Dali::Integration::Point point;
269 point.SetState(PointState::DOWN);
270 point.SetScreenPosition(pos);
274 Dali::Integration::Point GetPointUpInside(Vector2& pos)
276 Dali::Integration::Point point;
277 point.SetState(PointState::UP);
278 point.SetScreenPosition(pos);
282 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
284 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
286 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
288 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
290 Property::Value* valueSet = NULL;
291 if(valueGet.first.type == Property::Key::INDEX)
293 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
297 // Get Key is a string so searching Set Map for a string key
298 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
303 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
305 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
308 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
310 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
313 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
315 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
318 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
320 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
323 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
325 Vector2 vector2Get = valueGet.second.Get<Vector2>();
326 Vector2 vector2Set = valueSet->Get<Vector2>();
327 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
330 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
332 Vector4 vector4Get = valueGet.second.Get<Vector4>();
333 Vector4 vector4Set = valueSet->Get<Vector4>();
334 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);
340 if(valueGet.first.type == Property::Key::INDEX)
342 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
346 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
356 class ScrollStateChangeCallback : public Dali::ConnectionTracker
359 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
360 : mStartedCalled(startedCalled),
361 mFinishedCalled(finishedCalled)
365 void Callback(TextEditor editor, TextEditor::Scroll::Type type)
367 if(type == TextEditor::Scroll::STARTED)
369 mStartedCalled = true;
371 else if(type == TextEditor::Scroll::FINISHED)
373 mFinishedCalled = true;
377 bool& mStartedCalled;
378 bool& mFinishedCalled;
383 int UtcDaliToolkitTextEditorConstructorP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
387 TextEditor textEditor;
388 DALI_TEST_CHECK(!textEditor);
392 int UtcDaliToolkitTextEditorNewP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitTextEditorNewP");
396 TextEditor textEditor = TextEditor::New();
397 DALI_TEST_CHECK(textEditor);
401 int UtcDaliToolkitTextEditorDownCastP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
405 TextEditor textEditor1 = TextEditor::New();
406 BaseHandle object(textEditor1);
408 TextEditor textEditor2 = TextEditor::DownCast(object);
409 DALI_TEST_CHECK(textEditor2);
411 TextEditor textEditor3 = DownCast<TextEditor>(object);
412 DALI_TEST_CHECK(textEditor3);
416 int UtcDaliToolkitTextEditorDownCastN(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
420 BaseHandle uninitializedObject;
421 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
422 DALI_TEST_CHECK(!textEditor1);
424 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
425 DALI_TEST_CHECK(!textEditor2);
429 int UtcDaliToolkitTextEditorCopyConstructorP(void)
431 ToolkitTestApplication application;
432 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
433 TextEditor textEditor = TextEditor::New();
434 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
436 TextEditor copy(textEditor);
437 DALI_TEST_CHECK(copy);
438 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
442 int UtcDaliTextEditorMoveConstructor(void)
444 ToolkitTestApplication application;
446 TextEditor textEditor = TextEditor::New();
447 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
448 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
450 TextEditor moved = std::move(textEditor);
451 DALI_TEST_CHECK(moved);
452 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
453 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
454 DALI_TEST_CHECK(!textEditor);
459 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
463 TextEditor textEditor = TextEditor::New();
464 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
466 TextEditor copy = textEditor;
467 DALI_TEST_CHECK(copy);
468 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
472 int UtcDaliTextEditorMoveAssignment(void)
474 ToolkitTestApplication application;
476 TextEditor textEditor = TextEditor::New();
477 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
478 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
481 moved = std::move(textEditor);
482 DALI_TEST_CHECK(moved);
483 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
484 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
485 DALI_TEST_CHECK(!textEditor);
490 int UtcDaliTextEditorNewP(void)
492 ToolkitTestApplication application;
493 tet_infoline(" UtcDaliToolkitTextEditorNewP");
494 TextEditor textEditor = TextEditor::New();
495 DALI_TEST_CHECK(textEditor);
499 // Positive test case for a method
500 int UtcDaliTextEditorGetPropertyP(void)
502 ToolkitTestApplication application;
503 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
504 TextEditor editor = TextEditor::New();
505 DALI_TEST_CHECK(editor);
507 // Check Property Indices are correct
508 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
509 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
510 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
511 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
512 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
513 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
514 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
515 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
516 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
517 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
518 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
519 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
520 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
521 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
522 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
523 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
524 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
525 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
526 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
527 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
528 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
529 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
530 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
531 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
532 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
533 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
534 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
535 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
536 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
537 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
539 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
540 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
541 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
542 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
543 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
544 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
545 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
546 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
547 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
548 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
549 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
550 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
551 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
552 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
553 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
554 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
555 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
556 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
557 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
558 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
559 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
560 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
561 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
562 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
563 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
564 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
565 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
566 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
567 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
568 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
569 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
570 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
571 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
572 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
578 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
581 Property::Map imageMap;
582 imageMap[mapKey] = mapValue;
584 editor.SetProperty(property, imageMap);
585 Property::Value propValue = editor.GetProperty(property);
586 Property::Map* resultMap = propValue.GetMap();
588 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
596 // Positive test case for a method
597 int UtcDaliTextEditorSetPropertyP(void)
599 ToolkitTestApplication application;
600 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
601 TextEditor editor = TextEditor::New();
602 DALI_TEST_CHECK(editor);
603 application.GetScene().Add(editor);
605 // Note - we can't check the defaults since the stylesheets are platform-specific
607 // Check the render backend property.
608 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
609 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
611 // Check text property.
612 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
613 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
615 // Check text's color property
616 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
617 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
619 // Check font properties.
620 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
621 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
623 Property::Map fontStyleMapSet;
624 Property::Map fontStyleMapGet;
625 Property::Value* slantValue = NULL;
627 fontStyleMapSet.Insert("weight", "bold");
628 fontStyleMapSet.Insert("width", "condensed");
629 fontStyleMapSet.Insert("slant", "italic");
631 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
632 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
633 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
634 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
636 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
637 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
639 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
640 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
641 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
643 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
644 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
645 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
648 fontStyleMapSet.Clear();
649 fontStyleMapSet.Insert("weight", "normal");
650 fontStyleMapSet.Insert("slant", "oblique");
651 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
652 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
653 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
654 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
656 fontStyleMapSet.Clear();
657 fontStyleMapSet.Insert("slant", "roman");
658 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
659 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
661 // Replace 'roman' for 'normal'.
662 slantValue = fontStyleMapGet.Find("slant");
663 if(NULL != slantValue)
665 if("normal" == slantValue->Get<std::string>())
667 fontStyleMapGet["slant"] = "roman";
670 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
671 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
673 fontStyleMapSet.Clear();
675 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
676 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
677 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
678 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
680 // Check that the Alignment properties can be correctly set
681 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
682 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
684 // Check scroll properties.
685 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
686 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
687 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
688 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
690 // Check cursor properties
691 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
692 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
693 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
694 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
696 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
697 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
698 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
699 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
700 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
701 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
702 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
703 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
705 // Check handle images
706 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
707 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
708 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
709 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
710 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
712 // Check handle images
713 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
714 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
715 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
716 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
717 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
718 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
720 // Check the highlight color
721 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
722 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
724 // Decoration bounding box
725 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
726 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
728 // Check the enable markup property.
729 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
730 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
731 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
733 // Check input color property.
734 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
735 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
737 // Check input font properties.
738 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
739 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
741 fontStyleMapSet.Clear();
742 fontStyleMapSet.Insert("weight", "bold");
743 fontStyleMapSet.Insert("width", "condensed");
744 fontStyleMapSet.Insert("slant", "italic");
746 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
747 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
748 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
749 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
751 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
752 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
754 // Reset input font style.
755 fontStyleMapSet.Clear();
756 fontStyleMapSet.Insert("weight", "normal");
757 fontStyleMapSet.Insert("slant", "oblique");
759 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
760 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
761 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
762 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
764 fontStyleMapSet.Clear();
765 fontStyleMapSet.Insert("slant", "roman");
767 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
768 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
770 // Replace 'roman' for 'normal'.
771 slantValue = fontStyleMapGet.Find("slant");
772 if(NULL != slantValue)
774 if("normal" == slantValue->Get<std::string>())
776 fontStyleMapGet["slant"] = "roman";
779 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
780 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
782 fontStyleMapSet.Clear();
784 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
785 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
786 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
787 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
789 // Check the line spacing property
790 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
791 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
792 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
794 // Check the input line spacing property
795 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
796 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
797 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
799 // Check the underline property
801 Property::Map underlineMapSet;
802 Property::Map underlineMapGet;
804 underlineMapSet.Insert("enable", true);
805 underlineMapSet.Insert("color", Color::RED);
806 underlineMapSet.Insert("height", 1);
807 underlineMapSet.Insert("type", Text::Underline::SOLID);
808 underlineMapSet.Insert("dashWidth", 5);
809 underlineMapSet.Insert("dashGap", 3);
811 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
813 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
814 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
815 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
817 application.SendNotification();
818 application.Render();
820 // Check the dashed underline property
822 underlineMapSet.Clear();
823 underlineMapGet.Clear();
825 underlineMapSet.Insert("enable", true);
826 underlineMapSet.Insert("color", Color::RED);
827 underlineMapSet.Insert("height", 1);
828 underlineMapSet.Insert("type", Text::Underline::DASHED);
829 underlineMapSet.Insert("dashWidth", 5);
830 underlineMapSet.Insert("dashGap", 3);
832 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
834 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
835 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
836 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
838 application.SendNotification();
839 application.Render();
841 underlineMapSet.Clear();
842 underlineMapGet.Clear();
844 // Check the double underline property
846 underlineMapSet.Clear();
847 underlineMapGet.Clear();
849 underlineMapSet.Insert("enable", true);
850 underlineMapSet.Insert("color", Color::RED);
851 underlineMapSet.Insert("height", 1);
852 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
853 underlineMapSet.Insert("dashWidth", 5);
854 underlineMapSet.Insert("dashGap", 3);
856 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
858 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
859 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
860 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
862 application.SendNotification();
863 application.Render();
865 underlineMapSet.Clear();
866 underlineMapGet.Clear();
868 // Check the input underline property
869 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
870 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
872 // Check the shadow property
873 Property::Map shadowMapSet;
874 Property::Map shadowMapGet;
876 shadowMapSet.Insert("color", Color::GREEN);
877 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
878 shadowMapSet.Insert("blurRadius", 3.0f);
880 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
882 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
883 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
884 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
886 // Check the input shadow property
887 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
888 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
890 // Check the emboss property
891 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
892 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
894 // Check the input emboss property
895 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
896 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
898 // Check the outline property
900 // Test string type first
901 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
902 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
903 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
905 // Then test the property map type
906 Property::Map outlineMapSet;
907 Property::Map outlineMapGet;
909 outlineMapSet["color"] = Color::RED;
910 outlineMapSet["width"] = 2.0f;
912 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
914 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
915 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
916 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
918 // Check the input outline property
919 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
920 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
922 // Check the smooth scroll property
923 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
924 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
925 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
927 // Check the smooth scroll duration property
928 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
929 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
931 // Check the scroll bar property
932 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
933 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
934 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
936 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
937 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
938 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
939 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
941 // Check the pixel size of font
942 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
943 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
945 // Check placeholder text properties.
946 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
947 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
949 // Check placeholder text's color property.
950 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
951 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
953 // Check the enable selection property
954 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
955 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
957 // Check the placeholder property with pixel size
958 Property::Map placeholderPixelSizeMapSet;
959 Property::Map placeholderPixelSizeMapGet;
960 Property::Map placeholderFontstyleMap;
961 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
962 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
963 placeholderPixelSizeMapSet["color"] = Color::BLUE;
964 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
965 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
967 placeholderFontstyleMap.Insert("weight", "bold");
968 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
969 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
971 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
972 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
974 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
975 Property::Map placeholderConversionMap;
976 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
977 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
978 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
979 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
980 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
981 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
983 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
985 // Check the placeholder property with point size
986 Property::Map placeholderMapSet;
987 Property::Map placeholderMapGet;
988 placeholderMapSet["text"] = "Setting Placeholder Text";
989 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
990 placeholderMapSet["color"] = Color::RED;
991 placeholderMapSet["fontFamily"] = "Arial";
992 placeholderMapSet["pointSize"] = 12.0f;
993 // Check the placeholder font style property
994 placeholderFontstyleMap.Clear();
996 placeholderFontstyleMap.Insert("weight", "bold");
997 placeholderFontstyleMap.Insert("width", "condensed");
998 placeholderFontstyleMap.Insert("slant", "italic");
999 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1000 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1002 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1003 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1005 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1006 placeholderConversionMap.Clear();
1007 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1008 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1009 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1010 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1011 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1012 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1013 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1015 // Reset font style.
1016 placeholderFontstyleMap.Clear();
1017 placeholderFontstyleMap.Insert("weight", "normal");
1018 placeholderFontstyleMap.Insert("slant", "oblique");
1019 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1020 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1022 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1023 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1024 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1025 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1027 placeholderFontstyleMap.Clear();
1028 placeholderFontstyleMap.Insert("slant", "roman");
1029 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1030 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1032 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1034 placeholderFontstyleMap.Clear();
1035 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1037 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1038 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1039 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1040 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1041 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1043 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1044 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1046 // Check handle color
1047 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1048 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1050 // Test the ENABLE_GRAB_HANDLE_POPUP property
1051 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1052 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1054 // Check the input method setting
1055 Property::Map propertyMap;
1056 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1057 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1058 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1059 int inputVariation = 1;
1060 propertyMap["PANEL_LAYOUT"] = panelLayout;
1061 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1062 propertyMap["BUTTON_ACTION"] = buttonAction;
1063 propertyMap["VARIATION"] = inputVariation;
1064 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1066 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1068 DALI_TEST_CHECK(value.Get(map));
1071 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1072 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1075 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1076 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1079 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1080 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1083 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1084 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1086 // Check the input filter property
1087 Property::Map inputFilterMapSet;
1088 Property::Map inputFilterMapGet;
1089 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1090 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1092 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1094 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1095 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1098 inputFilterMapSet.Clear();
1099 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1101 // Check the strikethrough property
1103 Property::Map strikethroughMapSet;
1104 Property::Map strikethroughMapGet;
1106 application.SendNotification();
1107 application.Render();
1109 // Check the input strikethrough property
1111 strikethroughMapSet.Clear();
1112 strikethroughMapGet.Clear();
1113 strikethroughMapSet.Insert("enable", true);
1114 strikethroughMapSet.Insert("color", Color::BLUE);
1115 strikethroughMapSet.Insert("height", 2.0f);
1117 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1119 application.SendNotification();
1120 application.Render();
1122 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1124 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1125 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1127 // Check the input strikethrough property
1128 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1129 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1131 application.SendNotification();
1132 application.Render();
1134 // Check the line size property
1135 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1136 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1137 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1142 // Positive Atlas Text Renderer test
1143 int utcDaliTextEditorAtlasRenderP(void)
1145 ToolkitTestApplication application;
1146 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1147 StyleManager styleManager = StyleManager::Get();
1148 styleManager.ApplyDefaultTheme();
1149 TextEditor editor = TextEditor::New();
1150 DALI_TEST_CHECK(editor);
1152 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1154 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1156 application.GetScene().Add(editor);
1160 // Render some text with the shared atlas backend
1161 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1162 application.SendNotification();
1163 application.Render();
1167 tet_result(TET_FAIL);
1172 // Positive test for the anchorClicked signal.
1173 int utcDaliTextEditorAnchorClickedP(void)
1175 ToolkitTestApplication application;
1176 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1177 TextEditor editor = TextEditor::New();
1178 DALI_TEST_CHECK(editor);
1180 application.GetScene().Add(editor);
1182 // connect to the anchor clicked signal.
1183 ConnectionTracker* testTracker = new ConnectionTracker();
1184 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1185 bool anchorClickedSignal = false;
1186 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1188 gAnchorClickedCallBackCalled = false;
1189 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1190 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1191 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1192 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1193 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1195 application.SendNotification();
1196 application.Render();
1197 editor.SetKeyInputFocus();
1199 // Create a tap event to touch the text editor.
1200 TestGenerateTap(application, 5.0f, 5.0f);
1201 application.SendNotification();
1202 application.Render();
1204 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1205 DALI_TEST_CHECK(anchorClickedSignal);
1207 gAnchorClickedCallBackNotCalled = true;
1208 // Tap the outside of anchor, callback should not be called.
1209 TestGenerateTap(application, 150.f, 100.f);
1210 application.SendNotification();
1211 application.Render();
1213 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1218 // Positive test for the textChanged signal.
1219 int utcDaliTextEditorTextChangedP(void)
1221 ToolkitTestApplication application;
1222 tet_infoline(" utcDaliTextEditorTextChangedP");
1223 TextEditor editor = TextEditor::New();
1224 DALI_TEST_CHECK(editor);
1226 application.GetScene().Add(editor);
1228 // connect to the text changed signal.
1229 ConnectionTracker* testTracker = new ConnectionTracker();
1230 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1231 bool textChangedSignal = false;
1232 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1234 gTextChangedCallBackCalled = false;
1235 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1236 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1237 DALI_TEST_CHECK(textChangedSignal);
1239 application.SendNotification();
1240 editor.SetKeyInputFocus();
1242 gTextChangedCallBackCalled = false;
1243 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1244 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1247 editor.SetProperty(TextField::Property::TEXT, "");
1249 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1250 gTextChangedCallBackCalled = false;
1251 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1252 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1254 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1255 gTextChangedCallBackCalled = false;
1256 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1257 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1262 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1264 ToolkitTestApplication application;
1265 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1266 TextEditor editor = TextEditor::New();
1267 DALI_TEST_CHECK(editor);
1269 application.GetScene().Add(editor);
1271 // connect to the text changed signal.
1272 ConnectionTracker* testTracker = new ConnectionTracker();
1273 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1274 bool textChangedSignal = false;
1275 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1277 // get InputMethodContext
1279 InputMethodContext::EventData imfEvent;
1280 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1282 editor.SetKeyInputFocus();
1283 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1286 gTextChangedCallBackCalled = false;
1287 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1288 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1289 application.SendNotification();
1290 application.Render();
1291 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1292 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1294 gTextChangedCallBackCalled = false;
1295 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1296 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1297 application.SendNotification();
1298 application.Render();
1299 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1300 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1302 gTextChangedCallBackCalled = false;
1303 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1304 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1305 application.SendNotification();
1306 application.Render();
1307 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1308 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1310 gTextChangedCallBackCalled = false;
1311 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1312 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1313 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1315 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1316 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1317 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1319 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1320 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1321 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1323 application.SendNotification();
1324 application.Render();
1325 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1326 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1331 int utcDaliTextEditorInputStyleChanged01(void)
1333 // The text-editor emits signals when the input style changes. These changes of style are
1334 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1335 // can't be emitted during the size negotiation as the callbacks may update the UI.
1336 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1337 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1338 ToolkitTestApplication application;
1339 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1343 char* pathNamePtr = get_current_dir_name();
1344 const std::string pathName(pathNamePtr);
1347 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1348 fontClient.SetDpi(93u, 93u);
1350 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1351 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1353 TextEditor editor = TextEditor::New();
1354 DALI_TEST_CHECK(editor);
1356 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1357 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1358 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1360 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1361 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1363 // connect to the text changed signal.
1364 ConnectionTracker* testTracker = new ConnectionTracker();
1365 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1366 bool inputStyleChangedSignal = false;
1367 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1369 application.GetScene().Add(editor);
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Executes the idle callbacks added by the text control on the change of input style.
1376 application.RunIdles();
1378 gInputStyleChangedCallbackCalled = false;
1379 gInputStyleMask = TextEditor::InputStyle::NONE;
1380 inputStyleChangedSignal = false;
1382 // Create a tap event to touch the text editor.
1383 TestGenerateTap(application, 18.0f, 25.0f);
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Executes the idle callbacks added by the text control on the change of input style.
1390 application.RunIdles();
1392 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1393 if(gInputStyleChangedCallbackCalled)
1395 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1397 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1398 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1400 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1401 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1403 DALI_TEST_CHECK(inputStyleChangedSignal);
1405 gInputStyleChangedCallbackCalled = false;
1406 gInputStyleMask = TextEditor::InputStyle::NONE;
1407 inputStyleChangedSignal = false;
1409 // Create a tap event to touch the text editor.
1410 TestGenerateTap(application, 30.0f, 25.0f);
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Executes the idle callbacks added by the text control on the change of input style.
1417 application.RunIdles();
1419 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1420 DALI_TEST_CHECK(!inputStyleChangedSignal);
1422 gInputStyleChangedCallbackCalled = false;
1423 gInputStyleMask = TextEditor::InputStyle::NONE;
1424 inputStyleChangedSignal = false;
1426 // Create a tap event to touch the text editor.
1427 TestGenerateTap(application, 43.0f, 25.0f);
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Executes the idle callbacks added by the text control on the change of input style.
1434 application.RunIdles();
1436 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1437 if(gInputStyleChangedCallbackCalled)
1439 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1441 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1442 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1444 DALI_TEST_CHECK(inputStyleChangedSignal);
1446 gInputStyleChangedCallbackCalled = false;
1447 gInputStyleMask = TextEditor::InputStyle::NONE;
1448 inputStyleChangedSignal = false;
1450 // Create a tap event to touch the text editor.
1451 TestGenerateTap(application, 88.0f, 25.0f);
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 // Executes the idle callbacks added by the text control on the change of input style.
1458 application.RunIdles();
1460 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1461 if(gInputStyleChangedCallbackCalled)
1463 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1465 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1466 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1468 Property::Map fontStyleMapSet;
1469 Property::Map fontStyleMapGet;
1471 fontStyleMapSet.Insert("weight", "bold");
1473 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1474 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1475 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1477 DALI_TEST_CHECK(inputStyleChangedSignal);
1479 gInputStyleChangedCallbackCalled = false;
1480 gInputStyleMask = TextEditor::InputStyle::NONE;
1481 inputStyleChangedSignal = false;
1483 // Create a tap event to touch the text editor.
1484 TestGenerateTap(application, 115.0f, 25.0f);
1486 // Render and notify
1487 application.SendNotification();
1488 application.Render();
1490 // Executes the idle callbacks added by the text control on the change of input style.
1491 application.RunIdles();
1493 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1494 DALI_TEST_CHECK(!inputStyleChangedSignal);
1496 gInputStyleChangedCallbackCalled = false;
1497 gInputStyleMask = TextEditor::InputStyle::NONE;
1498 inputStyleChangedSignal = false;
1500 // Create a tap event to touch the text editor.
1501 TestGenerateTap(application, 164.0f, 25.0f);
1503 // Render and notify
1504 application.SendNotification();
1505 application.Render();
1507 // Executes the idle callbacks added by the text control on the change of input style.
1508 application.RunIdles();
1510 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1511 if(gInputStyleChangedCallbackCalled)
1513 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1515 Property::Map fontStyleMapSet;
1516 Property::Map fontStyleMapGet;
1518 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1519 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1520 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1522 DALI_TEST_CHECK(inputStyleChangedSignal);
1524 gInputStyleChangedCallbackCalled = false;
1525 gInputStyleMask = TextEditor::InputStyle::NONE;
1526 inputStyleChangedSignal = false;
1528 // Create a tap event to touch the text editor.
1529 TestGenerateTap(application, 191.0f, 25.0f);
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Executes the idle callbacks added by the text control on the change of input style.
1536 application.RunIdles();
1538 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1539 DALI_TEST_CHECK(!inputStyleChangedSignal);
1544 int utcDaliTextEditorInputStyleChanged02(void)
1546 // The text-editor emits signals when the input style changes. These changes of style are
1547 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1548 // can't be emitted during the size negotiation as the callbacks may update the UI.
1549 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1550 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1551 ToolkitTestApplication application;
1552 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1556 char* pathNamePtr = get_current_dir_name();
1557 const std::string pathName(pathNamePtr);
1560 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1561 fontClient.SetDpi(93u, 93u);
1563 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1564 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1566 TextEditor editor = TextEditor::New();
1567 DALI_TEST_CHECK(editor);
1569 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1570 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1571 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1573 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1574 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>");
1576 // connect to the text changed signal.
1577 ConnectionTracker* testTracker = new ConnectionTracker();
1578 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1579 bool inputStyleChangedSignal = false;
1580 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1582 application.GetScene().Add(editor);
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Executes the idle callbacks added by the text control on the change of input style.
1589 application.RunIdles();
1591 gInputStyleChangedCallbackCalled = false;
1592 gInputStyleMask = TextEditor::InputStyle::NONE;
1593 inputStyleChangedSignal = false;
1595 // Create a tap event to touch the text editor.
1596 TestGenerateTap(application, 53.0f, 25.0f, 100);
1597 TestGenerateTap(application, 53.0f, 25.0f, 200);
1599 // Render and notify
1600 application.SendNotification();
1601 application.Render();
1603 // Executes the idle callbacks added by the text control on the change of input style.
1604 application.RunIdles();
1606 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1607 if(gInputStyleChangedCallbackCalled)
1609 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1610 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1611 TextEditor::InputStyle::POINT_SIZE |
1612 TextEditor::InputStyle::COLOR),
1615 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1616 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1618 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1619 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1621 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1622 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1624 DALI_TEST_CHECK(inputStyleChangedSignal);
1626 gInputStyleChangedCallbackCalled = false;
1627 gInputStyleMask = TextEditor::InputStyle::NONE;
1628 inputStyleChangedSignal = false;
1630 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Executes the idle callbacks added by the text control on the change of input style.
1637 application.RunIdles();
1639 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1640 if(gInputStyleChangedCallbackCalled)
1642 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1643 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1646 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1647 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1649 DALI_TEST_CHECK(inputStyleChangedSignal);
1651 gInputStyleChangedCallbackCalled = false;
1652 gInputStyleMask = TextEditor::InputStyle::NONE;
1653 inputStyleChangedSignal = false;
1655 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 // Executes the idle callbacks added by the text control on the change of input style.
1662 application.RunIdles();
1664 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1665 DALI_TEST_CHECK(!inputStyleChangedSignal);
1667 gInputStyleChangedCallbackCalled = false;
1668 gInputStyleMask = TextEditor::InputStyle::NONE;
1669 inputStyleChangedSignal = false;
1671 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Executes the idle callbacks added by the text control on the change of input style.
1678 application.RunIdles();
1680 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1681 if(gInputStyleChangedCallbackCalled)
1683 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1684 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1687 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1688 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1690 DALI_TEST_CHECK(inputStyleChangedSignal);
1692 gInputStyleChangedCallbackCalled = false;
1693 gInputStyleMask = TextEditor::InputStyle::NONE;
1694 inputStyleChangedSignal = false;
1696 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1698 Property::Map fontStyleMapSet;
1699 fontStyleMapSet.Insert("weight", "thin");
1700 fontStyleMapSet.Insert("width", "condensed");
1701 fontStyleMapSet.Insert("slant", "italic");
1703 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1704 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1705 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1707 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1708 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1709 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1710 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1711 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1713 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Executes the idle callbacks added by the text control on the change of input style.
1720 application.RunIdles();
1722 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1723 DALI_TEST_CHECK(!inputStyleChangedSignal);
1725 // Create a tap event to touch the text editor.
1726 TestGenerateTap(application, 63.0f, 25.0f, 900);
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Executes the idle callbacks added by the text control on the change of input style.
1733 application.RunIdles();
1735 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1736 if(gInputStyleChangedCallbackCalled)
1738 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1739 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1740 TextEditor::InputStyle::POINT_SIZE |
1741 TextEditor::InputStyle::FONT_STYLE |
1742 TextEditor::InputStyle::LINE_SPACING |
1743 TextEditor::InputStyle::UNDERLINE |
1744 TextEditor::InputStyle::SHADOW |
1745 TextEditor::InputStyle::EMBOSS |
1746 TextEditor::InputStyle::OUTLINE),
1749 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1750 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1752 DALI_TEST_CHECK(inputStyleChangedSignal);
1754 gInputStyleChangedCallbackCalled = false;
1755 gInputStyleMask = TextEditor::InputStyle::NONE;
1756 inputStyleChangedSignal = false;
1758 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1760 fontStyleMapSet.Clear();
1761 fontStyleMapSet.Insert("weight", "black");
1762 fontStyleMapSet.Insert("width", "expanded");
1763 fontStyleMapSet.Insert("slant", "oblique");
1765 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1767 // Create a tap event to touch the text editor.
1768 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // Executes the idle callbacks added by the text control on the change of input style.
1775 application.RunIdles();
1777 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1778 if(gInputStyleChangedCallbackCalled)
1780 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1781 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1782 TextEditor::InputStyle::POINT_SIZE |
1783 TextEditor::InputStyle::FONT_STYLE),
1786 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1787 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1789 DALI_TEST_CHECK(inputStyleChangedSignal);
1794 int utcDaliTextEditorEvent01(void)
1796 ToolkitTestApplication application;
1797 tet_infoline(" utcDaliTextEditorEvent01");
1799 // Creates a tap event. After creating a tap event the text editor should
1800 // have the focus and add text with key events should be possible.
1802 TextEditor editor = TextEditor::New();
1803 DALI_TEST_CHECK(editor);
1805 application.GetScene().Add(editor);
1807 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1808 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1809 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1811 // Avoid a crash when core load gl resources.
1812 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Add a key event but as the text editor has not the focus it should do nothing.
1819 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1827 // Create a tap event to touch the text editor.
1828 TestGenerateTap(application, 150.0f, 25.0f);
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 // Now the text editor has the focus, so it can handle the key events.
1835 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1836 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1844 // Create a second text editor and send key events to it.
1845 TextEditor editor2 = TextEditor::New();
1847 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1848 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1849 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1850 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1852 application.GetScene().Add(editor2);
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 // Create a tap event on the second text editor.
1859 TestGenerateTap(application, 150.0f, 125.0f);
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 // The second text editor has the focus. It should handle the key events.
1866 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1867 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Check the text has been added to the second text editor.
1874 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1879 int utcDaliTextEditorEvent02(void)
1881 ToolkitTestApplication application;
1882 tet_infoline(" utcDaliTextEditorEvent02");
1884 // Checks if the right number of actors are created.
1886 TextEditor editor = TextEditor::New();
1887 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
1888 DALI_TEST_CHECK(editor);
1890 application.GetScene().Add(editor);
1892 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1893 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1894 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1896 // Avoid a crash when core load gl resources.
1897 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 // Check there are the expected number of children (the stencil).
1904 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
1906 Actor stencil = editor.GetChildAt(0u);
1908 // Create a tap event to touch the text editor.
1909 TestGenerateTap(application, 150.0f, 25.0f, 100);
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 Actor layer = editor.GetChildAt(1u);
1916 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1917 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
1919 // Now the text editor has the focus, so it can handle the key events.
1920 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1921 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Checks the cursor and the renderer have been created.
1928 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
1929 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION); // The renderer
1931 Control cursor = Control::DownCast(layer.GetChildAt(0u));
1932 DALI_TEST_CHECK(cursor);
1934 // The stencil actor has a container with all the actors which contain the text renderers.
1935 Actor container = stencil.GetChildAt(0u);
1936 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
1938 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
1939 DALI_TEST_CHECK(renderer);
1942 // Move the cursor and check the position changes.
1943 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1945 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1946 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1954 DALI_TEST_CHECK(position2.x < position1.x);
1956 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1957 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1965 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
1967 // Send some taps and check the cursor positions.
1969 // Try to tap at the beginning.
1970 TestGenerateTap(application, 1.0f, 25.0f, 700);
1972 // Render and notify
1973 application.SendNotification();
1974 application.Render();
1976 // Cursor position should be the same than position1.
1977 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1979 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
1981 // Tap away from the start position.
1982 TestGenerateTap(application, 16.0f, 25.0f, 1400);
1984 // Render and notify
1985 application.SendNotification();
1986 application.Render();
1988 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1990 DALI_TEST_CHECK(position5.x > position4.x);
1992 // Remove all the text.
1993 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1994 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1995 editor.SetProperty(TextEditor::Property::TEXT, "");
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2001 // Cursor position should be the same than position2.
2002 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2004 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2006 // Should not be a renderer.
2007 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2012 int utcDaliTextEditorEvent03(void)
2014 ToolkitTestApplication application;
2015 tet_infoline(" utcDaliTextEditorEvent03");
2017 // Checks if the highlight actor is created.
2019 TextEditor editor = TextEditor::New();
2020 DALI_TEST_CHECK(editor);
2022 application.GetScene().Add(editor);
2024 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2025 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2026 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2027 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2028 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2030 // Avoid a crash when core load gl resources.
2031 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 // Send some taps and check text controller with clipboard window
2038 Dali::Clipboard clipboard = Clipboard::Get();
2039 clipboard.ShowClipboard();
2040 TestGenerateTap(application, 3.0f, 25.0f, 100);
2041 clipboard.HideClipboard();
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2047 // Tap first to get the focus.
2048 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 // Double tap to select a word.
2055 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 // The stencil actor should have two actors: the renderer and the highlight actor.
2062 Actor stencil = editor.GetChildAt(0u);
2064 // Highlight needs to be drawn before text, so should come first in child order
2065 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2066 DALI_TEST_CHECK(highlight);
2068 // The stencil actor has a container with all the actors which contain the text renderers.
2069 Actor container = stencil.GetChildAt(1u);
2070 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2072 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2073 DALI_TEST_CHECK(renderer);
2076 // Double tap out of bounds
2077 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2078 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // The stencil actor should have one actors: the renderer actor.
2085 stencil = editor.GetChildAt(0u);
2087 // The stencil actor has a container with all the actors which contain the text renderers.
2088 container = stencil.GetChildAt(0u);
2089 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2091 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2092 DALI_TEST_CHECK(renderer);
2096 TestGenerateLongPress(application, 1.0f, 25.0f);
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2103 TestGenerateMiniPan(application);
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2112 int utcDaliTextEditorEvent04(void)
2114 ToolkitTestApplication application;
2115 tet_infoline(" utcDaliTextEditorEvent04");
2117 // Checks if the highlight actor is created.
2119 TextEditor editor = TextEditor::New();
2120 DALI_TEST_CHECK(editor);
2122 application.GetScene().Add(editor);
2124 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2125 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2126 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2127 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2128 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2130 // Avoid a crash when core load gl resources.
2131 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2133 // Render and notify
2134 application.SendNotification();
2135 application.Render();
2137 // Tap on the text editor
2138 TestGenerateTap(application, 3.0f, 25.0f);
2140 // Render and notify
2141 application.SendNotification();
2142 application.Render();
2144 // Move at the end of the text.
2145 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2146 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 for(unsigned int index = 0u; index < 10u; ++index)
2154 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2155 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2157 // Render and notify
2158 application.SendNotification();
2159 application.Render();
2163 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2165 // Render and notify
2166 application.SendNotification();
2167 application.Render();
2169 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2171 // Add some key events
2172 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2173 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 for(unsigned int index = 0u; index < 10u; ++index)
2181 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2182 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2190 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2201 int utcDaliTextEditorEvent05(void)
2203 ToolkitTestApplication application;
2204 tet_infoline(" utcDaliTextEditorEvent05");
2206 // Checks if the highlight actor is created.
2208 TextEditor editor = TextEditor::New();
2209 DALI_TEST_CHECK(editor);
2211 application.GetScene().Add(editor);
2213 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2214 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2215 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2216 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2217 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2218 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2219 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2220 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2221 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2222 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2224 // Avoid a crash when core load gl resources.
2225 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 // Tap on the text editor
2232 TestGenerateTap(application, 3.0f, 25.0f);
2234 // Render and notify
2235 application.SendNotification();
2236 application.Render();
2238 // Move at the end of the text.
2239 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2240 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 for(unsigned int index = 0u; index < 10u; ++index)
2249 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // Modify duration after scroll is enabled
2256 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2258 // Continuous scroll left to increase coverage
2259 for(unsigned int index = 0u; index < 10u; ++index)
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();
2267 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2268 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2269 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2270 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2271 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2273 // Press Escape to increase coverage
2274 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2275 application.SendNotification();
2276 application.Render();
2278 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2283 int utcDaliTextEditorEvent06(void)
2285 ToolkitTestApplication application;
2286 tet_infoline(" utcDaliTextEditorEvent06");
2288 // Checks if the highlight actor is created.
2290 TextEditor editor = TextEditor::New();
2291 DALI_TEST_CHECK(editor);
2293 application.GetScene().Add(editor);
2295 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2296 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2297 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2298 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2299 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2301 // Avoid a crash when core load gl resources.
2302 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2304 // Render and notify
2305 application.SendNotification();
2306 application.Render();
2308 // Tap on the text editor
2309 TestGenerateTap(application, 3.0f, 25.0f);
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // Move to seconds line of the text.
2316 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 float layoutHeight = editor.GetHeightForWidth(100.f);
2324 // Add another script characters ( glyph height is defferent )
2325 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2326 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2328 // Delete characters
2329 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2330 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2332 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2338 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2341 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2342 application.SendNotification();
2343 application.Render();
2345 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2346 application.SendNotification();
2347 application.Render();
2349 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2350 application.SendNotification();
2351 application.Render();
2353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2354 application.SendNotification();
2355 application.Render();
2357 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2358 application.SendNotification();
2359 application.Render();
2361 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2362 application.SendNotification();
2363 application.Render();
2365 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2366 application.SendNotification();
2367 application.Render();
2372 int utcDaliTextEditorEvent07(void)
2374 ToolkitTestApplication application;
2375 tet_infoline(" utcDaliTextEditorEvent07");
2377 // Checks if the highlight actor is created.
2379 TextEditor editor = TextEditor::New();
2380 DALI_TEST_CHECK(editor);
2382 application.GetScene().Add(editor);
2384 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2385 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2386 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2387 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2388 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2390 // Avoid a crash when core load gl resources.
2391 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Tap on the text editor
2398 TestGenerateTap(application, 3.0f, 25.0f);
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 // Move to second line of the text.
2405 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Select some text in the right of the current cursor position
2412 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2414 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2415 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Cut the selected text
2422 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2423 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));
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2431 // Select some text in the left of the current cursor position
2432 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2433 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2434 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2435 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Copy the selected text
2442 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2443 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));
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Move the cursor to the third line
2450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Paste the selected text at the current cursor position
2458 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459 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));
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2467 // Disable Shift Selection
2468 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2470 // Test to select some text in the right of the current cursor position
2471 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2472 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2473 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2474 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 // Cut the selected text
2481 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2482 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));
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2488 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2489 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2491 // Test to select some text in the left of the current cursor position
2492 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2493 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2494 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2495 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2497 // Render and notify
2498 application.SendNotification();
2499 application.Render();
2501 // Copy the selected text
2502 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2503 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));
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2510 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2513 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));
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // replace text with "c"
2520 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2527 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2530 DevelTextEditor::SelectWholeText(editor);
2532 // Render and notify
2533 application.SendNotification();
2534 application.Render();
2536 // Copy the selected text using logical keys
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("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2545 DevelTextEditor::SelectNone(editor);
2547 // Render and notify
2548 application.SendNotification();
2549 application.Render();
2551 // Paste the selected using logical keys
2552 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2553 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2556 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2558 // select all using logical keys
2559 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2560 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 // cut text using logical keys
2567 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2568 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2570 // Render and notify
2571 application.SendNotification();
2572 application.Render();
2575 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2580 int utcDaliTextEditorEvent08(void)
2582 ToolkitTestApplication application;
2583 tet_infoline(" utcDaliTextEditorEvent08");
2585 // Checks if the highlight actor is released correctly.
2587 TextEditor editor = TextEditor::New();
2588 DALI_TEST_CHECK(editor);
2590 application.GetScene().Add(editor);
2592 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2593 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2594 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2595 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2596 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2598 // Avoid a crash when core load gl resources.
2599 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2601 // Render and notify
2602 application.SendNotification();
2603 application.Render();
2605 // Tap on the text editor
2606 TestGenerateTap(application, 3.0f, 25.0f);
2608 // Render and notify
2609 application.SendNotification();
2610 application.Render();
2612 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2613 // Test to select some text in the left of the current cursor position
2614 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2615 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2616 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2617 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2623 // Test to the left selection handle position and the right selection handle position
2624 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2625 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2626 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2627 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2629 // Render and notify
2630 application.SendNotification();
2631 application.Render();
2633 // Test to select full text in the left of the current cursor position
2634 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2635 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2636 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2637 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2638 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2639 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2641 // Render and notify
2642 application.SendNotification();
2643 application.Render();
2645 // Test to release the current full text selection
2646 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2649 // Render and notify
2650 application.SendNotification();
2651 application.Render();
2653 // Test to move the current cursor position correctly
2654 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2656 // Render and notify
2657 application.SendNotification();
2658 application.Render();
2661 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2669 // Test to select some text in the right of the current cursor position
2670 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2671 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2672 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2674 // Render and notify
2675 application.SendNotification();
2676 application.Render();
2678 // Test the cursor position with right arrow key
2679 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2681 // Render and notify
2682 application.SendNotification();
2683 application.Render();
2686 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2688 // Render and notify
2689 application.SendNotification();
2690 application.Render();
2692 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2694 // Test to select some text in the left of the current cursor position
2695 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2697 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2698 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2699 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2701 // Render and notify
2702 application.SendNotification();
2703 application.Render();
2705 // Test the cursor position with left arrow key
2706 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2708 // Render and notify
2709 application.SendNotification();
2710 application.Render();
2713 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2715 // Render and notify
2716 application.SendNotification();
2717 application.Render();
2719 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2721 // Test to select some text in the right of the current cursor position
2722 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2723 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2724 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2725 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 // Test the cursor position with left arrow key
2732 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2734 // Render and notify
2735 application.SendNotification();
2736 application.Render();
2739 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2741 // Render and notify
2742 application.SendNotification();
2743 application.Render();
2745 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2747 // Test to select some text in the left of the current cursor position
2748 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2749 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2751 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 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("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2776 int utcDaliTextEditorHandles(void)
2778 ToolkitTestApplication application;
2779 tet_infoline(" utcDaliTextEditorHandles");
2781 TextEditor editor = TextEditor::New();
2782 DALI_TEST_CHECK(editor);
2784 application.GetScene().Add(editor);
2786 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2787 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2788 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2789 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2791 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2792 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2793 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2794 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2796 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2797 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2798 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2800 // Avoid a crash when core load gl resources.
2801 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2803 // Render and notify
2804 application.SendNotification();
2805 application.Render();
2807 // Tap first to get the focus.
2808 TestGenerateTap(application, 3.0f, 25.0f, 100);
2810 // Render and notify
2811 application.SendNotification();
2812 application.Render();
2814 // Tap to create the grab handle.
2815 TestGenerateTap(application, 3.0f, 25.0f, 700);
2817 // Render and notify
2818 application.SendNotification();
2819 application.Render();
2821 // Get the active layer where the text's decoration is added.
2822 Actor activeLayer = editor.GetChildAt(1u);
2824 // Get the handle's actor.
2825 Actor handle = activeLayer.GetChildAt(1u);
2826 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 // Touch the grab handle to set it as pressed.
2833 Vector2 touchPos(10.0f, 50.0f);
2834 Dali::Integration::TouchEvent event;
2835 event = Dali::Integration::TouchEvent();
2836 event.AddPoint(GetPointDownInside(touchPos));
2837 application.ProcessEvent(event);
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2843 // Pan the grab handle
2844 uint32_t time = 100;
2845 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2846 TestMovePan(application, Vector2(10.0f, 30.0f), time);
2847 TestEndPan(application, Vector2(10.0f, 50.0f), time);
2848 application.SendNotification();
2849 application.Render();
2851 // Release the grab handle.
2852 event = Dali::Integration::TouchEvent();
2853 event.AddPoint(GetPointUpInside(touchPos));
2854 application.ProcessEvent(event);
2856 // Render and notify
2857 application.SendNotification();
2858 application.Render();
2860 // Tap first to get the focus.
2861 TestGenerateTap(application, 3.0f, 25.0f, 1400);
2863 // Render and notify
2864 application.SendNotification();
2865 application.Render();
2867 // Double tap to select a word and create the selection handles.
2868 TestGenerateTap(application, 3.0f, 25.0f, 1500);
2870 // Render and notify
2871 application.SendNotification();
2872 application.Render();
2874 touchPos = Vector2(10.0f, 50.0f);
2876 // Touch the left selection handle to set it as pressed.
2877 event = Dali::Integration::TouchEvent();
2878 event.AddPoint(GetPointDownInside(touchPos));
2879 application.ProcessEvent(event);
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2885 // Release the left selection handle.
2886 event = Dali::Integration::TouchEvent();
2887 event.AddPoint(GetPointUpInside(touchPos));
2888 application.ProcessEvent(event);
2890 // Render and notify
2891 application.SendNotification();
2892 application.Render();
2897 int utcDaliTextEditorUnderPropertyStringP(void)
2899 ToolkitTestApplication application;
2900 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2901 TextEditor editor = TextEditor::New();
2902 DALI_TEST_CHECK(editor);
2904 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
2906 application.GetScene().Add(editor);
2908 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2909 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
2911 tet_infoline("Set underline settings with a map");
2912 // Check the input underline property
2913 Property::Map underlineMapSet;
2914 Property::Map underlineMapGet;
2915 underlineMapSet.Insert("enable", true);
2916 underlineMapSet.Insert("color", Color::BLUE);
2917 underlineMapSet.Insert("height", 1);
2918 underlineMapSet.Insert("type", Text::Underline::SOLID);
2919 underlineMapSet.Insert("dashWidth", 2);
2920 underlineMapSet.Insert("dashGap", 1);
2922 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2923 editor.SetProperty(TextEditor::Property::TEXT, "text");
2924 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2925 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2926 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2928 application.SendNotification();
2929 application.Render();
2931 underlineMapSet.Clear();
2932 underlineMapGet.Clear();
2934 tet_infoline("Set dashed underline settings with a map");
2935 // Check the input underline property
2936 underlineMapSet.Clear();
2937 underlineMapGet.Clear();
2938 underlineMapSet.Insert("enable", true);
2939 underlineMapSet.Insert("color", Color::BLUE);
2940 underlineMapSet.Insert("height", 1);
2941 underlineMapSet.Insert("type", Text::Underline::DASHED);
2942 underlineMapSet.Insert("dashWidth", 5);
2943 underlineMapSet.Insert("dashGap", 3);
2945 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2946 editor.SetProperty(TextEditor::Property::TEXT, "text");
2947 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2948 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2949 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2951 // Check the input underline property
2952 underlineMapSet.Clear();
2953 underlineMapGet.Clear();
2954 underlineMapSet.Insert("enable", true);
2955 underlineMapSet.Insert("color", Color::BLUE);
2956 underlineMapSet.Insert("height", 1);
2957 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2958 underlineMapSet.Insert("dashWidth", 5);
2959 underlineMapSet.Insert("dashGap", 3);
2961 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2962 editor.SetProperty(TextEditor::Property::TEXT, "text");
2963 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2964 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2965 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2967 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
2968 editor.SetProperty(TextEditor::Property::TEXT, "text");
2969 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
2970 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
2971 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
2973 application.SendNotification();
2974 application.Render();
2976 underlineMapSet.Clear();
2977 underlineMapGet.Clear();
2979 tet_infoline("Set underline settings with a string");
2980 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
2981 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
2984 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
2986 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2987 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
2988 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
2989 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
2991 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
2996 int utcDaliTextEditorStrikethroughPropertyStringP(void)
2998 ToolkitTestApplication application;
2999 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3000 TextEditor editor = TextEditor::New();
3001 DALI_TEST_CHECK(editor);
3003 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3005 application.GetScene().Add(editor);
3007 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3008 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3010 tet_infoline("Set strikethrough settings with a map");
3011 // Check the input strikethrough property
3012 Property::Map strikethroughMapSet;
3013 Property::Map strikethroughMapGet;
3014 strikethroughMapSet.Insert("enable", true);
3015 strikethroughMapSet.Insert("color", Color::BLUE);
3016 strikethroughMapSet.Insert("height", 2.0f);
3018 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3019 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3020 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3021 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3023 tet_infoline("Set strikethrough settings with a string");
3024 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3025 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3028 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3030 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3031 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3032 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3033 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3035 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3040 int utcDaliTextEditorShadowPropertyStringP(void)
3042 ToolkitTestApplication application;
3043 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3045 TextEditor editor = TextEditor::New();
3047 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3049 application.GetScene().Add(editor);
3051 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3053 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3057 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3062 int utcDaliTextEditorFontStylePropertyStringP(void)
3064 ToolkitTestApplication application;
3065 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3067 TextEditor editor = TextEditor::New();
3069 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3071 application.GetScene().Add(editor);
3073 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3075 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3079 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3084 int utcDaliTextEditorGetPropertyLinecountP(void)
3086 ToolkitTestApplication application;
3088 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3092 TextEditor editor = TextEditor::New();
3093 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3094 editor.SetProperty(TextEditor::Property::TEXT,
3095 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3097 application.GetScene().Add(editor);
3099 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3100 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3101 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3103 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3104 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3105 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3110 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3112 ToolkitTestApplication application;
3113 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3115 TextEditor editor = TextEditor::New();
3116 DALI_TEST_CHECK(editor);
3118 application.GetScene().Add(editor);
3120 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3121 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3122 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3123 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3124 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3125 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3127 bool startedCalled = false;
3128 bool finishedCalled = false;
3130 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3131 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3133 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3135 // Render and notify
3136 application.SendNotification();
3137 application.Render();
3139 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3140 application.SendNotification();
3141 application.Render(6000);
3143 application.SendNotification();
3144 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3145 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3150 int UtcDaliToolkitTextEditorTextWrapMode(void)
3152 ToolkitTestApplication application;
3153 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3157 TextEditor editor = TextEditor::New();
3158 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3159 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3161 application.GetScene().Add(editor);
3163 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3164 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3166 application.SendNotification();
3167 application.Render();
3169 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3170 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3172 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3173 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3175 application.SendNotification();
3176 application.Render();
3178 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3179 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3181 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3182 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3184 application.SendNotification();
3185 application.Render();
3187 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3188 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3190 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3191 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3193 application.SendNotification();
3194 application.Render();
3196 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3197 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3202 int UtcDaliTextEditorSetPaddingProperty(void)
3204 ToolkitTestApplication application;
3205 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3207 TextEditor editor = TextEditor::New();
3208 DALI_TEST_CHECK(editor);
3209 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3210 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3211 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3212 application.GetScene().Add(editor);
3214 application.SendNotification();
3215 application.Render();
3217 Vector3 originalSize = editor.GetNaturalSize();
3219 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3221 application.SendNotification();
3222 application.Render();
3224 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3226 Vector3 paddingAddedSize = editor.GetNaturalSize();
3228 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3230 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3235 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3237 ToolkitTestApplication application;
3238 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3240 TextEditor editor = TextEditor::New();
3241 DALI_TEST_CHECK(editor);
3242 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3243 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3244 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3245 application.GetScene().Add(editor);
3247 application.SendNotification();
3248 application.Render();
3250 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3251 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3253 // Check the enable shift selection property
3254 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3255 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3257 application.SendNotification();
3258 application.Render();
3263 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3265 ToolkitTestApplication application;
3266 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3268 TextEditor editor = TextEditor::New();
3269 DALI_TEST_CHECK(editor);
3270 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3271 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3272 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3273 application.GetScene().Add(editor);
3275 application.SendNotification();
3276 application.Render();
3278 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3279 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3281 // Check the enable grab handle property
3282 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3283 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3285 application.SendNotification();
3286 application.Render();
3291 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3293 ToolkitTestApplication application;
3294 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3296 TextEditor editor = TextEditor::New();
3297 DALI_TEST_CHECK(editor);
3298 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3299 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3300 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3301 application.GetScene().Add(editor);
3303 application.SendNotification();
3304 application.Render();
3306 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3307 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3309 // Check the disable match system language direction property
3310 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3311 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3313 application.SendNotification();
3314 application.Render();
3319 int UtcDaliTextEditorGetInputMethodContext(void)
3321 ToolkitTestApplication application;
3322 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3324 TextEditor editor = TextEditor::New();
3325 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3330 int utcDaliTextEditorMaxCharactersReached(void)
3332 ToolkitTestApplication application;
3333 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3335 TextEditor editor = TextEditor::New();
3336 DALI_TEST_CHECK(editor);
3338 application.GetScene().Add(editor);
3340 const int maxNumberOfCharacters = 1;
3341 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3342 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3344 editor.SetKeyInputFocus();
3346 // connect to the text changed signal.
3347 ConnectionTracker* testTracker = new ConnectionTracker();
3348 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3349 bool maxLengthReachedSignal = false;
3350 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3352 gMaxCharactersCallBackCalled = false;
3354 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3355 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3357 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3358 DALI_TEST_CHECK(maxLengthReachedSignal);
3363 int utcDaliTextEditorInputFiltered(void)
3365 ToolkitTestApplication application;
3366 tet_infoline(" utcDaliTextEditorInputFiltered");
3367 TextEditor editor = TextEditor::New();
3368 DALI_TEST_CHECK(editor);
3370 application.GetScene().Add(editor);
3372 Property::Map inputFilter;
3374 // Only digit is accepted.
3375 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3377 // Set input filter to TextEditor.
3378 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3380 editor.SetKeyInputFocus();
3382 // connect to the input filtered signal.
3383 ConnectionTracker* testTracker = new ConnectionTracker();
3384 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3385 bool inputFilteredSignal = false;
3386 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3388 gInputFilteredAcceptedCallbackCalled = false;
3390 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3392 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3393 DALI_TEST_CHECK(inputFilteredSignal);
3395 // Word is rejected.
3396 inputFilter[InputFilter::Property::ACCEPTED] = "";
3397 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3399 // Set input filter to TextEditor.
3400 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3402 editor.SetKeyInputFocus();
3404 inputFilteredSignal = false;
3405 gInputFilteredRejectedCallbackCalled = false;
3407 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3409 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3410 DALI_TEST_CHECK(inputFilteredSignal);
3415 int UtcDaliTextEditorSelectWholeText(void)
3417 ToolkitTestApplication application;
3418 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3420 TextEditor textEditor = TextEditor::New();
3422 application.GetScene().Add(textEditor);
3424 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3425 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3426 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3428 // Avoid a crash when core load gl resources.
3429 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3431 application.SendNotification();
3432 application.Render();
3434 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3436 DevelTextEditor::SelectWholeText(textEditor);
3438 application.SendNotification();
3439 application.Render();
3441 // Nothing should have been selected. The number of children is still 1
3442 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3444 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3446 application.SendNotification();
3447 application.Render();
3449 DevelTextEditor::SelectWholeText(textEditor);
3451 application.SendNotification();
3452 application.Render();
3454 // Should be 2 children, the stencil and the layer
3455 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3457 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3458 Actor stencil = textEditor.GetChildAt(0u);
3460 // The highlight actor is drawn first, so is the first actor in the list
3461 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3462 DALI_TEST_CHECK(highlight);
3467 int UtcDaliTextEditorSelectText(void)
3469 ToolkitTestApplication application;
3470 tet_infoline(" UtcDaliTextEditorSelectText ");
3472 TextEditor textEditor = TextEditor::New();
3474 application.GetScene().Add(textEditor);
3476 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3477 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3478 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3480 // Avoid a crash when core load gl resources.
3481 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3483 application.SendNotification();
3484 application.Render();
3486 DevelTextEditor::SelectText(textEditor, 0, 5);
3488 application.SendNotification();
3489 application.Render();
3491 // Nothing is selected
3492 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3493 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3495 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3497 application.SendNotification();
3498 application.Render();
3500 DevelTextEditor::SelectText(textEditor, 0, 5);
3502 application.SendNotification();
3503 application.Render();
3505 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3506 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3508 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3509 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3511 // world is selected
3512 DevelTextEditor::SelectText(textEditor, 6, 11);
3514 application.SendNotification();
3515 application.Render();
3517 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3518 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3520 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3521 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3526 int UtcDaliTextEditorSelectNone(void)
3528 ToolkitTestApplication application;
3529 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3531 TextEditor textEditor = TextEditor::New();
3533 application.GetScene().Add(textEditor);
3535 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3536 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3537 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3539 // Avoid a crash when core load gl resources.
3540 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3542 application.SendNotification();
3543 application.Render();
3545 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3547 application.SendNotification();
3548 application.Render();
3550 // Nothing is selected
3551 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3552 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3554 DevelTextEditor::SelectWholeText(textEditor);
3556 application.SendNotification();
3557 application.Render();
3559 // whole text is selected
3560 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3561 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3563 DevelTextEditor::SelectNone(textEditor);
3565 application.SendNotification();
3566 application.Render();
3568 // Nothing is selected
3569 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3570 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3575 int UtcDaliTextEditorSelectRange(void)
3577 ToolkitTestApplication application;
3578 tet_infoline("utcDaliTextEditorSelectRange");
3580 TextEditor textEditor = TextEditor::New();
3581 DALI_TEST_CHECK(textEditor);
3583 application.GetScene().Add(textEditor);
3585 // Avoid a crash when core load gl resources.
3586 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3588 application.SendNotification();
3589 application.Render();
3591 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3593 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3594 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3596 // Hello is selected
3597 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3598 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3600 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3601 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3606 int UtcDaliTextEditorEnableEditing(void)
3608 ToolkitTestApplication application;
3609 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3611 TextEditor textEditor = TextEditor::New();
3613 application.GetScene().Add(textEditor);
3615 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3616 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3617 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3619 // Avoid a crash when core load gl resources.
3620 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3622 application.SendNotification();
3623 application.Render();
3625 textEditor.SetKeyInputFocus();
3626 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3627 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3629 // Render and notify
3630 application.SendNotification();
3631 application.Render();
3633 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3634 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3636 textEditor.SetKeyInputFocus();
3637 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3638 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3640 // Render and notify
3641 application.SendNotification();
3642 application.Render();
3644 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3645 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3650 int UtcDaliTextEditorScrolling(void)
3652 ToolkitTestApplication application;
3653 tet_infoline(" UtcDaliTextEditorScrolling ");
3655 TextEditor textEditor = TextEditor::New();
3656 DALI_TEST_CHECK(textEditor);
3658 application.GetScene().Add(textEditor);
3660 // Avoid a crash when core load gl resources.
3661 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3663 application.SendNotification();
3664 application.Render();
3666 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3667 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3668 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3669 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3671 application.SendNotification();
3672 application.Render();
3674 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3675 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3677 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3679 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
3680 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3682 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3684 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
3685 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3687 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
3688 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
3690 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3691 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3696 int UtcDaliToolkitTextEditorFontSizeScale(void)
3698 ToolkitTestApplication application;
3699 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3701 TextEditor textEditor = TextEditor::New();
3702 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
3703 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3704 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3706 TextEditor textEditorScaled = TextEditor::New();
3707 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
3708 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3709 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3710 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3712 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3714 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
3715 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3716 nonScaledSize = textEditor.GetNaturalSize();
3718 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
3719 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3720 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3721 scaledSize = textEditorScaled.GetNaturalSize();
3723 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3728 int UtcDaliTextEditorPrimaryCursorPosition(void)
3730 ToolkitTestApplication application;
3731 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3733 TextEditor textEditor = TextEditor::New();
3735 application.GetScene().Add(textEditor);
3737 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
3738 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3739 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3740 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3742 // Avoid a crash when core load gl resources.
3743 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3745 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3746 application.SendNotification();
3747 application.Render();
3748 textEditor.SetKeyInputFocus();
3750 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3752 // Render and notify
3753 application.SendNotification();
3754 application.Render();
3756 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3757 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3762 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3764 ToolkitTestApplication application;
3765 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3767 TextEditor textEditor = TextEditor::New();
3768 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3769 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3770 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3771 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3772 application.GetScene().Add(textEditor);
3774 application.SendNotification();
3775 application.Render();
3778 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3779 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3781 textEditor.GetNaturalSize();
3783 // Create a tap event to touch the text editor.
3784 TestGenerateTap(application, 18.0f, 25.0f);
3786 application.SendNotification();
3787 application.Render();
3789 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3790 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3795 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3797 ToolkitTestApplication application;
3799 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3801 int lineCountBefore = 0;
3802 int lineCountAfter = 0;
3804 // Create a text editor
3805 TextEditor textEditor = TextEditor::New();
3806 //Set very large font-size using point-size
3807 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3808 //Specify font-family
3809 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3811 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3812 //Set text longer than width of textEditor
3813 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3815 application.GetScene().Add(textEditor);
3817 application.SendNotification();
3818 application.Render();
3820 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3821 //GetHeightForWidth is a retrieval method which should not modify object
3822 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3823 textEditor.GetHeightForWidth(200.f);
3825 //This is to simulate focus into text editor after calling GetHeightForWidth
3826 //Create a tap event to touch the text editor.
3827 TestGenerateTap(application, 18.0f, 25.0f);
3829 application.SendNotification();
3830 application.Render();
3832 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3834 //The LineCount must not be changed when calling GetHeightForWidth.
3835 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3840 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3842 ToolkitTestApplication application;
3844 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3846 int lineCountBefore = 0;
3847 int lineCountAfter = 0;
3849 // Create a text editor
3850 TextEditor textEditor = TextEditor::New();
3851 //Set very large font-size using point-size
3852 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3853 //Specify font-family
3854 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3856 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3857 //Set text longer than width of textEditor
3858 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3859 //Set line wrap mode Character
3860 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3862 application.GetScene().Add(textEditor);
3864 application.SendNotification();
3865 application.Render();
3867 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3868 //GetHeightForWidth is a retrieval method which should not modify object
3869 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3870 textEditor.GetHeightForWidth(200.f);
3872 //This is to simulate focus into text editor after calling GetHeightForWidth
3873 //Create a tap event to touch the text editor.
3874 TestGenerateTap(application, 18.0f, 25.0f);
3876 application.SendNotification();
3877 application.Render();
3879 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3881 //The LineCount must not be changed when calling GetHeightForWidth.
3882 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3887 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3889 ToolkitTestApplication application;
3891 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3893 int lineCountBefore = 0;
3894 int lineCountAfter = 0;
3896 // Create a text editor
3897 TextEditor textEditor = TextEditor::New();
3898 //Set very large font-size using point-size
3899 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3900 //Specify font-family
3901 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3903 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
3904 //Set text longer than width of textEditor
3905 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
3906 //Set line wrap mode Character
3907 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3909 application.GetScene().Add(textEditor);
3911 application.SendNotification();
3912 application.Render();
3914 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3916 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3917 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3919 // When the text changed, the Line-count should be updated according to new text.
3920 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3921 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
3922 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
3927 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3929 ToolkitTestApplication application;
3931 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3933 int lineCountBefore = 0;
3934 int lineCountAfter = 0;
3936 // Create a text editor
3937 TextEditor textEditor = TextEditor::New();
3938 //Set very large font-size using point-size
3939 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3940 //Specify font-family
3941 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3943 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3944 //Set text longer than width of textEditor
3945 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3947 application.GetScene().Add(textEditor);
3949 application.SendNotification();
3950 application.Render();
3952 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3953 //GetNaturalSize is a retrieval method which should not modify object
3954 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3955 textEditor.GetNaturalSize();
3957 //This is to simulate focus into text editor after calling GetNaturalSize
3958 //Create a tap event to touch the text editor.
3959 TestGenerateTap(application, 18.0f, 25.0f);
3961 application.SendNotification();
3962 application.Render();
3964 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3966 //The LineCount must not be changed when calling GetNaturalSize.
3967 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3972 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3974 ToolkitTestApplication application;
3976 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3978 int lineCountBefore = 0;
3979 int lineCountAfter = 0;
3981 // Create a text editor
3982 TextEditor textEditor = TextEditor::New();
3983 //Set very large font-size using point-size
3984 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3985 //Specify font-family
3986 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3988 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3989 //Set text longer than width of textEditor
3990 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3991 //Set line wrap mode Character
3992 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3994 application.GetScene().Add(textEditor);
3996 application.SendNotification();
3997 application.Render();
3999 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4000 //GetNaturalSize is a retrieval method which should not modify object
4001 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4002 textEditor.GetNaturalSize();
4004 //This is to simulate focus into text editor after calling GetNaturalSize
4005 //Create a tap event to touch the text editor.
4006 TestGenerateTap(application, 18.0f, 25.0f);
4008 application.SendNotification();
4009 application.Render();
4011 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4013 //The LineCount must not be changed when calling GetNaturalSize.
4014 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4019 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4021 ToolkitTestApplication application;
4022 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4024 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4025 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4026 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4028 // Create a text editor
4029 TextEditor textEditor = TextEditor::New();
4031 //Set size to avoid automatic eliding
4032 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4033 //Set very large font-size using point-size
4034 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4035 //Specify font-family
4036 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4037 //Set text to check if appear or not
4038 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4040 application.GetScene().Add(textEditor);
4042 application.SendNotification();
4043 application.Render();
4044 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4045 Vector3 naturalSize = textEditor.GetNaturalSize();
4047 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4048 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4053 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4055 ToolkitTestApplication application;
4056 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4058 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4059 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4060 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4062 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4063 // Create a text editor
4064 TextEditor textEditor = TextEditor::New();
4065 //Set size to avoid automatic eliding
4066 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4067 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4068 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4070 const int numberOfCases = 6;
4071 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4073 for(int index = 0; index < numberOfCases; index++)
4075 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4076 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4077 application.GetScene().Add(textEditor);
4078 application.SendNotification();
4079 application.Render();
4080 naturalSize = textEditor.GetNaturalSize();
4081 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4082 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4088 int UtcDaliTextEditorHyphenWrapMode(void)
4090 ToolkitTestApplication application;
4091 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4094 TextEditor textEditor = TextEditor::New();
4096 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4098 application.GetScene().Add(textEditor);
4099 application.SendNotification();
4100 application.Render();
4102 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4103 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4104 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4106 application.SendNotification();
4107 application.Render();
4109 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4115 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4117 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4118 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4119 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4121 application.SendNotification();
4122 application.Render();
4124 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4131 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4136 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4138 ToolkitTestApplication application;
4139 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4140 TextEditor textEditor = TextEditor::New();
4142 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4143 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4145 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4146 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4147 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4149 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4150 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4151 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4153 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4154 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4155 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4157 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4158 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4159 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4161 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4162 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4163 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4165 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4166 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4167 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4169 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4170 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4171 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4173 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4174 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4175 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4177 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4178 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4179 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4181 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4182 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4183 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4185 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4186 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4187 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4189 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4190 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4191 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4196 int UtcDaliTextEditorCopyText(void)
4198 ToolkitTestApplication application;
4199 tet_infoline(" UtcDaliTextEditorCopyText ");
4201 TextEditor textEditor = TextEditor::New();
4203 std::string selectedText = "";
4204 std::string copiedText = "";
4206 application.GetScene().Add(textEditor);
4208 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4209 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4210 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4212 // Avoid a crash when core load gl resources.
4213 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4215 application.SendNotification();
4216 application.Render();
4218 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4220 application.SendNotification();
4221 application.Render();
4223 // Hello is selected
4224 DevelTextEditor::SelectText(textEditor, 0, 5);
4226 application.SendNotification();
4227 application.Render();
4229 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4230 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4232 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4233 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4236 copiedText = DevelTextEditor::CopyText(textEditor);
4237 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4239 // world is selected
4240 DevelTextEditor::SelectText(textEditor, 6, 11);
4242 application.SendNotification();
4243 application.Render();
4245 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4246 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4248 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4249 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4252 copiedText = DevelTextEditor::CopyText(textEditor);
4253 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4255 // "lo wo" is selected
4256 DevelTextEditor::SelectText(textEditor, 3, 8);
4258 application.SendNotification();
4259 application.Render();
4261 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4262 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4264 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4265 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4267 // "lo wo" is copied
4268 copiedText = DevelTextEditor::CopyText(textEditor);
4269 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4274 int UtcDaliTextEditorCutText(void)
4276 ToolkitTestApplication application;
4277 tet_infoline(" UtcDaliTextEditorCutText ");
4279 TextEditor textEditor = TextEditor::New();
4281 std::string selectedText = "";
4283 application.GetScene().Add(textEditor);
4285 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4286 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4287 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4289 // Avoid a crash when core load gl resources.
4290 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4292 application.SendNotification();
4293 application.Render();
4295 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4297 application.SendNotification();
4298 application.Render();
4300 // Hello is selected
4301 DevelTextEditor::SelectText(textEditor, 0, 5);
4303 application.SendNotification();
4304 application.Render();
4306 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4307 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4309 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4310 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4313 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4315 application.SendNotification();
4316 application.Render();
4318 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4321 DevelTextEditor::SelectText(textEditor, 0, 2);
4323 application.SendNotification();
4324 application.Render();
4326 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4327 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4329 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4330 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4333 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4335 application.SendNotification();
4336 application.Render();
4338 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4340 // Test Cut from the middle
4343 DevelTextEditor::SelectText(textEditor, 1, 3);
4345 application.SendNotification();
4346 application.Render();
4348 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4349 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4351 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4352 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4355 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4357 application.SendNotification();
4358 application.Render();
4360 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4362 // Test Cut from the end
4365 DevelTextEditor::SelectText(textEditor, 1, 2);
4367 application.SendNotification();
4368 application.Render();
4370 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4371 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4373 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4374 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4377 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4379 application.SendNotification();
4380 application.Render();
4382 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4387 int UtcDaliTextEditorPasteText(void)
4389 ToolkitTestApplication application;
4390 tet_infoline(" UtcDaliTextEditorPasteText ");
4392 TextEditor editor = TextEditor::New();
4393 DALI_TEST_CHECK(editor);
4395 application.GetScene().Add(editor);
4397 std::string cutText = "";
4398 std::string copiedText = "";
4400 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4401 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4402 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4403 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4404 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4406 // Avoid a crash when core load gl resources.
4407 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4409 // Render and notify
4410 application.SendNotification();
4411 application.Render();
4413 // Tap on the text editor
4414 TestGenerateTap(application, 3.0f, 25.0f);
4416 // Render and notify
4417 application.SendNotification();
4418 application.Render();
4420 // Move to second line of the text.
4421 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4423 // Render and notify
4424 application.SendNotification();
4425 application.Render();
4427 // Select some text in the right of the current cursor position
4428 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4429 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4430 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4431 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4433 // Render and notify
4434 application.SendNotification();
4435 application.Render();
4437 // Cut the selected text
4438 cutText = DevelTextEditor::CutText(editor);
4440 // Render and notify
4441 application.SendNotification();
4442 application.Render();
4444 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4445 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4447 // Select some text in the left of the current cursor position
4448 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4449 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4453 // Render and notify
4454 application.SendNotification();
4455 application.Render();
4457 // Copy the selected text
4458 copiedText = DevelTextEditor::CopyText(editor);
4460 // Render and notify
4461 application.SendNotification();
4462 application.Render();
4464 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4465 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4467 // Move the cursor to the third line
4468 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4469 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4471 // Render and notify
4472 application.SendNotification();
4473 application.Render();
4475 // Paste the selected text at the current cursor position
4476 DevelTextEditor::PasteText(editor);
4478 // Render and notify
4479 application.SendNotification();
4480 application.Render();
4482 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4487 int UtcDaliTextEditorLineSpacing(void)
4489 ToolkitTestApplication application;
4490 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4492 TextEditor textEditor = TextEditor::New();
4493 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4494 application.GetScene().Add(textEditor);
4495 application.SendNotification();
4496 application.Render();
4498 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4499 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4501 Vector3 sizeBefore = textEditor.GetNaturalSize();
4503 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4505 //add 20 for each line 20 * 3
4506 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4511 int UtcDaliTextEditorMinLineSize(void)
4513 ToolkitTestApplication application;
4514 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4516 TextEditor textEditor = TextEditor::New();
4517 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4518 application.GetScene().Add(textEditor);
4519 application.SendNotification();
4520 application.Render();
4522 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4523 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4525 Vector3 sizeBefore = textEditor.GetNaturalSize();
4527 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4529 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4532 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4537 int utcDaliTextEditorCursorPositionChangedSignal(void)
4539 ToolkitTestApplication application;
4540 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4542 TextEditor editor = TextEditor::New();
4543 DALI_TEST_CHECK(editor);
4545 application.GetScene().Add(editor);
4547 // connect to the selection changed signal.
4548 ConnectionTracker* testTracker = new ConnectionTracker();
4549 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4550 bool cursorPositionChangedSignal = false;
4551 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4553 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4554 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4555 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4556 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4557 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4559 // Avoid a crash when core load gl resources.
4560 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4562 // Render and notify
4563 application.SendNotification();
4564 application.Render();
4566 editor.SetKeyInputFocus();
4568 // Tap on the text editor
4569 TestGenerateTap(application, 3.0f, 25.0f);
4571 // Render and notify
4572 application.SendNotification();
4573 application.Render();
4575 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4576 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4578 gCursorPositionChangedCallbackCalled = false;
4581 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4583 // Render and notify
4584 application.SendNotification();
4585 application.Render();
4587 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4588 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4590 gCursorPositionChangedCallbackCalled = false;
4593 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4595 // Render and notify
4596 application.SendNotification();
4597 application.Render();
4599 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4600 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4602 gCursorPositionChangedCallbackCalled = false;
4604 //delete one character
4605 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4607 // Render and notify
4608 application.SendNotification();
4609 application.Render();
4611 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4612 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4614 gCursorPositionChangedCallbackCalled = false;
4616 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
4618 // Render and notify
4619 application.SendNotification();
4620 application.Render();
4622 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4623 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4625 gCursorPositionChangedCallbackCalled = false;
4627 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4629 // Render and notify
4630 application.SendNotification();
4631 application.Render();
4633 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4634 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4639 int utcDaliTextEditorGeometryEllipsisStart(void)
4641 ToolkitTestApplication application;
4642 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4644 TextEditor editor = TextEditor::New();
4645 DALI_TEST_CHECK(editor);
4647 application.GetScene().Add(editor);
4649 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4650 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4651 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4652 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4653 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4654 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4655 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4656 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4657 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4659 // Avoid a crash when core load gl resources.
4660 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4662 // Render and notify
4663 application.SendNotification();
4664 application.Render();
4666 unsigned int expectedCount = 2;
4667 unsigned int startIndex = 0;
4668 unsigned int endIndex = 24;
4670 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4671 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4673 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4674 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4676 Vector<Vector2> expectedSizes;
4677 Vector<Vector2> expectedPositions;
4679 expectedPositions.PushBack(Vector2(37, 0));
4680 expectedSizes.PushBack(Vector2(20, 25));
4682 expectedPositions.PushBack(Vector2(-1, 25));
4683 expectedSizes.PushBack(Vector2(52, 25));
4685 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4690 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4692 ToolkitTestApplication application;
4693 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4695 TextEditor editor = TextEditor::New();
4696 DALI_TEST_CHECK(editor);
4698 application.GetScene().Add(editor);
4700 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4701 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4702 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4703 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4704 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4705 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4706 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4707 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4708 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4710 // Avoid a crash when core load gl resources.
4711 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4713 // Render and notify
4714 application.SendNotification();
4715 application.Render();
4717 unsigned int expectedCount = 2;
4718 unsigned int startIndex = 0;
4719 unsigned int endIndex = 24;
4721 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4722 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4724 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4725 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4727 Vector<Vector2> expectedSizes;
4728 Vector<Vector2> expectedPositions;
4730 expectedPositions.PushBack(Vector2(-1, 0));
4731 expectedSizes.PushBack(Vector2(25, 25));
4733 expectedPositions.PushBack(Vector2(-1, 25));
4734 expectedSizes.PushBack(Vector2(52, 25));
4736 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4741 int utcDaliTextEditorGeometryEllipsisEnd(void)
4743 ToolkitTestApplication application;
4744 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4746 TextEditor editor = TextEditor::New();
4747 DALI_TEST_CHECK(editor);
4749 application.GetScene().Add(editor);
4751 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4752 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4753 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4754 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4755 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4756 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4757 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4758 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4759 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4761 // Avoid a crash when core load gl resources.
4762 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4764 // Render and notify
4765 application.SendNotification();
4766 application.Render();
4768 unsigned int expectedCount = 2;
4769 unsigned int startIndex = 0;
4770 unsigned int endIndex = 24;
4772 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4773 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4775 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4776 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4778 Vector<Vector2> expectedSizes;
4779 Vector<Vector2> expectedPositions;
4781 expectedPositions.PushBack(Vector2(-1, 0));
4782 expectedSizes.PushBack(Vector2(59, 25));
4784 expectedPositions.PushBack(Vector2(-1, 25));
4785 expectedSizes.PushBack(Vector2(25, 25));
4787 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4792 int utcDaliTextEditorGeometryRTL(void)
4794 ToolkitTestApplication application;
4795 tet_infoline(" utcDaliTextEditorGeometryRTL");
4797 TextEditor editor = TextEditor::New();
4798 DALI_TEST_CHECK(editor);
4800 application.GetScene().Add(editor);
4802 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4803 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4804 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4805 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4806 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4807 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
4809 // Avoid a crash when core load gl resources.
4810 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4812 // Render and notify
4813 application.SendNotification();
4814 application.Render();
4816 unsigned int expectedCount = 4;
4817 unsigned int startIndex = 3;
4818 unsigned int endIndex = 24;
4820 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4821 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4823 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4824 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4826 Vector<Vector2> expectedSizes;
4827 Vector<Vector2> expectedPositions;
4829 expectedPositions.PushBack(Vector2(24, 0));
4830 expectedSizes.PushBack(Vector2(33, 25));
4832 expectedPositions.PushBack(Vector2(-1, 25));
4833 expectedSizes.PushBack(Vector2(52, 25));
4835 expectedPositions.PushBack(Vector2(-1, 50));
4836 expectedSizes.PushBack(Vector2(59, 25));
4838 expectedPositions.PushBack(Vector2(61, 75));
4839 expectedSizes.PushBack(Vector2(37, 25));
4841 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4846 int utcDaliTextEditorGeometryGlyphMiddle(void)
4848 ToolkitTestApplication application;
4849 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4851 TextEditor editor = TextEditor::New();
4852 DALI_TEST_CHECK(editor);
4854 application.GetScene().Add(editor);
4856 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4857 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4858 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4859 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4860 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4861 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
4863 // Avoid a crash when core load gl resources.
4864 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4866 // Render and notify
4867 application.SendNotification();
4868 application.Render();
4870 unsigned int expectedCount = 1;
4871 unsigned int startIndex = 1;
4872 unsigned int endIndex = 13;
4874 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4875 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4877 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4878 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4880 Vector<Vector2> expectedSizes;
4881 Vector<Vector2> expectedPositions;
4883 expectedPositions.PushBack(Vector2(6, 0));
4884 expectedSizes.PushBack(Vector2(124, 25));
4886 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4891 int utcDaliTextEditorSelectionClearedSignal(void)
4893 ToolkitTestApplication application;
4894 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4896 TextEditor editor = TextEditor::New();
4897 DALI_TEST_CHECK(editor);
4899 application.GetScene().Add(editor);
4901 // connect to the selection changed signal.
4902 ConnectionTracker* testTracker = new ConnectionTracker();
4903 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4904 bool selectionClearedSignal = false;
4905 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4907 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4908 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4909 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4910 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4911 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4913 // Avoid a crash when core load gl resources.
4914 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4916 // Render and notify
4917 application.SendNotification();
4918 application.Render();
4920 // Tap on the text editor
4921 TestGenerateTap(application, 3.0f, 25.0f);
4923 // Render and notify
4924 application.SendNotification();
4925 application.Render();
4927 // Move to second line of the text & Select some text in the right of the current cursor position
4928 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4929 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4932 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4934 // Render and notify
4935 application.SendNotification();
4936 application.Render();
4938 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4940 // Render and notify
4941 application.SendNotification();
4942 application.Render();
4944 // Tap on the text editor
4945 TestGenerateTap(application, 3.0f, 25.0f);
4947 // Render and notify
4948 application.SendNotification();
4949 application.Render();
4951 gSelectionClearedCallbackCalled = false;
4953 // Move to second line of the text & select.
4954 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4955 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4958 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4960 // Render and notify
4961 application.SendNotification();
4962 application.Render();
4964 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4966 gSelectionClearedCallbackCalled = false;
4968 // Render and notify
4969 application.SendNotification();
4970 application.Render();
4972 // Move to second line of the text & select.
4973 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4974 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4976 // replace C with selected text
4977 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4979 // Render and notify
4980 application.SendNotification();
4981 application.Render();
4983 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4985 gSelectionClearedCallbackCalled = false;
4987 // Render and notify
4988 application.SendNotification();
4989 application.Render();
4991 DevelTextEditor::SelectText(editor, 1, 3);
4993 // Render and notify
4994 application.SendNotification();
4995 application.Render();
4997 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4999 // Render and notify
5000 application.SendNotification();
5001 application.Render();
5003 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5005 gSelectionClearedCallbackCalled = false;
5007 DevelTextEditor::SelectText(editor, 1, 3);
5009 // Render and notify
5010 application.SendNotification();
5011 application.Render();
5014 DevelTextEditor::SelectNone(editor);
5016 // Render and notify
5017 application.SendNotification();
5018 application.Render();
5020 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5025 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5027 ToolkitTestApplication application;
5028 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5030 // Checks if the actor is created.
5032 TextEditor editor = TextEditor::New();
5033 DALI_TEST_CHECK(editor);
5035 application.GetScene().Add(editor);
5037 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5038 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5039 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5040 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5041 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5042 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5043 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5044 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5046 // Avoid a crash when core load gl resources.
5047 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5049 // Render and notify
5050 application.SendNotification();
5051 application.Render();
5053 // Tap on the text editor
5054 TestGenerateTap(application, 3.0f, 25.0f);
5056 // Render and notify
5057 application.SendNotification();
5058 application.Render();
5060 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5061 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5063 application.SendNotification();
5064 application.Render();
5066 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5067 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5072 int utcDaliTextEditorSelectionChangedSignal(void)
5074 ToolkitTestApplication application;
5075 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5077 TextEditor editor = TextEditor::New();
5078 DALI_TEST_CHECK(editor);
5080 application.GetScene().Add(editor);
5082 // connect to the selection changed signal.
5083 ConnectionTracker* testTracker = new ConnectionTracker();
5084 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5085 bool selectionChangedSignal = false;
5086 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5088 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5089 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5090 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5091 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5092 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5094 // Avoid a crash when core load gl resources.
5095 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5097 // Render and notify
5098 application.SendNotification();
5099 application.Render();
5101 // Tap on the text editor
5102 TestGenerateTap(application, 3.0f, 25.0f);
5104 // Render and notify
5105 application.SendNotification();
5106 application.Render();
5108 // Move to second line of the text.
5109 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5111 // Render and notify
5112 application.SendNotification();
5113 application.Render();
5115 // Select some text in the right of the current cursor position
5116 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5117 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5119 // Render and notify
5120 application.SendNotification();
5121 application.Render();
5123 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5124 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5126 gSelectionChangedCallbackCalled = false;
5128 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5130 // Render and notify
5131 application.SendNotification();
5132 application.Render();
5134 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5135 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5136 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5138 gSelectionChangedCallbackCalled = false;
5140 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5142 // Render and notify
5143 application.SendNotification();
5144 application.Render();
5146 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5147 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5148 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5150 gSelectionChangedCallbackCalled = false;
5151 editor.SetKeyInputFocus();
5153 // Render and notify
5154 application.SendNotification();
5155 application.Render();
5157 DevelTextEditor::SelectText(editor, 0, 5);
5159 application.SendNotification();
5160 application.Render();
5162 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5163 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5165 gSelectionChangedCallbackCalled = false;
5167 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5169 // Render and notify
5170 application.SendNotification();
5171 application.Render();
5173 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5174 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5175 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5177 gSelectionChangedCallbackCalled = false;
5180 DevelTextEditor::SelectWholeText(editor);
5182 // Render and notify
5183 application.SendNotification();
5184 application.Render();
5186 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5187 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5189 gSelectionChangedCallbackCalled = false;
5192 DevelTextEditor::SelectNone(editor);
5194 // Render and notify
5195 application.SendNotification();
5196 application.Render();
5198 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5199 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5200 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5205 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5207 ToolkitTestApplication application;
5208 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5210 TextEditor textEditor = TextEditor::New();
5211 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5212 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5213 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5214 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5216 application.GetScene().Add(textEditor);
5217 application.SendNotification();
5218 application.Render();
5220 Property::Map strikethroughMapSet;
5221 Property::Map strikethroughMapGet;
5223 strikethroughMapSet.Insert("enable", true);
5224 strikethroughMapSet.Insert("color", Color::RED);
5225 strikethroughMapSet.Insert("height", 2.0f);
5227 // Check the strikethrough property
5228 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5229 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5230 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5231 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5232 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5234 // Render and notify
5235 application.SendNotification();
5236 application.Render();
5238 strikethroughMapSet.Clear();
5239 strikethroughMapGet.Clear();
5244 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5246 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5247 //DaliException on vector: "Iterator not inside vector"
5249 ToolkitTestApplication application;
5250 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5252 TextEditor editor = TextEditor::New();
5253 DALI_TEST_CHECK(editor);
5255 application.GetScene().Add(editor);
5257 // Avoid a crash when core load gl resources.
5258 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5260 //Set multilines text
5261 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5262 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5263 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5265 //Set ResizePolicy to NaturalSize
5266 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5268 // Render and notify
5269 application.SendNotification();
5270 application.Render();
5272 // Create a tap event to touch the text editor.
5273 TestGenerateTap(application, 5.0f, 5.0f);
5275 // Render and notify
5276 application.SendNotification();
5277 application.Render();
5279 // Set currsor and add character (in first line)
5280 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5281 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5282 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5284 // Render and notify
5285 application.SendNotification();
5286 application.Render();
5288 //Check the changed text and cursor position
5289 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5290 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5292 // Render and notify
5293 application.SendNotification();
5294 application.Render();
5299 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5301 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5302 //DaliException on vector: "Iterator not inside vector"
5304 ToolkitTestApplication application;
5305 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5307 TextEditor editor = TextEditor::New();
5308 DALI_TEST_CHECK(editor);
5310 application.GetScene().Add(editor);
5312 // Avoid a crash when core load gl resources.
5313 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5315 //Set multilines text
5316 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5317 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5318 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5320 //Set ResizePolicy to NaturalSize
5321 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5324 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5325 application.SendNotification();
5326 application.Render();
5328 // Set focus and remove character
5329 editor.SetKeyInputFocus();
5330 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5332 // Render and notify
5333 application.SendNotification();
5334 application.Render();
5336 //Check the changed text and cursor position
5337 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5338 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5340 // Render and notify
5341 application.SendNotification();
5342 application.Render();
5347 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5349 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5350 //DaliException on vector: "Iterator not inside vector"
5352 ToolkitTestApplication application;
5353 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5355 TextEditor editor = TextEditor::New();
5356 DALI_TEST_CHECK(editor);
5358 application.GetScene().Add(editor);
5360 // Avoid a crash when core load gl resources.
5361 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5363 //Set multilines text
5364 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5365 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5366 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5368 //Set ResizePolicy to NaturalSize
5369 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5371 //Select text at initialization (before the first render)
5372 DevelTextEditor::SelectText(editor, 3, 5);
5374 // Render and notify
5375 application.SendNotification();
5376 application.Render();
5379 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5380 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));
5382 // Render and notify
5383 application.SendNotification();
5384 application.Render();
5386 //Check the changed text and cursor position
5387 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5388 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5390 // Render and notify
5391 application.SendNotification();
5392 application.Render();
5397 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5399 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5400 //DaliException on vector: "Iterator not inside vector"
5402 ToolkitTestApplication application;
5403 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5405 TextEditor editor = TextEditor::New();
5406 DALI_TEST_CHECK(editor);
5408 application.GetScene().Add(editor);
5410 // Avoid a crash when core load gl resources.
5411 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5413 //Set multilines text
5414 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5415 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5416 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5418 //Set ResizePolicy to NaturalSize
5419 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5422 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5423 application.SendNotification();
5424 application.Render();
5426 // Set focus and double enter (new line)
5427 editor.SetKeyInputFocus();
5428 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5429 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5431 // Render and notify
5432 application.SendNotification();
5433 application.Render();
5435 //Check the changed text and cursor position
5436 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5437 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5439 // Render and notify
5440 application.SendNotification();
5441 application.Render();
5446 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5448 ToolkitTestApplication application;
5449 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5450 TextEditor textEditor = TextEditor::New();
5451 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5452 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5453 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5454 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5456 application.GetScene().Add(textEditor);
5457 application.SendNotification();
5458 application.Render();
5460 Property::Map underlineMapSet;
5461 Property::Map underlineMapGet;
5463 underlineMapSet.Insert("enable", true);
5464 underlineMapSet.Insert("color", Color::RED);
5465 underlineMapSet.Insert("height", 1);
5466 underlineMapSet.Insert("type", Text::Underline::SOLID);
5467 underlineMapSet.Insert("dashWidth", 2);
5468 underlineMapSet.Insert("dashGap", 1);
5470 // Check the underline property
5471 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5473 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5474 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5475 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5477 // Render and notify
5478 application.SendNotification();
5479 application.Render();
5481 underlineMapSet.Clear();
5482 underlineMapGet.Clear();
5484 underlineMapSet.Insert("enable", true);
5485 underlineMapSet.Insert("color", Color::BLUE);
5486 underlineMapSet.Insert("height", 1);
5487 underlineMapSet.Insert("type", Text::Underline::DASHED);
5488 underlineMapSet.Insert("dashWidth", 4);
5489 underlineMapSet.Insert("dashGap", 2);
5491 // Check the dashed underline property
5492 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5494 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5495 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5496 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5498 // Render and notify
5499 application.SendNotification();
5500 application.Render();
5502 underlineMapSet.Clear();
5503 underlineMapGet.Clear();
5505 underlineMapSet.Insert("enable", true);
5506 underlineMapSet.Insert("color", Color::BLUE);
5507 underlineMapSet.Insert("height", 1);
5508 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5509 underlineMapSet.Insert("dashWidth", 4);
5510 underlineMapSet.Insert("dashGap", 2);
5512 // Check the dashed underline property
5513 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5515 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5516 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5517 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5519 // Render and notify
5520 application.SendNotification();
5521 application.Render();
5523 underlineMapSet.Clear();
5524 underlineMapGet.Clear();
5529 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
5531 ToolkitTestApplication application;
5532 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
5534 TextEditor textEditor1 = TextEditor::New();
5535 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
5536 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5537 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5538 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5540 Property::Map underlineMapSet1;
5541 Property::Map underlineMapGet1;
5543 underlineMapSet1.Insert("enable", true);
5544 underlineMapSet1.Insert("color", Color::RED);
5545 underlineMapSet1.Insert("height", 1);
5546 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5547 underlineMapSet1.Insert("dashWidth", 2);
5548 underlineMapSet1.Insert("dashGap", 1);
5550 // Check the underline property
5551 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5553 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5554 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5555 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5557 application.GetScene().Add(textEditor1);
5558 application.SendNotification();
5559 application.Render();
5561 TextEditor textEditor2 = TextEditor::New();
5562 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
5563 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5564 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5565 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5567 Property::Map underlineMapSet2;
5568 Property::Map underlineMapGet2;
5570 underlineMapSet2.Insert("enable", true);
5571 underlineMapSet2.Insert("color", Color::BLUE);
5572 underlineMapSet2.Insert("height", 1);
5573 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5574 underlineMapSet2.Insert("dashWidth", 4);
5575 underlineMapSet2.Insert("dashGap", 2);
5577 // Check the dashed underline property
5578 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
5580 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5581 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5582 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5584 application.GetScene().Add(textEditor2);
5585 application.SendNotification();
5586 application.Render();
5588 TextEditor textEditor3 = TextEditor::New();
5589 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
5590 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5591 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5592 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5594 Property::Map underlineMapSet3;
5595 Property::Map underlineMapGet3;
5597 underlineMapSet3.Insert("enable", true);
5598 underlineMapSet3.Insert("color", Color::BLUE);
5599 underlineMapSet3.Insert("height", 1);
5600 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5601 underlineMapSet3.Insert("dashWidth", 4);
5602 underlineMapSet3.Insert("dashGap", 2);
5604 // Check the dashed underline property
5605 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
5607 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5608 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5609 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5611 application.GetScene().Add(textEditor3);
5612 application.SendNotification();
5613 application.Render();
5618 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
5620 ToolkitTestApplication application;
5621 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
5623 TextEditor textEditor1 = TextEditor::New();
5624 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
5625 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5626 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5627 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5629 Property::Map underlineMapSet1;
5630 Property::Map underlineMapGet1;
5632 underlineMapSet1.Insert("enable", true);
5633 underlineMapSet1.Insert("color", Color::RED);
5634 underlineMapSet1.Insert("height", 1);
5635 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5636 underlineMapSet1.Insert("dashWidth", 2);
5637 underlineMapSet1.Insert("dashGap", 1);
5639 // Check the underline property
5640 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5641 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
5643 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5644 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5645 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5647 application.GetScene().Add(textEditor1);
5648 application.SendNotification();
5649 application.Render();