2 * Copyright (c) 2024 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/controls/text-controls/text-selection-popup.h>
22 #include <dali-toolkit/devel-api/text/rendering-backend.h>
23 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/devel-api/adaptor-framework/clipboard.h>
27 #include <dali/devel-api/adaptor-framework/key-devel.h>
28 #include <dali/devel-api/events/pan-gesture-devel.h>
29 #include <dali/devel-api/text-abstraction/font-client.h>
30 #include <dali/integration-api/events/key-event-integ.h>
31 #include <dali/integration-api/events/touch-event-integ.h>
32 #include <dali/public-api/rendering/renderer.h>
36 #include "test-text-geometry-utils.h"
39 using namespace Toolkit;
41 void dali_texteditor_startup(void)
43 test_return_value = TET_UNDEF;
46 void dali_texteditor_cleanup(void)
48 test_return_value = TET_PASS;
53 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT = "text";
55 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
56 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
57 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
58 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
61 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
62 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
63 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
64 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
67 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
70 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
78 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
79 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
80 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
81 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
82 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
83 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
85 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
86 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
87 const char* const PROPERTY_NAME_UNDERLINE = "underline";
88 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
89 const char* const PROPERTY_NAME_SHADOW = "shadow";
90 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
91 const char* const PROPERTY_NAME_EMBOSS = "emboss";
92 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
93 const char* const PROPERTY_NAME_OUTLINE = "outline";
94 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
95 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
96 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
98 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
99 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
100 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
101 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
102 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
103 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
104 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
105 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
106 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
107 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
108 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
109 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
110 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
111 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
112 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
116 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
117 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
118 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
120 const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
121 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
123 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
124 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
126 const float RENDER_FRAME_INTERVAL = 16.66f;
128 const unsigned int DEFAULT_FONT_SIZE = 1152u;
129 const std::string DEFAULT_FONT_DIR("/resources/fonts");
131 const int KEY_A_CODE = 38;
132 const int KEY_D_CODE = 40;
133 const int KEY_C_CODE = 54;
134 const int KEY_V_CODE = 55;
135 const int KEY_X_CODE = 53;
136 const int KEY_WHITE_SPACE_CODE = 65;
138 const int KEY_SHIFT_MODIFIER = 257;
139 const int KEY_CONTROL_MODIFIER = 258;
141 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
142 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
143 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
145 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
147 static bool gSelectionChangedCallbackCalled;
148 static uint32_t oldSelectionStart;
149 static uint32_t oldSelectionEnd;
150 static bool gSelectionClearedCallbackCalled;
151 static bool gSelectionStartedCallbackCalled;
152 static bool gAnchorClickedCallBackCalled;
153 static bool gAnchorClickedCallBackNotCalled;
154 static bool gTextChangedCallBackCalled;
155 static bool gInputFilteredAcceptedCallbackCalled;
156 static bool gInputFilteredRejectedCallbackCalled;
157 static bool gInputStyleChangedCallbackCalled;
158 static bool gMaxCharactersCallBackCalled;
159 static bool gCursorPositionChangedCallbackCalled;
160 static uint32_t oldCursorPos;
161 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
163 struct CallbackFunctor
165 CallbackFunctor(bool* callbackFlag)
166 : mCallbackFlag(callbackFlag)
172 *mCallbackFlag = true;
177 static void TestSelectionStartedCallback(TextEditor control)
179 tet_infoline(" TestSelectionStartedCallback");
181 gSelectionStartedCallbackCalled = true;
184 static void TestSelectionClearedCallback(TextEditor control)
186 tet_infoline(" TestSelectionClearedCallback");
188 gSelectionClearedCallbackCalled = true;
191 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
193 tet_infoline(" TestSelectionChangedCallback");
195 gSelectionChangedCallbackCalled = true;
196 oldSelectionStart = oldStart;
197 oldSelectionEnd = oldEnd;
200 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
202 tet_infoline(" TestAnchorClickedCallback");
204 gAnchorClickedCallBackNotCalled = false;
206 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
208 gAnchorClickedCallBackCalled = true;
212 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
214 tet_infoline(" TestCursorPositionChangedCallback");
216 gCursorPositionChangedCallbackCalled = true;
217 oldCursorPos = oldPos;
220 static void TestTextChangedCallback(TextEditor control)
222 tet_infoline(" TestTextChangedCallback");
224 gTextChangedCallBackCalled = true;
227 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
229 tet_infoline(" TestInputStyleChangedCallback");
231 gInputStyleChangedCallbackCalled = true;
232 gInputStyleMask = mask;
235 static void TestMaxLengthReachedCallback(TextEditor control)
237 tet_infoline(" TestMaxLengthReachedCallback");
239 gMaxCharactersCallBackCalled = true;
242 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
244 tet_infoline(" TestInputFilteredCallback");
246 if(type == Toolkit::InputFilter::Property::ACCEPTED)
248 gInputFilteredAcceptedCallbackCalled = true;
250 else if(type == Toolkit::InputFilter::Property::REJECTED)
252 gInputFilteredRejectedCallbackCalled = true;
256 // Generate a KeyEvent to send to Core.
257 Integration::KeyEvent GenerateKey(const std::string& keyName,
258 const std::string& logicalKey,
259 const std::string& keyString,
262 unsigned long timeStamp,
263 const Integration::KeyEvent::State& keyState,
264 const std::string& compose = "",
265 const std::string& deviceName = DEFAULT_DEVICE_NAME,
266 const Device::Class::Type& deviceClass = Device::Class::NONE,
267 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
269 return Integration::KeyEvent(keyName,
282 Dali::Integration::Point GetPointDownInside(Vector2& pos)
284 Dali::Integration::Point point;
285 point.SetState(PointState::DOWN);
286 point.SetScreenPosition(pos);
290 Dali::Integration::Point GetPointUpInside(Vector2& pos)
292 Dali::Integration::Point point;
293 point.SetState(PointState::UP);
294 point.SetScreenPosition(pos);
298 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
300 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
302 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
304 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
306 Property::Value* valueSet = NULL;
307 if(valueGet.first.type == Property::Key::INDEX)
309 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
313 // Get Key is a string so searching Set Map for a string key
314 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
319 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
321 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
324 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
326 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
329 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
331 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
334 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
336 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
339 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
341 Vector2 vector2Get = valueGet.second.Get<Vector2>();
342 Vector2 vector2Set = valueSet->Get<Vector2>();
343 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
346 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
348 Vector4 vector4Get = valueGet.second.Get<Vector4>();
349 Vector4 vector4Set = valueSet->Get<Vector4>();
350 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);
356 if(valueGet.first.type == Property::Key::INDEX)
358 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
362 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
372 class ScrollStateChangeCallback : public Dali::ConnectionTracker
375 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
376 : mStartedCalled(startedCalled),
377 mFinishedCalled(finishedCalled)
381 void Callback(TextEditor editor, TextEditor::Scroll::Type type)
383 if(type == TextEditor::Scroll::STARTED)
385 mStartedCalled = true;
387 else if(type == TextEditor::Scroll::FINISHED)
389 mFinishedCalled = true;
393 bool& mStartedCalled;
394 bool& mFinishedCalled;
397 // Stores data that is populated in the callback and will be read by the test cases
401 : functorCalled(false),
402 voidFunctorCalled(false),
409 functorCalled = false;
410 voidFunctorCalled = false;
412 receivedGesture.Reset();
418 bool voidFunctorCalled;
419 PanGesture receivedGesture;
423 // Functor that sets the data when called
424 struct GestureReceivedFunctor
426 GestureReceivedFunctor(SignalData& data)
431 void operator()(Actor actor, const PanGesture& pan)
433 signalData.functorCalled = true;
434 signalData.receivedGesture = pan;
435 signalData.pannedActor = actor;
440 signalData.voidFunctorCalled = true;
443 SignalData& signalData;
448 int UtcDaliToolkitTextEditorConstructorP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
452 TextEditor textEditor;
453 DALI_TEST_CHECK(!textEditor);
457 int UtcDaliToolkitTextEditorNewP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorNewP");
461 TextEditor textEditor = TextEditor::New();
462 DALI_TEST_CHECK(textEditor);
466 int UtcDaliToolkitTextEditorDownCastP(void)
468 ToolkitTestApplication application;
469 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
470 TextEditor textEditor1 = TextEditor::New();
471 BaseHandle object(textEditor1);
473 TextEditor textEditor2 = TextEditor::DownCast(object);
474 DALI_TEST_CHECK(textEditor2);
476 TextEditor textEditor3 = DownCast<TextEditor>(object);
477 DALI_TEST_CHECK(textEditor3);
481 int UtcDaliToolkitTextEditorDownCastN(void)
483 ToolkitTestApplication application;
484 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
485 BaseHandle uninitializedObject;
486 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
487 DALI_TEST_CHECK(!textEditor1);
489 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
490 DALI_TEST_CHECK(!textEditor2);
494 int UtcDaliToolkitTextEditorCopyConstructorP(void)
496 ToolkitTestApplication application;
497 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
498 TextEditor textEditor = TextEditor::New();
499 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
501 TextEditor copy(textEditor);
502 DALI_TEST_CHECK(copy);
503 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
507 int UtcDaliTextEditorMoveConstructor(void)
509 ToolkitTestApplication application;
511 TextEditor textEditor = TextEditor::New();
512 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
513 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
515 TextEditor moved = std::move(textEditor);
516 DALI_TEST_CHECK(moved);
517 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
518 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
519 DALI_TEST_CHECK(!textEditor);
524 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
526 ToolkitTestApplication application;
527 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
528 TextEditor textEditor = TextEditor::New();
529 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
531 TextEditor copy = textEditor;
532 DALI_TEST_CHECK(copy);
533 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
537 int UtcDaliTextEditorMoveAssignment(void)
539 ToolkitTestApplication application;
541 TextEditor textEditor = TextEditor::New();
542 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
543 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
546 moved = std::move(textEditor);
547 DALI_TEST_CHECK(moved);
548 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
549 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
550 DALI_TEST_CHECK(!textEditor);
555 int UtcDaliTextEditorNewP(void)
557 ToolkitTestApplication application;
558 tet_infoline(" UtcDaliToolkitTextEditorNewP");
559 TextEditor textEditor = TextEditor::New();
560 DALI_TEST_CHECK(textEditor);
564 // Positive test case for a method
565 int UtcDaliTextEditorGetPropertyP(void)
567 ToolkitTestApplication application;
568 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
569 TextEditor editor = TextEditor::New();
570 DALI_TEST_CHECK(editor);
572 // Check Property Indices are correct
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
574 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
575 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
576 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
577 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
578 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
579 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
580 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
581 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
582 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
583 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
584 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
585 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
586 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
587 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
588 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
589 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
590 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
591 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
592 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
593 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
594 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
595 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
596 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
597 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
598 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
599 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
600 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
601 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
602 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
604 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
605 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
606 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
607 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
608 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
609 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
610 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
611 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
612 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
613 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
614 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
615 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
616 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
617 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
618 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
619 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
620 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
621 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
622 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
623 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
624 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
625 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
626 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
627 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
628 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
629 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
630 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
631 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
632 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
633 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
634 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
635 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
636 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
637 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
638 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
639 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
640 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextEditor::Property::REMOVE_FRONT_INSET);
641 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextEditor::Property::REMOVE_BACK_INSET);
646 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
649 Property::Map imageMap;
650 imageMap[mapKey] = mapValue;
652 editor.SetProperty(property, imageMap);
653 Property::Value propValue = editor.GetProperty(property);
654 Property::Map* resultMap = propValue.GetMap();
656 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
664 // Positive test case for a method
665 int UtcDaliTextEditorSetPropertyP(void)
667 ToolkitTestApplication application;
668 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
669 TextEditor editor = TextEditor::New();
670 DALI_TEST_CHECK(editor);
671 application.GetScene().Add(editor);
673 // Note - we can't check the defaults since the stylesheets are platform-specific
675 // Check the render backend property.
676 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
677 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
679 // Check text property.
680 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
681 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
683 // Check text's color property
684 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
685 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
687 // Check font properties.
688 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
689 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
691 Property::Map fontStyleMapSet;
692 Property::Map fontStyleMapGet;
693 Property::Value* slantValue = NULL;
695 fontStyleMapSet.Insert("weight", "bold");
696 fontStyleMapSet.Insert("width", "condensed");
697 fontStyleMapSet.Insert("slant", "italic");
699 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
700 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
701 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
702 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
704 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
705 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
707 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
708 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
709 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
711 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
712 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
713 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
716 fontStyleMapSet.Clear();
717 fontStyleMapSet.Insert("weight", "normal");
718 fontStyleMapSet.Insert("slant", "oblique");
719 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
720 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
721 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
722 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
724 fontStyleMapSet.Clear();
725 fontStyleMapSet.Insert("slant", "roman");
726 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
727 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
729 // Replace 'roman' for 'normal'.
730 slantValue = fontStyleMapGet.Find("slant");
731 if(NULL != slantValue)
733 if("normal" == slantValue->Get<std::string>())
735 fontStyleMapGet["slant"] = "roman";
738 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
739 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
741 fontStyleMapSet.Clear();
743 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
744 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
745 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
746 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
748 // Check that the Alignment properties can be correctly set
749 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
750 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
752 // Check that the Alignment properties can be correctly set
753 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
754 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
755 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
756 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
757 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
758 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
760 // Check scroll properties.
761 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
762 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
763 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
764 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
766 // Check cursor properties
767 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
768 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
769 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
770 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
772 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
773 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
774 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
775 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
776 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
777 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
778 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
779 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
781 // Check handle images
782 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
783 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
784 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
785 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
786 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
788 // Check handle images
789 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
790 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
791 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
792 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
793 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
794 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
796 // Check the selection popup style
797 const Vector2 popupMaxSize(200.0f, 300.0f);
798 const Vector2 optionDividerSize(30.0f, 5.0f);
799 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
800 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
802 Property::Map selectionPopupStyle;
803 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
804 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
805 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
806 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
808 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
810 Property::Map selectionPopupStyleGet;
811 selectionPopupStyleGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::SELECTION_POPUP_STYLE);
813 Property::Value* popupValue;
814 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
815 DALI_TEST_CHECK(NULL != popupValue);
818 Vector2 popupMaxSizeGet;
819 popupValue->Get(popupMaxSizeGet);
820 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
823 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
824 DALI_TEST_CHECK(NULL != popupValue);
827 Vector2 optionDividerSizeGet;
828 popupValue->Get(optionDividerSizeGet);
829 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
832 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
833 DALI_TEST_CHECK(NULL != popupValue);
836 Vector4 optionDividerPaddingGet;
837 popupValue->Get(optionDividerPaddingGet);
838 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
841 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
842 DALI_TEST_CHECK(NULL != popupValue);
845 Vector4 labelPaddingGet;
846 popupValue->Get(labelPaddingGet);
847 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
850 // Reset selection popup style
851 selectionPopupStyle.Clear();
852 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
854 // Check the highlight color
855 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
856 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
858 // Decoration bounding box
859 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
860 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
862 // Check the enable markup property.
863 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
864 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
865 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
867 // Check input color property.
868 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
869 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
871 // Check input font properties.
872 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
873 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
875 fontStyleMapSet.Clear();
876 fontStyleMapSet.Insert("weight", "bold");
877 fontStyleMapSet.Insert("width", "condensed");
878 fontStyleMapSet.Insert("slant", "italic");
880 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
881 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
882 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
883 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
885 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
886 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
888 // Reset input font style.
889 fontStyleMapSet.Clear();
890 fontStyleMapSet.Insert("weight", "normal");
891 fontStyleMapSet.Insert("slant", "oblique");
893 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
894 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
895 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
896 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
898 fontStyleMapSet.Clear();
899 fontStyleMapSet.Insert("slant", "roman");
901 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
902 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
904 // Replace 'roman' for 'normal'.
905 slantValue = fontStyleMapGet.Find("slant");
906 if(NULL != slantValue)
908 if("normal" == slantValue->Get<std::string>())
910 fontStyleMapGet["slant"] = "roman";
913 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
914 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
916 fontStyleMapSet.Clear();
918 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
919 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
920 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
921 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
923 // Check the line spacing property
924 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
925 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
926 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
928 // Check the input line spacing property
929 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
930 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
931 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
933 // Check the underline property
935 Property::Map underlineMapSet;
936 Property::Map underlineMapGet;
938 underlineMapSet.Insert("enable", true);
939 underlineMapSet.Insert("color", Color::RED);
940 underlineMapSet.Insert("height", 1);
941 underlineMapSet.Insert("type", Text::Underline::SOLID);
942 underlineMapSet.Insert("dashWidth", 5);
943 underlineMapSet.Insert("dashGap", 3);
945 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
947 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
948 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
949 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
951 application.SendNotification();
952 application.Render();
954 // Check the dashed underline property
956 underlineMapSet.Clear();
957 underlineMapGet.Clear();
959 underlineMapSet.Insert("enable", true);
960 underlineMapSet.Insert("color", Color::RED);
961 underlineMapSet.Insert("height", 1);
962 underlineMapSet.Insert("type", Text::Underline::DASHED);
963 underlineMapSet.Insert("dashWidth", 5);
964 underlineMapSet.Insert("dashGap", 3);
966 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
968 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
969 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
970 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
972 application.SendNotification();
973 application.Render();
975 underlineMapSet.Clear();
976 underlineMapGet.Clear();
978 // Check the double underline property
980 underlineMapSet.Clear();
981 underlineMapGet.Clear();
983 underlineMapSet.Insert("enable", true);
984 underlineMapSet.Insert("color", Color::RED);
985 underlineMapSet.Insert("height", 1);
986 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
987 underlineMapSet.Insert("dashWidth", 5);
988 underlineMapSet.Insert("dashGap", 3);
990 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
992 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
993 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
994 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
996 application.SendNotification();
997 application.Render();
999 underlineMapSet.Clear();
1000 underlineMapGet.Clear();
1002 // Check the input underline property
1003 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
1004 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1006 // Check the shadow property
1007 Property::Map shadowMapSet;
1008 Property::Map shadowMapGet;
1010 shadowMapSet.Insert("color", Color::GREEN);
1011 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1012 shadowMapSet.Insert("blurRadius", 3.0f);
1014 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
1016 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
1017 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1018 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1020 // Check the input shadow property
1021 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
1022 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1024 // Check the emboss property
1025 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
1026 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1028 // Check the input emboss property
1029 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
1030 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1032 // Check the outline property
1034 // Test string type first
1035 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1036 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
1037 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1039 // Then test the property map type
1040 Property::Map outlineMapSet;
1041 Property::Map outlineMapGet;
1043 outlineMapSet["color"] = Color::RED;
1044 outlineMapSet["width"] = 2.0f;
1045 outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
1047 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1049 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1050 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1051 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1053 // Check the input outline property
1054 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1055 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1057 // Check the smooth scroll property
1058 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1059 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1060 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1062 // Check the smooth scroll duration property
1063 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1064 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1066 // Check the scroll bar property
1067 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1068 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1069 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1071 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1072 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1073 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1074 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1076 // Check the pixel size of font
1077 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1078 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1080 // Check placeholder text properties.
1081 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1082 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1084 // Check placeholder text's color property.
1085 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1086 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1088 // Check the enable selection property
1089 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1090 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1092 // Check the placeholder property with pixel size
1093 Property::Map placeholderPixelSizeMapSet;
1094 Property::Map placeholderPixelSizeMapGet;
1095 Property::Map placeholderFontstyleMap;
1096 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1097 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1098 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1099 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1100 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1102 placeholderFontstyleMap.Insert("weight", "bold");
1103 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1104 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1106 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1107 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1109 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1110 Property::Map placeholderConversionMap;
1111 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1112 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1113 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1114 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1115 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1116 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1118 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1120 // Check the placeholder property with point size
1121 Property::Map placeholderMapSet;
1122 Property::Map placeholderMapGet;
1123 placeholderMapSet["text"] = "Setting Placeholder Text";
1124 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1125 placeholderMapSet["color"] = Color::RED;
1126 placeholderMapSet["fontFamily"] = "Arial";
1127 placeholderMapSet["pointSize"] = 12.0f;
1128 // Check the placeholder font style property
1129 placeholderFontstyleMap.Clear();
1131 placeholderFontstyleMap.Insert("weight", "bold");
1132 placeholderFontstyleMap.Insert("width", "condensed");
1133 placeholderFontstyleMap.Insert("slant", "italic");
1134 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1135 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1137 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1138 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1140 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1141 placeholderConversionMap.Clear();
1142 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1143 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1144 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1145 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1146 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1147 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1148 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1150 // Reset font style.
1151 placeholderFontstyleMap.Clear();
1152 placeholderFontstyleMap.Insert("weight", "normal");
1153 placeholderFontstyleMap.Insert("slant", "oblique");
1154 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1155 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1157 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1158 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1159 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1160 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1162 placeholderFontstyleMap.Clear();
1163 placeholderFontstyleMap.Insert("slant", "roman");
1164 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1165 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1167 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1169 placeholderFontstyleMap.Clear();
1170 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1172 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1173 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1174 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1175 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1176 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1178 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1179 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1181 // Check handle color
1182 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1183 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1185 // Test the ENABLE_GRAB_HANDLE_POPUP property
1186 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1187 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1189 // Check the input method setting
1190 Property::Map propertyMap;
1191 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1192 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1193 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1194 int inputVariation = 1;
1195 propertyMap["PANEL_LAYOUT"] = panelLayout;
1196 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1197 propertyMap["BUTTON_ACTION"] = buttonAction;
1198 propertyMap["VARIATION"] = inputVariation;
1199 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1201 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1203 DALI_TEST_CHECK(value.Get(map));
1206 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1207 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1210 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1211 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1214 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1215 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1218 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1219 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1221 // Check the input filter property
1222 Property::Map inputFilterMapSet;
1223 Property::Map inputFilterMapGet;
1224 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1225 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1227 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1229 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1230 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1233 inputFilterMapSet.Clear();
1234 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1236 // Check the strikethrough property
1238 Property::Map strikethroughMapSet;
1239 Property::Map strikethroughMapGet;
1241 application.SendNotification();
1242 application.Render();
1244 // Check the input strikethrough property
1246 strikethroughMapSet.Clear();
1247 strikethroughMapGet.Clear();
1248 strikethroughMapSet.Insert("enable", true);
1249 strikethroughMapSet.Insert("color", Color::BLUE);
1250 strikethroughMapSet.Insert("height", 2.0f);
1252 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1254 application.SendNotification();
1255 application.Render();
1257 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1259 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1260 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1262 // Check the input strikethrough property
1263 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1264 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1266 application.SendNotification();
1267 application.Render();
1269 // Check the line size property
1270 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1271 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1272 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1274 // Check Remove Front/Back Inset Property
1275 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1276 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, false);
1277 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1279 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1280 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, false);
1281 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1283 application.SendNotification();
1284 application.Render();
1289 // Positive Atlas Text Renderer test
1290 int utcDaliTextEditorAtlasRenderP(void)
1292 ToolkitTestApplication application;
1293 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1294 StyleManager styleManager = StyleManager::Get();
1295 styleManager.ApplyDefaultTheme();
1296 TextEditor editor = TextEditor::New();
1297 DALI_TEST_CHECK(editor);
1299 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1301 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1303 application.GetScene().Add(editor);
1307 // Render some text with the shared atlas backend
1308 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1309 application.SendNotification();
1310 application.Render();
1314 tet_result(TET_FAIL);
1319 // Positive test for the anchorClicked signal.
1320 int utcDaliTextEditorAnchorClickedP(void)
1322 ToolkitTestApplication application;
1323 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1324 TextEditor editor = TextEditor::New();
1325 DALI_TEST_CHECK(editor);
1327 application.GetScene().Add(editor);
1329 // connect to the anchor clicked signal.
1330 ConnectionTracker* testTracker = new ConnectionTracker();
1331 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1332 bool anchorClickedSignal = false;
1333 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1335 gAnchorClickedCallBackCalled = false;
1336 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1337 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1338 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1339 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1340 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1342 application.SendNotification();
1343 application.Render();
1344 editor.SetKeyInputFocus();
1346 // Create a tap event to touch the text editor.
1347 TestGenerateTap(application, 5.0f, 5.0f);
1348 application.SendNotification();
1349 application.Render();
1351 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1352 DALI_TEST_CHECK(anchorClickedSignal);
1354 gAnchorClickedCallBackNotCalled = true;
1355 // Tap the outside of anchor, callback should not be called.
1356 TestGenerateTap(application, 150.f, 100.f);
1357 application.SendNotification();
1358 application.Render();
1360 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1365 // Positive test for the textChanged signal.
1366 int utcDaliTextEditorTextChangedP(void)
1368 ToolkitTestApplication application;
1369 tet_infoline(" utcDaliTextEditorTextChangedP");
1370 TextEditor editor = TextEditor::New();
1371 DALI_TEST_CHECK(editor);
1373 application.GetScene().Add(editor);
1375 // connect to the text changed signal.
1376 ConnectionTracker* testTracker = new ConnectionTracker();
1377 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1378 bool textChangedSignal = false;
1379 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1381 gTextChangedCallBackCalled = false;
1382 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1383 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1384 DALI_TEST_CHECK(textChangedSignal);
1386 application.SendNotification();
1387 editor.SetKeyInputFocus();
1389 gTextChangedCallBackCalled = false;
1390 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1391 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1394 editor.SetProperty(TextField::Property::TEXT, "");
1396 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1397 gTextChangedCallBackCalled = false;
1398 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1399 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1401 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1402 gTextChangedCallBackCalled = false;
1403 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1404 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1409 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1411 ToolkitTestApplication application;
1412 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1413 TextEditor editor = TextEditor::New();
1414 DALI_TEST_CHECK(editor);
1416 application.GetScene().Add(editor);
1418 // connect to the text changed signal.
1419 ConnectionTracker* testTracker = new ConnectionTracker();
1420 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1421 bool textChangedSignal = false;
1422 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1424 // get InputMethodContext
1426 InputMethodContext::EventData imfEvent;
1427 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1429 editor.SetKeyInputFocus();
1430 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1433 gTextChangedCallBackCalled = false;
1434 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1435 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1436 application.SendNotification();
1437 application.Render();
1438 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1439 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1441 gTextChangedCallBackCalled = false;
1442 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1443 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1444 application.SendNotification();
1445 application.Render();
1446 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1447 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1449 gTextChangedCallBackCalled = false;
1450 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1451 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1452 application.SendNotification();
1453 application.Render();
1454 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1455 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1457 gTextChangedCallBackCalled = false;
1458 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1459 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1460 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1462 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1463 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1464 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1466 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1467 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1468 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1470 application.SendNotification();
1471 application.Render();
1472 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1473 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1478 int utcDaliTextEditorInputStyleChanged01(void)
1480 // The text-editor emits signals when the input style changes. These changes of style are
1481 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1482 // can't be emitted during the size negotiation as the callbacks may update the UI.
1483 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1484 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1485 ToolkitTestApplication application;
1486 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1490 char* pathNamePtr = get_current_dir_name();
1491 const std::string pathName(pathNamePtr);
1494 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1495 fontClient.SetDpi(93u, 93u);
1497 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1498 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1500 TextEditor editor = TextEditor::New();
1501 DALI_TEST_CHECK(editor);
1503 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1504 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1505 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1507 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1508 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1510 // connect to the text changed signal.
1511 ConnectionTracker* testTracker = new ConnectionTracker();
1512 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1513 bool inputStyleChangedSignal = false;
1514 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1516 application.GetScene().Add(editor);
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Executes the idle callbacks added by the text control on the change of input style.
1523 application.RunIdles();
1525 gInputStyleChangedCallbackCalled = false;
1526 gInputStyleMask = TextEditor::InputStyle::NONE;
1527 inputStyleChangedSignal = false;
1529 // Create a tap event to touch the text editor.
1530 TestGenerateTap(application, 18.0f, 25.0f);
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Executes the idle callbacks added by the text control on the change of input style.
1537 application.RunIdles();
1539 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1540 if(gInputStyleChangedCallbackCalled)
1542 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1544 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1545 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1547 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1548 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1550 DALI_TEST_CHECK(inputStyleChangedSignal);
1552 gInputStyleChangedCallbackCalled = false;
1553 gInputStyleMask = TextEditor::InputStyle::NONE;
1554 inputStyleChangedSignal = false;
1556 // Create a tap event to touch the text editor.
1557 TestGenerateTap(application, 30.0f, 25.0f);
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Executes the idle callbacks added by the text control on the change of input style.
1564 application.RunIdles();
1566 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1567 DALI_TEST_CHECK(!inputStyleChangedSignal);
1569 gInputStyleChangedCallbackCalled = false;
1570 gInputStyleMask = TextEditor::InputStyle::NONE;
1571 inputStyleChangedSignal = false;
1573 // Create a tap event to touch the text editor.
1574 TestGenerateTap(application, 43.0f, 25.0f);
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Executes the idle callbacks added by the text control on the change of input style.
1581 application.RunIdles();
1583 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1584 if(gInputStyleChangedCallbackCalled)
1586 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1588 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1589 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1591 DALI_TEST_CHECK(inputStyleChangedSignal);
1593 gInputStyleChangedCallbackCalled = false;
1594 gInputStyleMask = TextEditor::InputStyle::NONE;
1595 inputStyleChangedSignal = false;
1597 // Create a tap event to touch the text editor.
1598 TestGenerateTap(application, 88.0f, 25.0f);
1600 // Render and notify
1601 application.SendNotification();
1602 application.Render();
1604 // Executes the idle callbacks added by the text control on the change of input style.
1605 application.RunIdles();
1607 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1608 if(gInputStyleChangedCallbackCalled)
1610 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1612 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1613 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1615 Property::Map fontStyleMapSet;
1616 Property::Map fontStyleMapGet;
1618 fontStyleMapSet.Insert("weight", "bold");
1620 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1621 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1622 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1624 DALI_TEST_CHECK(inputStyleChangedSignal);
1626 gInputStyleChangedCallbackCalled = false;
1627 gInputStyleMask = TextEditor::InputStyle::NONE;
1628 inputStyleChangedSignal = false;
1630 // Create a tap event to touch the text editor.
1631 TestGenerateTap(application, 115.0f, 25.0f);
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Executes the idle callbacks added by the text control on the change of input style.
1638 application.RunIdles();
1640 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1641 DALI_TEST_CHECK(!inputStyleChangedSignal);
1643 gInputStyleChangedCallbackCalled = false;
1644 gInputStyleMask = TextEditor::InputStyle::NONE;
1645 inputStyleChangedSignal = false;
1647 // Create a tap event to touch the text editor.
1648 TestGenerateTap(application, 164.0f, 25.0f);
1650 // Render and notify
1651 application.SendNotification();
1652 application.Render();
1654 // Executes the idle callbacks added by the text control on the change of input style.
1655 application.RunIdles();
1657 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1658 if(gInputStyleChangedCallbackCalled)
1660 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1662 Property::Map fontStyleMapSet;
1663 Property::Map fontStyleMapGet;
1665 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1666 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1667 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1669 DALI_TEST_CHECK(inputStyleChangedSignal);
1671 gInputStyleChangedCallbackCalled = false;
1672 gInputStyleMask = TextEditor::InputStyle::NONE;
1673 inputStyleChangedSignal = false;
1675 // Create a tap event to touch the text editor.
1676 TestGenerateTap(application, 191.0f, 25.0f);
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // Executes the idle callbacks added by the text control on the change of input style.
1683 application.RunIdles();
1685 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1686 DALI_TEST_CHECK(!inputStyleChangedSignal);
1691 int utcDaliTextEditorInputStyleChanged02(void)
1693 // The text-editor emits signals when the input style changes. These changes of style are
1694 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1695 // can't be emitted during the size negotiation as the callbacks may update the UI.
1696 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1697 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1698 ToolkitTestApplication application;
1699 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1703 char* pathNamePtr = get_current_dir_name();
1704 const std::string pathName(pathNamePtr);
1707 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1708 fontClient.SetDpi(93u, 93u);
1710 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1711 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1713 TextEditor editor = TextEditor::New();
1714 DALI_TEST_CHECK(editor);
1716 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1717 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1718 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1720 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1721 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>");
1723 // connect to the text changed signal.
1724 ConnectionTracker* testTracker = new ConnectionTracker();
1725 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1726 bool inputStyleChangedSignal = false;
1727 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1729 application.GetScene().Add(editor);
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 // Executes the idle callbacks added by the text control on the change of input style.
1736 application.RunIdles();
1738 gInputStyleChangedCallbackCalled = false;
1739 gInputStyleMask = TextEditor::InputStyle::NONE;
1740 inputStyleChangedSignal = false;
1742 // Create a tap event to touch the text editor.
1743 TestGenerateTap(application, 53.0f, 25.0f, 100);
1744 TestGenerateTap(application, 53.0f, 25.0f, 200);
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Executes the idle callbacks added by the text control on the change of input style.
1751 application.RunIdles();
1753 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1754 if(gInputStyleChangedCallbackCalled)
1756 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1757 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1758 TextEditor::InputStyle::POINT_SIZE |
1759 TextEditor::InputStyle::COLOR),
1762 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1763 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1765 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1766 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1768 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1769 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1771 DALI_TEST_CHECK(inputStyleChangedSignal);
1773 gInputStyleChangedCallbackCalled = false;
1774 gInputStyleMask = TextEditor::InputStyle::NONE;
1775 inputStyleChangedSignal = false;
1777 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 // Executes the idle callbacks added by the text control on the change of input style.
1784 application.RunIdles();
1786 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1787 if(gInputStyleChangedCallbackCalled)
1789 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1790 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1793 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1794 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1796 DALI_TEST_CHECK(inputStyleChangedSignal);
1798 gInputStyleChangedCallbackCalled = false;
1799 gInputStyleMask = TextEditor::InputStyle::NONE;
1800 inputStyleChangedSignal = false;
1802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 // Executes the idle callbacks added by the text control on the change of input style.
1809 application.RunIdles();
1811 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1812 DALI_TEST_CHECK(!inputStyleChangedSignal);
1814 gInputStyleChangedCallbackCalled = false;
1815 gInputStyleMask = TextEditor::InputStyle::NONE;
1816 inputStyleChangedSignal = false;
1818 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Executes the idle callbacks added by the text control on the change of input style.
1825 application.RunIdles();
1827 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1828 if(gInputStyleChangedCallbackCalled)
1830 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1831 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1834 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1835 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1837 DALI_TEST_CHECK(inputStyleChangedSignal);
1839 gInputStyleChangedCallbackCalled = false;
1840 gInputStyleMask = TextEditor::InputStyle::NONE;
1841 inputStyleChangedSignal = false;
1843 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1845 Property::Map fontStyleMapSet;
1846 fontStyleMapSet.Insert("weight", "thin");
1847 fontStyleMapSet.Insert("width", "condensed");
1848 fontStyleMapSet.Insert("slant", "italic");
1850 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1851 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1852 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1854 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1855 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1856 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1857 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1858 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1860 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1862 // Render and notify
1863 application.SendNotification();
1864 application.Render();
1866 // Executes the idle callbacks added by the text control on the change of input style.
1867 application.RunIdles();
1869 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1870 DALI_TEST_CHECK(!inputStyleChangedSignal);
1872 // Create a tap event to touch the text editor.
1873 TestGenerateTap(application, 63.0f, 25.0f, 900);
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Executes the idle callbacks added by the text control on the change of input style.
1880 application.RunIdles();
1882 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1883 if(gInputStyleChangedCallbackCalled)
1885 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1886 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1887 TextEditor::InputStyle::POINT_SIZE |
1888 TextEditor::InputStyle::FONT_STYLE |
1889 TextEditor::InputStyle::LINE_SPACING |
1890 TextEditor::InputStyle::UNDERLINE |
1891 TextEditor::InputStyle::SHADOW |
1892 TextEditor::InputStyle::EMBOSS |
1893 TextEditor::InputStyle::OUTLINE),
1896 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1897 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1899 DALI_TEST_CHECK(inputStyleChangedSignal);
1901 gInputStyleChangedCallbackCalled = false;
1902 gInputStyleMask = TextEditor::InputStyle::NONE;
1903 inputStyleChangedSignal = false;
1905 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1907 fontStyleMapSet.Clear();
1908 fontStyleMapSet.Insert("weight", "black");
1909 fontStyleMapSet.Insert("width", "expanded");
1910 fontStyleMapSet.Insert("slant", "oblique");
1912 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1914 // Create a tap event to touch the text editor.
1915 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 // Executes the idle callbacks added by the text control on the change of input style.
1922 application.RunIdles();
1924 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1925 if(gInputStyleChangedCallbackCalled)
1927 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1928 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1929 TextEditor::InputStyle::POINT_SIZE |
1930 TextEditor::InputStyle::FONT_STYLE),
1933 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1934 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1936 DALI_TEST_CHECK(inputStyleChangedSignal);
1941 int utcDaliTextEditorInputStyleChanged03(void)
1943 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1944 ToolkitTestApplication application;
1945 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1949 char* pathNamePtr = get_current_dir_name();
1950 const std::string pathName(pathNamePtr);
1953 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1954 fontClient.SetDpi(93u, 93u);
1956 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1957 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1959 TextEditor editor = TextEditor::New();
1960 DALI_TEST_CHECK(editor);
1962 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1963 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1964 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1966 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1967 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1969 // connect to the text changed signal.
1970 ConnectionTracker* testTracker = new ConnectionTracker();
1971 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1972 bool inputStyleChangedSignal = false;
1973 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1975 application.GetScene().Add(editor);
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 // Executes the idle callbacks added by the text control on the change of input style.
1982 application.RunIdles();
1984 gInputStyleChangedCallbackCalled = false;
1985 gInputStyleMask = TextEditor::InputStyle::NONE;
1986 inputStyleChangedSignal = false;
1988 // Create a tap event to touch the text editor.
1989 TestGenerateTap(application, 18.0f, 25.0f);
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1995 // Executes the idle callbacks added by the text control on the change of input style.
1996 application.RunIdles();
1998 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1999 if(gInputStyleChangedCallbackCalled)
2001 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
2003 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
2004 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2006 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
2007 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2009 DALI_TEST_CHECK(inputStyleChangedSignal);
2011 gInputStyleChangedCallbackCalled = false;
2012 gInputStyleMask = TextEditor::InputStyle::NONE;
2013 inputStyleChangedSignal = false;
2015 // Create a tap event to touch the text editor.
2016 TestGenerateTap(application, 30.0f, 25.0f);
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Executes the idle callbacks added by the text control on the change of input style.
2023 application.RunIdles();
2025 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2026 DALI_TEST_CHECK(!inputStyleChangedSignal);
2028 gInputStyleChangedCallbackCalled = false;
2029 gInputStyleMask = TextEditor::InputStyle::NONE;
2030 inputStyleChangedSignal = false;
2032 // Create a tap event to touch the text editor.
2033 TestGenerateTap(application, 43.0f, 25.0f);
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2039 // Executes the idle callbacks added by the text control on the change of input style.
2040 application.RunIdles();
2042 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2043 if(gInputStyleChangedCallbackCalled)
2045 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2047 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2048 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2050 DALI_TEST_CHECK(inputStyleChangedSignal);
2052 gInputStyleChangedCallbackCalled = false;
2053 gInputStyleMask = TextEditor::InputStyle::NONE;
2054 inputStyleChangedSignal = false;
2056 // Make AddIdle return false.
2057 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2059 // Create a tap event to touch the text editor.
2060 TestGenerateTap(application, 88.0f, 25.0f);
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 // Execute the idle callbacks.
2067 // And check whether we didn't change of input style.
2068 application.RunIdles();
2070 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2071 DALI_TEST_CHECK(!inputStyleChangedSignal);
2073 gInputStyleChangedCallbackCalled = false;
2074 gInputStyleMask = TextEditor::InputStyle::NONE;
2075 inputStyleChangedSignal = false;
2077 // Create a tap event to touch the text editor.
2078 TestGenerateTap(application, 115.0f, 25.0f);
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // Execute the idle callbacks.
2085 // And check whether we didn't change of input style.
2086 application.RunIdles();
2088 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2089 DALI_TEST_CHECK(!inputStyleChangedSignal);
2091 gInputStyleChangedCallbackCalled = false;
2092 gInputStyleMask = TextEditor::InputStyle::NONE;
2093 inputStyleChangedSignal = false;
2095 // Revert AddIdle return true.
2096 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2098 // Create a tap event to touch the text editor.
2099 TestGenerateTap(application, 164.0f, 25.0f);
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 // Executes the idle callbacks added by the text control on the change of input style.
2106 application.RunIdles();
2108 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2109 if(gInputStyleChangedCallbackCalled)
2111 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2113 Property::Map fontStyleMapSet;
2114 Property::Map fontStyleMapGet;
2116 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2117 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2118 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2120 DALI_TEST_CHECK(inputStyleChangedSignal);
2122 gInputStyleChangedCallbackCalled = false;
2123 gInputStyleMask = TextEditor::InputStyle::NONE;
2124 inputStyleChangedSignal = false;
2126 // Create a tap event to touch the text editor.
2127 TestGenerateTap(application, 191.0f, 25.0f);
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Executes the idle callbacks added by the text control on the change of input style.
2134 application.RunIdles();
2136 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2137 DALI_TEST_CHECK(!inputStyleChangedSignal);
2142 int utcDaliTextEditorEvent01(void)
2144 ToolkitTestApplication application;
2145 tet_infoline(" utcDaliTextEditorEvent01");
2147 // Creates a tap event. After creating a tap event the text editor should
2148 // have the focus and add text with key events should be possible.
2150 TextEditor editor = TextEditor::New();
2151 DALI_TEST_CHECK(editor);
2153 application.GetScene().Add(editor);
2155 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2156 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2157 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2159 // Avoid a crash when core load gl resources.
2160 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Add a key event but as the text editor has not the focus it should do nothing.
2167 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2175 // Create a tap event to touch the text editor.
2176 TestGenerateTap(application, 150.0f, 25.0f);
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2182 // Now the text editor has the focus, so it can handle the key events.
2183 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2184 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2192 // Create a second text editor and send key events to it.
2193 TextEditor editor2 = TextEditor::New();
2195 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2196 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2197 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2198 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2200 application.GetScene().Add(editor2);
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // Create a tap event on the second text editor.
2207 TestGenerateTap(application, 150.0f, 125.0f);
2209 // Render and notify
2210 application.SendNotification();
2211 application.Render();
2213 // The second text editor has the focus. It should handle the key events.
2214 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2215 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 // Check the text has been added to the second text editor.
2222 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2227 int utcDaliTextEditorEvent02(void)
2229 ToolkitTestApplication application;
2230 tet_infoline(" utcDaliTextEditorEvent02");
2232 // Checks if the right number of actors are created.
2234 TextEditor editor = TextEditor::New();
2235 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2236 DALI_TEST_CHECK(editor);
2238 application.GetScene().Add(editor);
2240 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2241 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2242 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2244 // Avoid a crash when core load gl resources.
2245 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2247 // Render and notify
2248 application.SendNotification();
2249 application.Render();
2251 // Check there are the expected number of children (the stencil).
2252 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2254 Actor stencil = editor.GetChildAt(0u);
2256 // Create a tap event to touch the text editor.
2257 TestGenerateTap(application, 150.0f, 25.0f, 100);
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 Actor layer = editor.GetChildAt(2u);
2264 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2265 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2267 // Now the text editor has the focus, so it can handle the key events.
2268 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2269 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2271 // Render and notify
2272 application.SendNotification();
2273 application.Render();
2275 // Checks the cursor and the renderer have been created.
2276 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2277 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2279 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2280 DALI_TEST_CHECK(cursor);
2282 // The stencil actor has a container with all the actors which contain the text renderers.
2283 Actor container = stencil.GetChildAt(0u);
2284 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2286 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2287 DALI_TEST_CHECK(renderer);
2290 // Move the cursor and check the position changes.
2291 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2293 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2294 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2302 DALI_TEST_CHECK(position2.x < position1.x);
2304 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2305 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2307 // Render and notify
2308 application.SendNotification();
2309 application.Render();
2311 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2313 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2315 // Send some taps and check the cursor positions.
2317 // Try to tap at the beginning.
2318 TestGenerateTap(application, 1.0f, 25.0f, 700);
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2324 // Cursor position should be the same than position1.
2325 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2327 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2329 // Tap away from the start position.
2330 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2338 DALI_TEST_CHECK(position5.x > position4.x);
2340 // Remove all the text.
2341 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2342 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2343 editor.SetProperty(TextEditor::Property::TEXT, "");
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 // Cursor position should be the same than position2.
2350 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2352 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2354 // Should not be a renderer, there is only a clipped cursor.
2355 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2360 int utcDaliTextEditorEvent03(void)
2362 ToolkitTestApplication application;
2363 tet_infoline(" utcDaliTextEditorEvent03");
2365 // Checks if the highlight actor is created.
2367 TextEditor editor = TextEditor::New();
2368 DALI_TEST_CHECK(editor);
2370 application.GetScene().Add(editor);
2372 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2373 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2374 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2375 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2376 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2378 // Avoid a crash when core load gl resources.
2379 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 // Send some taps and check text controller with clipboard window
2386 Dali::Clipboard clipboard = Clipboard::Get();
2387 clipboard.ShowClipboard();
2388 TestGenerateTap(application, 3.0f, 25.0f, 100);
2389 clipboard.HideClipboard();
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2395 // Tap first to get the focus.
2396 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 // Double tap to select a word.
2403 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // The stencil actor should have two actors: the renderer and the highlight actor.
2410 Actor stencil = editor.GetChildAt(0u);
2412 // Highlight needs to be drawn before text, so should come first in child order
2413 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2414 DALI_TEST_CHECK(highlight);
2416 // The stencil actor has a container with all the actors which contain the text renderers.
2417 Actor container = stencil.GetChildAt(1u);
2418 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2420 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2421 DALI_TEST_CHECK(renderer);
2424 // Double tap out of bounds
2425 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2426 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2428 // Render and notify
2429 application.SendNotification();
2430 application.Render();
2432 // The stencil actor should have one actors: the renderer actor.
2433 stencil = editor.GetChildAt(0u);
2435 // The stencil actor has a container with all the actors which contain the text renderers.
2436 container = stencil.GetChildAt(0u);
2437 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2439 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2440 DALI_TEST_CHECK(renderer);
2444 TestGenerateLongPress(application, 1.0f, 25.0f);
2446 // Render and notify
2447 application.SendNotification();
2448 application.Render();
2451 TestGenerateMiniPan(application);
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2460 int utcDaliTextEditorEvent04(void)
2462 ToolkitTestApplication application;
2463 tet_infoline(" utcDaliTextEditorEvent04");
2465 // Checks if the highlight actor is created.
2467 TextEditor editor = TextEditor::New();
2468 DALI_TEST_CHECK(editor);
2470 application.GetScene().Add(editor);
2472 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2473 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2474 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2475 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2476 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2478 // Avoid a crash when core load gl resources.
2479 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2485 // Tap on the text editor
2486 TestGenerateTap(application, 3.0f, 25.0f);
2488 // Render and notify
2489 application.SendNotification();
2490 application.Render();
2492 // Move at the end of the text.
2493 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2494 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 for(unsigned int index = 0u; index < 10u; ++index)
2502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2511 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2513 // Render and notify
2514 application.SendNotification();
2515 application.Render();
2517 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2519 // Add some key events
2520 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 for(unsigned int index = 0u; index < 10u; ++index)
2529 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2530 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2532 // Render and notify
2533 application.SendNotification();
2534 application.Render();
2538 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2549 int utcDaliTextEditorEvent05(void)
2551 ToolkitTestApplication application;
2552 tet_infoline(" utcDaliTextEditorEvent05");
2554 // Checks if the highlight actor is created.
2556 TextEditor editor = TextEditor::New();
2557 DALI_TEST_CHECK(editor);
2559 application.GetScene().Add(editor);
2561 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2562 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2563 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2564 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2565 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2566 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2567 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2568 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2569 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2570 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2572 // Avoid a crash when core load gl resources.
2573 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2579 // Tap on the text editor
2580 TestGenerateTap(application, 3.0f, 25.0f);
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 // Move at the end of the text.
2587 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2588 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2590 // Render and notify
2591 application.SendNotification();
2592 application.Render();
2594 for(unsigned int index = 0u; index < 10u; ++index)
2597 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2599 // Render and notify
2600 application.SendNotification();
2601 application.Render();
2603 // Modify duration after scroll is enabled
2604 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2606 // Continuous scroll left to increase coverage
2607 for(unsigned int index = 0u; index < 10u; ++index)
2609 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2615 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2616 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2617 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2618 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2619 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2621 // Press Escape to increase coverage
2622 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2623 application.SendNotification();
2624 application.Render();
2626 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2631 int utcDaliTextEditorEvent06(void)
2633 ToolkitTestApplication application;
2634 tet_infoline(" utcDaliTextEditorEvent06");
2636 // Checks if the highlight actor is created.
2638 TextEditor editor = TextEditor::New();
2639 DALI_TEST_CHECK(editor);
2641 application.GetScene().Add(editor);
2643 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2644 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2645 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2646 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2647 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2649 // Avoid a crash when core load gl resources.
2650 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 // Tap on the text editor
2657 TestGenerateTap(application, 3.0f, 25.0f);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Move to seconds line of the text.
2664 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2666 // Render and notify
2667 application.SendNotification();
2668 application.Render();
2670 float layoutHeight = editor.GetHeightForWidth(100.f);
2672 // Add another script characters ( glyph height is defferent )
2673 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2674 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2676 // Delete characters
2677 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2678 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2680 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2682 // Render and notify
2683 application.SendNotification();
2684 application.Render();
2686 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2689 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2690 application.SendNotification();
2691 application.Render();
2693 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2694 application.SendNotification();
2695 application.Render();
2697 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2698 application.SendNotification();
2699 application.Render();
2701 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2702 application.SendNotification();
2703 application.Render();
2705 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2706 application.SendNotification();
2707 application.Render();
2709 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2710 application.SendNotification();
2711 application.Render();
2713 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2714 application.SendNotification();
2715 application.Render();
2720 int utcDaliTextEditorEvent07(void)
2722 ToolkitTestApplication application;
2723 tet_infoline(" utcDaliTextEditorEvent07");
2725 // Checks if the highlight actor is created.
2727 TextEditor editor = TextEditor::New();
2728 DALI_TEST_CHECK(editor);
2730 application.GetScene().Add(editor);
2732 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2733 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2734 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2735 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2736 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2738 // Avoid a crash when core load gl resources.
2739 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2741 // Render and notify
2742 application.SendNotification();
2743 application.Render();
2745 // Tap on the text editor
2746 TestGenerateTap(application, 3.0f, 25.0f);
2748 // Render and notify
2749 application.SendNotification();
2750 application.Render();
2752 // Move to second line of the text.
2753 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 // Select some text in the right of the current cursor position
2760 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2761 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2762 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2763 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2765 // Render and notify
2766 application.SendNotification();
2767 application.Render();
2769 // Cut the selected text
2770 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2771 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));
2773 // Render and notify
2774 application.SendNotification();
2775 application.Render();
2777 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2779 // Select some text in the left of the current cursor position
2780 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2782 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2783 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2785 // Render and notify
2786 application.SendNotification();
2787 application.Render();
2789 // Copy the selected text
2790 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2791 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));
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2797 // Move the cursor to the third line
2798 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2801 // Render and notify
2802 application.SendNotification();
2803 application.Render();
2805 // Paste the selected text at the current cursor position
2806 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2807 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));
2809 // Render and notify
2810 application.SendNotification();
2811 application.Render();
2813 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2815 // Disable Shift Selection
2816 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2818 // Test to select some text in the right of the current cursor position
2819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2821 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2822 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2824 // Render and notify
2825 application.SendNotification();
2826 application.Render();
2828 // Cut the selected text
2829 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2830 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));
2832 // Render and notify
2833 application.SendNotification();
2834 application.Render();
2836 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2837 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2839 // Test to select some text in the left of the current cursor position
2840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2841 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2842 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2843 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2849 // Copy the selected text
2850 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2851 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));
2853 // Render and notify
2854 application.SendNotification();
2855 application.Render();
2857 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2858 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2861 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));
2863 // Render and notify
2864 application.SendNotification();
2865 application.Render();
2867 // replace text with "c"
2868 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2870 // Render and notify
2871 application.SendNotification();
2872 application.Render();
2875 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2878 DevelTextEditor::SelectWholeText(editor);
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 // Copy the selected text using logical keys
2885 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2886 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2888 // Render and notify
2889 application.SendNotification();
2890 application.Render();
2893 DevelTextEditor::SelectNone(editor);
2895 // Render and notify
2896 application.SendNotification();
2897 application.Render();
2899 // Paste the selected using logical keys
2900 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2901 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2904 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2906 // select all using logical keys
2907 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2908 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2910 // Render and notify
2911 application.SendNotification();
2912 application.Render();
2914 // cut text using logical keys
2915 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2916 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2923 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2928 int utcDaliTextEditorEvent08(void)
2930 ToolkitTestApplication application;
2931 tet_infoline(" utcDaliTextEditorEvent08");
2933 // Checks if the highlight actor is released correctly.
2935 TextEditor editor = TextEditor::New();
2936 DALI_TEST_CHECK(editor);
2938 application.GetScene().Add(editor);
2940 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2941 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2942 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2943 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2944 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2946 // Avoid a crash when core load gl resources.
2947 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 // Tap on the text editor
2954 TestGenerateTap(application, 3.0f, 25.0f);
2956 // Render and notify
2957 application.SendNotification();
2958 application.Render();
2960 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2961 // Test to select some text in the left of the current cursor position
2962 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2963 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2964 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2965 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2967 // Render and notify
2968 application.SendNotification();
2969 application.Render();
2971 // Test to the left selection handle position and the right selection handle position
2972 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2973 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2974 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2975 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2977 // Render and notify
2978 application.SendNotification();
2979 application.Render();
2981 // Test to select full text in the left of the current cursor position
2982 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2983 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2984 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2985 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2986 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2987 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2989 // Render and notify
2990 application.SendNotification();
2991 application.Render();
2993 // Test to release the current full text selection
2994 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2995 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2997 // Render and notify
2998 application.SendNotification();
2999 application.Render();
3001 // Test to move the current cursor position correctly
3002 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3004 // Render and notify
3005 application.SendNotification();
3006 application.Render();
3009 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3011 // Render and notify
3012 application.SendNotification();
3013 application.Render();
3015 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3017 // Test to select some text in the right of the current cursor position
3018 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3019 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3020 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Test the cursor position with right arrow key
3027 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3034 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3042 // Test to select some text in the left of the current cursor position
3043 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3044 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3046 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3047 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3049 // Render and notify
3050 application.SendNotification();
3051 application.Render();
3053 // Test the cursor position with left arrow key
3054 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3056 // Render and notify
3057 application.SendNotification();
3058 application.Render();
3061 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3063 // Render and notify
3064 application.SendNotification();
3065 application.Render();
3067 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3069 // Test to select some text in the right of the current cursor position
3070 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3071 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3072 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3073 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3075 // Render and notify
3076 application.SendNotification();
3077 application.Render();
3079 // Test the cursor position with left arrow key
3080 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3082 // Render and notify
3083 application.SendNotification();
3084 application.Render();
3087 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3089 // Render and notify
3090 application.SendNotification();
3091 application.Render();
3093 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3095 // Test to select some text in the left of the current cursor position
3096 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3097 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3098 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3099 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3101 // Render and notify
3102 application.SendNotification();
3103 application.Render();
3105 // Test the cursor position with right arrow key
3106 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3108 // Render and notify
3109 application.SendNotification();
3110 application.Render();
3113 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3124 int utcDaliTextEditorHandles(void)
3126 ToolkitTestApplication application;
3127 tet_infoline(" utcDaliTextEditorHandles");
3129 TextEditor editor = TextEditor::New();
3130 DALI_TEST_CHECK(editor);
3132 application.GetScene().Add(editor);
3134 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3135 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3136 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3137 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3139 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3140 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3141 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3142 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3144 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3145 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3146 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3148 // Avoid a crash when core load gl resources.
3149 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3151 // Render and notify
3152 application.SendNotification();
3153 application.Render();
3155 // Tap first to get the focus.
3156 TestGenerateTap(application, 3.0f, 25.0f, 100);
3158 // Render and notify
3159 application.SendNotification();
3160 application.Render();
3162 // Tap to create the grab handle.
3163 TestGenerateTap(application, 3.0f, 25.0f, 700);
3165 // Render and notify
3166 application.SendNotification();
3167 application.Render();
3169 // Get the active layer where the text's decoration is added.
3170 Actor activeLayer = editor.GetChildAt(1u);
3172 // Get the handle's actor.
3173 Actor handle = activeLayer.GetChildAt(0u);
3174 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3176 // Render and notify
3177 application.SendNotification();
3178 application.Render();
3180 // Touch the grab handle to set it as pressed.
3181 Vector2 touchPos(10.0f, 50.0f);
3182 Dali::Integration::TouchEvent event;
3183 event = Dali::Integration::TouchEvent();
3184 event.AddPoint(GetPointDownInside(touchPos));
3185 application.ProcessEvent(event);
3187 // Render and notify
3188 application.SendNotification();
3189 application.Render();
3191 // Pan the grab handle
3192 uint32_t time = 100;
3193 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3194 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3195 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3196 application.SendNotification();
3197 application.Render();
3199 // Release the grab handle.
3200 event = Dali::Integration::TouchEvent();
3201 event.AddPoint(GetPointUpInside(touchPos));
3202 application.ProcessEvent(event);
3204 // Render and notify
3205 application.SendNotification();
3206 application.Render();
3208 // Tap first to get the focus.
3209 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3211 // Render and notify
3212 application.SendNotification();
3213 application.Render();
3215 // Double tap to select a word and create the selection handles.
3216 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3218 // Render and notify
3219 application.SendNotification();
3220 application.Render();
3222 touchPos = Vector2(10.0f, 50.0f);
3224 // Touch the left selection handle to set it as pressed.
3225 event = Dali::Integration::TouchEvent();
3226 event.AddPoint(GetPointDownInside(touchPos));
3227 application.ProcessEvent(event);
3229 // Render and notify
3230 application.SendNotification();
3231 application.Render();
3233 // Release the left selection handle.
3234 event = Dali::Integration::TouchEvent();
3235 event.AddPoint(GetPointUpInside(touchPos));
3236 application.ProcessEvent(event);
3238 // Render and notify
3239 application.SendNotification();
3240 application.Render();
3245 int utcDaliTextEditorUnderPropertyStringP(void)
3247 ToolkitTestApplication application;
3248 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3249 TextEditor editor = TextEditor::New();
3250 DALI_TEST_CHECK(editor);
3252 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3254 application.GetScene().Add(editor);
3256 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3257 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3259 tet_infoline("Set underline settings with a map");
3260 // Check the input underline property
3261 Property::Map underlineMapSet;
3262 Property::Map underlineMapGet;
3263 underlineMapSet.Insert("enable", true);
3264 underlineMapSet.Insert("color", Color::BLUE);
3265 underlineMapSet.Insert("height", 1);
3266 underlineMapSet.Insert("type", Text::Underline::SOLID);
3267 underlineMapSet.Insert("dashWidth", 2);
3268 underlineMapSet.Insert("dashGap", 1);
3270 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3271 editor.SetProperty(TextEditor::Property::TEXT, "text");
3272 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3273 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3274 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3276 application.SendNotification();
3277 application.Render();
3279 underlineMapSet.Clear();
3280 underlineMapGet.Clear();
3282 tet_infoline("Set dashed underline settings with a map");
3283 // Check the input underline property
3284 underlineMapSet.Clear();
3285 underlineMapGet.Clear();
3286 underlineMapSet.Insert("enable", true);
3287 underlineMapSet.Insert("color", Color::BLUE);
3288 underlineMapSet.Insert("height", 1);
3289 underlineMapSet.Insert("type", Text::Underline::DASHED);
3290 underlineMapSet.Insert("dashWidth", 5);
3291 underlineMapSet.Insert("dashGap", 3);
3293 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3294 editor.SetProperty(TextEditor::Property::TEXT, "text");
3295 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3296 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3297 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3299 // Check the input underline property
3300 underlineMapSet.Clear();
3301 underlineMapGet.Clear();
3302 underlineMapSet.Insert("enable", true);
3303 underlineMapSet.Insert("color", Color::BLUE);
3304 underlineMapSet.Insert("height", 1);
3305 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3306 underlineMapSet.Insert("dashWidth", 5);
3307 underlineMapSet.Insert("dashGap", 3);
3309 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3310 editor.SetProperty(TextEditor::Property::TEXT, "text");
3311 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3312 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3313 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3315 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3316 editor.SetProperty(TextEditor::Property::TEXT, "text");
3317 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3318 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3319 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3321 application.SendNotification();
3322 application.Render();
3324 underlineMapSet.Clear();
3325 underlineMapGet.Clear();
3327 tet_infoline("Set underline settings with a string");
3328 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3329 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3332 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3334 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3335 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3336 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3337 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3339 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3344 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3346 ToolkitTestApplication application;
3347 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3348 TextEditor editor = TextEditor::New();
3349 DALI_TEST_CHECK(editor);
3351 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3353 application.GetScene().Add(editor);
3355 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3356 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3358 tet_infoline("Set strikethrough settings with a map");
3359 // Check the input strikethrough property
3360 Property::Map strikethroughMapSet;
3361 Property::Map strikethroughMapGet;
3362 strikethroughMapSet.Insert("enable", true);
3363 strikethroughMapSet.Insert("color", Color::BLUE);
3364 strikethroughMapSet.Insert("height", 2.0f);
3366 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3367 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3368 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3369 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3371 tet_infoline("Set strikethrough settings with a string");
3372 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3373 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3376 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3378 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3379 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3380 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3381 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3383 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3388 int utcDaliTextEditorShadowPropertyStringP(void)
3390 ToolkitTestApplication application;
3391 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3393 TextEditor editor = TextEditor::New();
3395 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3397 application.GetScene().Add(editor);
3399 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3401 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3405 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3410 int utcDaliTextEditorFontStylePropertyStringP(void)
3412 ToolkitTestApplication application;
3413 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3415 TextEditor editor = TextEditor::New();
3417 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3419 application.GetScene().Add(editor);
3421 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3423 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3427 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3432 int utcDaliTextEditorGetPropertyLinecountP(void)
3434 ToolkitTestApplication application;
3436 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3440 TextEditor editor = TextEditor::New();
3441 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3442 editor.SetProperty(TextEditor::Property::TEXT,
3443 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3445 application.GetScene().Add(editor);
3447 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3448 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3449 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3451 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3452 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3453 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3458 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3460 ToolkitTestApplication application;
3461 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3463 TextEditor editor = TextEditor::New();
3464 DALI_TEST_CHECK(editor);
3466 application.GetScene().Add(editor);
3468 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3469 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3470 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3471 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3472 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3473 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3475 bool startedCalled = false;
3476 bool finishedCalled = false;
3478 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3479 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3481 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3483 // Render and notify
3484 application.SendNotification();
3485 application.Render();
3487 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3488 application.SendNotification();
3489 application.Render(6000);
3491 application.SendNotification();
3492 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3493 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3498 int UtcDaliToolkitTextEditorTextWrapMode(void)
3500 ToolkitTestApplication application;
3501 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3505 TextEditor editor = TextEditor::New();
3506 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3507 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3509 application.GetScene().Add(editor);
3511 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3512 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3514 application.SendNotification();
3515 application.Render();
3517 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3518 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3520 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3521 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3523 application.SendNotification();
3524 application.Render();
3526 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3527 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3529 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3530 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3532 application.SendNotification();
3533 application.Render();
3535 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3536 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3538 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3539 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3541 application.SendNotification();
3542 application.Render();
3544 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3545 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3550 int UtcDaliTextEditorSetPaddingProperty(void)
3552 ToolkitTestApplication application;
3553 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3555 TextEditor editor = TextEditor::New();
3556 DALI_TEST_CHECK(editor);
3557 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3558 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3559 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3560 application.GetScene().Add(editor);
3562 application.SendNotification();
3563 application.Render();
3565 Vector3 originalSize = editor.GetNaturalSize();
3567 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3569 application.SendNotification();
3570 application.Render();
3572 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3574 Vector3 paddingAddedSize = editor.GetNaturalSize();
3576 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3578 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3583 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3585 ToolkitTestApplication application;
3586 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3588 TextEditor editor = TextEditor::New();
3589 DALI_TEST_CHECK(editor);
3590 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3591 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3592 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3593 application.GetScene().Add(editor);
3595 application.SendNotification();
3596 application.Render();
3598 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3599 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3601 // Check the enable shift selection property
3602 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3603 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3605 application.SendNotification();
3606 application.Render();
3611 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3613 ToolkitTestApplication application;
3614 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3616 TextEditor editor = TextEditor::New();
3617 DALI_TEST_CHECK(editor);
3618 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3619 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3620 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3621 application.GetScene().Add(editor);
3623 application.SendNotification();
3624 application.Render();
3626 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3627 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3629 // Check the enable grab handle property
3630 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3631 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3633 application.SendNotification();
3634 application.Render();
3639 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3641 ToolkitTestApplication application;
3642 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3644 TextEditor editor = TextEditor::New();
3645 DALI_TEST_CHECK(editor);
3646 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3647 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3648 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3649 application.GetScene().Add(editor);
3651 application.SendNotification();
3652 application.Render();
3654 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3655 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3657 // Check the disable match system language direction property
3658 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3659 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3661 application.SendNotification();
3662 application.Render();
3667 int UtcDaliTextEditorGetInputMethodContext(void)
3669 ToolkitTestApplication application;
3670 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3672 TextEditor editor = TextEditor::New();
3673 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3678 int utcDaliTextEditorMaxCharactersReached(void)
3680 ToolkitTestApplication application;
3681 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3683 TextEditor editor = TextEditor::New();
3684 DALI_TEST_CHECK(editor);
3686 application.GetScene().Add(editor);
3688 const int maxNumberOfCharacters = 1;
3689 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3690 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3692 editor.SetKeyInputFocus();
3694 // connect to the text changed signal.
3695 ConnectionTracker* testTracker = new ConnectionTracker();
3696 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3697 bool maxLengthReachedSignal = false;
3698 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3700 gMaxCharactersCallBackCalled = false;
3702 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3703 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3705 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3706 DALI_TEST_CHECK(maxLengthReachedSignal);
3711 int utcDaliTextEditorInputFiltered(void)
3713 ToolkitTestApplication application;
3714 tet_infoline(" utcDaliTextEditorInputFiltered");
3715 TextEditor editor = TextEditor::New();
3716 DALI_TEST_CHECK(editor);
3718 application.GetScene().Add(editor);
3720 Property::Map inputFilter;
3722 // Only digit is accepted.
3723 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3725 // Set input filter to TextEditor.
3726 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3728 editor.SetKeyInputFocus();
3730 // connect to the input filtered signal.
3731 ConnectionTracker* testTracker = new ConnectionTracker();
3732 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3733 bool inputFilteredSignal = false;
3734 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3736 gInputFilteredAcceptedCallbackCalled = false;
3738 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3740 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3741 DALI_TEST_CHECK(inputFilteredSignal);
3743 // Word is rejected.
3744 inputFilter[InputFilter::Property::ACCEPTED] = "";
3745 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3747 // Set input filter to TextEditor.
3748 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3750 editor.SetKeyInputFocus();
3752 inputFilteredSignal = false;
3753 gInputFilteredRejectedCallbackCalled = false;
3755 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3757 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3758 DALI_TEST_CHECK(inputFilteredSignal);
3763 int UtcDaliTextEditorSelectWholeText(void)
3765 ToolkitTestApplication application;
3766 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3768 TextEditor textEditor = TextEditor::New();
3770 application.GetScene().Add(textEditor);
3772 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3773 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3774 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3776 // Avoid a crash when core load gl resources.
3777 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3779 application.SendNotification();
3780 application.Render();
3782 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3784 DevelTextEditor::SelectWholeText(textEditor);
3786 application.SendNotification();
3787 application.Render();
3789 // Nothing should have been selected. The number of children is still 1
3790 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3792 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3794 application.SendNotification();
3795 application.Render();
3797 DevelTextEditor::SelectWholeText(textEditor);
3799 application.SendNotification();
3800 application.Render();
3802 // Should be 2 children, the stencil and the layer
3803 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3805 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3806 Actor stencil = textEditor.GetChildAt(0u);
3808 // The highlight actor is drawn first, so is the first actor in the list
3809 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3810 DALI_TEST_CHECK(highlight);
3815 int UtcDaliTextEditorSelectText(void)
3817 ToolkitTestApplication application;
3818 tet_infoline(" UtcDaliTextEditorSelectText ");
3820 TextEditor textEditor = TextEditor::New();
3822 application.GetScene().Add(textEditor);
3824 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3825 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3826 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3828 // Avoid a crash when core load gl resources.
3829 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3831 application.SendNotification();
3832 application.Render();
3834 DevelTextEditor::SelectText(textEditor, 0, 5);
3836 application.SendNotification();
3837 application.Render();
3839 // Nothing is selected
3840 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3841 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3843 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3845 application.SendNotification();
3846 application.Render();
3848 DevelTextEditor::SelectText(textEditor, 0, 5);
3850 application.SendNotification();
3851 application.Render();
3853 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3854 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3856 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3857 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3859 // world is selected
3860 DevelTextEditor::SelectText(textEditor, 6, 11);
3862 application.SendNotification();
3863 application.Render();
3865 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3866 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3868 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3869 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3874 int UtcDaliTextEditorSelectNone(void)
3876 ToolkitTestApplication application;
3877 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3879 TextEditor textEditor = TextEditor::New();
3881 application.GetScene().Add(textEditor);
3883 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3884 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3885 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3887 // Avoid a crash when core load gl resources.
3888 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3890 application.SendNotification();
3891 application.Render();
3893 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3895 application.SendNotification();
3896 application.Render();
3898 // Nothing is selected
3899 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3900 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3902 DevelTextEditor::SelectWholeText(textEditor);
3904 application.SendNotification();
3905 application.Render();
3907 // whole text is selected
3908 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3909 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3911 DevelTextEditor::SelectNone(textEditor);
3913 application.SendNotification();
3914 application.Render();
3916 // Nothing is selected
3917 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3918 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3923 int UtcDaliTextEditorSelectRange(void)
3925 ToolkitTestApplication application;
3926 tet_infoline("utcDaliTextEditorSelectRange");
3928 TextEditor textEditor = TextEditor::New();
3929 DALI_TEST_CHECK(textEditor);
3931 application.GetScene().Add(textEditor);
3933 // Avoid a crash when core load gl resources.
3934 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3936 application.SendNotification();
3937 application.Render();
3939 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3941 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3942 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3944 // Hello is selected
3945 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3946 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3948 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3949 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3954 int UtcDaliTextEditorEnableEditing(void)
3956 ToolkitTestApplication application;
3957 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3959 TextEditor textEditor = TextEditor::New();
3961 application.GetScene().Add(textEditor);
3963 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3964 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3965 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3967 // Avoid a crash when core load gl resources.
3968 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3970 application.SendNotification();
3971 application.Render();
3973 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3974 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3976 textEditor.SetKeyInputFocus();
3977 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3978 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3980 // Render and notify
3981 application.SendNotification();
3982 application.Render();
3984 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3985 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3987 textEditor.SetKeyInputFocus();
3988 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3989 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3991 // Render and notify
3992 application.SendNotification();
3993 application.Render();
3995 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3996 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3998 // Check the user interaction enabled and for coverage
3999 DevelTextEditor::SelectWholeText(textEditor);
4001 // Render and notify
4002 application.SendNotification();
4003 application.Render();
4005 textEditor.SetKeyInputFocus();
4006 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4007 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4009 // Render and notify
4010 application.SendNotification();
4011 application.Render();
4013 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4014 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4019 int UtcDaliTextEditorScrolling(void)
4021 ToolkitTestApplication application;
4022 tet_infoline(" UtcDaliTextEditorScrolling ");
4024 TextEditor textEditor = TextEditor::New();
4025 DALI_TEST_CHECK(textEditor);
4027 application.GetScene().Add(textEditor);
4029 // Avoid a crash when core load gl resources.
4030 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4032 application.SendNotification();
4033 application.Render();
4035 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4036 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4037 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4038 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4040 application.SendNotification();
4041 application.Render();
4043 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4044 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4046 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4048 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4049 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4051 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4053 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4054 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4056 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4057 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4059 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4060 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4065 int UtcDaliToolkitTextEditorFontSizeScale(void)
4067 ToolkitTestApplication application;
4068 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4070 TextEditor textEditor = TextEditor::New();
4071 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4072 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4073 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4075 TextEditor textEditorScaled = TextEditor::New();
4076 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4077 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4078 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4079 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4081 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4083 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4084 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4085 nonScaledSize = textEditor.GetNaturalSize();
4087 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4088 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4089 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4090 scaledSize = textEditorScaled.GetNaturalSize();
4092 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4097 int UtcDaliTextEditorPrimaryCursorPosition(void)
4099 ToolkitTestApplication application;
4100 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4102 TextEditor textEditor = TextEditor::New();
4104 application.GetScene().Add(textEditor);
4106 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4107 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4108 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4109 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4111 // Avoid a crash when core load gl resources.
4112 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4114 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4115 application.SendNotification();
4116 application.Render();
4117 textEditor.SetKeyInputFocus();
4119 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4121 // Render and notify
4122 application.SendNotification();
4123 application.Render();
4125 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4126 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4131 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4133 ToolkitTestApplication application;
4134 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4136 TextEditor textEditor = TextEditor::New();
4137 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4138 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4139 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4140 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4141 application.GetScene().Add(textEditor);
4143 application.SendNotification();
4144 application.Render();
4147 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4148 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4150 textEditor.GetNaturalSize();
4152 // Create a tap event to touch the text editor.
4153 TestGenerateTap(application, 18.0f, 25.0f);
4155 application.SendNotification();
4156 application.Render();
4158 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4159 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4164 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4166 ToolkitTestApplication application;
4168 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4170 int lineCountBefore = 0;
4171 int lineCountAfter = 0;
4173 // Create a text editor
4174 TextEditor textEditor = TextEditor::New();
4175 //Set very large font-size using point-size
4176 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4177 //Specify font-family
4178 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4180 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4181 //Set text longer than width of textEditor
4182 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4184 application.GetScene().Add(textEditor);
4186 application.SendNotification();
4187 application.Render();
4189 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
4190 //GetHeightForWidth is a retrieval method which should not modify object
4191 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4192 textEditor.GetHeightForWidth(200.f);
4194 //This is to simulate focus into text editor after calling GetHeightForWidth
4195 //Create a tap event to touch the text editor.
4196 TestGenerateTap(application, 18.0f, 25.0f);
4198 application.SendNotification();
4199 application.Render();
4201 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4203 //The LineCount must not be changed when calling GetHeightForWidth.
4204 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4209 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4211 ToolkitTestApplication application;
4213 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
4215 int lineCountBefore = 0;
4216 int lineCountAfter = 0;
4218 // Create a text editor
4219 TextEditor textEditor = TextEditor::New();
4220 //Set very large font-size using point-size
4221 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4222 //Specify font-family
4223 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4225 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4226 //Set text longer than width of textEditor
4227 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4228 //Set line wrap mode Character
4229 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4231 application.GetScene().Add(textEditor);
4233 application.SendNotification();
4234 application.Render();
4236 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4237 //GetHeightForWidth is a retrieval method which should not modify object
4238 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4239 textEditor.GetHeightForWidth(200.f);
4241 //This is to simulate focus into text editor after calling GetHeightForWidth
4242 //Create a tap event to touch the text editor.
4243 TestGenerateTap(application, 18.0f, 25.0f);
4245 application.SendNotification();
4246 application.Render();
4248 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4250 //The LineCount must not be changed when calling GetHeightForWidth.
4251 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4256 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4258 ToolkitTestApplication application;
4260 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4262 int lineCountBefore = 0;
4263 int lineCountAfter = 0;
4265 // Create a text editor
4266 TextEditor textEditor = TextEditor::New();
4267 //Set very large font-size using point-size
4268 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4269 //Specify font-family
4270 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4272 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4273 //Set text longer than width of textEditor
4274 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4275 //Set line wrap mode Character
4276 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4278 application.GetScene().Add(textEditor);
4280 application.SendNotification();
4281 application.Render();
4283 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4285 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4286 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4288 // When the text changed, the Line-count should be updated according to new text.
4289 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4290 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4291 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4296 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4298 ToolkitTestApplication application;
4300 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4302 int lineCountBefore = 0;
4303 int lineCountAfter = 0;
4305 // Create a text editor
4306 TextEditor textEditor = TextEditor::New();
4307 //Set very large font-size using point-size
4308 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4309 //Specify font-family
4310 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4312 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4313 //Set text longer than width of textEditor
4314 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4316 application.GetScene().Add(textEditor);
4318 application.SendNotification();
4319 application.Render();
4321 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4322 //GetNaturalSize is a retrieval method which should not modify object
4323 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4324 textEditor.GetNaturalSize();
4326 //This is to simulate focus into text editor after calling GetNaturalSize
4327 //Create a tap event to touch the text editor.
4328 TestGenerateTap(application, 18.0f, 25.0f);
4330 application.SendNotification();
4331 application.Render();
4333 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4335 //The LineCount must not be changed when calling GetNaturalSize.
4336 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4341 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4343 ToolkitTestApplication application;
4345 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4347 int lineCountBefore = 0;
4348 int lineCountAfter = 0;
4350 // Create a text editor
4351 TextEditor textEditor = TextEditor::New();
4352 //Set very large font-size using point-size
4353 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4354 //Specify font-family
4355 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4357 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4358 //Set text longer than width of textEditor
4359 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4360 //Set line wrap mode Character
4361 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4363 application.GetScene().Add(textEditor);
4365 application.SendNotification();
4366 application.Render();
4368 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4369 //GetNaturalSize is a retrieval method which should not modify object
4370 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4371 textEditor.GetNaturalSize();
4373 //This is to simulate focus into text editor after calling GetNaturalSize
4374 //Create a tap event to touch the text editor.
4375 TestGenerateTap(application, 18.0f, 25.0f);
4377 application.SendNotification();
4378 application.Render();
4380 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4382 //The LineCount must not be changed when calling GetNaturalSize.
4383 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4388 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4390 ToolkitTestApplication application;
4391 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4393 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4394 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4395 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4397 // Create a text editor
4398 TextEditor textEditor = TextEditor::New();
4400 //Set size to avoid automatic eliding
4401 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4402 //Set very large font-size using point-size
4403 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4404 //Specify font-family
4405 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4406 //Set text to check if appear or not
4407 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4409 application.GetScene().Add(textEditor);
4411 application.SendNotification();
4412 application.Render();
4413 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4414 Vector3 naturalSize = textEditor.GetNaturalSize();
4416 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4417 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4422 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4424 ToolkitTestApplication application;
4425 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4427 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4428 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4429 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4431 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4432 // Create a text editor
4433 TextEditor textEditor = TextEditor::New();
4434 //Set size to avoid automatic eliding
4435 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4436 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4437 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4439 const int numberOfCases = 6;
4440 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4442 for(int index = 0; index < numberOfCases; index++)
4444 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4445 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4446 application.GetScene().Add(textEditor);
4447 application.SendNotification();
4448 application.Render();
4449 naturalSize = textEditor.GetNaturalSize();
4450 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4451 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4457 int UtcDaliTextEditorHyphenWrapMode(void)
4459 ToolkitTestApplication application;
4460 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4463 TextEditor textEditor = TextEditor::New();
4465 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4467 application.GetScene().Add(textEditor);
4468 application.SendNotification();
4469 application.Render();
4471 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4472 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4473 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4475 application.SendNotification();
4476 application.Render();
4478 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4484 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4486 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4487 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4488 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4490 application.SendNotification();
4491 application.Render();
4493 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4500 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4505 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4507 ToolkitTestApplication application;
4508 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4509 TextEditor textEditor = TextEditor::New();
4511 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4512 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4514 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4515 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4516 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4518 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4519 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4520 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4522 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4523 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4524 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4526 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4527 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4528 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4530 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4531 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4532 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4534 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4535 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4536 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4538 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4539 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4540 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4542 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4543 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4544 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4546 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4547 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4548 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4550 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4551 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4552 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4554 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4555 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4556 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4558 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4559 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4560 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4565 int UtcDaliTextEditorCopyText(void)
4567 ToolkitTestApplication application;
4568 tet_infoline(" UtcDaliTextEditorCopyText ");
4570 TextEditor textEditor = TextEditor::New();
4572 std::string selectedText = "";
4573 std::string copiedText = "";
4575 application.GetScene().Add(textEditor);
4577 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4578 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4579 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4581 // Avoid a crash when core load gl resources.
4582 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4584 application.SendNotification();
4585 application.Render();
4587 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4589 application.SendNotification();
4590 application.Render();
4592 // Hello is selected
4593 DevelTextEditor::SelectText(textEditor, 0, 5);
4595 application.SendNotification();
4596 application.Render();
4598 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4599 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4601 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4602 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4605 copiedText = DevelTextEditor::CopyText(textEditor);
4606 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4608 // world is selected
4609 DevelTextEditor::SelectText(textEditor, 6, 11);
4611 application.SendNotification();
4612 application.Render();
4614 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4615 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4617 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4618 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4621 copiedText = DevelTextEditor::CopyText(textEditor);
4622 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4624 // "lo wo" is selected
4625 DevelTextEditor::SelectText(textEditor, 3, 8);
4627 application.SendNotification();
4628 application.Render();
4630 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4631 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4633 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4634 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4636 // "lo wo" is copied
4637 copiedText = DevelTextEditor::CopyText(textEditor);
4638 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4643 int UtcDaliTextEditorCutText(void)
4645 ToolkitTestApplication application;
4646 tet_infoline(" UtcDaliTextEditorCutText ");
4648 TextEditor textEditor = TextEditor::New();
4650 std::string selectedText = "";
4652 application.GetScene().Add(textEditor);
4654 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4655 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4656 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4658 // Avoid a crash when core load gl resources.
4659 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4661 application.SendNotification();
4662 application.Render();
4664 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4666 application.SendNotification();
4667 application.Render();
4669 // Hello is selected
4670 DevelTextEditor::SelectText(textEditor, 0, 5);
4672 application.SendNotification();
4673 application.Render();
4675 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4676 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4678 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4679 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4682 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4684 application.SendNotification();
4685 application.Render();
4687 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4690 DevelTextEditor::SelectText(textEditor, 0, 2);
4692 application.SendNotification();
4693 application.Render();
4695 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4696 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4698 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4699 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4702 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4704 application.SendNotification();
4705 application.Render();
4707 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4709 // Test Cut from the middle
4712 DevelTextEditor::SelectText(textEditor, 1, 3);
4714 application.SendNotification();
4715 application.Render();
4717 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4718 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4720 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4721 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4724 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4726 application.SendNotification();
4727 application.Render();
4729 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4731 // Test Cut from the end
4734 DevelTextEditor::SelectText(textEditor, 1, 2);
4736 application.SendNotification();
4737 application.Render();
4739 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4740 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4742 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4743 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4746 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4748 application.SendNotification();
4749 application.Render();
4751 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4756 int UtcDaliTextEditorPasteText(void)
4758 ToolkitTestApplication application;
4759 tet_infoline(" UtcDaliTextEditorPasteText ");
4761 TextEditor editor = TextEditor::New();
4762 DALI_TEST_CHECK(editor);
4764 application.GetScene().Add(editor);
4766 std::string cutText = "";
4767 std::string copiedText = "";
4769 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4770 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4771 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4772 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4773 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4775 // Avoid a crash when core load gl resources.
4776 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4778 // Render and notify
4779 application.SendNotification();
4780 application.Render();
4782 // Tap on the text editor
4783 TestGenerateTap(application, 3.0f, 25.0f);
4785 // Render and notify
4786 application.SendNotification();
4787 application.Render();
4789 // Move to second line of the text.
4790 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4792 // Render and notify
4793 application.SendNotification();
4794 application.Render();
4796 // Select some text in the right of the current cursor position
4797 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4798 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4800 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4802 // Render and notify
4803 application.SendNotification();
4804 application.Render();
4806 // Cut the selected text
4807 cutText = DevelTextEditor::CutText(editor);
4809 // Render and notify
4810 application.SendNotification();
4811 application.Render();
4813 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4814 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4816 // Select some text in the left of the current cursor position
4817 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4818 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4822 // Render and notify
4823 application.SendNotification();
4824 application.Render();
4826 // Copy the selected text
4827 copiedText = DevelTextEditor::CopyText(editor);
4829 // Render and notify
4830 application.SendNotification();
4831 application.Render();
4833 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4834 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4836 // Move the cursor to the third line
4837 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4838 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4840 // Render and notify
4841 application.SendNotification();
4842 application.Render();
4844 // Paste the selected text at the current cursor position
4845 DevelTextEditor::PasteText(editor);
4847 // Render and notify
4848 application.SendNotification();
4849 application.Render();
4851 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4856 int UtcDaliTextEditorLineSpacing(void)
4858 ToolkitTestApplication application;
4859 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4861 TextEditor textEditor = TextEditor::New();
4862 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4863 application.GetScene().Add(textEditor);
4864 application.SendNotification();
4865 application.Render();
4867 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4868 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4870 Vector3 sizeBefore = textEditor.GetNaturalSize();
4872 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4874 //add 20 for each line 20 * 3
4875 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4880 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4882 //Only for test coverage
4883 ToolkitTestApplication application;
4884 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4886 TextEditor textEditor = TextEditor::New();
4887 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4888 application.GetScene().Add(textEditor);
4889 application.SendNotification();
4890 application.Render();
4892 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4893 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4895 application.SendNotification();
4896 application.Render();
4898 DevelTextEditor::SelectWholeText(textEditor);
4900 application.SendNotification();
4901 application.Render();
4903 DevelTextEditor::SelectNone(textEditor);
4904 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4906 application.SendNotification();
4907 application.Render();
4909 DevelTextEditor::SelectWholeText(textEditor);
4911 application.SendNotification();
4912 application.Render();
4914 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4919 int UtcDaliTextEditorMinLineSize(void)
4921 ToolkitTestApplication application;
4922 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4924 TextEditor textEditor = TextEditor::New();
4925 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4926 application.GetScene().Add(textEditor);
4927 application.SendNotification();
4928 application.Render();
4930 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4931 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4933 Vector3 sizeBefore = textEditor.GetNaturalSize();
4935 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4937 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4940 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4945 int utcDaliTextEditorCursorPositionChangedSignal(void)
4947 ToolkitTestApplication application;
4948 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4950 TextEditor editor = TextEditor::New();
4951 DALI_TEST_CHECK(editor);
4953 application.GetScene().Add(editor);
4955 // connect to the selection changed signal.
4956 ConnectionTracker* testTracker = new ConnectionTracker();
4957 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4958 bool cursorPositionChangedSignal = false;
4959 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4961 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4962 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4963 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4964 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4965 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4967 // Avoid a crash when core load gl resources.
4968 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4970 // Render and notify
4971 application.SendNotification();
4972 application.Render();
4974 editor.SetKeyInputFocus();
4976 // Tap on the text editor
4977 TestGenerateTap(application, 3.0f, 25.0f);
4979 // Render and notify
4980 application.SendNotification();
4981 application.Render();
4983 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4984 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4986 gCursorPositionChangedCallbackCalled = false;
4989 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4991 // Render and notify
4992 application.SendNotification();
4993 application.Render();
4995 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4996 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4998 gCursorPositionChangedCallbackCalled = false;
5001 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5003 // Render and notify
5004 application.SendNotification();
5005 application.Render();
5007 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5008 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5010 gCursorPositionChangedCallbackCalled = false;
5012 //delete one character
5013 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5015 // Render and notify
5016 application.SendNotification();
5017 application.Render();
5019 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5020 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5022 gCursorPositionChangedCallbackCalled = false;
5024 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5026 // Render and notify
5027 application.SendNotification();
5028 application.Render();
5030 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5031 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5033 gCursorPositionChangedCallbackCalled = false;
5035 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5037 // Render and notify
5038 application.SendNotification();
5039 application.Render();
5041 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5042 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5047 int utcDaliTextEditorGeometryEllipsisStart(void)
5049 ToolkitTestApplication application;
5050 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5052 TextEditor editor = TextEditor::New();
5053 DALI_TEST_CHECK(editor);
5055 application.GetScene().Add(editor);
5057 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5058 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5059 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5060 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5061 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5062 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5063 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5064 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5065 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5067 // Avoid a crash when core load gl resources.
5068 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5070 // Render and notify
5071 application.SendNotification();
5072 application.Render();
5074 unsigned int expectedCount = 2;
5075 unsigned int startIndex = 0;
5076 unsigned int endIndex = 24;
5078 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5079 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5081 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5082 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5084 Vector<Vector2> expectedSizes;
5085 Vector<Vector2> expectedPositions;
5087 expectedPositions.PushBack(Vector2(38, 0));
5088 expectedSizes.PushBack(Vector2(21, 25));
5090 expectedPositions.PushBack(Vector2(-1, 25));
5091 expectedSizes.PushBack(Vector2(53, 25));
5093 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5098 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5100 ToolkitTestApplication application;
5101 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
5103 TextEditor editor = TextEditor::New();
5104 DALI_TEST_CHECK(editor);
5106 application.GetScene().Add(editor);
5108 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5109 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5110 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5111 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5112 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5113 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5114 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5115 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
5116 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5118 // Avoid a crash when core load gl resources.
5119 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5121 // Render and notify
5122 application.SendNotification();
5123 application.Render();
5125 unsigned int expectedCount = 2;
5126 unsigned int startIndex = 0;
5127 unsigned int endIndex = 24;
5129 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5130 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5132 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5133 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5135 Vector<Vector2> expectedSizes;
5136 Vector<Vector2> expectedPositions;
5138 expectedPositions.PushBack(Vector2(-1, 0));
5139 expectedSizes.PushBack(Vector2(26, 25));
5141 expectedPositions.PushBack(Vector2(-1, 25));
5142 expectedSizes.PushBack(Vector2(53, 25));
5144 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5149 int utcDaliTextEditorGeometryEllipsisEnd(void)
5151 ToolkitTestApplication application;
5152 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5154 TextEditor editor = TextEditor::New();
5155 DALI_TEST_CHECK(editor);
5157 application.GetScene().Add(editor);
5159 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5160 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5161 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5162 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5163 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5164 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5165 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5166 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5167 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5169 // Avoid a crash when core load gl resources.
5170 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5172 // Render and notify
5173 application.SendNotification();
5174 application.Render();
5176 unsigned int expectedCount = 2;
5177 unsigned int startIndex = 0;
5178 unsigned int endIndex = 24;
5180 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5181 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5183 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5184 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5186 Vector<Vector2> expectedSizes;
5187 Vector<Vector2> expectedPositions;
5189 expectedPositions.PushBack(Vector2(-1, 0));
5190 expectedSizes.PushBack(Vector2(60, 25));
5192 expectedPositions.PushBack(Vector2(-1, 25));
5193 expectedSizes.PushBack(Vector2(39, 25));
5195 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5200 int utcDaliTextEditorGeometryRTL(void)
5202 ToolkitTestApplication application;
5203 tet_infoline(" utcDaliTextEditorGeometryRTL");
5205 TextEditor editor = TextEditor::New();
5206 DALI_TEST_CHECK(editor);
5208 application.GetScene().Add(editor);
5210 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5211 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5212 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5213 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5214 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5215 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5217 // Avoid a crash when core load gl resources.
5218 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5220 // Render and notify
5221 application.SendNotification();
5222 application.Render();
5224 unsigned int expectedCount = 4;
5225 unsigned int startIndex = 3;
5226 unsigned int endIndex = 24;
5228 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5229 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5231 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5232 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5234 Vector<Vector2> expectedSizes;
5235 Vector<Vector2> expectedPositions;
5237 expectedPositions.PushBack(Vector2(25, 0));
5238 expectedSizes.PushBack(Vector2(34, 25));
5240 expectedPositions.PushBack(Vector2(-1, 25));
5241 expectedSizes.PushBack(Vector2(53, 25));
5243 expectedPositions.PushBack(Vector2(-1, 50));
5244 expectedSizes.PushBack(Vector2(60, 25));
5246 expectedPositions.PushBack(Vector2(63, 75));
5247 expectedSizes.PushBack(Vector2(37, 25));
5249 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5254 int utcDaliTextEditorGeometryGlyphMiddle(void)
5256 ToolkitTestApplication application;
5257 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5259 TextEditor editor = TextEditor::New();
5260 DALI_TEST_CHECK(editor);
5262 application.GetScene().Add(editor);
5264 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5265 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5266 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5267 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5268 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5269 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5271 // Avoid a crash when core load gl resources.
5272 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5274 // Render and notify
5275 application.SendNotification();
5276 application.Render();
5278 unsigned int expectedCount = 1;
5279 unsigned int startIndex = 1;
5280 unsigned int endIndex = 13;
5282 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5283 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5285 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5286 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5288 Vector<Vector2> expectedSizes;
5289 Vector<Vector2> expectedPositions;
5291 expectedPositions.PushBack(Vector2(6, 0));
5292 expectedSizes.PushBack(Vector2(125, 25));
5294 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5299 int utcDaliTextEditorGeometryOneGlyph(void)
5301 ToolkitTestApplication application;
5302 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5304 TextEditor label = TextEditor::New();
5305 DALI_TEST_CHECK(label);
5307 application.GetScene().Add(label);
5309 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5310 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5311 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5312 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5313 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5314 label.SetProperty(TextEditor::Property::TEXT, "H");
5316 // Avoid a crash when core load gl resources.
5317 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5319 // Render and notify
5320 application.SendNotification();
5321 application.Render();
5323 unsigned int expectedCount = 1;
5324 unsigned int startIndex = 0;
5325 unsigned int endIndex = 0;
5327 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5328 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5330 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5331 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5333 Vector<Vector2> expectedSizes;
5334 Vector<Vector2> expectedPositions;
5336 expectedPositions.PushBack(Vector2(-2, 0));
5337 expectedSizes.PushBack(Vector2(16, 25));
5339 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5344 int utcDaliTextEditorGeometryNullPtr(void)
5346 ToolkitTestApplication application;
5347 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5349 TextEditor editor = TextEditor::New();
5350 DALI_TEST_CHECK(editor);
5352 application.GetScene().Add(editor);
5354 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5355 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5356 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5357 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5358 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5359 editor.SetProperty(TextEditor::Property::TEXT, "");
5361 // Avoid a crash when core load gl resources.
5362 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5364 unsigned int expectedCount = 0;
5365 unsigned int startIndex = 0;
5366 unsigned int endIndex = 0;
5368 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5369 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5371 // Render and notify
5372 application.SendNotification();
5373 application.Render();
5375 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5376 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5381 int utcDaliTextEditorSelectionClearedSignal(void)
5383 ToolkitTestApplication application;
5384 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5386 TextEditor editor = TextEditor::New();
5387 DALI_TEST_CHECK(editor);
5389 application.GetScene().Add(editor);
5391 // connect to the selection changed signal.
5392 ConnectionTracker* testTracker = new ConnectionTracker();
5393 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5394 bool selectionClearedSignal = false;
5395 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5397 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5398 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5399 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5400 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5401 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5403 // Avoid a crash when core load gl resources.
5404 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5406 // Render and notify
5407 application.SendNotification();
5408 application.Render();
5410 // Tap on the text editor
5411 TestGenerateTap(application, 3.0f, 25.0f);
5413 // Render and notify
5414 application.SendNotification();
5415 application.Render();
5417 // Move to second line of the text & Select some text in the right of the current cursor position
5418 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5419 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5422 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5424 // Render and notify
5425 application.SendNotification();
5426 application.Render();
5428 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5430 // Render and notify
5431 application.SendNotification();
5432 application.Render();
5434 // Tap on the text editor
5435 TestGenerateTap(application, 3.0f, 25.0f);
5437 // Render and notify
5438 application.SendNotification();
5439 application.Render();
5441 gSelectionClearedCallbackCalled = false;
5443 // Move to second line of the text & select.
5444 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5445 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5448 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5450 // Render and notify
5451 application.SendNotification();
5452 application.Render();
5454 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5456 gSelectionClearedCallbackCalled = false;
5458 // Render and notify
5459 application.SendNotification();
5460 application.Render();
5462 // Move to second line of the text & select.
5463 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5464 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5466 // replace C with selected text
5467 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5469 // Render and notify
5470 application.SendNotification();
5471 application.Render();
5473 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5475 gSelectionClearedCallbackCalled = false;
5477 // Render and notify
5478 application.SendNotification();
5479 application.Render();
5481 DevelTextEditor::SelectText(editor, 1, 3);
5483 // Render and notify
5484 application.SendNotification();
5485 application.Render();
5487 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5489 // Render and notify
5490 application.SendNotification();
5491 application.Render();
5493 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5495 gSelectionClearedCallbackCalled = false;
5497 DevelTextEditor::SelectText(editor, 1, 3);
5499 // Render and notify
5500 application.SendNotification();
5501 application.Render();
5504 DevelTextEditor::SelectNone(editor);
5506 // Render and notify
5507 application.SendNotification();
5508 application.Render();
5510 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5515 int utcDaliTextEditorSelectionStartedSignal(void)
5517 ToolkitTestApplication application;
5518 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5520 TextEditor editor = TextEditor::New();
5521 DALI_TEST_CHECK(editor);
5523 application.GetScene().Add(editor);
5525 // connect to the selection changed signal.
5526 ConnectionTracker* testTracker = new ConnectionTracker();
5527 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5528 bool selectionStartedSignal = false;
5529 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5531 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5532 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5533 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5534 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5535 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5537 // Avoid a crash when core load gl resources.
5538 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5540 // Render and notify
5541 application.SendNotification();
5542 application.Render();
5544 // Tap on the text editor
5545 TestGenerateTap(application, 3.0f, 25.0f);
5547 // Render and notify
5548 application.SendNotification();
5549 application.Render();
5551 // Move to second line of the text & Select some text in the right of the current cursor position
5552 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5553 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5555 // Render and notify
5556 application.SendNotification();
5557 application.Render();
5559 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5562 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5564 // Render and notify
5565 application.SendNotification();
5566 application.Render();
5568 gSelectionStartedCallbackCalled = false;
5570 DevelTextEditor::SelectText(editor, 1, 3);
5572 // Render and notify
5573 application.SendNotification();
5574 application.Render();
5576 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5581 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5583 ToolkitTestApplication application;
5584 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5586 // Checks if the actor is created.
5588 TextEditor editor = TextEditor::New();
5589 DALI_TEST_CHECK(editor);
5591 application.GetScene().Add(editor);
5593 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5594 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5595 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5596 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5597 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5598 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5599 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5600 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5602 // Avoid a crash when core load gl resources.
5603 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5605 // Render and notify
5606 application.SendNotification();
5607 application.Render();
5609 // Tap on the text editor
5610 TestGenerateTap(application, 3.0f, 25.0f);
5612 // Render and notify
5613 application.SendNotification();
5614 application.Render();
5616 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5617 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5619 application.SendNotification();
5620 application.Render();
5622 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5623 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5628 int utcDaliTextEditorSelectionChangedSignal(void)
5630 ToolkitTestApplication application;
5631 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5633 TextEditor editor = TextEditor::New();
5634 DALI_TEST_CHECK(editor);
5636 application.GetScene().Add(editor);
5638 // connect to the selection changed signal.
5639 ConnectionTracker* testTracker = new ConnectionTracker();
5640 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5641 bool selectionChangedSignal = false;
5642 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5644 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5645 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5646 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5647 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5648 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5650 // Avoid a crash when core load gl resources.
5651 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5653 // Render and notify
5654 application.SendNotification();
5655 application.Render();
5657 // Tap on the text editor
5658 TestGenerateTap(application, 3.0f, 25.0f);
5660 // Render and notify
5661 application.SendNotification();
5662 application.Render();
5664 // Move to second line of the text.
5665 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5667 // Render and notify
5668 application.SendNotification();
5669 application.Render();
5671 // Select some text in the right of the current cursor position
5672 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5673 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5675 // Render and notify
5676 application.SendNotification();
5677 application.Render();
5679 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5680 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5682 gSelectionChangedCallbackCalled = false;
5684 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5686 // Render and notify
5687 application.SendNotification();
5688 application.Render();
5690 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5691 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5692 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5694 gSelectionChangedCallbackCalled = false;
5696 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5698 // Render and notify
5699 application.SendNotification();
5700 application.Render();
5702 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5703 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5704 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5706 gSelectionChangedCallbackCalled = false;
5707 editor.SetKeyInputFocus();
5709 // Render and notify
5710 application.SendNotification();
5711 application.Render();
5713 DevelTextEditor::SelectText(editor, 0, 5);
5715 application.SendNotification();
5716 application.Render();
5718 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5719 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5721 gSelectionChangedCallbackCalled = false;
5723 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5725 // Render and notify
5726 application.SendNotification();
5727 application.Render();
5729 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5730 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5731 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5733 gSelectionChangedCallbackCalled = false;
5736 DevelTextEditor::SelectWholeText(editor);
5738 // Render and notify
5739 application.SendNotification();
5740 application.Render();
5742 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5743 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5745 gSelectionChangedCallbackCalled = false;
5748 DevelTextEditor::SelectNone(editor);
5750 // Render and notify
5751 application.SendNotification();
5752 application.Render();
5754 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5755 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5756 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5761 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5763 ToolkitTestApplication application;
5764 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5766 TextEditor textEditor = TextEditor::New();
5767 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5768 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5769 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5770 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5772 application.GetScene().Add(textEditor);
5773 application.SendNotification();
5774 application.Render();
5776 Property::Map strikethroughMapSet;
5777 Property::Map strikethroughMapGet;
5779 strikethroughMapSet.Insert("enable", true);
5780 strikethroughMapSet.Insert("color", Color::RED);
5781 strikethroughMapSet.Insert("height", 2.0f);
5783 // Check the strikethrough property
5784 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5785 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5786 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5787 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5788 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5790 // Render and notify
5791 application.SendNotification();
5792 application.Render();
5794 strikethroughMapSet.Clear();
5795 strikethroughMapGet.Clear();
5800 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5802 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5803 //DaliException on vector: "Iterator not inside vector"
5805 ToolkitTestApplication application;
5806 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5808 TextEditor editor = TextEditor::New();
5809 DALI_TEST_CHECK(editor);
5811 application.GetScene().Add(editor);
5813 // Avoid a crash when core load gl resources.
5814 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5816 //Set multilines text
5817 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5818 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5819 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5821 //Set ResizePolicy to NaturalSize
5822 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5824 // Render and notify
5825 application.SendNotification();
5826 application.Render();
5828 // Create a tap event to touch the text editor.
5829 TestGenerateTap(application, 5.0f, 5.0f);
5831 // Render and notify
5832 application.SendNotification();
5833 application.Render();
5835 // Set currsor and add character (in first line)
5836 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5837 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5838 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5840 // Render and notify
5841 application.SendNotification();
5842 application.Render();
5844 //Check the changed text and cursor position
5845 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5846 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5848 // Render and notify
5849 application.SendNotification();
5850 application.Render();
5855 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5857 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5858 //DaliException on vector: "Iterator not inside vector"
5860 ToolkitTestApplication application;
5861 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5863 TextEditor editor = TextEditor::New();
5864 DALI_TEST_CHECK(editor);
5866 application.GetScene().Add(editor);
5868 // Avoid a crash when core load gl resources.
5869 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5871 //Set multilines text
5872 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5873 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5874 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5876 //Set ResizePolicy to NaturalSize
5877 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5880 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5881 application.SendNotification();
5882 application.Render();
5884 // Set focus and remove character
5885 editor.SetKeyInputFocus();
5886 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5888 // Render and notify
5889 application.SendNotification();
5890 application.Render();
5892 //Check the changed text and cursor position
5893 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5894 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5896 // Render and notify
5897 application.SendNotification();
5898 application.Render();
5903 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5905 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5906 //DaliException on vector: "Iterator not inside vector"
5908 ToolkitTestApplication application;
5909 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5911 TextEditor editor = TextEditor::New();
5912 DALI_TEST_CHECK(editor);
5914 application.GetScene().Add(editor);
5916 // Avoid a crash when core load gl resources.
5917 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5919 //Set multilines text
5920 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5921 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5922 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5924 //Set ResizePolicy to NaturalSize
5925 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5927 //Select text at initialization (before the first render)
5928 DevelTextEditor::SelectText(editor, 3, 5);
5930 // Render and notify
5931 application.SendNotification();
5932 application.Render();
5935 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5936 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));
5938 // Render and notify
5939 application.SendNotification();
5940 application.Render();
5942 //Check the changed text and cursor position
5943 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5944 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5946 // Render and notify
5947 application.SendNotification();
5948 application.Render();
5953 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5955 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5956 //DaliException on vector: "Iterator not inside vector"
5958 ToolkitTestApplication application;
5959 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5961 TextEditor editor = TextEditor::New();
5962 DALI_TEST_CHECK(editor);
5964 application.GetScene().Add(editor);
5966 // Avoid a crash when core load gl resources.
5967 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5969 //Set multilines text
5970 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5971 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5972 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5974 //Set ResizePolicy to NaturalSize
5975 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5978 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5979 application.SendNotification();
5980 application.Render();
5982 // Set focus and double enter (new line)
5983 editor.SetKeyInputFocus();
5984 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5985 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5987 // Render and notify
5988 application.SendNotification();
5989 application.Render();
5991 //Check the changed text and cursor position
5992 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5993 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5995 // Render and notify
5996 application.SendNotification();
5997 application.Render();
6002 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
6004 ToolkitTestApplication application;
6005 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
6006 TextEditor textEditor = TextEditor::New();
6007 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
6008 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6009 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6010 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6012 application.GetScene().Add(textEditor);
6013 application.SendNotification();
6014 application.Render();
6016 Property::Map underlineMapSet;
6017 Property::Map underlineMapGet;
6019 underlineMapSet.Insert("enable", true);
6020 underlineMapSet.Insert("color", Color::RED);
6021 underlineMapSet.Insert("height", 1);
6022 underlineMapSet.Insert("type", Text::Underline::SOLID);
6023 underlineMapSet.Insert("dashWidth", 2);
6024 underlineMapSet.Insert("dashGap", 1);
6026 // Check the underline property
6027 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6029 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6030 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6031 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6033 // Render and notify
6034 application.SendNotification();
6035 application.Render();
6037 underlineMapSet.Clear();
6038 underlineMapGet.Clear();
6040 underlineMapSet.Insert("enable", true);
6041 underlineMapSet.Insert("color", Color::BLUE);
6042 underlineMapSet.Insert("height", 1);
6043 underlineMapSet.Insert("type", Text::Underline::DASHED);
6044 underlineMapSet.Insert("dashWidth", 4);
6045 underlineMapSet.Insert("dashGap", 2);
6047 // Check the dashed underline property
6048 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6050 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6051 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6052 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6054 // Render and notify
6055 application.SendNotification();
6056 application.Render();
6058 underlineMapSet.Clear();
6059 underlineMapGet.Clear();
6061 underlineMapSet.Insert("enable", true);
6062 underlineMapSet.Insert("color", Color::BLUE);
6063 underlineMapSet.Insert("height", 1);
6064 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6065 underlineMapSet.Insert("dashWidth", 4);
6066 underlineMapSet.Insert("dashGap", 2);
6068 // Check the dashed underline property
6069 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6071 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6072 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6073 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6075 // Render and notify
6076 application.SendNotification();
6077 application.Render();
6079 underlineMapSet.Clear();
6080 underlineMapGet.Clear();
6085 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6087 ToolkitTestApplication application;
6088 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6090 TextEditor textEditor1 = TextEditor::New();
6091 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6092 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6093 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6094 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6096 Property::Map underlineMapSet1;
6097 Property::Map underlineMapGet1;
6099 underlineMapSet1.Insert("enable", true);
6100 underlineMapSet1.Insert("color", Color::RED);
6101 underlineMapSet1.Insert("height", 1);
6102 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6103 underlineMapSet1.Insert("dashWidth", 2);
6104 underlineMapSet1.Insert("dashGap", 1);
6106 // Check the underline property
6107 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6109 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6110 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6111 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6113 application.GetScene().Add(textEditor1);
6114 application.SendNotification();
6115 application.Render();
6117 TextEditor textEditor2 = TextEditor::New();
6118 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6119 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6120 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6121 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6123 Property::Map underlineMapSet2;
6124 Property::Map underlineMapGet2;
6126 underlineMapSet2.Insert("enable", true);
6127 underlineMapSet2.Insert("color", Color::BLUE);
6128 underlineMapSet2.Insert("height", 1);
6129 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6130 underlineMapSet2.Insert("dashWidth", 4);
6131 underlineMapSet2.Insert("dashGap", 2);
6133 // Check the dashed underline property
6134 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6136 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6137 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6138 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6140 application.GetScene().Add(textEditor2);
6141 application.SendNotification();
6142 application.Render();
6144 TextEditor textEditor3 = TextEditor::New();
6145 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6146 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6147 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6148 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6150 Property::Map underlineMapSet3;
6151 Property::Map underlineMapGet3;
6153 underlineMapSet3.Insert("enable", true);
6154 underlineMapSet3.Insert("color", Color::BLUE);
6155 underlineMapSet3.Insert("height", 1);
6156 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6157 underlineMapSet3.Insert("dashWidth", 4);
6158 underlineMapSet3.Insert("dashGap", 2);
6160 // Check the dashed underline property
6161 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6163 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6164 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6165 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6167 application.GetScene().Add(textEditor3);
6168 application.SendNotification();
6169 application.Render();
6174 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6176 ToolkitTestApplication application;
6177 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6179 TextEditor textEditor1 = TextEditor::New();
6180 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6181 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6182 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6183 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6185 Property::Map underlineMapSet1;
6186 Property::Map underlineMapGet1;
6188 underlineMapSet1.Insert("enable", true);
6189 underlineMapSet1.Insert("color", Color::RED);
6190 underlineMapSet1.Insert("height", 1);
6191 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6192 underlineMapSet1.Insert("dashWidth", 2);
6193 underlineMapSet1.Insert("dashGap", 1);
6195 // Check the underline property
6196 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6197 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6199 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6200 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6201 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6203 application.GetScene().Add(textEditor1);
6205 application.SendNotification();
6206 application.Render();
6211 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6213 ToolkitTestApplication application;
6214 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6216 TextEditor editor = TextEditor::New();
6217 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6218 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6219 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6220 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6221 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6222 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6224 TextEditor editorSingleLineParagraph = TextEditor::New();
6225 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6226 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6227 editorSingleLineParagraph.SetProperty(TextEditor::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line 2</p>line 3<p rel-line-height=3>line 4</p>line 5");
6228 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6229 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6230 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6232 TextEditor editorMultiLineParagraph = TextEditor::New();
6233 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6234 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6235 editorMultiLineParagraph.SetProperty(TextEditor::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5");
6236 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6237 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6238 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6240 application.GetScene().Add(editor);
6241 application.GetScene().Add(editorSingleLineParagraph);
6242 application.GetScene().Add(editorMultiLineParagraph);
6243 application.SendNotification();
6244 application.Render();
6246 Vector3 naturalSize = editor.GetNaturalSize();
6247 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6248 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6250 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6252 //no effect of relative line size for paragraph with single line
6253 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6255 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6260 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6262 ToolkitTestApplication application;
6263 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6265 TextEditor editor = TextEditor::New();
6266 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6267 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6268 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6270 application.GetScene().Add(editor);
6271 application.SendNotification();
6272 application.Render();
6274 Vector3 naturalSize = editor.GetNaturalSize();
6276 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6278 application.SendNotification();
6279 application.Render();
6281 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6283 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6285 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6287 application.SendNotification();
6288 application.Render();
6290 relativeNaturalSize = editor.GetNaturalSize();
6292 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6296 int UtcDaliTextEditorCharacterSpacing(void)
6298 ToolkitTestApplication application;
6299 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6301 TextEditor textEditor = TextEditor::New();
6303 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6305 application.GetScene().Add(textEditor);
6306 application.SendNotification();
6307 application.Render();
6309 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6310 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6311 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6313 application.SendNotification();
6314 application.Render();
6319 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6321 ToolkitTestApplication application;
6322 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6324 TextEditor editor = TextEditor::New();
6326 float lineSpacing = -20.f;
6328 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6329 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6330 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6331 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6333 application.GetScene().Add(editor);
6334 application.SendNotification();
6335 application.Render();
6337 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6338 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6340 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6341 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6343 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6344 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6346 application.SendNotification();
6347 application.Render();
6352 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6354 ToolkitTestApplication application;
6355 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6357 TextEditor editor = TextEditor::New();
6358 DALI_TEST_CHECK(editor);
6360 application.GetScene().Add(editor);
6362 std::string cutText = "";
6363 std::string copiedText = "";
6365 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6366 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6367 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6368 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6369 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6370 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6371 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6373 // Render and notify
6374 application.SendNotification();
6375 application.Render();
6377 // Tap on the text editor
6378 TestGenerateTap(application, 1.0f, 1.0f);
6380 // Render and notify
6381 application.SendNotification();
6382 application.Render();
6384 // Move to second line of the text.
6385 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6387 // Render and notify
6388 application.SendNotification();
6389 application.Render();
6391 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6396 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6398 ToolkitTestApplication application;
6399 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6401 TextEditor editor = TextEditor::New();
6403 float lineSpacing = -20.f;
6405 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6406 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6407 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6408 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6409 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6411 application.GetScene().Add(editor);
6412 application.SendNotification();
6413 application.Render();
6415 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6417 int lineCount = sizeList.Size();
6418 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6420 application.SendNotification();
6421 application.Render();
6426 int UtcDaliToolkitTexteditorParagraphTag(void)
6428 ToolkitTestApplication application;
6429 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6430 TextEditor editorNewlineSeparator = TextEditor::New();
6431 TextEditor editorParagraphTag = TextEditor::New();
6432 DALI_TEST_CHECK(editorNewlineSeparator);
6433 DALI_TEST_CHECK(editorParagraphTag);
6435 application.GetScene().Add(editorNewlineSeparator);
6436 application.GetScene().Add(editorParagraphTag);
6438 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6439 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6440 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6441 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6442 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6443 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6445 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6446 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6447 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6448 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6449 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6451 application.SendNotification();
6452 application.Render();
6454 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6455 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6457 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6459 application.SendNotification();
6460 application.Render();
6465 //Handle Emoji clustering for cursor handling
6466 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6468 ToolkitTestApplication application;
6469 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6470 TextEditor textEditor = TextEditor::New();
6471 DALI_TEST_CHECK(textEditor);
6473 application.GetScene().Add(textEditor);
6475 // Avoid a crash when core load gl resources.
6476 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6478 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6479 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6481 // Render and notify
6482 application.SendNotification();
6483 application.Render();
6486 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6487 application.SendNotification();
6488 application.Render();
6490 // Set focus and remove Emoji
6491 textEditor.SetKeyInputFocus();
6492 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6494 //Check the changed text and cursor position
6495 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6496 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6498 // Render and notify
6499 application.SendNotification();
6500 application.Render();
6505 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6507 ToolkitTestApplication application;
6508 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6509 TextEditor textEditor = TextEditor::New();
6510 DALI_TEST_CHECK(textEditor);
6512 application.GetScene().Add(textEditor);
6514 // Avoid a crash when core load gl resources.
6515 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6517 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6518 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6520 // Render and notify
6521 application.SendNotification();
6522 application.Render();
6525 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6526 application.SendNotification();
6527 application.Render();
6529 // Set focus and remove Emoji
6530 textEditor.SetKeyInputFocus();
6531 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6533 //Check the changed text and cursor position
6534 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6535 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6537 // Render and notify
6538 application.SendNotification();
6539 application.Render();
6544 int utcDaliTextEditorPanGesturePropagation(void)
6546 ToolkitTestApplication application;
6547 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6549 Actor actor = Actor::New();
6550 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6551 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6552 application.GetScene().Add(actor);
6554 TextEditor editor = TextEditor::New();
6555 DALI_TEST_CHECK(editor);
6557 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6558 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6560 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6561 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6562 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6566 // Render and notify
6567 application.SendNotification();
6568 application.Render();
6571 GestureReceivedFunctor functor(data);
6573 PanGestureDetector detector = PanGestureDetector::New();
6574 detector.Attach(actor);
6575 detector.DetectedSignal().Connect(&application, functor);
6577 // Tap first to get the focus.
6578 TestGenerateTap(application, 3.0f, 25.0f, 100);
6580 // Render and notify
6581 application.SendNotification();
6582 application.Render();
6584 // Pan the text editor
6585 uint32_t time = 100;
6586 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6587 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6588 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6589 application.SendNotification();
6590 application.Render();
6592 // The text scrolls because there is text that is scrolling.
6593 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6596 // Set the size large enough to prevent scrolling.
6597 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6599 // Render and notify
6600 application.SendNotification();
6601 application.Render();
6604 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6605 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6606 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6608 // Because scrolling is not possible, the pan gesture is propagated.
6609 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6615 int utcDaliTextEditorGetTextBoundingRectangle(void)
6617 ToolkitTestApplication application;
6618 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6620 TextEditor editor = TextEditor::New();
6621 DALI_TEST_CHECK(editor);
6623 application.GetScene().Add(editor);
6625 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6626 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6627 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6628 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6629 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6631 // Avoid a crash when core load gl resources.
6632 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6634 // Render and notify
6635 application.SendNotification();
6636 application.Render();
6638 unsigned int startIndex = 0;
6639 unsigned int endIndex = 15;
6641 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6642 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6644 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6649 int utcDaliTextEditorRemoveFrontInset(void)
6651 ToolkitTestApplication application;
6652 tet_infoline(" utcDaliTextEditorRemoveFrontInset");
6653 TextEditor editor = TextEditor::New();
6654 DALI_TEST_CHECK(editor);
6655 application.GetScene().Add(editor);
6656 application.SendNotification();
6657 application.Render();
6658 DevelTextEditor::SetRemoveFrontInset(editor, false);
6659 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveFrontInset(editor));
6662 int utcDaliTextEditorRemoveBackInset(void)
6664 ToolkitTestApplication application;
6665 tet_infoline(" utcDaliTextEditorRemoveBackInset");
6666 TextEditor editor = TextEditor::New();
6667 DALI_TEST_CHECK(editor);
6668 application.GetScene().Add(editor);
6669 application.SendNotification();
6670 application.Render();
6671 DevelTextEditor::SetRemoveBackInset(editor, false);
6672 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveBackInset(editor));