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);
1046 outlineMapSet["blurRadius"] = 0.0f;
1048 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1050 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1051 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1052 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1054 // Check the input outline property
1055 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1056 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1058 // Check the smooth scroll property
1059 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1060 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1061 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1063 // Check the smooth scroll duration property
1064 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1065 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1067 // Check the scroll bar property
1068 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1069 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1070 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1072 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1073 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1074 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1075 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1077 // Check the pixel size of font
1078 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1079 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1081 // Check placeholder text properties.
1082 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1083 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1085 // Check placeholder text's color property.
1086 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1087 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1089 // Check the enable selection property
1090 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1091 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1093 // Check the placeholder property with pixel size
1094 Property::Map placeholderPixelSizeMapSet;
1095 Property::Map placeholderPixelSizeMapGet;
1096 Property::Map placeholderFontstyleMap;
1097 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1098 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1099 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1100 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1101 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1103 placeholderFontstyleMap.Insert("weight", "bold");
1104 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1105 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1107 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1108 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1110 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1111 Property::Map placeholderConversionMap;
1112 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1113 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1114 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1115 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1116 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1117 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1119 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1121 // Check the placeholder property with point size
1122 Property::Map placeholderMapSet;
1123 Property::Map placeholderMapGet;
1124 placeholderMapSet["text"] = "Setting Placeholder Text";
1125 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1126 placeholderMapSet["color"] = Color::RED;
1127 placeholderMapSet["fontFamily"] = "Arial";
1128 placeholderMapSet["pointSize"] = 12.0f;
1129 // Check the placeholder font style property
1130 placeholderFontstyleMap.Clear();
1132 placeholderFontstyleMap.Insert("weight", "bold");
1133 placeholderFontstyleMap.Insert("width", "condensed");
1134 placeholderFontstyleMap.Insert("slant", "italic");
1135 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1136 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1138 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1139 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1141 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1142 placeholderConversionMap.Clear();
1143 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1144 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1145 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1146 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1147 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1148 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1149 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1151 // Reset font style.
1152 placeholderFontstyleMap.Clear();
1153 placeholderFontstyleMap.Insert("weight", "normal");
1154 placeholderFontstyleMap.Insert("slant", "oblique");
1155 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1156 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1158 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1159 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1160 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1161 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1163 placeholderFontstyleMap.Clear();
1164 placeholderFontstyleMap.Insert("slant", "roman");
1165 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1166 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1168 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1170 placeholderFontstyleMap.Clear();
1171 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1173 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1174 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1175 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1176 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1177 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1179 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1180 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1182 // Check handle color
1183 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1184 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1186 // Test the ENABLE_GRAB_HANDLE_POPUP property
1187 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1188 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1190 // Check the input method setting
1191 Property::Map propertyMap;
1192 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1193 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1194 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1195 int inputVariation = 1;
1196 propertyMap["PANEL_LAYOUT"] = panelLayout;
1197 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1198 propertyMap["BUTTON_ACTION"] = buttonAction;
1199 propertyMap["VARIATION"] = inputVariation;
1200 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1202 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1204 DALI_TEST_CHECK(value.Get(map));
1207 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1208 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1211 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1212 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1215 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1216 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1219 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1220 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1222 // Check the input filter property
1223 Property::Map inputFilterMapSet;
1224 Property::Map inputFilterMapGet;
1225 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1226 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1228 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1230 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1231 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1234 inputFilterMapSet.Clear();
1235 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1237 // Check the strikethrough property
1239 Property::Map strikethroughMapSet;
1240 Property::Map strikethroughMapGet;
1242 application.SendNotification();
1243 application.Render();
1245 // Check the input strikethrough property
1247 strikethroughMapSet.Clear();
1248 strikethroughMapGet.Clear();
1249 strikethroughMapSet.Insert("enable", true);
1250 strikethroughMapSet.Insert("color", Color::BLUE);
1251 strikethroughMapSet.Insert("height", 2.0f);
1253 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1255 application.SendNotification();
1256 application.Render();
1258 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1260 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1261 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1263 // Check the input strikethrough property
1264 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1265 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1267 application.SendNotification();
1268 application.Render();
1270 // Check the line size property
1271 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1272 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1273 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1275 // Check Remove Front/Back Inset Property
1276 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1277 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, false);
1278 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1280 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1281 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, false);
1282 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1284 application.SendNotification();
1285 application.Render();
1290 // Positive Atlas Text Renderer test
1291 int utcDaliTextEditorAtlasRenderP(void)
1293 ToolkitTestApplication application;
1294 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1295 StyleManager styleManager = StyleManager::Get();
1296 styleManager.ApplyDefaultTheme();
1297 TextEditor editor = TextEditor::New();
1298 DALI_TEST_CHECK(editor);
1300 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1302 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1304 application.GetScene().Add(editor);
1308 // Render some text with the shared atlas backend
1309 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1310 application.SendNotification();
1311 application.Render();
1315 tet_result(TET_FAIL);
1320 // Positive test for the anchorClicked signal.
1321 int utcDaliTextEditorAnchorClickedP(void)
1323 ToolkitTestApplication application;
1324 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1325 TextEditor editor = TextEditor::New();
1326 DALI_TEST_CHECK(editor);
1328 application.GetScene().Add(editor);
1330 // connect to the anchor clicked signal.
1331 ConnectionTracker* testTracker = new ConnectionTracker();
1332 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1333 bool anchorClickedSignal = false;
1334 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1336 gAnchorClickedCallBackCalled = false;
1337 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1338 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1339 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1340 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1341 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1343 application.SendNotification();
1344 application.Render();
1345 editor.SetKeyInputFocus();
1347 // Create a tap event to touch the text editor.
1348 TestGenerateTap(application, 5.0f, 5.0f);
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1353 DALI_TEST_CHECK(anchorClickedSignal);
1355 gAnchorClickedCallBackNotCalled = true;
1356 // Tap the outside of anchor, callback should not be called.
1357 TestGenerateTap(application, 150.f, 100.f);
1358 application.SendNotification();
1359 application.Render();
1361 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1366 // Positive test for the textChanged signal.
1367 int utcDaliTextEditorTextChangedP(void)
1369 ToolkitTestApplication application;
1370 tet_infoline(" utcDaliTextEditorTextChangedP");
1371 TextEditor editor = TextEditor::New();
1372 DALI_TEST_CHECK(editor);
1374 application.GetScene().Add(editor);
1376 // connect to the text changed signal.
1377 ConnectionTracker* testTracker = new ConnectionTracker();
1378 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1379 bool textChangedSignal = false;
1380 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1382 gTextChangedCallBackCalled = false;
1383 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1384 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1385 DALI_TEST_CHECK(textChangedSignal);
1387 application.SendNotification();
1388 editor.SetKeyInputFocus();
1390 gTextChangedCallBackCalled = false;
1391 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1392 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1395 editor.SetProperty(TextField::Property::TEXT, "");
1397 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1398 gTextChangedCallBackCalled = false;
1399 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1400 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1402 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1403 gTextChangedCallBackCalled = false;
1404 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1405 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1410 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1412 ToolkitTestApplication application;
1413 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1414 TextEditor editor = TextEditor::New();
1415 DALI_TEST_CHECK(editor);
1417 application.GetScene().Add(editor);
1419 // connect to the text changed signal.
1420 ConnectionTracker* testTracker = new ConnectionTracker();
1421 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1422 bool textChangedSignal = false;
1423 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1425 // get InputMethodContext
1427 InputMethodContext::EventData imfEvent;
1428 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1430 editor.SetKeyInputFocus();
1431 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1434 gTextChangedCallBackCalled = false;
1435 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1436 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1437 application.SendNotification();
1438 application.Render();
1439 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1440 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1442 gTextChangedCallBackCalled = false;
1443 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1444 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1445 application.SendNotification();
1446 application.Render();
1447 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1448 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1450 gTextChangedCallBackCalled = false;
1451 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1452 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1453 application.SendNotification();
1454 application.Render();
1455 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1456 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1458 gTextChangedCallBackCalled = false;
1459 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1460 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1461 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1463 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1464 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1465 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1467 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1468 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1469 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1471 application.SendNotification();
1472 application.Render();
1473 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1474 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1479 int utcDaliTextEditorInputStyleChanged01(void)
1481 // The text-editor emits signals when the input style changes. These changes of style are
1482 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1483 // can't be emitted during the size negotiation as the callbacks may update the UI.
1484 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1485 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1486 ToolkitTestApplication application;
1487 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1491 char* pathNamePtr = get_current_dir_name();
1492 const std::string pathName(pathNamePtr);
1495 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1496 fontClient.SetDpi(93u, 93u);
1498 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1499 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1501 TextEditor editor = TextEditor::New();
1502 DALI_TEST_CHECK(editor);
1504 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1505 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1506 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1508 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1509 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1511 // connect to the text changed signal.
1512 ConnectionTracker* testTracker = new ConnectionTracker();
1513 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1514 bool inputStyleChangedSignal = false;
1515 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1517 application.GetScene().Add(editor);
1519 // Render and notify
1520 application.SendNotification();
1521 application.Render();
1523 // Executes the idle callbacks added by the text control on the change of input style.
1524 application.RunIdles();
1526 gInputStyleChangedCallbackCalled = false;
1527 gInputStyleMask = TextEditor::InputStyle::NONE;
1528 inputStyleChangedSignal = false;
1530 // Create a tap event to touch the text editor.
1531 TestGenerateTap(application, 18.0f, 25.0f);
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Executes the idle callbacks added by the text control on the change of input style.
1538 application.RunIdles();
1540 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1541 if(gInputStyleChangedCallbackCalled)
1543 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1545 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1546 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1548 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1549 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1551 DALI_TEST_CHECK(inputStyleChangedSignal);
1553 gInputStyleChangedCallbackCalled = false;
1554 gInputStyleMask = TextEditor::InputStyle::NONE;
1555 inputStyleChangedSignal = false;
1557 // Create a tap event to touch the text editor.
1558 TestGenerateTap(application, 30.0f, 25.0f);
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Executes the idle callbacks added by the text control on the change of input style.
1565 application.RunIdles();
1567 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1568 DALI_TEST_CHECK(!inputStyleChangedSignal);
1570 gInputStyleChangedCallbackCalled = false;
1571 gInputStyleMask = TextEditor::InputStyle::NONE;
1572 inputStyleChangedSignal = false;
1574 // Create a tap event to touch the text editor.
1575 TestGenerateTap(application, 43.0f, 25.0f);
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1581 // Executes the idle callbacks added by the text control on the change of input style.
1582 application.RunIdles();
1584 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1585 if(gInputStyleChangedCallbackCalled)
1587 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1589 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1590 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1592 DALI_TEST_CHECK(inputStyleChangedSignal);
1594 gInputStyleChangedCallbackCalled = false;
1595 gInputStyleMask = TextEditor::InputStyle::NONE;
1596 inputStyleChangedSignal = false;
1598 // Create a tap event to touch the text editor.
1599 TestGenerateTap(application, 88.0f, 25.0f);
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Executes the idle callbacks added by the text control on the change of input style.
1606 application.RunIdles();
1608 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1609 if(gInputStyleChangedCallbackCalled)
1611 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1613 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1614 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1616 Property::Map fontStyleMapSet;
1617 Property::Map fontStyleMapGet;
1619 fontStyleMapSet.Insert("weight", "bold");
1621 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1622 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1623 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1625 DALI_TEST_CHECK(inputStyleChangedSignal);
1627 gInputStyleChangedCallbackCalled = false;
1628 gInputStyleMask = TextEditor::InputStyle::NONE;
1629 inputStyleChangedSignal = false;
1631 // Create a tap event to touch the text editor.
1632 TestGenerateTap(application, 115.0f, 25.0f);
1634 // Render and notify
1635 application.SendNotification();
1636 application.Render();
1638 // Executes the idle callbacks added by the text control on the change of input style.
1639 application.RunIdles();
1641 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1642 DALI_TEST_CHECK(!inputStyleChangedSignal);
1644 gInputStyleChangedCallbackCalled = false;
1645 gInputStyleMask = TextEditor::InputStyle::NONE;
1646 inputStyleChangedSignal = false;
1648 // Create a tap event to touch the text editor.
1649 TestGenerateTap(application, 164.0f, 25.0f);
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // Executes the idle callbacks added by the text control on the change of input style.
1656 application.RunIdles();
1658 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1659 if(gInputStyleChangedCallbackCalled)
1661 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1663 Property::Map fontStyleMapSet;
1664 Property::Map fontStyleMapGet;
1666 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1667 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1668 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1670 DALI_TEST_CHECK(inputStyleChangedSignal);
1672 gInputStyleChangedCallbackCalled = false;
1673 gInputStyleMask = TextEditor::InputStyle::NONE;
1674 inputStyleChangedSignal = false;
1676 // Create a tap event to touch the text editor.
1677 TestGenerateTap(application, 191.0f, 25.0f);
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Executes the idle callbacks added by the text control on the change of input style.
1684 application.RunIdles();
1686 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1687 DALI_TEST_CHECK(!inputStyleChangedSignal);
1692 int utcDaliTextEditorInputStyleChanged02(void)
1694 // The text-editor emits signals when the input style changes. These changes of style are
1695 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1696 // can't be emitted during the size negotiation as the callbacks may update the UI.
1697 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1698 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1704 char* pathNamePtr = get_current_dir_name();
1705 const std::string pathName(pathNamePtr);
1708 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1709 fontClient.SetDpi(93u, 93u);
1711 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1712 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1714 TextEditor editor = TextEditor::New();
1715 DALI_TEST_CHECK(editor);
1717 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1718 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1719 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1721 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1722 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>");
1724 // connect to the text changed signal.
1725 ConnectionTracker* testTracker = new ConnectionTracker();
1726 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1727 bool inputStyleChangedSignal = false;
1728 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1730 application.GetScene().Add(editor);
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 // Executes the idle callbacks added by the text control on the change of input style.
1737 application.RunIdles();
1739 gInputStyleChangedCallbackCalled = false;
1740 gInputStyleMask = TextEditor::InputStyle::NONE;
1741 inputStyleChangedSignal = false;
1743 // Create a tap event to touch the text editor.
1744 TestGenerateTap(application, 53.0f, 25.0f, 100);
1745 TestGenerateTap(application, 53.0f, 25.0f, 200);
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 // Executes the idle callbacks added by the text control on the change of input style.
1752 application.RunIdles();
1754 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1755 if(gInputStyleChangedCallbackCalled)
1757 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1758 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1759 TextEditor::InputStyle::POINT_SIZE |
1760 TextEditor::InputStyle::COLOR),
1763 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1764 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1766 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1767 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1769 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1770 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1772 DALI_TEST_CHECK(inputStyleChangedSignal);
1774 gInputStyleChangedCallbackCalled = false;
1775 gInputStyleMask = TextEditor::InputStyle::NONE;
1776 inputStyleChangedSignal = false;
1778 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 // Executes the idle callbacks added by the text control on the change of input style.
1785 application.RunIdles();
1787 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1788 if(gInputStyleChangedCallbackCalled)
1790 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1791 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1794 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1795 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1797 DALI_TEST_CHECK(inputStyleChangedSignal);
1799 gInputStyleChangedCallbackCalled = false;
1800 gInputStyleMask = TextEditor::InputStyle::NONE;
1801 inputStyleChangedSignal = false;
1803 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 // Executes the idle callbacks added by the text control on the change of input style.
1810 application.RunIdles();
1812 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1813 DALI_TEST_CHECK(!inputStyleChangedSignal);
1815 gInputStyleChangedCallbackCalled = false;
1816 gInputStyleMask = TextEditor::InputStyle::NONE;
1817 inputStyleChangedSignal = false;
1819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // Executes the idle callbacks added by the text control on the change of input style.
1826 application.RunIdles();
1828 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1829 if(gInputStyleChangedCallbackCalled)
1831 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1832 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1835 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1836 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1838 DALI_TEST_CHECK(inputStyleChangedSignal);
1840 gInputStyleChangedCallbackCalled = false;
1841 gInputStyleMask = TextEditor::InputStyle::NONE;
1842 inputStyleChangedSignal = false;
1844 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1846 Property::Map fontStyleMapSet;
1847 fontStyleMapSet.Insert("weight", "thin");
1848 fontStyleMapSet.Insert("width", "condensed");
1849 fontStyleMapSet.Insert("slant", "italic");
1851 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1852 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1853 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1855 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1856 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1857 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1858 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1859 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1861 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // Executes the idle callbacks added by the text control on the change of input style.
1868 application.RunIdles();
1870 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1871 DALI_TEST_CHECK(!inputStyleChangedSignal);
1873 // Create a tap event to touch the text editor.
1874 TestGenerateTap(application, 63.0f, 25.0f, 900);
1876 // Render and notify
1877 application.SendNotification();
1878 application.Render();
1880 // Executes the idle callbacks added by the text control on the change of input style.
1881 application.RunIdles();
1883 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1884 if(gInputStyleChangedCallbackCalled)
1886 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1887 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1888 TextEditor::InputStyle::POINT_SIZE |
1889 TextEditor::InputStyle::FONT_STYLE |
1890 TextEditor::InputStyle::LINE_SPACING |
1891 TextEditor::InputStyle::UNDERLINE |
1892 TextEditor::InputStyle::SHADOW |
1893 TextEditor::InputStyle::EMBOSS |
1894 TextEditor::InputStyle::OUTLINE),
1897 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1898 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1900 DALI_TEST_CHECK(inputStyleChangedSignal);
1902 gInputStyleChangedCallbackCalled = false;
1903 gInputStyleMask = TextEditor::InputStyle::NONE;
1904 inputStyleChangedSignal = false;
1906 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1908 fontStyleMapSet.Clear();
1909 fontStyleMapSet.Insert("weight", "black");
1910 fontStyleMapSet.Insert("width", "expanded");
1911 fontStyleMapSet.Insert("slant", "oblique");
1913 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1915 // Create a tap event to touch the text editor.
1916 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 // Executes the idle callbacks added by the text control on the change of input style.
1923 application.RunIdles();
1925 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1926 if(gInputStyleChangedCallbackCalled)
1928 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1929 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1930 TextEditor::InputStyle::POINT_SIZE |
1931 TextEditor::InputStyle::FONT_STYLE),
1934 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1935 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1937 DALI_TEST_CHECK(inputStyleChangedSignal);
1942 int utcDaliTextEditorInputStyleChanged03(void)
1944 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1945 ToolkitTestApplication application;
1946 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1950 char* pathNamePtr = get_current_dir_name();
1951 const std::string pathName(pathNamePtr);
1954 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1955 fontClient.SetDpi(93u, 93u);
1957 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1958 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1960 TextEditor editor = TextEditor::New();
1961 DALI_TEST_CHECK(editor);
1963 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1964 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1965 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1967 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1968 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1970 // connect to the text changed signal.
1971 ConnectionTracker* testTracker = new ConnectionTracker();
1972 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1973 bool inputStyleChangedSignal = false;
1974 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1976 application.GetScene().Add(editor);
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 // Executes the idle callbacks added by the text control on the change of input style.
1983 application.RunIdles();
1985 gInputStyleChangedCallbackCalled = false;
1986 gInputStyleMask = TextEditor::InputStyle::NONE;
1987 inputStyleChangedSignal = false;
1989 // Create a tap event to touch the text editor.
1990 TestGenerateTap(application, 18.0f, 25.0f);
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Executes the idle callbacks added by the text control on the change of input style.
1997 application.RunIdles();
1999 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2000 if(gInputStyleChangedCallbackCalled)
2002 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
2004 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
2005 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2007 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
2008 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2010 DALI_TEST_CHECK(inputStyleChangedSignal);
2012 gInputStyleChangedCallbackCalled = false;
2013 gInputStyleMask = TextEditor::InputStyle::NONE;
2014 inputStyleChangedSignal = false;
2016 // Create a tap event to touch the text editor.
2017 TestGenerateTap(application, 30.0f, 25.0f);
2019 // Render and notify
2020 application.SendNotification();
2021 application.Render();
2023 // Executes the idle callbacks added by the text control on the change of input style.
2024 application.RunIdles();
2026 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2027 DALI_TEST_CHECK(!inputStyleChangedSignal);
2029 gInputStyleChangedCallbackCalled = false;
2030 gInputStyleMask = TextEditor::InputStyle::NONE;
2031 inputStyleChangedSignal = false;
2033 // Create a tap event to touch the text editor.
2034 TestGenerateTap(application, 43.0f, 25.0f);
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 // Executes the idle callbacks added by the text control on the change of input style.
2041 application.RunIdles();
2043 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2044 if(gInputStyleChangedCallbackCalled)
2046 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2048 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2049 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2051 DALI_TEST_CHECK(inputStyleChangedSignal);
2053 gInputStyleChangedCallbackCalled = false;
2054 gInputStyleMask = TextEditor::InputStyle::NONE;
2055 inputStyleChangedSignal = false;
2057 // Make AddIdle return false.
2058 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2060 // Create a tap event to touch the text editor.
2061 TestGenerateTap(application, 88.0f, 25.0f);
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 // Execute the idle callbacks.
2068 // And check whether we didn't change of input style.
2069 application.RunIdles();
2071 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2072 DALI_TEST_CHECK(!inputStyleChangedSignal);
2074 gInputStyleChangedCallbackCalled = false;
2075 gInputStyleMask = TextEditor::InputStyle::NONE;
2076 inputStyleChangedSignal = false;
2078 // Create a tap event to touch the text editor.
2079 TestGenerateTap(application, 115.0f, 25.0f);
2081 // Render and notify
2082 application.SendNotification();
2083 application.Render();
2085 // Execute the idle callbacks.
2086 // And check whether we didn't change of input style.
2087 application.RunIdles();
2089 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2090 DALI_TEST_CHECK(!inputStyleChangedSignal);
2092 gInputStyleChangedCallbackCalled = false;
2093 gInputStyleMask = TextEditor::InputStyle::NONE;
2094 inputStyleChangedSignal = false;
2096 // Revert AddIdle return true.
2097 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2099 // Create a tap event to touch the text editor.
2100 TestGenerateTap(application, 164.0f, 25.0f);
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 // Executes the idle callbacks added by the text control on the change of input style.
2107 application.RunIdles();
2109 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2110 if(gInputStyleChangedCallbackCalled)
2112 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2114 Property::Map fontStyleMapSet;
2115 Property::Map fontStyleMapGet;
2117 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2118 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2119 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2121 DALI_TEST_CHECK(inputStyleChangedSignal);
2123 gInputStyleChangedCallbackCalled = false;
2124 gInputStyleMask = TextEditor::InputStyle::NONE;
2125 inputStyleChangedSignal = false;
2127 // Create a tap event to touch the text editor.
2128 TestGenerateTap(application, 191.0f, 25.0f);
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2134 // Executes the idle callbacks added by the text control on the change of input style.
2135 application.RunIdles();
2137 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2138 DALI_TEST_CHECK(!inputStyleChangedSignal);
2143 int utcDaliTextEditorEvent01(void)
2145 ToolkitTestApplication application;
2146 tet_infoline(" utcDaliTextEditorEvent01");
2148 // Creates a tap event. After creating a tap event the text editor should
2149 // have the focus and add text with key events should be possible.
2151 TextEditor editor = TextEditor::New();
2152 DALI_TEST_CHECK(editor);
2154 application.GetScene().Add(editor);
2156 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2157 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2158 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2160 // Avoid a crash when core load gl resources.
2161 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Add a key event but as the text editor has not the focus it should do nothing.
2168 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2170 // Render and notify
2171 application.SendNotification();
2172 application.Render();
2174 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2176 // Create a tap event to touch the text editor.
2177 TestGenerateTap(application, 150.0f, 25.0f);
2179 // Render and notify
2180 application.SendNotification();
2181 application.Render();
2183 // Now the text editor has the focus, so it can handle the key events.
2184 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2185 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2191 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2193 // Create a second text editor and send key events to it.
2194 TextEditor editor2 = TextEditor::New();
2196 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2197 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2198 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2199 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2201 application.GetScene().Add(editor2);
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Create a tap event on the second text editor.
2208 TestGenerateTap(application, 150.0f, 125.0f);
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 // The second text editor has the focus. It should handle the key events.
2215 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2216 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2218 // Render and notify
2219 application.SendNotification();
2220 application.Render();
2222 // Check the text has been added to the second text editor.
2223 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2228 int utcDaliTextEditorEvent02(void)
2230 ToolkitTestApplication application;
2231 tet_infoline(" utcDaliTextEditorEvent02");
2233 // Checks if the right number of actors are created.
2235 TextEditor editor = TextEditor::New();
2236 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2237 DALI_TEST_CHECK(editor);
2239 application.GetScene().Add(editor);
2241 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2242 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2243 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2245 // Avoid a crash when core load gl resources.
2246 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // Check there are the expected number of children (the stencil).
2253 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2255 Actor stencil = editor.GetChildAt(0u);
2257 // Create a tap event to touch the text editor.
2258 TestGenerateTap(application, 150.0f, 25.0f, 100);
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2264 Actor layer = editor.GetChildAt(2u);
2265 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2266 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2268 // Now the text editor has the focus, so it can handle the key events.
2269 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2270 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2276 // Checks the cursor and the renderer have been created.
2277 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2278 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2280 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2281 DALI_TEST_CHECK(cursor);
2283 // The stencil actor has a container with all the actors which contain the text renderers.
2284 Actor container = stencil.GetChildAt(0u);
2285 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2287 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2288 DALI_TEST_CHECK(renderer);
2291 // Move the cursor and check the position changes.
2292 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2294 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2295 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2301 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2303 DALI_TEST_CHECK(position2.x < position1.x);
2305 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2306 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2312 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2314 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2316 // Send some taps and check the cursor positions.
2318 // Try to tap at the beginning.
2319 TestGenerateTap(application, 1.0f, 25.0f, 700);
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 // Cursor position should be the same than position1.
2326 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2328 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2330 // Tap away from the start position.
2331 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2339 DALI_TEST_CHECK(position5.x > position4.x);
2341 // Remove all the text.
2342 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2343 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2344 editor.SetProperty(TextEditor::Property::TEXT, "");
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Cursor position should be the same than position2.
2351 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2353 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2355 // Should not be a renderer, there is only a clipped cursor.
2356 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2361 int utcDaliTextEditorEvent03(void)
2363 ToolkitTestApplication application;
2364 tet_infoline(" utcDaliTextEditorEvent03");
2366 // Checks if the highlight actor is created.
2368 TextEditor editor = TextEditor::New();
2369 DALI_TEST_CHECK(editor);
2371 application.GetScene().Add(editor);
2373 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2374 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2375 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2376 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2377 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2379 // Avoid a crash when core load gl resources.
2380 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 // Send some taps and check text controller with clipboard window
2387 Dali::Clipboard clipboard = Clipboard::Get();
2388 clipboard.ShowClipboard();
2389 TestGenerateTap(application, 3.0f, 25.0f, 100);
2390 clipboard.HideClipboard();
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 // Tap first to get the focus.
2397 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2399 // Render and notify
2400 application.SendNotification();
2401 application.Render();
2403 // Double tap to select a word.
2404 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 // The stencil actor should have two actors: the renderer and the highlight actor.
2411 Actor stencil = editor.GetChildAt(0u);
2413 // Highlight needs to be drawn before text, so should come first in child order
2414 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2415 DALI_TEST_CHECK(highlight);
2417 // The stencil actor has a container with all the actors which contain the text renderers.
2418 Actor container = stencil.GetChildAt(1u);
2419 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2421 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2422 DALI_TEST_CHECK(renderer);
2425 // Double tap out of bounds
2426 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2427 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 // The stencil actor should have one actors: the renderer actor.
2434 stencil = editor.GetChildAt(0u);
2436 // The stencil actor has a container with all the actors which contain the text renderers.
2437 container = stencil.GetChildAt(0u);
2438 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2440 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2441 DALI_TEST_CHECK(renderer);
2445 TestGenerateLongPress(application, 1.0f, 25.0f);
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2452 TestGenerateMiniPan(application);
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2461 int utcDaliTextEditorEvent04(void)
2463 ToolkitTestApplication application;
2464 tet_infoline(" utcDaliTextEditorEvent04");
2466 // Checks if the highlight actor is created.
2468 TextEditor editor = TextEditor::New();
2469 DALI_TEST_CHECK(editor);
2471 application.GetScene().Add(editor);
2473 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2474 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2475 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2476 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2477 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2479 // Avoid a crash when core load gl resources.
2480 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2482 // Render and notify
2483 application.SendNotification();
2484 application.Render();
2486 // Tap on the text editor
2487 TestGenerateTap(application, 3.0f, 25.0f);
2489 // Render and notify
2490 application.SendNotification();
2491 application.Render();
2493 // Move at the end of the text.
2494 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2495 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2497 // Render and notify
2498 application.SendNotification();
2499 application.Render();
2501 for(unsigned int index = 0u; index < 10u; ++index)
2503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2504 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2512 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2514 // Render and notify
2515 application.SendNotification();
2516 application.Render();
2518 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2520 // Add some key events
2521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 for(unsigned int index = 0u; index < 10u; ++index)
2530 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2531 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2539 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2541 // Render and notify
2542 application.SendNotification();
2543 application.Render();
2545 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2550 int utcDaliTextEditorEvent05(void)
2552 ToolkitTestApplication application;
2553 tet_infoline(" utcDaliTextEditorEvent05");
2555 // Checks if the highlight actor is created.
2557 TextEditor editor = TextEditor::New();
2558 DALI_TEST_CHECK(editor);
2560 application.GetScene().Add(editor);
2562 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2563 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2564 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2565 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2566 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2567 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2568 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2569 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2570 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2571 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2573 // Avoid a crash when core load gl resources.
2574 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Tap on the text editor
2581 TestGenerateTap(application, 3.0f, 25.0f);
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2587 // Move at the end of the text.
2588 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2589 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2591 // Render and notify
2592 application.SendNotification();
2593 application.Render();
2595 for(unsigned int index = 0u; index < 10u; ++index)
2598 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2600 // Render and notify
2601 application.SendNotification();
2602 application.Render();
2604 // Modify duration after scroll is enabled
2605 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2607 // Continuous scroll left to increase coverage
2608 for(unsigned int index = 0u; index < 10u; ++index)
2610 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2616 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2617 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2618 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2619 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2620 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2622 // Press Escape to increase coverage
2623 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2624 application.SendNotification();
2625 application.Render();
2627 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2632 int utcDaliTextEditorEvent06(void)
2634 ToolkitTestApplication application;
2635 tet_infoline(" utcDaliTextEditorEvent06");
2637 // Checks if the highlight actor is created.
2639 TextEditor editor = TextEditor::New();
2640 DALI_TEST_CHECK(editor);
2642 application.GetScene().Add(editor);
2644 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2645 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2646 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2647 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2648 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2650 // Avoid a crash when core load gl resources.
2651 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2653 // Render and notify
2654 application.SendNotification();
2655 application.Render();
2657 // Tap on the text editor
2658 TestGenerateTap(application, 3.0f, 25.0f);
2660 // Render and notify
2661 application.SendNotification();
2662 application.Render();
2664 // Move to seconds line of the text.
2665 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2667 // Render and notify
2668 application.SendNotification();
2669 application.Render();
2671 float layoutHeight = editor.GetHeightForWidth(100.f);
2673 // Add another script characters ( glyph height is defferent )
2674 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2675 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2677 // Delete characters
2678 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2679 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2681 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2687 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2690 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2691 application.SendNotification();
2692 application.Render();
2694 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2695 application.SendNotification();
2696 application.Render();
2698 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2699 application.SendNotification();
2700 application.Render();
2702 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2703 application.SendNotification();
2704 application.Render();
2706 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2707 application.SendNotification();
2708 application.Render();
2710 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2711 application.SendNotification();
2712 application.Render();
2714 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2715 application.SendNotification();
2716 application.Render();
2721 int utcDaliTextEditorEvent07(void)
2723 ToolkitTestApplication application;
2724 tet_infoline(" utcDaliTextEditorEvent07");
2726 // Checks if the highlight actor is created.
2728 TextEditor editor = TextEditor::New();
2729 DALI_TEST_CHECK(editor);
2731 application.GetScene().Add(editor);
2733 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2734 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2735 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2736 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2737 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2739 // Avoid a crash when core load gl resources.
2740 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2742 // Render and notify
2743 application.SendNotification();
2744 application.Render();
2746 // Tap on the text editor
2747 TestGenerateTap(application, 3.0f, 25.0f);
2749 // Render and notify
2750 application.SendNotification();
2751 application.Render();
2753 // Move to second line of the text.
2754 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2756 // Render and notify
2757 application.SendNotification();
2758 application.Render();
2760 // Select some text in the right of the current cursor position
2761 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2764 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2770 // Cut the selected text
2771 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2772 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));
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2780 // Select some text in the left of the current cursor position
2781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2784 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2786 // Render and notify
2787 application.SendNotification();
2788 application.Render();
2790 // Copy the selected text
2791 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2792 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));
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 // Move the cursor to the third line
2799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2800 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2802 // Render and notify
2803 application.SendNotification();
2804 application.Render();
2806 // Paste the selected text at the current cursor position
2807 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2808 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));
2810 // Render and notify
2811 application.SendNotification();
2812 application.Render();
2814 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2816 // Disable Shift Selection
2817 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2819 // Test to select some text in the right of the current cursor position
2820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2823 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2825 // Render and notify
2826 application.SendNotification();
2827 application.Render();
2829 // Cut the selected text
2830 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2831 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));
2833 // Render and notify
2834 application.SendNotification();
2835 application.Render();
2837 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2838 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2840 // Test to select some text in the left of the current cursor position
2841 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2844 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 // Copy the selected text
2851 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2852 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));
2854 // Render and notify
2855 application.SendNotification();
2856 application.Render();
2858 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2859 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2862 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));
2864 // Render and notify
2865 application.SendNotification();
2866 application.Render();
2868 // replace text with "c"
2869 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2871 // Render and notify
2872 application.SendNotification();
2873 application.Render();
2876 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2879 DevelTextEditor::SelectWholeText(editor);
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2885 // Copy the selected text using logical keys
2886 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2887 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2889 // Render and notify
2890 application.SendNotification();
2891 application.Render();
2894 DevelTextEditor::SelectNone(editor);
2896 // Render and notify
2897 application.SendNotification();
2898 application.Render();
2900 // Paste the selected using logical keys
2901 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2902 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2905 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2907 // select all using logical keys
2908 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2909 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2911 // Render and notify
2912 application.SendNotification();
2913 application.Render();
2915 // cut text using logical keys
2916 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2917 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2919 // Render and notify
2920 application.SendNotification();
2921 application.Render();
2924 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2929 int utcDaliTextEditorEvent08(void)
2931 ToolkitTestApplication application;
2932 tet_infoline(" utcDaliTextEditorEvent08");
2934 // Checks if the highlight actor is released correctly.
2936 TextEditor editor = TextEditor::New();
2937 DALI_TEST_CHECK(editor);
2939 application.GetScene().Add(editor);
2941 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2942 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2943 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2944 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2945 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2947 // Avoid a crash when core load gl resources.
2948 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2950 // Render and notify
2951 application.SendNotification();
2952 application.Render();
2954 // Tap on the text editor
2955 TestGenerateTap(application, 3.0f, 25.0f);
2957 // Render and notify
2958 application.SendNotification();
2959 application.Render();
2961 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2962 // Test to select some text in the left of the current cursor position
2963 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2966 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2968 // Render and notify
2969 application.SendNotification();
2970 application.Render();
2972 // Test to the left selection handle position and the right selection handle position
2973 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2976 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2978 // Render and notify
2979 application.SendNotification();
2980 application.Render();
2982 // Test to select full text in the left of the current cursor position
2983 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2988 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2990 // Render and notify
2991 application.SendNotification();
2992 application.Render();
2994 // Test to release the current full text selection
2995 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2996 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2998 // Render and notify
2999 application.SendNotification();
3000 application.Render();
3002 // Test to move the current cursor position correctly
3003 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3005 // Render and notify
3006 application.SendNotification();
3007 application.Render();
3010 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3018 // Test to select some text in the right of the current cursor position
3019 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3021 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3023 // Render and notify
3024 application.SendNotification();
3025 application.Render();
3027 // Test the cursor position with right arrow key
3028 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3030 // Render and notify
3031 application.SendNotification();
3032 application.Render();
3035 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3043 // Test to select some text in the left of the current cursor position
3044 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3048 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3050 // Render and notify
3051 application.SendNotification();
3052 application.Render();
3054 // Test the cursor position with left arrow key
3055 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3057 // Render and notify
3058 application.SendNotification();
3059 application.Render();
3062 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3064 // Render and notify
3065 application.SendNotification();
3066 application.Render();
3068 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3070 // Test to select some text in the right of the current cursor position
3071 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3074 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3076 // Render and notify
3077 application.SendNotification();
3078 application.Render();
3080 // Test the cursor position with left arrow key
3081 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3083 // Render and notify
3084 application.SendNotification();
3085 application.Render();
3088 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3090 // Render and notify
3091 application.SendNotification();
3092 application.Render();
3094 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3096 // Test to select some text in the left of the current cursor position
3097 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3100 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3102 // Render and notify
3103 application.SendNotification();
3104 application.Render();
3106 // Test the cursor position with right arrow key
3107 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3109 // Render and notify
3110 application.SendNotification();
3111 application.Render();
3114 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3116 // Render and notify
3117 application.SendNotification();
3118 application.Render();
3120 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3125 int utcDaliTextEditorHandles(void)
3127 ToolkitTestApplication application;
3128 tet_infoline(" utcDaliTextEditorHandles");
3130 TextEditor editor = TextEditor::New();
3131 DALI_TEST_CHECK(editor);
3133 application.GetScene().Add(editor);
3135 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3136 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3137 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3138 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3140 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3141 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3142 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3143 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3145 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3146 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3147 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3149 // Avoid a crash when core load gl resources.
3150 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3152 // Render and notify
3153 application.SendNotification();
3154 application.Render();
3156 // Tap first to get the focus.
3157 TestGenerateTap(application, 3.0f, 25.0f, 100);
3159 // Render and notify
3160 application.SendNotification();
3161 application.Render();
3163 // Tap to create the grab handle.
3164 TestGenerateTap(application, 3.0f, 25.0f, 700);
3166 // Render and notify
3167 application.SendNotification();
3168 application.Render();
3170 // Get the active layer where the text's decoration is added.
3171 Actor activeLayer = editor.GetChildAt(1u);
3173 // Get the handle's actor.
3174 Actor handle = activeLayer.GetChildAt(0u);
3175 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3177 // Render and notify
3178 application.SendNotification();
3179 application.Render();
3181 // Touch the grab handle to set it as pressed.
3182 Vector2 touchPos(10.0f, 50.0f);
3183 Dali::Integration::TouchEvent event;
3184 event = Dali::Integration::TouchEvent();
3185 event.AddPoint(GetPointDownInside(touchPos));
3186 application.ProcessEvent(event);
3188 // Render and notify
3189 application.SendNotification();
3190 application.Render();
3192 // Pan the grab handle
3193 uint32_t time = 100;
3194 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3195 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3196 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3197 application.SendNotification();
3198 application.Render();
3200 // Release the grab handle.
3201 event = Dali::Integration::TouchEvent();
3202 event.AddPoint(GetPointUpInside(touchPos));
3203 application.ProcessEvent(event);
3205 // Render and notify
3206 application.SendNotification();
3207 application.Render();
3209 // Tap first to get the focus.
3210 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3212 // Render and notify
3213 application.SendNotification();
3214 application.Render();
3216 // Double tap to select a word and create the selection handles.
3217 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3219 // Render and notify
3220 application.SendNotification();
3221 application.Render();
3223 touchPos = Vector2(10.0f, 50.0f);
3225 // Touch the left selection handle to set it as pressed.
3226 event = Dali::Integration::TouchEvent();
3227 event.AddPoint(GetPointDownInside(touchPos));
3228 application.ProcessEvent(event);
3230 // Render and notify
3231 application.SendNotification();
3232 application.Render();
3234 // Release the left selection handle.
3235 event = Dali::Integration::TouchEvent();
3236 event.AddPoint(GetPointUpInside(touchPos));
3237 application.ProcessEvent(event);
3239 // Render and notify
3240 application.SendNotification();
3241 application.Render();
3246 int utcDaliTextEditorUnderPropertyStringP(void)
3248 ToolkitTestApplication application;
3249 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3250 TextEditor editor = TextEditor::New();
3251 DALI_TEST_CHECK(editor);
3253 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3255 application.GetScene().Add(editor);
3257 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3258 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3260 tet_infoline("Set underline settings with a map");
3261 // Check the input underline property
3262 Property::Map underlineMapSet;
3263 Property::Map underlineMapGet;
3264 underlineMapSet.Insert("enable", true);
3265 underlineMapSet.Insert("color", Color::BLUE);
3266 underlineMapSet.Insert("height", 1);
3267 underlineMapSet.Insert("type", Text::Underline::SOLID);
3268 underlineMapSet.Insert("dashWidth", 2);
3269 underlineMapSet.Insert("dashGap", 1);
3271 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3272 editor.SetProperty(TextEditor::Property::TEXT, "text");
3273 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3274 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3275 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3277 application.SendNotification();
3278 application.Render();
3280 underlineMapSet.Clear();
3281 underlineMapGet.Clear();
3283 tet_infoline("Set dashed underline settings with a map");
3284 // Check the input underline property
3285 underlineMapSet.Clear();
3286 underlineMapGet.Clear();
3287 underlineMapSet.Insert("enable", true);
3288 underlineMapSet.Insert("color", Color::BLUE);
3289 underlineMapSet.Insert("height", 1);
3290 underlineMapSet.Insert("type", Text::Underline::DASHED);
3291 underlineMapSet.Insert("dashWidth", 5);
3292 underlineMapSet.Insert("dashGap", 3);
3294 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3295 editor.SetProperty(TextEditor::Property::TEXT, "text");
3296 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3297 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3298 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3300 // Check the input underline property
3301 underlineMapSet.Clear();
3302 underlineMapGet.Clear();
3303 underlineMapSet.Insert("enable", true);
3304 underlineMapSet.Insert("color", Color::BLUE);
3305 underlineMapSet.Insert("height", 1);
3306 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3307 underlineMapSet.Insert("dashWidth", 5);
3308 underlineMapSet.Insert("dashGap", 3);
3310 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3311 editor.SetProperty(TextEditor::Property::TEXT, "text");
3312 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3313 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3314 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3316 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3317 editor.SetProperty(TextEditor::Property::TEXT, "text");
3318 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3319 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3320 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3322 application.SendNotification();
3323 application.Render();
3325 underlineMapSet.Clear();
3326 underlineMapGet.Clear();
3328 tet_infoline("Set underline settings with a string");
3329 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3330 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3333 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3335 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3336 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3337 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3338 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3340 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3345 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3347 ToolkitTestApplication application;
3348 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3349 TextEditor editor = TextEditor::New();
3350 DALI_TEST_CHECK(editor);
3352 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3354 application.GetScene().Add(editor);
3356 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3357 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3359 tet_infoline("Set strikethrough settings with a map");
3360 // Check the input strikethrough property
3361 Property::Map strikethroughMapSet;
3362 Property::Map strikethroughMapGet;
3363 strikethroughMapSet.Insert("enable", true);
3364 strikethroughMapSet.Insert("color", Color::BLUE);
3365 strikethroughMapSet.Insert("height", 2.0f);
3367 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3368 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3369 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3370 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3372 tet_infoline("Set strikethrough settings with a string");
3373 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3374 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3377 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3379 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3380 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3381 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3382 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3384 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3389 int utcDaliTextEditorShadowPropertyStringP(void)
3391 ToolkitTestApplication application;
3392 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3394 TextEditor editor = TextEditor::New();
3396 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3398 application.GetScene().Add(editor);
3400 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3402 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3406 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3411 int utcDaliTextEditorFontStylePropertyStringP(void)
3413 ToolkitTestApplication application;
3414 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3416 TextEditor editor = TextEditor::New();
3418 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3420 application.GetScene().Add(editor);
3422 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3424 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3428 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3433 int utcDaliTextEditorGetPropertyLinecountP(void)
3435 ToolkitTestApplication application;
3437 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3441 TextEditor editor = TextEditor::New();
3442 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3443 editor.SetProperty(TextEditor::Property::TEXT,
3444 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3446 application.GetScene().Add(editor);
3448 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3449 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3450 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3452 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3453 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3454 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3459 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3461 ToolkitTestApplication application;
3462 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3464 TextEditor editor = TextEditor::New();
3465 DALI_TEST_CHECK(editor);
3467 application.GetScene().Add(editor);
3469 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3470 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3471 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3472 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3473 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3474 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3476 bool startedCalled = false;
3477 bool finishedCalled = false;
3479 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3480 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3482 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3484 // Render and notify
3485 application.SendNotification();
3486 application.Render();
3488 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3489 application.SendNotification();
3490 application.Render(6000);
3492 application.SendNotification();
3493 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3494 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3499 int UtcDaliToolkitTextEditorTextWrapMode(void)
3501 ToolkitTestApplication application;
3502 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3506 TextEditor editor = TextEditor::New();
3507 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3508 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3510 application.GetScene().Add(editor);
3512 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3513 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3515 application.SendNotification();
3516 application.Render();
3518 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3519 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3521 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3522 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3524 application.SendNotification();
3525 application.Render();
3527 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3528 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3530 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3531 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3533 application.SendNotification();
3534 application.Render();
3536 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3537 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3539 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3540 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3542 application.SendNotification();
3543 application.Render();
3545 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3546 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3551 int UtcDaliTextEditorSetPaddingProperty(void)
3553 ToolkitTestApplication application;
3554 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3556 TextEditor editor = TextEditor::New();
3557 DALI_TEST_CHECK(editor);
3558 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3559 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3560 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3561 application.GetScene().Add(editor);
3563 application.SendNotification();
3564 application.Render();
3566 Vector3 originalSize = editor.GetNaturalSize();
3568 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3570 application.SendNotification();
3571 application.Render();
3573 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3575 Vector3 paddingAddedSize = editor.GetNaturalSize();
3577 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3579 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3584 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3586 ToolkitTestApplication application;
3587 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3589 TextEditor editor = TextEditor::New();
3590 DALI_TEST_CHECK(editor);
3591 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3592 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3593 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3594 application.GetScene().Add(editor);
3596 application.SendNotification();
3597 application.Render();
3599 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3600 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3602 // Check the enable shift selection property
3603 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3604 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3606 application.SendNotification();
3607 application.Render();
3612 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3614 ToolkitTestApplication application;
3615 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3617 TextEditor editor = TextEditor::New();
3618 DALI_TEST_CHECK(editor);
3619 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3620 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3621 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3622 application.GetScene().Add(editor);
3624 application.SendNotification();
3625 application.Render();
3627 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3628 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3630 // Check the enable grab handle property
3631 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3632 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3634 application.SendNotification();
3635 application.Render();
3640 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3642 ToolkitTestApplication application;
3643 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3645 TextEditor editor = TextEditor::New();
3646 DALI_TEST_CHECK(editor);
3647 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3648 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3649 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3650 application.GetScene().Add(editor);
3652 application.SendNotification();
3653 application.Render();
3655 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3656 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3658 // Check the disable match system language direction property
3659 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3660 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3662 application.SendNotification();
3663 application.Render();
3668 int UtcDaliTextEditorGetInputMethodContext(void)
3670 ToolkitTestApplication application;
3671 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3673 TextEditor editor = TextEditor::New();
3674 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3679 int utcDaliTextEditorMaxCharactersReached(void)
3681 ToolkitTestApplication application;
3682 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3684 TextEditor editor = TextEditor::New();
3685 DALI_TEST_CHECK(editor);
3687 application.GetScene().Add(editor);
3689 const int maxNumberOfCharacters = 1;
3690 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3691 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3693 editor.SetKeyInputFocus();
3695 // connect to the text changed signal.
3696 ConnectionTracker* testTracker = new ConnectionTracker();
3697 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3698 bool maxLengthReachedSignal = false;
3699 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3701 gMaxCharactersCallBackCalled = false;
3703 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3704 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3706 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3707 DALI_TEST_CHECK(maxLengthReachedSignal);
3712 int utcDaliTextEditorInputFiltered(void)
3714 ToolkitTestApplication application;
3715 tet_infoline(" utcDaliTextEditorInputFiltered");
3716 TextEditor editor = TextEditor::New();
3717 DALI_TEST_CHECK(editor);
3719 application.GetScene().Add(editor);
3721 Property::Map inputFilter;
3723 // Only digit is accepted.
3724 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3726 // Set input filter to TextEditor.
3727 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3729 editor.SetKeyInputFocus();
3731 // connect to the input filtered signal.
3732 ConnectionTracker* testTracker = new ConnectionTracker();
3733 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3734 bool inputFilteredSignal = false;
3735 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3737 gInputFilteredAcceptedCallbackCalled = false;
3739 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3741 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3742 DALI_TEST_CHECK(inputFilteredSignal);
3744 // Word is rejected.
3745 inputFilter[InputFilter::Property::ACCEPTED] = "";
3746 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3748 // Set input filter to TextEditor.
3749 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3751 editor.SetKeyInputFocus();
3753 inputFilteredSignal = false;
3754 gInputFilteredRejectedCallbackCalled = false;
3756 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3758 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3759 DALI_TEST_CHECK(inputFilteredSignal);
3764 int UtcDaliTextEditorSelectWholeText(void)
3766 ToolkitTestApplication application;
3767 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3769 TextEditor textEditor = TextEditor::New();
3771 application.GetScene().Add(textEditor);
3773 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3774 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3775 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3777 // Avoid a crash when core load gl resources.
3778 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3780 application.SendNotification();
3781 application.Render();
3783 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3785 DevelTextEditor::SelectWholeText(textEditor);
3787 application.SendNotification();
3788 application.Render();
3790 // Nothing should have been selected. The number of children is still 1
3791 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3793 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3795 application.SendNotification();
3796 application.Render();
3798 DevelTextEditor::SelectWholeText(textEditor);
3800 application.SendNotification();
3801 application.Render();
3803 // Should be 2 children, the stencil and the layer
3804 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3806 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3807 Actor stencil = textEditor.GetChildAt(0u);
3809 // The highlight actor is drawn first, so is the first actor in the list
3810 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3811 DALI_TEST_CHECK(highlight);
3816 int UtcDaliTextEditorSelectText(void)
3818 ToolkitTestApplication application;
3819 tet_infoline(" UtcDaliTextEditorSelectText ");
3821 TextEditor textEditor = TextEditor::New();
3823 application.GetScene().Add(textEditor);
3825 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3826 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3827 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3829 // Avoid a crash when core load gl resources.
3830 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3832 application.SendNotification();
3833 application.Render();
3835 DevelTextEditor::SelectText(textEditor, 0, 5);
3837 application.SendNotification();
3838 application.Render();
3840 // Nothing is selected
3841 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3842 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3844 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3846 application.SendNotification();
3847 application.Render();
3849 DevelTextEditor::SelectText(textEditor, 0, 5);
3851 application.SendNotification();
3852 application.Render();
3854 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3855 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3857 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3858 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3860 // world is selected
3861 DevelTextEditor::SelectText(textEditor, 6, 11);
3863 application.SendNotification();
3864 application.Render();
3866 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3867 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3869 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3870 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3875 int UtcDaliTextEditorSelectNone(void)
3877 ToolkitTestApplication application;
3878 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3880 TextEditor textEditor = TextEditor::New();
3882 application.GetScene().Add(textEditor);
3884 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3885 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3886 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3888 // Avoid a crash when core load gl resources.
3889 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3891 application.SendNotification();
3892 application.Render();
3894 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3896 application.SendNotification();
3897 application.Render();
3899 // Nothing is selected
3900 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3901 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3903 DevelTextEditor::SelectWholeText(textEditor);
3905 application.SendNotification();
3906 application.Render();
3908 // whole text is selected
3909 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3910 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3912 DevelTextEditor::SelectNone(textEditor);
3914 application.SendNotification();
3915 application.Render();
3917 // Nothing is selected
3918 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3919 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3924 int UtcDaliTextEditorSelectRange(void)
3926 ToolkitTestApplication application;
3927 tet_infoline("utcDaliTextEditorSelectRange");
3929 TextEditor textEditor = TextEditor::New();
3930 DALI_TEST_CHECK(textEditor);
3932 application.GetScene().Add(textEditor);
3934 // Avoid a crash when core load gl resources.
3935 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3937 application.SendNotification();
3938 application.Render();
3940 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3942 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3943 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3945 // Hello is selected
3946 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3947 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3949 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3950 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3955 int UtcDaliTextEditorEnableEditing(void)
3957 ToolkitTestApplication application;
3958 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3960 TextEditor textEditor = TextEditor::New();
3962 application.GetScene().Add(textEditor);
3964 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3965 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3966 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3968 // Avoid a crash when core load gl resources.
3969 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3971 application.SendNotification();
3972 application.Render();
3974 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3975 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3977 textEditor.SetKeyInputFocus();
3978 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3979 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3981 // Render and notify
3982 application.SendNotification();
3983 application.Render();
3985 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3986 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3988 textEditor.SetKeyInputFocus();
3989 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3990 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3992 // Render and notify
3993 application.SendNotification();
3994 application.Render();
3996 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3997 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3999 // Check the user interaction enabled and for coverage
4000 DevelTextEditor::SelectWholeText(textEditor);
4002 // Render and notify
4003 application.SendNotification();
4004 application.Render();
4006 textEditor.SetKeyInputFocus();
4007 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4008 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4010 // Render and notify
4011 application.SendNotification();
4012 application.Render();
4014 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4015 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4020 int UtcDaliTextEditorScrolling(void)
4022 ToolkitTestApplication application;
4023 tet_infoline(" UtcDaliTextEditorScrolling ");
4025 TextEditor textEditor = TextEditor::New();
4026 DALI_TEST_CHECK(textEditor);
4028 application.GetScene().Add(textEditor);
4030 // Avoid a crash when core load gl resources.
4031 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4033 application.SendNotification();
4034 application.Render();
4036 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4037 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4038 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4039 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4041 application.SendNotification();
4042 application.Render();
4044 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4045 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4047 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4049 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4050 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4052 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4054 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4055 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4057 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4058 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4060 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4061 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4066 int UtcDaliToolkitTextEditorFontSizeScale(void)
4068 ToolkitTestApplication application;
4069 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4071 TextEditor textEditor = TextEditor::New();
4072 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4073 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4074 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4076 TextEditor textEditorScaled = TextEditor::New();
4077 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4078 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4079 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4080 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4082 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4084 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4085 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4086 nonScaledSize = textEditor.GetNaturalSize();
4088 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4089 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4090 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4091 scaledSize = textEditorScaled.GetNaturalSize();
4093 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4098 int UtcDaliTextEditorPrimaryCursorPosition(void)
4100 ToolkitTestApplication application;
4101 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4103 TextEditor textEditor = TextEditor::New();
4105 application.GetScene().Add(textEditor);
4107 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4108 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4109 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4110 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4112 // Avoid a crash when core load gl resources.
4113 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4115 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4116 application.SendNotification();
4117 application.Render();
4118 textEditor.SetKeyInputFocus();
4120 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4122 // Render and notify
4123 application.SendNotification();
4124 application.Render();
4126 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4127 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4132 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4134 ToolkitTestApplication application;
4135 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4137 TextEditor textEditor = TextEditor::New();
4138 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4139 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4140 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4141 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4142 application.GetScene().Add(textEditor);
4144 application.SendNotification();
4145 application.Render();
4148 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4149 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4151 textEditor.GetNaturalSize();
4153 // Create a tap event to touch the text editor.
4154 TestGenerateTap(application, 18.0f, 25.0f);
4156 application.SendNotification();
4157 application.Render();
4159 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4160 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4165 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4167 ToolkitTestApplication application;
4169 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4171 int lineCountBefore = 0;
4172 int lineCountAfter = 0;
4174 // Create a text editor
4175 TextEditor textEditor = TextEditor::New();
4176 //Set very large font-size using point-size
4177 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4178 //Specify font-family
4179 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4181 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4182 //Set text longer than width of textEditor
4183 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4185 application.GetScene().Add(textEditor);
4187 application.SendNotification();
4188 application.Render();
4190 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
4191 //GetHeightForWidth is a retrieval method which should not modify object
4192 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4193 textEditor.GetHeightForWidth(200.f);
4195 //This is to simulate focus into text editor after calling GetHeightForWidth
4196 //Create a tap event to touch the text editor.
4197 TestGenerateTap(application, 18.0f, 25.0f);
4199 application.SendNotification();
4200 application.Render();
4202 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4204 //The LineCount must not be changed when calling GetHeightForWidth.
4205 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4210 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4212 ToolkitTestApplication application;
4214 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
4216 int lineCountBefore = 0;
4217 int lineCountAfter = 0;
4219 // Create a text editor
4220 TextEditor textEditor = TextEditor::New();
4221 //Set very large font-size using point-size
4222 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4223 //Specify font-family
4224 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4226 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4227 //Set text longer than width of textEditor
4228 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4229 //Set line wrap mode Character
4230 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4232 application.GetScene().Add(textEditor);
4234 application.SendNotification();
4235 application.Render();
4237 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4238 //GetHeightForWidth is a retrieval method which should not modify object
4239 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4240 textEditor.GetHeightForWidth(200.f);
4242 //This is to simulate focus into text editor after calling GetHeightForWidth
4243 //Create a tap event to touch the text editor.
4244 TestGenerateTap(application, 18.0f, 25.0f);
4246 application.SendNotification();
4247 application.Render();
4249 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4251 //The LineCount must not be changed when calling GetHeightForWidth.
4252 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4257 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4259 ToolkitTestApplication application;
4261 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4263 int lineCountBefore = 0;
4264 int lineCountAfter = 0;
4266 // Create a text editor
4267 TextEditor textEditor = TextEditor::New();
4268 //Set very large font-size using point-size
4269 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4270 //Specify font-family
4271 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4273 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4274 //Set text longer than width of textEditor
4275 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4276 //Set line wrap mode Character
4277 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4279 application.GetScene().Add(textEditor);
4281 application.SendNotification();
4282 application.Render();
4284 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4286 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4287 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4289 // When the text changed, the Line-count should be updated according to new text.
4290 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4291 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4292 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4297 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4299 ToolkitTestApplication application;
4301 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4303 int lineCountBefore = 0;
4304 int lineCountAfter = 0;
4306 // Create a text editor
4307 TextEditor textEditor = TextEditor::New();
4308 //Set very large font-size using point-size
4309 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4310 //Specify font-family
4311 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4313 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4314 //Set text longer than width of textEditor
4315 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4317 application.GetScene().Add(textEditor);
4319 application.SendNotification();
4320 application.Render();
4322 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4323 //GetNaturalSize is a retrieval method which should not modify object
4324 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4325 textEditor.GetNaturalSize();
4327 //This is to simulate focus into text editor after calling GetNaturalSize
4328 //Create a tap event to touch the text editor.
4329 TestGenerateTap(application, 18.0f, 25.0f);
4331 application.SendNotification();
4332 application.Render();
4334 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4336 //The LineCount must not be changed when calling GetNaturalSize.
4337 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4342 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4344 ToolkitTestApplication application;
4346 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4348 int lineCountBefore = 0;
4349 int lineCountAfter = 0;
4351 // Create a text editor
4352 TextEditor textEditor = TextEditor::New();
4353 //Set very large font-size using point-size
4354 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4355 //Specify font-family
4356 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4358 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4359 //Set text longer than width of textEditor
4360 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4361 //Set line wrap mode Character
4362 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4364 application.GetScene().Add(textEditor);
4366 application.SendNotification();
4367 application.Render();
4369 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4370 //GetNaturalSize is a retrieval method which should not modify object
4371 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4372 textEditor.GetNaturalSize();
4374 //This is to simulate focus into text editor after calling GetNaturalSize
4375 //Create a tap event to touch the text editor.
4376 TestGenerateTap(application, 18.0f, 25.0f);
4378 application.SendNotification();
4379 application.Render();
4381 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4383 //The LineCount must not be changed when calling GetNaturalSize.
4384 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4389 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4391 ToolkitTestApplication application;
4392 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4394 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4395 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4396 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4398 // Create a text editor
4399 TextEditor textEditor = TextEditor::New();
4401 //Set size to avoid automatic eliding
4402 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4403 //Set very large font-size using point-size
4404 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4405 //Specify font-family
4406 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4407 //Set text to check if appear or not
4408 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4410 application.GetScene().Add(textEditor);
4412 application.SendNotification();
4413 application.Render();
4414 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4415 Vector3 naturalSize = textEditor.GetNaturalSize();
4417 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4418 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4423 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4425 ToolkitTestApplication application;
4426 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4428 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4429 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4430 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4432 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4433 // Create a text editor
4434 TextEditor textEditor = TextEditor::New();
4435 //Set size to avoid automatic eliding
4436 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4437 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4438 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4440 const int numberOfCases = 6;
4441 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4443 for(int index = 0; index < numberOfCases; index++)
4445 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4446 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4447 application.GetScene().Add(textEditor);
4448 application.SendNotification();
4449 application.Render();
4450 naturalSize = textEditor.GetNaturalSize();
4451 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4452 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4458 int UtcDaliTextEditorHyphenWrapMode(void)
4460 ToolkitTestApplication application;
4461 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4464 TextEditor textEditor = TextEditor::New();
4466 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4468 application.GetScene().Add(textEditor);
4469 application.SendNotification();
4470 application.Render();
4472 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4473 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4474 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4476 application.SendNotification();
4477 application.Render();
4479 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4485 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4487 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4488 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4489 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4491 application.SendNotification();
4492 application.Render();
4494 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4501 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4506 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4508 ToolkitTestApplication application;
4509 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4510 TextEditor textEditor = TextEditor::New();
4512 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4513 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4515 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4516 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4517 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4519 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4520 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4521 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4523 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4524 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4525 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4527 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4528 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4529 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4531 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4532 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4533 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4535 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4536 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4537 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4539 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4540 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4541 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4543 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4544 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4545 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4547 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4548 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4549 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4551 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4552 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4553 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4555 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4556 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4557 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4559 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4560 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4561 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4566 int UtcDaliTextEditorCopyText(void)
4568 ToolkitTestApplication application;
4569 tet_infoline(" UtcDaliTextEditorCopyText ");
4571 TextEditor textEditor = TextEditor::New();
4573 std::string selectedText = "";
4574 std::string copiedText = "";
4576 application.GetScene().Add(textEditor);
4578 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4579 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4580 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4582 // Avoid a crash when core load gl resources.
4583 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4585 application.SendNotification();
4586 application.Render();
4588 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4590 application.SendNotification();
4591 application.Render();
4593 // Hello is selected
4594 DevelTextEditor::SelectText(textEditor, 0, 5);
4596 application.SendNotification();
4597 application.Render();
4599 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4600 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4602 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4603 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4606 copiedText = DevelTextEditor::CopyText(textEditor);
4607 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4609 // world is selected
4610 DevelTextEditor::SelectText(textEditor, 6, 11);
4612 application.SendNotification();
4613 application.Render();
4615 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4616 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4618 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4619 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4622 copiedText = DevelTextEditor::CopyText(textEditor);
4623 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4625 // "lo wo" is selected
4626 DevelTextEditor::SelectText(textEditor, 3, 8);
4628 application.SendNotification();
4629 application.Render();
4631 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4632 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4634 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4635 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4637 // "lo wo" is copied
4638 copiedText = DevelTextEditor::CopyText(textEditor);
4639 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4644 int UtcDaliTextEditorCutText(void)
4646 ToolkitTestApplication application;
4647 tet_infoline(" UtcDaliTextEditorCutText ");
4649 TextEditor textEditor = TextEditor::New();
4651 std::string selectedText = "";
4653 application.GetScene().Add(textEditor);
4655 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4656 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4657 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4659 // Avoid a crash when core load gl resources.
4660 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4662 application.SendNotification();
4663 application.Render();
4665 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4667 application.SendNotification();
4668 application.Render();
4670 // Hello is selected
4671 DevelTextEditor::SelectText(textEditor, 0, 5);
4673 application.SendNotification();
4674 application.Render();
4676 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4677 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4679 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4680 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4683 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4685 application.SendNotification();
4686 application.Render();
4688 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4691 DevelTextEditor::SelectText(textEditor, 0, 2);
4693 application.SendNotification();
4694 application.Render();
4696 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4697 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4699 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4700 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4703 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4705 application.SendNotification();
4706 application.Render();
4708 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4710 // Test Cut from the middle
4713 DevelTextEditor::SelectText(textEditor, 1, 3);
4715 application.SendNotification();
4716 application.Render();
4718 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4719 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4721 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4722 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4725 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4727 application.SendNotification();
4728 application.Render();
4730 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4732 // Test Cut from the end
4735 DevelTextEditor::SelectText(textEditor, 1, 2);
4737 application.SendNotification();
4738 application.Render();
4740 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4741 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4743 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4744 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4747 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4749 application.SendNotification();
4750 application.Render();
4752 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4757 int UtcDaliTextEditorPasteText(void)
4759 ToolkitTestApplication application;
4760 tet_infoline(" UtcDaliTextEditorPasteText ");
4762 TextEditor editor = TextEditor::New();
4763 DALI_TEST_CHECK(editor);
4765 application.GetScene().Add(editor);
4767 std::string cutText = "";
4768 std::string copiedText = "";
4770 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4771 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4772 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4773 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4774 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4776 // Avoid a crash when core load gl resources.
4777 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4779 // Render and notify
4780 application.SendNotification();
4781 application.Render();
4783 // Tap on the text editor
4784 TestGenerateTap(application, 3.0f, 25.0f);
4786 // Render and notify
4787 application.SendNotification();
4788 application.Render();
4790 // Move to second line of the text.
4791 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4793 // Render and notify
4794 application.SendNotification();
4795 application.Render();
4797 // Select some text in the right of the current cursor position
4798 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
4801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4803 // Render and notify
4804 application.SendNotification();
4805 application.Render();
4807 // Cut the selected text
4808 cutText = DevelTextEditor::CutText(editor);
4810 // Render and notify
4811 application.SendNotification();
4812 application.Render();
4814 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4815 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4817 // Select some text in the left of the current cursor position
4818 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
4821 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4823 // Render and notify
4824 application.SendNotification();
4825 application.Render();
4827 // Copy the selected text
4828 copiedText = DevelTextEditor::CopyText(editor);
4830 // Render and notify
4831 application.SendNotification();
4832 application.Render();
4834 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4835 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4837 // Move the cursor to the third line
4838 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4839 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4841 // Render and notify
4842 application.SendNotification();
4843 application.Render();
4845 // Paste the selected text at the current cursor position
4846 DevelTextEditor::PasteText(editor);
4848 // Render and notify
4849 application.SendNotification();
4850 application.Render();
4852 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4857 int UtcDaliTextEditorLineSpacing(void)
4859 ToolkitTestApplication application;
4860 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4862 TextEditor textEditor = TextEditor::New();
4863 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4864 application.GetScene().Add(textEditor);
4865 application.SendNotification();
4866 application.Render();
4868 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4869 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4871 Vector3 sizeBefore = textEditor.GetNaturalSize();
4873 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4875 //add 20 for each line 20 * 3
4876 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4881 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4883 //Only for test coverage
4884 ToolkitTestApplication application;
4885 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4887 TextEditor textEditor = TextEditor::New();
4888 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4889 application.GetScene().Add(textEditor);
4890 application.SendNotification();
4891 application.Render();
4893 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4894 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4896 application.SendNotification();
4897 application.Render();
4899 DevelTextEditor::SelectWholeText(textEditor);
4901 application.SendNotification();
4902 application.Render();
4904 DevelTextEditor::SelectNone(textEditor);
4905 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4907 application.SendNotification();
4908 application.Render();
4910 DevelTextEditor::SelectWholeText(textEditor);
4912 application.SendNotification();
4913 application.Render();
4915 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4920 int UtcDaliTextEditorMinLineSize(void)
4922 ToolkitTestApplication application;
4923 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4925 TextEditor textEditor = TextEditor::New();
4926 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4927 application.GetScene().Add(textEditor);
4928 application.SendNotification();
4929 application.Render();
4931 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4932 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4934 Vector3 sizeBefore = textEditor.GetNaturalSize();
4936 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4938 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4941 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4946 int utcDaliTextEditorCursorPositionChangedSignal(void)
4948 ToolkitTestApplication application;
4949 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4951 TextEditor editor = TextEditor::New();
4952 DALI_TEST_CHECK(editor);
4954 application.GetScene().Add(editor);
4956 // connect to the selection changed signal.
4957 ConnectionTracker* testTracker = new ConnectionTracker();
4958 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4959 bool cursorPositionChangedSignal = false;
4960 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4962 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4963 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4964 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4965 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4966 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4968 // Avoid a crash when core load gl resources.
4969 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4971 // Render and notify
4972 application.SendNotification();
4973 application.Render();
4975 editor.SetKeyInputFocus();
4977 // Tap on the text editor
4978 TestGenerateTap(application, 3.0f, 25.0f);
4980 // Render and notify
4981 application.SendNotification();
4982 application.Render();
4984 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4985 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4987 gCursorPositionChangedCallbackCalled = false;
4990 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4992 // Render and notify
4993 application.SendNotification();
4994 application.Render();
4996 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4997 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4999 gCursorPositionChangedCallbackCalled = false;
5002 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5004 // Render and notify
5005 application.SendNotification();
5006 application.Render();
5008 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5009 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5011 gCursorPositionChangedCallbackCalled = false;
5013 //delete one character
5014 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5016 // Render and notify
5017 application.SendNotification();
5018 application.Render();
5020 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5021 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5023 gCursorPositionChangedCallbackCalled = false;
5025 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5027 // Render and notify
5028 application.SendNotification();
5029 application.Render();
5031 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5032 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5034 gCursorPositionChangedCallbackCalled = false;
5036 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5038 // Render and notify
5039 application.SendNotification();
5040 application.Render();
5042 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5043 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5048 int utcDaliTextEditorGeometryEllipsisStart(void)
5050 ToolkitTestApplication application;
5051 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5053 TextEditor editor = TextEditor::New();
5054 DALI_TEST_CHECK(editor);
5056 application.GetScene().Add(editor);
5058 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5059 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5060 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5061 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5062 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5063 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5064 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5065 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5066 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5068 // Avoid a crash when core load gl resources.
5069 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5071 // Render and notify
5072 application.SendNotification();
5073 application.Render();
5075 unsigned int expectedCount = 2;
5076 unsigned int startIndex = 0;
5077 unsigned int endIndex = 24;
5079 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5080 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5082 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5083 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5085 Vector<Vector2> expectedSizes;
5086 Vector<Vector2> expectedPositions;
5088 expectedPositions.PushBack(Vector2(38, 0));
5089 expectedSizes.PushBack(Vector2(21, 25));
5091 expectedPositions.PushBack(Vector2(-1, 25));
5092 expectedSizes.PushBack(Vector2(53, 25));
5094 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5099 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5101 ToolkitTestApplication application;
5102 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
5104 TextEditor editor = TextEditor::New();
5105 DALI_TEST_CHECK(editor);
5107 application.GetScene().Add(editor);
5109 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5110 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5111 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5112 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5113 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5114 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5115 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5116 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
5117 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5119 // Avoid a crash when core load gl resources.
5120 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5122 // Render and notify
5123 application.SendNotification();
5124 application.Render();
5126 unsigned int expectedCount = 2;
5127 unsigned int startIndex = 0;
5128 unsigned int endIndex = 24;
5130 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5131 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5133 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5134 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5136 Vector<Vector2> expectedSizes;
5137 Vector<Vector2> expectedPositions;
5139 expectedPositions.PushBack(Vector2(-1, 0));
5140 expectedSizes.PushBack(Vector2(26, 25));
5142 expectedPositions.PushBack(Vector2(-1, 25));
5143 expectedSizes.PushBack(Vector2(53, 25));
5145 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5150 int utcDaliTextEditorGeometryEllipsisEnd(void)
5152 ToolkitTestApplication application;
5153 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5155 TextEditor editor = TextEditor::New();
5156 DALI_TEST_CHECK(editor);
5158 application.GetScene().Add(editor);
5160 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5161 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5162 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5163 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5164 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5165 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5166 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5167 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5168 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5170 // Avoid a crash when core load gl resources.
5171 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5173 // Render and notify
5174 application.SendNotification();
5175 application.Render();
5177 unsigned int expectedCount = 2;
5178 unsigned int startIndex = 0;
5179 unsigned int endIndex = 24;
5181 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5182 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5184 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5185 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5187 Vector<Vector2> expectedSizes;
5188 Vector<Vector2> expectedPositions;
5190 expectedPositions.PushBack(Vector2(-1, 0));
5191 expectedSizes.PushBack(Vector2(60, 25));
5193 expectedPositions.PushBack(Vector2(-1, 25));
5194 expectedSizes.PushBack(Vector2(39, 25));
5196 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5201 int utcDaliTextEditorGeometryRTL(void)
5203 ToolkitTestApplication application;
5204 tet_infoline(" utcDaliTextEditorGeometryRTL");
5206 TextEditor editor = TextEditor::New();
5207 DALI_TEST_CHECK(editor);
5209 application.GetScene().Add(editor);
5211 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5212 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5213 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5214 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5215 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5216 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5218 // Avoid a crash when core load gl resources.
5219 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5221 // Render and notify
5222 application.SendNotification();
5223 application.Render();
5225 unsigned int expectedCount = 4;
5226 unsigned int startIndex = 3;
5227 unsigned int endIndex = 24;
5229 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5230 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5232 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5233 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5235 Vector<Vector2> expectedSizes;
5236 Vector<Vector2> expectedPositions;
5238 expectedPositions.PushBack(Vector2(25, 0));
5239 expectedSizes.PushBack(Vector2(34, 25));
5241 expectedPositions.PushBack(Vector2(-1, 25));
5242 expectedSizes.PushBack(Vector2(53, 25));
5244 expectedPositions.PushBack(Vector2(-1, 50));
5245 expectedSizes.PushBack(Vector2(60, 25));
5247 expectedPositions.PushBack(Vector2(63, 75));
5248 expectedSizes.PushBack(Vector2(37, 25));
5250 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5255 int utcDaliTextEditorGeometryGlyphMiddle(void)
5257 ToolkitTestApplication application;
5258 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5260 TextEditor editor = TextEditor::New();
5261 DALI_TEST_CHECK(editor);
5263 application.GetScene().Add(editor);
5265 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5266 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5267 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5268 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5269 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5270 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5272 // Avoid a crash when core load gl resources.
5273 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5275 // Render and notify
5276 application.SendNotification();
5277 application.Render();
5279 unsigned int expectedCount = 1;
5280 unsigned int startIndex = 1;
5281 unsigned int endIndex = 13;
5283 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5284 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5286 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5287 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5289 Vector<Vector2> expectedSizes;
5290 Vector<Vector2> expectedPositions;
5292 expectedPositions.PushBack(Vector2(6, 0));
5293 expectedSizes.PushBack(Vector2(125, 25));
5295 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5300 int utcDaliTextEditorGeometryOneGlyph(void)
5302 ToolkitTestApplication application;
5303 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5305 TextEditor label = TextEditor::New();
5306 DALI_TEST_CHECK(label);
5308 application.GetScene().Add(label);
5310 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5311 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5312 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5313 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5314 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5315 label.SetProperty(TextEditor::Property::TEXT, "H");
5317 // Avoid a crash when core load gl resources.
5318 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5320 // Render and notify
5321 application.SendNotification();
5322 application.Render();
5324 unsigned int expectedCount = 1;
5325 unsigned int startIndex = 0;
5326 unsigned int endIndex = 0;
5328 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5329 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5331 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5332 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5334 Vector<Vector2> expectedSizes;
5335 Vector<Vector2> expectedPositions;
5337 expectedPositions.PushBack(Vector2(-2, 0));
5338 expectedSizes.PushBack(Vector2(16, 25));
5340 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5345 int utcDaliTextEditorGeometryNullPtr(void)
5347 ToolkitTestApplication application;
5348 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5350 TextEditor editor = TextEditor::New();
5351 DALI_TEST_CHECK(editor);
5353 application.GetScene().Add(editor);
5355 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5356 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5357 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5358 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5359 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5360 editor.SetProperty(TextEditor::Property::TEXT, "");
5362 // Avoid a crash when core load gl resources.
5363 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5365 unsigned int expectedCount = 0;
5366 unsigned int startIndex = 0;
5367 unsigned int endIndex = 0;
5369 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5370 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5372 // Render and notify
5373 application.SendNotification();
5374 application.Render();
5376 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5377 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5382 int utcDaliTextEditorSelectionClearedSignal(void)
5384 ToolkitTestApplication application;
5385 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5387 TextEditor editor = TextEditor::New();
5388 DALI_TEST_CHECK(editor);
5390 application.GetScene().Add(editor);
5392 // connect to the selection changed signal.
5393 ConnectionTracker* testTracker = new ConnectionTracker();
5394 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5395 bool selectionClearedSignal = false;
5396 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5398 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5399 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5400 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5401 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5402 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5404 // Avoid a crash when core load gl resources.
5405 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5407 // Render and notify
5408 application.SendNotification();
5409 application.Render();
5411 // Tap on the text editor
5412 TestGenerateTap(application, 3.0f, 25.0f);
5414 // Render and notify
5415 application.SendNotification();
5416 application.Render();
5418 // Move to second line of the text & Select some text in the right of the current cursor position
5419 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5420 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5423 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5425 // Render and notify
5426 application.SendNotification();
5427 application.Render();
5429 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5431 // Render and notify
5432 application.SendNotification();
5433 application.Render();
5435 // Tap on the text editor
5436 TestGenerateTap(application, 3.0f, 25.0f);
5438 // Render and notify
5439 application.SendNotification();
5440 application.Render();
5442 gSelectionClearedCallbackCalled = false;
5444 // Move to second line of the text & select.
5445 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5446 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5449 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5451 // Render and notify
5452 application.SendNotification();
5453 application.Render();
5455 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5457 gSelectionClearedCallbackCalled = false;
5459 // Render and notify
5460 application.SendNotification();
5461 application.Render();
5463 // Move to second line of the text & select.
5464 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5465 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5467 // replace C with selected text
5468 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5470 // Render and notify
5471 application.SendNotification();
5472 application.Render();
5474 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5476 gSelectionClearedCallbackCalled = false;
5478 // Render and notify
5479 application.SendNotification();
5480 application.Render();
5482 DevelTextEditor::SelectText(editor, 1, 3);
5484 // Render and notify
5485 application.SendNotification();
5486 application.Render();
5488 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5490 // Render and notify
5491 application.SendNotification();
5492 application.Render();
5494 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5496 gSelectionClearedCallbackCalled = false;
5498 DevelTextEditor::SelectText(editor, 1, 3);
5500 // Render and notify
5501 application.SendNotification();
5502 application.Render();
5505 DevelTextEditor::SelectNone(editor);
5507 // Render and notify
5508 application.SendNotification();
5509 application.Render();
5511 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5516 int utcDaliTextEditorSelectionStartedSignal(void)
5518 ToolkitTestApplication application;
5519 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5521 TextEditor editor = TextEditor::New();
5522 DALI_TEST_CHECK(editor);
5524 application.GetScene().Add(editor);
5526 // connect to the selection changed signal.
5527 ConnectionTracker* testTracker = new ConnectionTracker();
5528 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5529 bool selectionStartedSignal = false;
5530 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5532 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5533 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5534 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5535 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5536 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5538 // Avoid a crash when core load gl resources.
5539 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5541 // Render and notify
5542 application.SendNotification();
5543 application.Render();
5545 // Tap on the text editor
5546 TestGenerateTap(application, 3.0f, 25.0f);
5548 // Render and notify
5549 application.SendNotification();
5550 application.Render();
5552 // Move to second line of the text & Select some text in the right of the current cursor position
5553 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5554 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5556 // Render and notify
5557 application.SendNotification();
5558 application.Render();
5560 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5563 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5565 // Render and notify
5566 application.SendNotification();
5567 application.Render();
5569 gSelectionStartedCallbackCalled = false;
5571 DevelTextEditor::SelectText(editor, 1, 3);
5573 // Render and notify
5574 application.SendNotification();
5575 application.Render();
5577 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5582 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5584 ToolkitTestApplication application;
5585 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5587 // Checks if the actor is created.
5589 TextEditor editor = TextEditor::New();
5590 DALI_TEST_CHECK(editor);
5592 application.GetScene().Add(editor);
5594 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5595 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5596 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5597 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5598 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5599 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5600 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5601 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5603 // Avoid a crash when core load gl resources.
5604 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5606 // Render and notify
5607 application.SendNotification();
5608 application.Render();
5610 // Tap on the text editor
5611 TestGenerateTap(application, 3.0f, 25.0f);
5613 // Render and notify
5614 application.SendNotification();
5615 application.Render();
5617 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5618 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5620 application.SendNotification();
5621 application.Render();
5623 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5624 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5629 int utcDaliTextEditorSelectionChangedSignal(void)
5631 ToolkitTestApplication application;
5632 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5634 TextEditor editor = TextEditor::New();
5635 DALI_TEST_CHECK(editor);
5637 application.GetScene().Add(editor);
5639 // connect to the selection changed signal.
5640 ConnectionTracker* testTracker = new ConnectionTracker();
5641 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5642 bool selectionChangedSignal = false;
5643 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5645 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5646 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5647 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5648 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5649 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5651 // Avoid a crash when core load gl resources.
5652 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5654 // Render and notify
5655 application.SendNotification();
5656 application.Render();
5658 // Tap on the text editor
5659 TestGenerateTap(application, 3.0f, 25.0f);
5661 // Render and notify
5662 application.SendNotification();
5663 application.Render();
5665 // Move to second line of the text.
5666 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5668 // Render and notify
5669 application.SendNotification();
5670 application.Render();
5672 // Select some text in the right of the current cursor position
5673 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5674 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5676 // Render and notify
5677 application.SendNotification();
5678 application.Render();
5680 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5681 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5683 gSelectionChangedCallbackCalled = false;
5685 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5687 // Render and notify
5688 application.SendNotification();
5689 application.Render();
5691 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5692 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5693 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5695 gSelectionChangedCallbackCalled = false;
5697 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5699 // Render and notify
5700 application.SendNotification();
5701 application.Render();
5703 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5704 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5705 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5707 gSelectionChangedCallbackCalled = false;
5708 editor.SetKeyInputFocus();
5710 // Render and notify
5711 application.SendNotification();
5712 application.Render();
5714 DevelTextEditor::SelectText(editor, 0, 5);
5716 application.SendNotification();
5717 application.Render();
5719 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5720 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5722 gSelectionChangedCallbackCalled = false;
5724 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5726 // Render and notify
5727 application.SendNotification();
5728 application.Render();
5730 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5731 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5732 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5734 gSelectionChangedCallbackCalled = false;
5737 DevelTextEditor::SelectWholeText(editor);
5739 // Render and notify
5740 application.SendNotification();
5741 application.Render();
5743 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5744 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5746 gSelectionChangedCallbackCalled = false;
5749 DevelTextEditor::SelectNone(editor);
5751 // Render and notify
5752 application.SendNotification();
5753 application.Render();
5755 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5756 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5757 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5762 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5764 ToolkitTestApplication application;
5765 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5767 TextEditor textEditor = TextEditor::New();
5768 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5769 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5770 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5771 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5773 application.GetScene().Add(textEditor);
5774 application.SendNotification();
5775 application.Render();
5777 Property::Map strikethroughMapSet;
5778 Property::Map strikethroughMapGet;
5780 strikethroughMapSet.Insert("enable", true);
5781 strikethroughMapSet.Insert("color", Color::RED);
5782 strikethroughMapSet.Insert("height", 2.0f);
5784 // Check the strikethrough property
5785 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5786 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5787 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5788 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5789 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5791 // Render and notify
5792 application.SendNotification();
5793 application.Render();
5795 strikethroughMapSet.Clear();
5796 strikethroughMapGet.Clear();
5801 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5803 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5804 //DaliException on vector: "Iterator not inside vector"
5806 ToolkitTestApplication application;
5807 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5809 TextEditor editor = TextEditor::New();
5810 DALI_TEST_CHECK(editor);
5812 application.GetScene().Add(editor);
5814 // Avoid a crash when core load gl resources.
5815 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5817 //Set multilines text
5818 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5819 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5820 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5822 //Set ResizePolicy to NaturalSize
5823 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5825 // Render and notify
5826 application.SendNotification();
5827 application.Render();
5829 // Create a tap event to touch the text editor.
5830 TestGenerateTap(application, 5.0f, 5.0f);
5832 // Render and notify
5833 application.SendNotification();
5834 application.Render();
5836 // Set currsor and add character (in first line)
5837 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5838 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5839 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5841 // Render and notify
5842 application.SendNotification();
5843 application.Render();
5845 //Check the changed text and cursor position
5846 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5847 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5849 // Render and notify
5850 application.SendNotification();
5851 application.Render();
5856 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5858 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5859 //DaliException on vector: "Iterator not inside vector"
5861 ToolkitTestApplication application;
5862 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5864 TextEditor editor = TextEditor::New();
5865 DALI_TEST_CHECK(editor);
5867 application.GetScene().Add(editor);
5869 // Avoid a crash when core load gl resources.
5870 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5872 //Set multilines text
5873 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5874 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5875 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5877 //Set ResizePolicy to NaturalSize
5878 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5881 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5882 application.SendNotification();
5883 application.Render();
5885 // Set focus and remove character
5886 editor.SetKeyInputFocus();
5887 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5889 // Render and notify
5890 application.SendNotification();
5891 application.Render();
5893 //Check the changed text and cursor position
5894 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5895 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5897 // Render and notify
5898 application.SendNotification();
5899 application.Render();
5904 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5906 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5907 //DaliException on vector: "Iterator not inside vector"
5909 ToolkitTestApplication application;
5910 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5912 TextEditor editor = TextEditor::New();
5913 DALI_TEST_CHECK(editor);
5915 application.GetScene().Add(editor);
5917 // Avoid a crash when core load gl resources.
5918 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5920 //Set multilines text
5921 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5922 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5923 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5925 //Set ResizePolicy to NaturalSize
5926 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5928 //Select text at initialization (before the first render)
5929 DevelTextEditor::SelectText(editor, 3, 5);
5931 // Render and notify
5932 application.SendNotification();
5933 application.Render();
5936 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5937 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));
5939 // Render and notify
5940 application.SendNotification();
5941 application.Render();
5943 //Check the changed text and cursor position
5944 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5945 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5947 // Render and notify
5948 application.SendNotification();
5949 application.Render();
5954 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5956 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5957 //DaliException on vector: "Iterator not inside vector"
5959 ToolkitTestApplication application;
5960 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5962 TextEditor editor = TextEditor::New();
5963 DALI_TEST_CHECK(editor);
5965 application.GetScene().Add(editor);
5967 // Avoid a crash when core load gl resources.
5968 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5970 //Set multilines text
5971 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5972 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5973 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5975 //Set ResizePolicy to NaturalSize
5976 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5979 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5980 application.SendNotification();
5981 application.Render();
5983 // Set focus and double enter (new line)
5984 editor.SetKeyInputFocus();
5985 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5986 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5988 // Render and notify
5989 application.SendNotification();
5990 application.Render();
5992 //Check the changed text and cursor position
5993 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5994 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5996 // Render and notify
5997 application.SendNotification();
5998 application.Render();
6003 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
6005 ToolkitTestApplication application;
6006 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
6007 TextEditor textEditor = TextEditor::New();
6008 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
6009 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6010 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6011 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6013 application.GetScene().Add(textEditor);
6014 application.SendNotification();
6015 application.Render();
6017 Property::Map underlineMapSet;
6018 Property::Map underlineMapGet;
6020 underlineMapSet.Insert("enable", true);
6021 underlineMapSet.Insert("color", Color::RED);
6022 underlineMapSet.Insert("height", 1);
6023 underlineMapSet.Insert("type", Text::Underline::SOLID);
6024 underlineMapSet.Insert("dashWidth", 2);
6025 underlineMapSet.Insert("dashGap", 1);
6027 // Check the underline property
6028 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6030 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6031 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6032 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6034 // Render and notify
6035 application.SendNotification();
6036 application.Render();
6038 underlineMapSet.Clear();
6039 underlineMapGet.Clear();
6041 underlineMapSet.Insert("enable", true);
6042 underlineMapSet.Insert("color", Color::BLUE);
6043 underlineMapSet.Insert("height", 1);
6044 underlineMapSet.Insert("type", Text::Underline::DASHED);
6045 underlineMapSet.Insert("dashWidth", 4);
6046 underlineMapSet.Insert("dashGap", 2);
6048 // Check the dashed underline property
6049 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6051 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6052 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6053 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6055 // Render and notify
6056 application.SendNotification();
6057 application.Render();
6059 underlineMapSet.Clear();
6060 underlineMapGet.Clear();
6062 underlineMapSet.Insert("enable", true);
6063 underlineMapSet.Insert("color", Color::BLUE);
6064 underlineMapSet.Insert("height", 1);
6065 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6066 underlineMapSet.Insert("dashWidth", 4);
6067 underlineMapSet.Insert("dashGap", 2);
6069 // Check the dashed underline property
6070 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6072 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6073 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6074 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6076 // Render and notify
6077 application.SendNotification();
6078 application.Render();
6080 underlineMapSet.Clear();
6081 underlineMapGet.Clear();
6086 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6088 ToolkitTestApplication application;
6089 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6091 TextEditor textEditor1 = TextEditor::New();
6092 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6093 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6094 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6095 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6097 Property::Map underlineMapSet1;
6098 Property::Map underlineMapGet1;
6100 underlineMapSet1.Insert("enable", true);
6101 underlineMapSet1.Insert("color", Color::RED);
6102 underlineMapSet1.Insert("height", 1);
6103 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6104 underlineMapSet1.Insert("dashWidth", 2);
6105 underlineMapSet1.Insert("dashGap", 1);
6107 // Check the underline property
6108 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6110 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6111 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6112 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6114 application.GetScene().Add(textEditor1);
6115 application.SendNotification();
6116 application.Render();
6118 TextEditor textEditor2 = TextEditor::New();
6119 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6120 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6121 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6122 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6124 Property::Map underlineMapSet2;
6125 Property::Map underlineMapGet2;
6127 underlineMapSet2.Insert("enable", true);
6128 underlineMapSet2.Insert("color", Color::BLUE);
6129 underlineMapSet2.Insert("height", 1);
6130 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6131 underlineMapSet2.Insert("dashWidth", 4);
6132 underlineMapSet2.Insert("dashGap", 2);
6134 // Check the dashed underline property
6135 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6137 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6138 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6139 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6141 application.GetScene().Add(textEditor2);
6142 application.SendNotification();
6143 application.Render();
6145 TextEditor textEditor3 = TextEditor::New();
6146 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6147 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6148 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6149 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6151 Property::Map underlineMapSet3;
6152 Property::Map underlineMapGet3;
6154 underlineMapSet3.Insert("enable", true);
6155 underlineMapSet3.Insert("color", Color::BLUE);
6156 underlineMapSet3.Insert("height", 1);
6157 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6158 underlineMapSet3.Insert("dashWidth", 4);
6159 underlineMapSet3.Insert("dashGap", 2);
6161 // Check the dashed underline property
6162 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6164 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6165 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6166 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6168 application.GetScene().Add(textEditor3);
6169 application.SendNotification();
6170 application.Render();
6175 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6177 ToolkitTestApplication application;
6178 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6180 TextEditor textEditor1 = TextEditor::New();
6181 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6182 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6183 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6184 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6186 Property::Map underlineMapSet1;
6187 Property::Map underlineMapGet1;
6189 underlineMapSet1.Insert("enable", true);
6190 underlineMapSet1.Insert("color", Color::RED);
6191 underlineMapSet1.Insert("height", 1);
6192 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6193 underlineMapSet1.Insert("dashWidth", 2);
6194 underlineMapSet1.Insert("dashGap", 1);
6196 // Check the underline property
6197 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6198 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6200 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6201 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6202 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6204 application.GetScene().Add(textEditor1);
6206 application.SendNotification();
6207 application.Render();
6212 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6214 ToolkitTestApplication application;
6215 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6217 TextEditor editor = TextEditor::New();
6218 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6219 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6220 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6221 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6222 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6223 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6225 TextEditor editorSingleLineParagraph = TextEditor::New();
6226 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6227 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6228 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");
6229 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6230 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6231 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6233 TextEditor editorMultiLineParagraph = TextEditor::New();
6234 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6235 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6236 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");
6237 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6238 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6239 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6241 application.GetScene().Add(editor);
6242 application.GetScene().Add(editorSingleLineParagraph);
6243 application.GetScene().Add(editorMultiLineParagraph);
6244 application.SendNotification();
6245 application.Render();
6247 Vector3 naturalSize = editor.GetNaturalSize();
6248 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6249 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6251 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6253 //no effect of relative line size for paragraph with single line
6254 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6256 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6261 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6263 ToolkitTestApplication application;
6264 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6266 TextEditor editor = TextEditor::New();
6267 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6268 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6269 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6271 application.GetScene().Add(editor);
6272 application.SendNotification();
6273 application.Render();
6275 Vector3 naturalSize = editor.GetNaturalSize();
6277 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6279 application.SendNotification();
6280 application.Render();
6282 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6284 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6286 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6288 application.SendNotification();
6289 application.Render();
6291 relativeNaturalSize = editor.GetNaturalSize();
6293 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6297 int UtcDaliTextEditorCharacterSpacing(void)
6299 ToolkitTestApplication application;
6300 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6302 TextEditor textEditor = TextEditor::New();
6304 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6306 application.GetScene().Add(textEditor);
6307 application.SendNotification();
6308 application.Render();
6310 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6311 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6312 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6314 application.SendNotification();
6315 application.Render();
6320 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6322 ToolkitTestApplication application;
6323 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6325 TextEditor editor = TextEditor::New();
6327 float lineSpacing = -20.f;
6329 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6330 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6331 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6332 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6334 application.GetScene().Add(editor);
6335 application.SendNotification();
6336 application.Render();
6338 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6339 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6341 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6342 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6344 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6345 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6347 application.SendNotification();
6348 application.Render();
6353 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6355 ToolkitTestApplication application;
6356 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6358 TextEditor editor = TextEditor::New();
6359 DALI_TEST_CHECK(editor);
6361 application.GetScene().Add(editor);
6363 std::string cutText = "";
6364 std::string copiedText = "";
6366 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6367 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6368 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6369 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6370 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6371 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6372 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6374 // Render and notify
6375 application.SendNotification();
6376 application.Render();
6378 // Tap on the text editor
6379 TestGenerateTap(application, 1.0f, 1.0f);
6381 // Render and notify
6382 application.SendNotification();
6383 application.Render();
6385 // Move to second line of the text.
6386 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6388 // Render and notify
6389 application.SendNotification();
6390 application.Render();
6392 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6397 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6399 ToolkitTestApplication application;
6400 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6402 TextEditor editor = TextEditor::New();
6404 float lineSpacing = -20.f;
6406 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6407 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6408 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6409 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6410 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6412 application.GetScene().Add(editor);
6413 application.SendNotification();
6414 application.Render();
6416 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6418 int lineCount = sizeList.Size();
6419 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6421 application.SendNotification();
6422 application.Render();
6427 int UtcDaliToolkitTexteditorParagraphTag(void)
6429 ToolkitTestApplication application;
6430 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6431 TextEditor editorNewlineSeparator = TextEditor::New();
6432 TextEditor editorParagraphTag = TextEditor::New();
6433 DALI_TEST_CHECK(editorNewlineSeparator);
6434 DALI_TEST_CHECK(editorParagraphTag);
6436 application.GetScene().Add(editorNewlineSeparator);
6437 application.GetScene().Add(editorParagraphTag);
6439 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6440 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6441 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6442 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6443 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6444 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6446 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6447 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6448 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6449 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6450 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6452 application.SendNotification();
6453 application.Render();
6455 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6456 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6458 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6460 application.SendNotification();
6461 application.Render();
6466 //Handle Emoji clustering for cursor handling
6467 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6469 ToolkitTestApplication application;
6470 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6471 TextEditor textEditor = TextEditor::New();
6472 DALI_TEST_CHECK(textEditor);
6474 application.GetScene().Add(textEditor);
6476 // Avoid a crash when core load gl resources.
6477 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6479 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6480 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6482 // Render and notify
6483 application.SendNotification();
6484 application.Render();
6487 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6488 application.SendNotification();
6489 application.Render();
6491 // Set focus and remove Emoji
6492 textEditor.SetKeyInputFocus();
6493 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6495 //Check the changed text and cursor position
6496 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6497 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6499 // Render and notify
6500 application.SendNotification();
6501 application.Render();
6506 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6508 ToolkitTestApplication application;
6509 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6510 TextEditor textEditor = TextEditor::New();
6511 DALI_TEST_CHECK(textEditor);
6513 application.GetScene().Add(textEditor);
6515 // Avoid a crash when core load gl resources.
6516 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6518 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6519 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6521 // Render and notify
6522 application.SendNotification();
6523 application.Render();
6526 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6527 application.SendNotification();
6528 application.Render();
6530 // Set focus and remove Emoji
6531 textEditor.SetKeyInputFocus();
6532 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6534 //Check the changed text and cursor position
6535 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6536 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6538 // Render and notify
6539 application.SendNotification();
6540 application.Render();
6545 int utcDaliTextEditorPanGesturePropagation(void)
6547 ToolkitTestApplication application;
6548 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6550 Actor actor = Actor::New();
6551 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6552 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6553 application.GetScene().Add(actor);
6555 TextEditor editor = TextEditor::New();
6556 DALI_TEST_CHECK(editor);
6558 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6559 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6561 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6562 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6563 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6567 // Render and notify
6568 application.SendNotification();
6569 application.Render();
6572 GestureReceivedFunctor functor(data);
6574 PanGestureDetector detector = PanGestureDetector::New();
6575 detector.Attach(actor);
6576 detector.DetectedSignal().Connect(&application, functor);
6578 // Tap first to get the focus.
6579 TestGenerateTap(application, 3.0f, 25.0f, 100);
6581 // Render and notify
6582 application.SendNotification();
6583 application.Render();
6585 // Pan the text editor
6586 uint32_t time = 100;
6587 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6588 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6589 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6590 application.SendNotification();
6591 application.Render();
6593 // The text scrolls because there is text that is scrolling.
6594 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6597 // Set the size large enough to prevent scrolling.
6598 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6600 // Render and notify
6601 application.SendNotification();
6602 application.Render();
6605 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6606 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6607 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6609 // Because scrolling is not possible, the pan gesture is propagated.
6610 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6616 int utcDaliTextEditorGetTextBoundingRectangle(void)
6618 ToolkitTestApplication application;
6619 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6621 TextEditor editor = TextEditor::New();
6622 DALI_TEST_CHECK(editor);
6624 application.GetScene().Add(editor);
6626 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6627 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6628 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6629 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6630 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6632 // Avoid a crash when core load gl resources.
6633 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6635 // Render and notify
6636 application.SendNotification();
6637 application.Render();
6639 unsigned int startIndex = 0;
6640 unsigned int endIndex = 15;
6642 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6643 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6645 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6650 int utcDaliTextEditorRemoveFrontInset(void)
6652 ToolkitTestApplication application;
6653 tet_infoline(" utcDaliTextEditorRemoveFrontInset");
6654 TextEditor editor = TextEditor::New();
6655 DALI_TEST_CHECK(editor);
6656 application.GetScene().Add(editor);
6657 application.SendNotification();
6658 application.Render();
6659 DevelTextEditor::SetRemoveFrontInset(editor, false);
6660 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveFrontInset(editor));
6663 int utcDaliTextEditorRemoveBackInset(void)
6665 ToolkitTestApplication application;
6666 tet_infoline(" utcDaliTextEditorRemoveBackInset");
6667 TextEditor editor = TextEditor::New();
6668 DALI_TEST_CHECK(editor);
6669 application.GetScene().Add(editor);
6670 application.SendNotification();
6671 application.Render();
6672 DevelTextEditor::SetRemoveBackInset(editor, false);
6673 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveBackInset(editor));