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, true);
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, true);
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 utcDaliTextEditorFocusWithInputMethodContext(void)
1481 ToolkitTestApplication application;
1482 tet_infoline(" utcDaliTextEditorFocusWithInputMethodContext");
1483 TextEditor editor = TextEditor::New();
1484 DALI_TEST_CHECK(editor);
1486 application.GetScene().Add(editor);
1487 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1488 application.SendNotification();
1489 application.Render();
1491 // get InputMethodContext
1492 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1493 DALI_TEST_CHECK(inputMethodContext);
1495 // connect StatusChangedSignal
1496 editor.SetKeyInputFocus();
1499 inputMethodContext.StatusChangedSignal().Emit(true);
1500 application.SendNotification();
1501 application.Render();
1504 inputMethodContext.StatusChangedSignal().Emit(false);
1505 application.SendNotification();
1506 application.Render();
1508 // set focus and keyboard shown
1509 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
1510 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
1512 inputMethodContext.StatusChangedSignal().Emit(true);
1513 application.SendNotification();
1514 application.Render();
1516 // keyboard hidden, focus should remain
1517 inputMethodContext.StatusChangedSignal().Emit(false);
1518 application.SendNotification();
1519 application.Render();
1521 DALI_TEST_EQUALS(editor, KeyboardFocusManager::Get().GetCurrentFocusActor(), TEST_LOCATION);
1526 int utcDaliTextEditorInputStyleChanged01(void)
1528 // The text-editor emits signals when the input style changes. These changes of style are
1529 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1530 // can't be emitted during the size negotiation as the callbacks may update the UI.
1531 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1532 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1533 ToolkitTestApplication application;
1534 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1538 char* pathNamePtr = get_current_dir_name();
1539 const std::string pathName(pathNamePtr);
1542 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1543 fontClient.SetDpi(93u, 93u);
1545 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1546 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1548 TextEditor editor = TextEditor::New();
1549 DALI_TEST_CHECK(editor);
1551 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1552 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1553 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1555 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1556 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1558 // connect to the text changed signal.
1559 ConnectionTracker* testTracker = new ConnectionTracker();
1560 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1561 bool inputStyleChangedSignal = false;
1562 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1564 application.GetScene().Add(editor);
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Executes the idle callbacks added by the text control on the change of input style.
1571 application.RunIdles();
1573 gInputStyleChangedCallbackCalled = false;
1574 gInputStyleMask = TextEditor::InputStyle::NONE;
1575 inputStyleChangedSignal = false;
1577 // Create a tap event to touch the text editor.
1578 TestGenerateTap(application, 18.0f, 25.0f);
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Executes the idle callbacks added by the text control on the change of input style.
1585 application.RunIdles();
1587 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1588 if(gInputStyleChangedCallbackCalled)
1590 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1592 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1593 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1595 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1596 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1598 DALI_TEST_CHECK(inputStyleChangedSignal);
1600 gInputStyleChangedCallbackCalled = false;
1601 gInputStyleMask = TextEditor::InputStyle::NONE;
1602 inputStyleChangedSignal = false;
1604 // Create a tap event to touch the text editor.
1605 TestGenerateTap(application, 30.0f, 25.0f);
1607 // Render and notify
1608 application.SendNotification();
1609 application.Render();
1611 // Executes the idle callbacks added by the text control on the change of input style.
1612 application.RunIdles();
1614 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1615 DALI_TEST_CHECK(!inputStyleChangedSignal);
1617 gInputStyleChangedCallbackCalled = false;
1618 gInputStyleMask = TextEditor::InputStyle::NONE;
1619 inputStyleChangedSignal = false;
1621 // Create a tap event to touch the text editor.
1622 TestGenerateTap(application, 43.0f, 25.0f);
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 // Executes the idle callbacks added by the text control on the change of input style.
1629 application.RunIdles();
1631 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1632 if(gInputStyleChangedCallbackCalled)
1634 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1636 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1637 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1639 DALI_TEST_CHECK(inputStyleChangedSignal);
1641 gInputStyleChangedCallbackCalled = false;
1642 gInputStyleMask = TextEditor::InputStyle::NONE;
1643 inputStyleChangedSignal = false;
1645 // Create a tap event to touch the text editor.
1646 TestGenerateTap(application, 88.0f, 25.0f);
1648 // Render and notify
1649 application.SendNotification();
1650 application.Render();
1652 // Executes the idle callbacks added by the text control on the change of input style.
1653 application.RunIdles();
1655 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1656 if(gInputStyleChangedCallbackCalled)
1658 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1660 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1661 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1663 Property::Map fontStyleMapSet;
1664 Property::Map fontStyleMapGet;
1666 fontStyleMapSet.Insert("weight", "bold");
1668 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1669 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1670 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1672 DALI_TEST_CHECK(inputStyleChangedSignal);
1674 gInputStyleChangedCallbackCalled = false;
1675 gInputStyleMask = TextEditor::InputStyle::NONE;
1676 inputStyleChangedSignal = false;
1678 // Create a tap event to touch the text editor.
1679 TestGenerateTap(application, 115.0f, 25.0f);
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1685 // Executes the idle callbacks added by the text control on the change of input style.
1686 application.RunIdles();
1688 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1689 DALI_TEST_CHECK(!inputStyleChangedSignal);
1691 gInputStyleChangedCallbackCalled = false;
1692 gInputStyleMask = TextEditor::InputStyle::NONE;
1693 inputStyleChangedSignal = false;
1695 // Create a tap event to touch the text editor.
1696 TestGenerateTap(application, 164.0f, 25.0f);
1698 // Render and notify
1699 application.SendNotification();
1700 application.Render();
1702 // Executes the idle callbacks added by the text control on the change of input style.
1703 application.RunIdles();
1705 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1706 if(gInputStyleChangedCallbackCalled)
1708 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1710 Property::Map fontStyleMapSet;
1711 Property::Map fontStyleMapGet;
1713 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1714 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1715 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1717 DALI_TEST_CHECK(inputStyleChangedSignal);
1719 gInputStyleChangedCallbackCalled = false;
1720 gInputStyleMask = TextEditor::InputStyle::NONE;
1721 inputStyleChangedSignal = false;
1723 // Create a tap event to touch the text editor.
1724 TestGenerateTap(application, 191.0f, 25.0f);
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // Executes the idle callbacks added by the text control on the change of input style.
1731 application.RunIdles();
1733 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1734 DALI_TEST_CHECK(!inputStyleChangedSignal);
1739 int utcDaliTextEditorInputStyleChanged02(void)
1741 // The text-editor emits signals when the input style changes. These changes of style are
1742 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1743 // can't be emitted during the size negotiation as the callbacks may update the UI.
1744 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1745 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1746 ToolkitTestApplication application;
1747 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1751 char* pathNamePtr = get_current_dir_name();
1752 const std::string pathName(pathNamePtr);
1755 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1756 fontClient.SetDpi(93u, 93u);
1758 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1759 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1761 TextEditor editor = TextEditor::New();
1762 DALI_TEST_CHECK(editor);
1764 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1765 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1766 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1768 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1769 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>");
1771 // connect to the text changed signal.
1772 ConnectionTracker* testTracker = new ConnectionTracker();
1773 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1774 bool inputStyleChangedSignal = false;
1775 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1777 application.GetScene().Add(editor);
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 // Executes the idle callbacks added by the text control on the change of input style.
1784 application.RunIdles();
1786 gInputStyleChangedCallbackCalled = false;
1787 gInputStyleMask = TextEditor::InputStyle::NONE;
1788 inputStyleChangedSignal = false;
1790 // Create a tap event to touch the text editor.
1791 TestGenerateTap(application, 53.0f, 25.0f, 100);
1792 TestGenerateTap(application, 53.0f, 25.0f, 200);
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Executes the idle callbacks added by the text control on the change of input style.
1799 application.RunIdles();
1801 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1802 if(gInputStyleChangedCallbackCalled)
1804 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1805 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1806 TextEditor::InputStyle::POINT_SIZE |
1807 TextEditor::InputStyle::COLOR),
1810 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1811 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1813 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1814 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1816 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1817 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1819 DALI_TEST_CHECK(inputStyleChangedSignal);
1821 gInputStyleChangedCallbackCalled = false;
1822 gInputStyleMask = TextEditor::InputStyle::NONE;
1823 inputStyleChangedSignal = false;
1825 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1827 // Render and notify
1828 application.SendNotification();
1829 application.Render();
1831 // Executes the idle callbacks added by the text control on the change of input style.
1832 application.RunIdles();
1834 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1835 if(gInputStyleChangedCallbackCalled)
1837 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1838 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1841 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1842 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1844 DALI_TEST_CHECK(inputStyleChangedSignal);
1846 gInputStyleChangedCallbackCalled = false;
1847 gInputStyleMask = TextEditor::InputStyle::NONE;
1848 inputStyleChangedSignal = false;
1850 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Executes the idle callbacks added by the text control on the change of input style.
1857 application.RunIdles();
1859 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1860 DALI_TEST_CHECK(!inputStyleChangedSignal);
1862 gInputStyleChangedCallbackCalled = false;
1863 gInputStyleMask = TextEditor::InputStyle::NONE;
1864 inputStyleChangedSignal = false;
1866 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1868 // Render and notify
1869 application.SendNotification();
1870 application.Render();
1872 // Executes the idle callbacks added by the text control on the change of input style.
1873 application.RunIdles();
1875 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1876 if(gInputStyleChangedCallbackCalled)
1878 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1879 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1882 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1883 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1885 DALI_TEST_CHECK(inputStyleChangedSignal);
1887 gInputStyleChangedCallbackCalled = false;
1888 gInputStyleMask = TextEditor::InputStyle::NONE;
1889 inputStyleChangedSignal = false;
1891 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1893 Property::Map fontStyleMapSet;
1894 fontStyleMapSet.Insert("weight", "thin");
1895 fontStyleMapSet.Insert("width", "condensed");
1896 fontStyleMapSet.Insert("slant", "italic");
1898 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1899 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1900 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1902 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1903 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1904 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1905 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1906 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1908 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 // Executes the idle callbacks added by the text control on the change of input style.
1915 application.RunIdles();
1917 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1918 DALI_TEST_CHECK(!inputStyleChangedSignal);
1920 // Create a tap event to touch the text editor.
1921 TestGenerateTap(application, 63.0f, 25.0f, 900);
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Executes the idle callbacks added by the text control on the change of input style.
1928 application.RunIdles();
1930 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1931 if(gInputStyleChangedCallbackCalled)
1933 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1934 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1935 TextEditor::InputStyle::POINT_SIZE |
1936 TextEditor::InputStyle::FONT_STYLE |
1937 TextEditor::InputStyle::LINE_SPACING |
1938 TextEditor::InputStyle::UNDERLINE |
1939 TextEditor::InputStyle::SHADOW |
1940 TextEditor::InputStyle::EMBOSS |
1941 TextEditor::InputStyle::OUTLINE),
1944 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1945 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1947 DALI_TEST_CHECK(inputStyleChangedSignal);
1949 gInputStyleChangedCallbackCalled = false;
1950 gInputStyleMask = TextEditor::InputStyle::NONE;
1951 inputStyleChangedSignal = false;
1953 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1955 fontStyleMapSet.Clear();
1956 fontStyleMapSet.Insert("weight", "black");
1957 fontStyleMapSet.Insert("width", "expanded");
1958 fontStyleMapSet.Insert("slant", "oblique");
1960 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1962 // Create a tap event to touch the text editor.
1963 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // Executes the idle callbacks added by the text control on the change of input style.
1970 application.RunIdles();
1972 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1973 if(gInputStyleChangedCallbackCalled)
1975 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1976 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1977 TextEditor::InputStyle::POINT_SIZE |
1978 TextEditor::InputStyle::FONT_STYLE),
1981 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1982 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1984 DALI_TEST_CHECK(inputStyleChangedSignal);
1989 int utcDaliTextEditorInputStyleChanged03(void)
1991 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1992 ToolkitTestApplication application;
1993 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1997 char* pathNamePtr = get_current_dir_name();
1998 const std::string pathName(pathNamePtr);
2001 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2002 fontClient.SetDpi(93u, 93u);
2004 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2005 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2007 TextEditor editor = TextEditor::New();
2008 DALI_TEST_CHECK(editor);
2010 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2011 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2012 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2014 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
2015 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2017 // connect to the text changed signal.
2018 ConnectionTracker* testTracker = new ConnectionTracker();
2019 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2020 bool inputStyleChangedSignal = false;
2021 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2023 application.GetScene().Add(editor);
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2029 // Executes the idle callbacks added by the text control on the change of input style.
2030 application.RunIdles();
2032 gInputStyleChangedCallbackCalled = false;
2033 gInputStyleMask = TextEditor::InputStyle::NONE;
2034 inputStyleChangedSignal = false;
2036 // Create a tap event to touch the text editor.
2037 TestGenerateTap(application, 18.0f, 25.0f);
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 // Executes the idle callbacks added by the text control on the change of input style.
2044 application.RunIdles();
2046 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2047 if(gInputStyleChangedCallbackCalled)
2049 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
2051 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
2052 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2054 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
2055 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2057 DALI_TEST_CHECK(inputStyleChangedSignal);
2059 gInputStyleChangedCallbackCalled = false;
2060 gInputStyleMask = TextEditor::InputStyle::NONE;
2061 inputStyleChangedSignal = false;
2063 // Create a tap event to touch the text editor.
2064 TestGenerateTap(application, 30.0f, 25.0f);
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2070 // Executes the idle callbacks added by the text control on the change of input style.
2071 application.RunIdles();
2073 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2074 DALI_TEST_CHECK(!inputStyleChangedSignal);
2076 gInputStyleChangedCallbackCalled = false;
2077 gInputStyleMask = TextEditor::InputStyle::NONE;
2078 inputStyleChangedSignal = false;
2080 // Create a tap event to touch the text editor.
2081 TestGenerateTap(application, 43.0f, 25.0f);
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 // Executes the idle callbacks added by the text control on the change of input style.
2088 application.RunIdles();
2090 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2091 if(gInputStyleChangedCallbackCalled)
2093 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2095 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2096 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2098 DALI_TEST_CHECK(inputStyleChangedSignal);
2100 gInputStyleChangedCallbackCalled = false;
2101 gInputStyleMask = TextEditor::InputStyle::NONE;
2102 inputStyleChangedSignal = false;
2104 // Make AddIdle return false.
2105 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2107 // Create a tap event to touch the text editor.
2108 TestGenerateTap(application, 88.0f, 25.0f);
2110 // Render and notify
2111 application.SendNotification();
2112 application.Render();
2114 // Execute the idle callbacks.
2115 // And check whether we didn't change of input style.
2116 application.RunIdles();
2118 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2119 DALI_TEST_CHECK(!inputStyleChangedSignal);
2121 gInputStyleChangedCallbackCalled = false;
2122 gInputStyleMask = TextEditor::InputStyle::NONE;
2123 inputStyleChangedSignal = false;
2125 // Create a tap event to touch the text editor.
2126 TestGenerateTap(application, 115.0f, 25.0f);
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 // Execute the idle callbacks.
2133 // And check whether we didn't change of input style.
2134 application.RunIdles();
2136 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2137 DALI_TEST_CHECK(!inputStyleChangedSignal);
2139 gInputStyleChangedCallbackCalled = false;
2140 gInputStyleMask = TextEditor::InputStyle::NONE;
2141 inputStyleChangedSignal = false;
2143 // Revert AddIdle return true.
2144 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2146 // Create a tap event to touch the text editor.
2147 TestGenerateTap(application, 164.0f, 25.0f);
2149 // Render and notify
2150 application.SendNotification();
2151 application.Render();
2153 // Executes the idle callbacks added by the text control on the change of input style.
2154 application.RunIdles();
2156 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2157 if(gInputStyleChangedCallbackCalled)
2159 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2161 Property::Map fontStyleMapSet;
2162 Property::Map fontStyleMapGet;
2164 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2165 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2166 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2168 DALI_TEST_CHECK(inputStyleChangedSignal);
2170 gInputStyleChangedCallbackCalled = false;
2171 gInputStyleMask = TextEditor::InputStyle::NONE;
2172 inputStyleChangedSignal = false;
2174 // Create a tap event to touch the text editor.
2175 TestGenerateTap(application, 191.0f, 25.0f);
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Executes the idle callbacks added by the text control on the change of input style.
2182 application.RunIdles();
2184 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2185 DALI_TEST_CHECK(!inputStyleChangedSignal);
2190 int utcDaliTextEditorEvent01(void)
2192 ToolkitTestApplication application;
2193 tet_infoline(" utcDaliTextEditorEvent01");
2195 // Creates a tap event. After creating a tap event the text editor should
2196 // have the focus and add text with key events should be possible.
2198 TextEditor editor = TextEditor::New();
2199 DALI_TEST_CHECK(editor);
2201 application.GetScene().Add(editor);
2203 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2204 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2205 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2207 // Avoid a crash when core load gl resources.
2208 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 // Add a key event but as the text editor has not the focus it should do nothing.
2215 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2223 // Create a tap event to touch the text editor.
2224 TestGenerateTap(application, 150.0f, 25.0f);
2226 // Render and notify
2227 application.SendNotification();
2228 application.Render();
2230 // Now the text editor has the focus, so it can handle the key events.
2231 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2232 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2234 // Render and notify
2235 application.SendNotification();
2236 application.Render();
2238 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2240 // Create a second text editor and send key events to it.
2241 TextEditor editor2 = TextEditor::New();
2243 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2244 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2245 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2246 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2248 application.GetScene().Add(editor2);
2250 // Render and notify
2251 application.SendNotification();
2252 application.Render();
2254 // Create a tap event on the second text editor.
2255 TestGenerateTap(application, 150.0f, 125.0f);
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2261 // The second text editor has the focus. It should handle the key events.
2262 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2263 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2269 // Check the text has been added to the second text editor.
2270 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2275 int utcDaliTextEditorEvent02(void)
2277 ToolkitTestApplication application;
2278 tet_infoline(" utcDaliTextEditorEvent02");
2280 // Checks if the right number of actors are created.
2282 TextEditor editor = TextEditor::New();
2283 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2284 DALI_TEST_CHECK(editor);
2286 application.GetScene().Add(editor);
2288 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2289 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2290 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2292 // Avoid a crash when core load gl resources.
2293 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 // Check there are the expected number of children (the stencil).
2300 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2302 Actor stencil = editor.GetChildAt(0u);
2304 // Create a tap event to touch the text editor.
2305 TestGenerateTap(application, 150.0f, 25.0f, 100);
2307 // Render and notify
2308 application.SendNotification();
2309 application.Render();
2311 Actor layer = editor.GetChildAt(2u);
2312 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2313 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2315 // Now the text editor has the focus, so it can handle the key events.
2316 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2317 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // Checks the cursor and the renderer have been created.
2324 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2325 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2327 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2328 DALI_TEST_CHECK(cursor);
2330 // The stencil actor has a container with all the actors which contain the text renderers.
2331 Actor container = stencil.GetChildAt(0u);
2332 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2334 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2335 DALI_TEST_CHECK(renderer);
2338 // Move the cursor and check the position changes.
2339 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2341 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2342 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2350 DALI_TEST_CHECK(position2.x < position1.x);
2352 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2361 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2363 // Send some taps and check the cursor positions.
2365 // Try to tap at the beginning.
2366 TestGenerateTap(application, 1.0f, 25.0f, 700);
2368 // Render and notify
2369 application.SendNotification();
2370 application.Render();
2372 // Cursor position should be the same than position1.
2373 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2375 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2377 // Tap away from the start position.
2378 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2386 DALI_TEST_CHECK(position5.x > position4.x);
2388 // Remove all the text.
2389 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2390 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2391 editor.SetProperty(TextEditor::Property::TEXT, "");
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Cursor position should be the same than position2.
2398 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2400 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2402 // Should not be a renderer, there is only a clipped cursor.
2403 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2408 int utcDaliTextEditorEvent03(void)
2410 ToolkitTestApplication application;
2411 tet_infoline(" utcDaliTextEditorEvent03");
2413 // Checks if the highlight actor is created.
2415 TextEditor editor = TextEditor::New();
2416 DALI_TEST_CHECK(editor);
2418 application.GetScene().Add(editor);
2420 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2421 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2422 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2423 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2424 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2426 // Avoid a crash when core load gl resources.
2427 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 // Send some taps and check text controller with clipboard window
2434 Dali::Clipboard clipboard = Clipboard::Get();
2435 clipboard.ShowClipboard();
2436 TestGenerateTap(application, 3.0f, 25.0f, 100);
2437 clipboard.HideClipboard();
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2443 // Tap first to get the focus.
2444 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2446 // Render and notify
2447 application.SendNotification();
2448 application.Render();
2450 // Double tap to select a word.
2451 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // The stencil actor should have two actors: the renderer and the highlight actor.
2458 Actor stencil = editor.GetChildAt(0u);
2460 // Highlight needs to be drawn before text, so should come first in child order
2461 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2462 DALI_TEST_CHECK(highlight);
2464 // The stencil actor has a container with all the actors which contain the text renderers.
2465 Actor container = stencil.GetChildAt(1u);
2466 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2468 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2469 DALI_TEST_CHECK(renderer);
2472 // Double tap out of bounds
2473 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2474 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 // The stencil actor should have one actors: the renderer actor.
2481 stencil = editor.GetChildAt(0u);
2483 // The stencil actor has a container with all the actors which contain the text renderers.
2484 container = stencil.GetChildAt(0u);
2485 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2487 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2488 DALI_TEST_CHECK(renderer);
2492 TestGenerateLongPress(application, 1.0f, 25.0f);
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2499 TestGenerateMiniPan(application);
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2508 int utcDaliTextEditorEvent04(void)
2510 ToolkitTestApplication application;
2511 tet_infoline(" utcDaliTextEditorEvent04");
2513 // Checks if the highlight actor is created.
2515 TextEditor editor = TextEditor::New();
2516 DALI_TEST_CHECK(editor);
2518 application.GetScene().Add(editor);
2520 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2521 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2522 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2523 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2524 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2526 // Avoid a crash when core load gl resources.
2527 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2529 // Render and notify
2530 application.SendNotification();
2531 application.Render();
2533 // Tap on the text editor
2534 TestGenerateTap(application, 3.0f, 25.0f);
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2540 // Move at the end of the text.
2541 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2542 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2548 for(unsigned int index = 0u; index < 10u; ++index)
2550 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2551 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2553 // Render and notify
2554 application.SendNotification();
2555 application.Render();
2559 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2561 // Render and notify
2562 application.SendNotification();
2563 application.Render();
2565 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2567 // Add some key events
2568 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2569 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2575 for(unsigned int index = 0u; index < 10u; ++index)
2577 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2578 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2586 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2592 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2597 int utcDaliTextEditorEvent05(void)
2599 ToolkitTestApplication application;
2600 tet_infoline(" utcDaliTextEditorEvent05");
2602 // Checks if the highlight actor is created.
2604 TextEditor editor = TextEditor::New();
2605 DALI_TEST_CHECK(editor);
2607 application.GetScene().Add(editor);
2609 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2610 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2611 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2612 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2613 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2614 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2615 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2616 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2617 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2618 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2620 // Avoid a crash when core load gl resources.
2621 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2623 // Render and notify
2624 application.SendNotification();
2625 application.Render();
2627 // Tap on the text editor
2628 TestGenerateTap(application, 3.0f, 25.0f);
2630 // Render and notify
2631 application.SendNotification();
2632 application.Render();
2634 // Move at the end of the text.
2635 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2636 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2638 // Render and notify
2639 application.SendNotification();
2640 application.Render();
2642 for(unsigned int index = 0u; index < 10u; ++index)
2645 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 // Modify duration after scroll is enabled
2652 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2654 // Continuous scroll left to increase coverage
2655 for(unsigned int index = 0u; index < 10u; ++index)
2657 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2664 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2665 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2666 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2667 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2669 // Press Escape to increase coverage
2670 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2671 application.SendNotification();
2672 application.Render();
2674 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2679 int utcDaliTextEditorEvent06(void)
2681 ToolkitTestApplication application;
2682 tet_infoline(" utcDaliTextEditorEvent06");
2684 // Checks if the highlight actor is created.
2686 TextEditor editor = TextEditor::New();
2687 DALI_TEST_CHECK(editor);
2689 application.GetScene().Add(editor);
2691 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2692 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2693 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2694 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2695 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2697 // Avoid a crash when core load gl resources.
2698 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2700 // Render and notify
2701 application.SendNotification();
2702 application.Render();
2704 // Tap on the text editor
2705 TestGenerateTap(application, 3.0f, 25.0f);
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2711 // Move to seconds line of the text.
2712 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 float layoutHeight = editor.GetHeightForWidth(100.f);
2720 // Add another script characters ( glyph height is defferent )
2721 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2722 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2724 // Delete characters
2725 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2726 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2728 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2730 // Render and notify
2731 application.SendNotification();
2732 application.Render();
2734 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2737 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2738 application.SendNotification();
2739 application.Render();
2741 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2742 application.SendNotification();
2743 application.Render();
2745 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2746 application.SendNotification();
2747 application.Render();
2749 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 application.SendNotification();
2751 application.Render();
2753 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2754 application.SendNotification();
2755 application.Render();
2757 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2758 application.SendNotification();
2759 application.Render();
2761 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2762 application.SendNotification();
2763 application.Render();
2768 int utcDaliTextEditorEvent07(void)
2770 ToolkitTestApplication application;
2771 tet_infoline(" utcDaliTextEditorEvent07");
2773 // Checks if the highlight actor is created.
2775 TextEditor editor = TextEditor::New();
2776 DALI_TEST_CHECK(editor);
2778 application.GetScene().Add(editor);
2780 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2781 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2782 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2783 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2784 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2786 // Avoid a crash when core load gl resources.
2787 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2789 // Render and notify
2790 application.SendNotification();
2791 application.Render();
2793 // Tap on the text editor
2794 TestGenerateTap(application, 3.0f, 25.0f);
2796 // Render and notify
2797 application.SendNotification();
2798 application.Render();
2800 // Move to second line of the text.
2801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2803 // Render and notify
2804 application.SendNotification();
2805 application.Render();
2807 // Select some text in the right of the current cursor position
2808 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2809 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2810 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2811 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2813 // Render and notify
2814 application.SendNotification();
2815 application.Render();
2817 // Cut the selected text
2818 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2819 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));
2821 // Render and notify
2822 application.SendNotification();
2823 application.Render();
2825 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2827 // Select some text in the left of the current cursor position
2828 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2829 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2830 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2831 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2833 // Render and notify
2834 application.SendNotification();
2835 application.Render();
2837 // Copy the selected text
2838 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2839 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));
2841 // Render and notify
2842 application.SendNotification();
2843 application.Render();
2845 // Move the cursor to the third line
2846 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2847 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2849 // Render and notify
2850 application.SendNotification();
2851 application.Render();
2853 // Paste the selected text at the current cursor position
2854 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2855 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));
2857 // Render and notify
2858 application.SendNotification();
2859 application.Render();
2861 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2863 // Disable Shift Selection
2864 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2866 // Test to select some text in the right of the current cursor position
2867 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2868 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2870 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2872 // Render and notify
2873 application.SendNotification();
2874 application.Render();
2876 // Cut the selected text
2877 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2878 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));
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2885 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2887 // Test to select some text in the left of the current cursor position
2888 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2889 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2890 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2891 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2893 // Render and notify
2894 application.SendNotification();
2895 application.Render();
2897 // Copy the selected text
2898 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2899 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));
2901 // Render and notify
2902 application.SendNotification();
2903 application.Render();
2905 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2906 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2909 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));
2911 // Render and notify
2912 application.SendNotification();
2913 application.Render();
2915 // replace text with "c"
2916 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2923 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2926 DevelTextEditor::SelectWholeText(editor);
2928 // Render and notify
2929 application.SendNotification();
2930 application.Render();
2932 // Copy the selected text using logical keys
2933 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2934 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2936 // Render and notify
2937 application.SendNotification();
2938 application.Render();
2941 DevelTextEditor::SelectNone(editor);
2943 // Render and notify
2944 application.SendNotification();
2945 application.Render();
2947 // Paste the selected using logical keys
2948 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2949 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2952 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2954 // select all using logical keys
2955 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2956 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2958 // Render and notify
2959 application.SendNotification();
2960 application.Render();
2962 // cut text using logical keys
2963 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2964 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2966 // Render and notify
2967 application.SendNotification();
2968 application.Render();
2971 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2976 int utcDaliTextEditorEvent08(void)
2978 ToolkitTestApplication application;
2979 tet_infoline(" utcDaliTextEditorEvent08");
2981 // Checks if the highlight actor is released correctly.
2983 TextEditor editor = TextEditor::New();
2984 DALI_TEST_CHECK(editor);
2986 application.GetScene().Add(editor);
2988 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2989 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2990 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2991 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2992 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2994 // Avoid a crash when core load gl resources.
2995 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2997 // Render and notify
2998 application.SendNotification();
2999 application.Render();
3001 // Tap on the text editor
3002 TestGenerateTap(application, 3.0f, 25.0f);
3004 // Render and notify
3005 application.SendNotification();
3006 application.Render();
3008 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
3009 // Test to select some text in the left of the current cursor position
3010 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3011 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3012 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3013 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3015 // Render and notify
3016 application.SendNotification();
3017 application.Render();
3019 // Test to the left selection handle position and the right selection handle position
3020 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3022 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3023 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3025 // Render and notify
3026 application.SendNotification();
3027 application.Render();
3029 // Test to select full text in the left of the current cursor position
3030 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3031 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3032 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3033 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3034 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3035 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 // Test to release the current full text selection
3042 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3043 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 // Render and notify
3046 application.SendNotification();
3047 application.Render();
3049 // Test to move the current cursor position correctly
3050 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3052 // Render and notify
3053 application.SendNotification();
3054 application.Render();
3057 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3059 // Render and notify
3060 application.SendNotification();
3061 application.Render();
3063 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3065 // Test to select some text in the right of the current cursor position
3066 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3067 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3068 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3070 // Render and notify
3071 application.SendNotification();
3072 application.Render();
3074 // Test the cursor position with right arrow key
3075 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3077 // Render and notify
3078 application.SendNotification();
3079 application.Render();
3082 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3084 // Render and notify
3085 application.SendNotification();
3086 application.Render();
3088 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3090 // Test to select some text in the left of the current cursor position
3091 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3092 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3093 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3094 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3095 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3097 // Render and notify
3098 application.SendNotification();
3099 application.Render();
3101 // Test the cursor position with left arrow key
3102 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3104 // Render and notify
3105 application.SendNotification();
3106 application.Render();
3109 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3111 // Render and notify
3112 application.SendNotification();
3113 application.Render();
3115 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3117 // Test to select some text in the right of the current cursor position
3118 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3119 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3120 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3121 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3123 // Render and notify
3124 application.SendNotification();
3125 application.Render();
3127 // Test the cursor position with left arrow key
3128 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3130 // Render and notify
3131 application.SendNotification();
3132 application.Render();
3135 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3137 // Render and notify
3138 application.SendNotification();
3139 application.Render();
3141 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3143 // Test to select some text in the left of the current cursor position
3144 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3145 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3146 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3147 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3149 // Render and notify
3150 application.SendNotification();
3151 application.Render();
3153 // Test the cursor position with right arrow key
3154 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3156 // Render and notify
3157 application.SendNotification();
3158 application.Render();
3161 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3163 // Render and notify
3164 application.SendNotification();
3165 application.Render();
3167 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3172 int utcDaliTextEditorHandles(void)
3174 ToolkitTestApplication application;
3175 tet_infoline(" utcDaliTextEditorHandles");
3177 TextEditor editor = TextEditor::New();
3178 DALI_TEST_CHECK(editor);
3180 application.GetScene().Add(editor);
3182 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3183 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3184 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3185 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3187 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3188 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3189 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3190 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3192 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3193 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3194 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3196 // Avoid a crash when core load gl resources.
3197 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3199 // Render and notify
3200 application.SendNotification();
3201 application.Render();
3203 // Tap first to get the focus.
3204 TestGenerateTap(application, 3.0f, 25.0f, 100);
3206 // Render and notify
3207 application.SendNotification();
3208 application.Render();
3210 // Tap to create the grab handle.
3211 TestGenerateTap(application, 3.0f, 25.0f, 700);
3213 // Render and notify
3214 application.SendNotification();
3215 application.Render();
3217 // Get the active layer where the text's decoration is added.
3218 Actor activeLayer = editor.GetChildAt(1u);
3220 // Get the handle's actor.
3221 Actor handle = activeLayer.GetChildAt(0u);
3222 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3224 // Render and notify
3225 application.SendNotification();
3226 application.Render();
3228 // Touch the grab handle to set it as pressed.
3229 Vector2 touchPos(10.0f, 50.0f);
3230 Dali::Integration::TouchEvent event;
3231 event = Dali::Integration::TouchEvent();
3232 event.AddPoint(GetPointDownInside(touchPos));
3233 application.ProcessEvent(event);
3235 // Render and notify
3236 application.SendNotification();
3237 application.Render();
3239 // Pan the grab handle
3240 uint32_t time = 100;
3241 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3242 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3243 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3244 application.SendNotification();
3245 application.Render();
3247 // Release the grab handle.
3248 event = Dali::Integration::TouchEvent();
3249 event.AddPoint(GetPointUpInside(touchPos));
3250 application.ProcessEvent(event);
3252 // Render and notify
3253 application.SendNotification();
3254 application.Render();
3256 // Tap first to get the focus.
3257 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3259 // Render and notify
3260 application.SendNotification();
3261 application.Render();
3263 // Double tap to select a word and create the selection handles.
3264 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3266 // Render and notify
3267 application.SendNotification();
3268 application.Render();
3270 touchPos = Vector2(10.0f, 50.0f);
3272 // Touch the left selection handle to set it as pressed.
3273 event = Dali::Integration::TouchEvent();
3274 event.AddPoint(GetPointDownInside(touchPos));
3275 application.ProcessEvent(event);
3277 // Render and notify
3278 application.SendNotification();
3279 application.Render();
3281 // Release the left selection handle.
3282 event = Dali::Integration::TouchEvent();
3283 event.AddPoint(GetPointUpInside(touchPos));
3284 application.ProcessEvent(event);
3286 // Render and notify
3287 application.SendNotification();
3288 application.Render();
3293 int utcDaliTextEditorUnderPropertyStringP(void)
3295 ToolkitTestApplication application;
3296 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3297 TextEditor editor = TextEditor::New();
3298 DALI_TEST_CHECK(editor);
3300 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3302 application.GetScene().Add(editor);
3304 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3305 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3307 tet_infoline("Set underline settings with a map");
3308 // Check the input underline property
3309 Property::Map underlineMapSet;
3310 Property::Map underlineMapGet;
3311 underlineMapSet.Insert("enable", true);
3312 underlineMapSet.Insert("color", Color::BLUE);
3313 underlineMapSet.Insert("height", 1);
3314 underlineMapSet.Insert("type", Text::Underline::SOLID);
3315 underlineMapSet.Insert("dashWidth", 2);
3316 underlineMapSet.Insert("dashGap", 1);
3318 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3319 editor.SetProperty(TextEditor::Property::TEXT, "text");
3320 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3321 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3322 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3324 application.SendNotification();
3325 application.Render();
3327 underlineMapSet.Clear();
3328 underlineMapGet.Clear();
3330 tet_infoline("Set dashed underline settings with a map");
3331 // Check the input underline property
3332 underlineMapSet.Clear();
3333 underlineMapGet.Clear();
3334 underlineMapSet.Insert("enable", true);
3335 underlineMapSet.Insert("color", Color::BLUE);
3336 underlineMapSet.Insert("height", 1);
3337 underlineMapSet.Insert("type", Text::Underline::DASHED);
3338 underlineMapSet.Insert("dashWidth", 5);
3339 underlineMapSet.Insert("dashGap", 3);
3341 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3342 editor.SetProperty(TextEditor::Property::TEXT, "text");
3343 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3344 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3345 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3347 // Check the input underline property
3348 underlineMapSet.Clear();
3349 underlineMapGet.Clear();
3350 underlineMapSet.Insert("enable", true);
3351 underlineMapSet.Insert("color", Color::BLUE);
3352 underlineMapSet.Insert("height", 1);
3353 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3354 underlineMapSet.Insert("dashWidth", 5);
3355 underlineMapSet.Insert("dashGap", 3);
3357 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3358 editor.SetProperty(TextEditor::Property::TEXT, "text");
3359 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3360 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3361 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3363 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3364 editor.SetProperty(TextEditor::Property::TEXT, "text");
3365 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3366 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3367 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3369 application.SendNotification();
3370 application.Render();
3372 underlineMapSet.Clear();
3373 underlineMapGet.Clear();
3375 tet_infoline("Set underline settings with a string");
3376 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3377 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3380 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3382 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3383 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3384 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3385 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3387 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3392 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3394 ToolkitTestApplication application;
3395 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3396 TextEditor editor = TextEditor::New();
3397 DALI_TEST_CHECK(editor);
3399 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3401 application.GetScene().Add(editor);
3403 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3404 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3406 tet_infoline("Set strikethrough settings with a map");
3407 // Check the input strikethrough property
3408 Property::Map strikethroughMapSet;
3409 Property::Map strikethroughMapGet;
3410 strikethroughMapSet.Insert("enable", true);
3411 strikethroughMapSet.Insert("color", Color::BLUE);
3412 strikethroughMapSet.Insert("height", 2.0f);
3414 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3415 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3416 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3417 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3419 tet_infoline("Set strikethrough settings with a string");
3420 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3421 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3424 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3426 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3427 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3428 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3429 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3431 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3436 int utcDaliTextEditorShadowPropertyStringP(void)
3438 ToolkitTestApplication application;
3439 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3441 TextEditor editor = TextEditor::New();
3443 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3445 application.GetScene().Add(editor);
3447 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3449 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3453 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3458 int utcDaliTextEditorFontStylePropertyStringP(void)
3460 ToolkitTestApplication application;
3461 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3463 TextEditor editor = TextEditor::New();
3465 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3467 application.GetScene().Add(editor);
3469 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3471 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3475 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3480 int utcDaliTextEditorGetPropertyLinecountP(void)
3482 ToolkitTestApplication application;
3484 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3488 TextEditor editor = TextEditor::New();
3489 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3490 editor.SetProperty(TextEditor::Property::TEXT,
3491 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3493 application.GetScene().Add(editor);
3495 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3496 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3497 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3499 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3500 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3501 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3506 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3508 ToolkitTestApplication application;
3509 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3511 TextEditor editor = TextEditor::New();
3512 DALI_TEST_CHECK(editor);
3514 application.GetScene().Add(editor);
3516 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3517 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3518 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3519 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3520 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3521 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3523 bool startedCalled = false;
3524 bool finishedCalled = false;
3526 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3527 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3529 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3531 // Render and notify
3532 application.SendNotification();
3533 application.Render();
3535 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3536 application.SendNotification();
3537 application.Render(6000);
3539 application.SendNotification();
3540 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3541 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3546 int UtcDaliToolkitTextEditorTextWrapMode(void)
3548 ToolkitTestApplication application;
3549 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3553 TextEditor editor = TextEditor::New();
3554 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3555 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3557 application.GetScene().Add(editor);
3559 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3560 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3562 application.SendNotification();
3563 application.Render();
3565 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3566 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3568 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3569 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3571 application.SendNotification();
3572 application.Render();
3574 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3575 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3577 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3578 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3580 application.SendNotification();
3581 application.Render();
3583 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3584 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3586 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3587 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3589 application.SendNotification();
3590 application.Render();
3592 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3593 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3598 int UtcDaliTextEditorSetPaddingProperty(void)
3600 ToolkitTestApplication application;
3601 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3603 TextEditor editor = TextEditor::New();
3604 DALI_TEST_CHECK(editor);
3605 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3606 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3607 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3608 application.GetScene().Add(editor);
3610 application.SendNotification();
3611 application.Render();
3613 Vector3 originalSize = editor.GetNaturalSize();
3615 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3617 application.SendNotification();
3618 application.Render();
3620 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3622 Vector3 paddingAddedSize = editor.GetNaturalSize();
3624 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3626 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3631 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3633 ToolkitTestApplication application;
3634 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3636 TextEditor editor = TextEditor::New();
3637 DALI_TEST_CHECK(editor);
3638 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3639 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3640 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3641 application.GetScene().Add(editor);
3643 application.SendNotification();
3644 application.Render();
3646 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3647 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3649 // Check the enable shift selection property
3650 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3651 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3653 application.SendNotification();
3654 application.Render();
3659 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3661 ToolkitTestApplication application;
3662 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3664 TextEditor editor = TextEditor::New();
3665 DALI_TEST_CHECK(editor);
3666 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3667 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3668 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3669 application.GetScene().Add(editor);
3671 application.SendNotification();
3672 application.Render();
3674 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3675 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3677 // Check the enable grab handle property
3678 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3679 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3681 application.SendNotification();
3682 application.Render();
3687 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3689 ToolkitTestApplication application;
3690 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3692 TextEditor editor = TextEditor::New();
3693 DALI_TEST_CHECK(editor);
3694 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3695 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3696 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3697 application.GetScene().Add(editor);
3699 application.SendNotification();
3700 application.Render();
3702 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3703 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3705 // Check the disable match system language direction property
3706 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3707 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3709 application.SendNotification();
3710 application.Render();
3715 int UtcDaliTextEditorGetInputMethodContext(void)
3717 ToolkitTestApplication application;
3718 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3720 TextEditor editor = TextEditor::New();
3721 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3726 int utcDaliTextEditorMaxCharactersReached(void)
3728 ToolkitTestApplication application;
3729 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3731 TextEditor editor = TextEditor::New();
3732 DALI_TEST_CHECK(editor);
3734 application.GetScene().Add(editor);
3736 const int maxNumberOfCharacters = 1;
3737 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3738 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3740 editor.SetKeyInputFocus();
3742 // connect to the text changed signal.
3743 ConnectionTracker* testTracker = new ConnectionTracker();
3744 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3745 bool maxLengthReachedSignal = false;
3746 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3748 gMaxCharactersCallBackCalled = false;
3750 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3751 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3753 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3754 DALI_TEST_CHECK(maxLengthReachedSignal);
3759 int utcDaliTextEditorInputFiltered(void)
3761 ToolkitTestApplication application;
3762 tet_infoline(" utcDaliTextEditorInputFiltered");
3763 TextEditor editor = TextEditor::New();
3764 DALI_TEST_CHECK(editor);
3766 application.GetScene().Add(editor);
3768 Property::Map inputFilter;
3770 // Only digit is accepted.
3771 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3773 // Set input filter to TextEditor.
3774 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3776 editor.SetKeyInputFocus();
3778 // connect to the input filtered signal.
3779 ConnectionTracker* testTracker = new ConnectionTracker();
3780 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3781 bool inputFilteredSignal = false;
3782 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3784 gInputFilteredAcceptedCallbackCalled = false;
3786 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3788 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3789 DALI_TEST_CHECK(inputFilteredSignal);
3791 // Word is rejected.
3792 inputFilter[InputFilter::Property::ACCEPTED] = "";
3793 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3795 // Set input filter to TextEditor.
3796 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3798 editor.SetKeyInputFocus();
3800 inputFilteredSignal = false;
3801 gInputFilteredRejectedCallbackCalled = false;
3803 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3805 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3806 DALI_TEST_CHECK(inputFilteredSignal);
3811 int UtcDaliTextEditorSelectWholeText(void)
3813 ToolkitTestApplication application;
3814 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3816 TextEditor textEditor = TextEditor::New();
3818 application.GetScene().Add(textEditor);
3820 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3821 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3822 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3824 // Avoid a crash when core load gl resources.
3825 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3827 application.SendNotification();
3828 application.Render();
3830 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3832 DevelTextEditor::SelectWholeText(textEditor);
3834 application.SendNotification();
3835 application.Render();
3837 // Nothing should have been selected. The number of children is still 1
3838 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3840 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3842 application.SendNotification();
3843 application.Render();
3845 DevelTextEditor::SelectWholeText(textEditor);
3847 application.SendNotification();
3848 application.Render();
3850 // Should be 2 children, the stencil and the layer
3851 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3853 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3854 Actor stencil = textEditor.GetChildAt(0u);
3856 // The highlight actor is drawn first, so is the first actor in the list
3857 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3858 DALI_TEST_CHECK(highlight);
3863 int UtcDaliTextEditorSelectText(void)
3865 ToolkitTestApplication application;
3866 tet_infoline(" UtcDaliTextEditorSelectText ");
3868 TextEditor textEditor = TextEditor::New();
3870 application.GetScene().Add(textEditor);
3872 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3873 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3874 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3876 // Avoid a crash when core load gl resources.
3877 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3879 application.SendNotification();
3880 application.Render();
3882 DevelTextEditor::SelectText(textEditor, 0, 5);
3884 application.SendNotification();
3885 application.Render();
3887 // Nothing is selected
3888 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3889 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3891 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3893 application.SendNotification();
3894 application.Render();
3896 DevelTextEditor::SelectText(textEditor, 0, 5);
3898 application.SendNotification();
3899 application.Render();
3901 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3902 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3904 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3905 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3907 // world is selected
3908 DevelTextEditor::SelectText(textEditor, 6, 11);
3910 application.SendNotification();
3911 application.Render();
3913 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3914 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3916 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3917 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3922 int UtcDaliTextEditorSelectNone(void)
3924 ToolkitTestApplication application;
3925 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3927 TextEditor textEditor = TextEditor::New();
3929 application.GetScene().Add(textEditor);
3931 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3932 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3933 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3935 // Avoid a crash when core load gl resources.
3936 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3938 application.SendNotification();
3939 application.Render();
3941 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3943 application.SendNotification();
3944 application.Render();
3946 // Nothing is selected
3947 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3948 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3950 DevelTextEditor::SelectWholeText(textEditor);
3952 application.SendNotification();
3953 application.Render();
3955 // whole text is selected
3956 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3957 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3959 DevelTextEditor::SelectNone(textEditor);
3961 application.SendNotification();
3962 application.Render();
3964 // Nothing is selected
3965 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3966 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3971 int UtcDaliTextEditorSelectRange(void)
3973 ToolkitTestApplication application;
3974 tet_infoline("utcDaliTextEditorSelectRange");
3976 TextEditor textEditor = TextEditor::New();
3977 DALI_TEST_CHECK(textEditor);
3979 application.GetScene().Add(textEditor);
3981 // Avoid a crash when core load gl resources.
3982 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3984 application.SendNotification();
3985 application.Render();
3987 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3989 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3990 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3992 // Hello is selected
3993 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3994 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3996 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3997 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4002 int UtcDaliTextEditorEnableEditing(void)
4004 ToolkitTestApplication application;
4005 tet_infoline(" UtcDaliTextEditorEnableEditing ");
4007 TextEditor textEditor = TextEditor::New();
4009 application.GetScene().Add(textEditor);
4011 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4012 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4013 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4015 // Avoid a crash when core load gl resources.
4016 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4018 application.SendNotification();
4019 application.Render();
4021 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4022 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4024 textEditor.SetKeyInputFocus();
4025 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
4026 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4028 // Render and notify
4029 application.SendNotification();
4030 application.Render();
4032 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4033 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4035 textEditor.SetKeyInputFocus();
4036 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
4037 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4039 // Render and notify
4040 application.SendNotification();
4041 application.Render();
4043 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4044 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4046 // Check the user interaction enabled and for coverage
4047 DevelTextEditor::SelectWholeText(textEditor);
4049 // Render and notify
4050 application.SendNotification();
4051 application.Render();
4053 textEditor.SetKeyInputFocus();
4054 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4055 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4057 // Render and notify
4058 application.SendNotification();
4059 application.Render();
4061 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4062 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4067 int UtcDaliTextEditorScrolling(void)
4069 ToolkitTestApplication application;
4070 tet_infoline(" UtcDaliTextEditorScrolling ");
4072 TextEditor textEditor = TextEditor::New();
4073 DALI_TEST_CHECK(textEditor);
4075 application.GetScene().Add(textEditor);
4077 // Avoid a crash when core load gl resources.
4078 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4080 application.SendNotification();
4081 application.Render();
4083 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4084 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4085 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4086 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4088 application.SendNotification();
4089 application.Render();
4091 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4092 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4094 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4096 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4097 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4099 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4101 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4102 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4104 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4105 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4107 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4108 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4113 int UtcDaliToolkitTextEditorFontSizeScale(void)
4115 ToolkitTestApplication application;
4116 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4118 TextEditor textEditor = TextEditor::New();
4119 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4120 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4121 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4123 TextEditor textEditorScaled = TextEditor::New();
4124 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4125 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4126 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4127 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4129 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4131 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4132 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4133 nonScaledSize = textEditor.GetNaturalSize();
4135 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4136 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4137 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4138 scaledSize = textEditorScaled.GetNaturalSize();
4140 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4145 int UtcDaliTextEditorPrimaryCursorPosition(void)
4147 ToolkitTestApplication application;
4148 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4150 TextEditor textEditor = TextEditor::New();
4152 application.GetScene().Add(textEditor);
4154 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4155 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4156 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4157 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4159 // Avoid a crash when core load gl resources.
4160 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4162 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4163 application.SendNotification();
4164 application.Render();
4165 textEditor.SetKeyInputFocus();
4167 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4169 // Render and notify
4170 application.SendNotification();
4171 application.Render();
4173 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4174 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4179 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4181 ToolkitTestApplication application;
4182 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4184 TextEditor textEditor = TextEditor::New();
4185 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4186 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4187 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4188 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4189 application.GetScene().Add(textEditor);
4191 application.SendNotification();
4192 application.Render();
4195 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4196 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4198 textEditor.GetNaturalSize();
4200 // Create a tap event to touch the text editor.
4201 TestGenerateTap(application, 18.0f, 25.0f);
4203 application.SendNotification();
4204 application.Render();
4206 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4207 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4212 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4214 ToolkitTestApplication application;
4216 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4218 int lineCountBefore = 0;
4219 int lineCountAfter = 0;
4221 // Create a text editor
4222 TextEditor textEditor = TextEditor::New();
4223 //Set very large font-size using point-size
4224 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4225 //Specify font-family
4226 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4228 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4229 //Set text longer than width of textEditor
4230 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4232 application.GetScene().Add(textEditor);
4234 application.SendNotification();
4235 application.Render();
4237 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
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 utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4259 ToolkitTestApplication application;
4261 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
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(50.f, 100.f));
4274 //Set text longer than width of textEditor
4275 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
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 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4285 //GetHeightForWidth is a retrieval method which should not modify object
4286 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4287 textEditor.GetHeightForWidth(200.f);
4289 //This is to simulate focus into text editor after calling GetHeightForWidth
4290 //Create a tap event to touch the text editor.
4291 TestGenerateTap(application, 18.0f, 25.0f);
4293 application.SendNotification();
4294 application.Render();
4296 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4298 //The LineCount must not be changed when calling GetHeightForWidth.
4299 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4304 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4306 ToolkitTestApplication application;
4308 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4310 int lineCountBefore = 0;
4311 int lineCountAfter = 0;
4313 // Create a text editor
4314 TextEditor textEditor = TextEditor::New();
4315 //Set very large font-size using point-size
4316 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4317 //Specify font-family
4318 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4320 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4321 //Set text longer than width of textEditor
4322 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4323 //Set line wrap mode Character
4324 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4326 application.GetScene().Add(textEditor);
4328 application.SendNotification();
4329 application.Render();
4331 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4333 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4334 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4336 // When the text changed, the Line-count should be updated according to new text.
4337 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4338 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4339 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4344 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4346 ToolkitTestApplication application;
4348 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4350 int lineCountBefore = 0;
4351 int lineCountAfter = 0;
4353 // Create a text editor
4354 TextEditor textEditor = TextEditor::New();
4355 //Set very large font-size using point-size
4356 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4357 //Specify font-family
4358 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4360 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4361 //Set text longer than width of textEditor
4362 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4364 application.GetScene().Add(textEditor);
4366 application.SendNotification();
4367 application.Render();
4369 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
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 utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4391 ToolkitTestApplication application;
4393 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4395 int lineCountBefore = 0;
4396 int lineCountAfter = 0;
4398 // Create a text editor
4399 TextEditor textEditor = TextEditor::New();
4400 //Set very large font-size using point-size
4401 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4402 //Specify font-family
4403 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4405 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4406 //Set text longer than width of textEditor
4407 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4408 //Set line wrap mode Character
4409 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4411 application.GetScene().Add(textEditor);
4413 application.SendNotification();
4414 application.Render();
4416 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4417 //GetNaturalSize is a retrieval method which should not modify object
4418 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4419 textEditor.GetNaturalSize();
4421 //This is to simulate focus into text editor after calling GetNaturalSize
4422 //Create a tap event to touch the text editor.
4423 TestGenerateTap(application, 18.0f, 25.0f);
4425 application.SendNotification();
4426 application.Render();
4428 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4430 //The LineCount must not be changed when calling GetNaturalSize.
4431 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4436 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4438 ToolkitTestApplication application;
4439 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4441 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4442 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4443 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4445 // Create a text editor
4446 TextEditor textEditor = TextEditor::New();
4448 //Set size to avoid automatic eliding
4449 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4450 //Set very large font-size using point-size
4451 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4452 //Specify font-family
4453 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4454 //Set text to check if appear or not
4455 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4457 application.GetScene().Add(textEditor);
4459 application.SendNotification();
4460 application.Render();
4461 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4462 Vector3 naturalSize = textEditor.GetNaturalSize();
4464 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4465 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4470 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4472 ToolkitTestApplication application;
4473 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4475 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4476 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4477 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4479 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4480 // Create a text editor
4481 TextEditor textEditor = TextEditor::New();
4482 //Set size to avoid automatic eliding
4483 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4484 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4485 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4487 const int numberOfCases = 6;
4488 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4490 for(int index = 0; index < numberOfCases; index++)
4492 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4493 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4494 application.GetScene().Add(textEditor);
4495 application.SendNotification();
4496 application.Render();
4497 naturalSize = textEditor.GetNaturalSize();
4498 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4499 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4505 int UtcDaliTextEditorHyphenWrapMode(void)
4507 ToolkitTestApplication application;
4508 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4511 TextEditor textEditor = TextEditor::New();
4513 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4514 textEditor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
4515 textEditor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
4517 application.GetScene().Add(textEditor);
4518 application.SendNotification();
4519 application.Render();
4521 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4522 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4523 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4525 application.SendNotification();
4526 application.Render();
4528 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4534 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4536 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4537 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4538 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4540 application.SendNotification();
4541 application.Render();
4543 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4550 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4555 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4557 ToolkitTestApplication application;
4558 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4559 TextEditor textEditor = TextEditor::New();
4561 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4562 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4564 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4565 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4566 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4568 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4569 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4570 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4572 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4573 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4574 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4576 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4577 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4578 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4580 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4581 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4582 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4584 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4585 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4586 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4588 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4589 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4590 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4592 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4593 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4594 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4596 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4597 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4598 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4600 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4601 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4602 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4604 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4605 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4606 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4608 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4609 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4610 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4615 int UtcDaliTextEditorCopyText(void)
4617 ToolkitTestApplication application;
4618 tet_infoline(" UtcDaliTextEditorCopyText ");
4620 TextEditor textEditor = TextEditor::New();
4622 std::string selectedText = "";
4623 std::string copiedText = "";
4625 application.GetScene().Add(textEditor);
4627 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4628 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4629 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4631 // Avoid a crash when core load gl resources.
4632 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4634 application.SendNotification();
4635 application.Render();
4637 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4639 application.SendNotification();
4640 application.Render();
4642 // Hello is selected
4643 DevelTextEditor::SelectText(textEditor, 0, 5);
4645 application.SendNotification();
4646 application.Render();
4648 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4649 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4651 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4652 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4655 copiedText = DevelTextEditor::CopyText(textEditor);
4656 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4658 // world is selected
4659 DevelTextEditor::SelectText(textEditor, 6, 11);
4661 application.SendNotification();
4662 application.Render();
4664 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4665 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4667 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4668 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4671 copiedText = DevelTextEditor::CopyText(textEditor);
4672 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4674 // "lo wo" is selected
4675 DevelTextEditor::SelectText(textEditor, 3, 8);
4677 application.SendNotification();
4678 application.Render();
4680 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4681 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4683 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4684 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4686 // "lo wo" is copied
4687 copiedText = DevelTextEditor::CopyText(textEditor);
4688 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4693 int UtcDaliTextEditorCutText(void)
4695 ToolkitTestApplication application;
4696 tet_infoline(" UtcDaliTextEditorCutText ");
4698 TextEditor textEditor = TextEditor::New();
4700 std::string selectedText = "";
4702 application.GetScene().Add(textEditor);
4704 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4705 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4706 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4708 // Avoid a crash when core load gl resources.
4709 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4711 application.SendNotification();
4712 application.Render();
4714 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4716 application.SendNotification();
4717 application.Render();
4719 // Hello is selected
4720 DevelTextEditor::SelectText(textEditor, 0, 5);
4722 application.SendNotification();
4723 application.Render();
4725 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4726 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4728 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4729 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4732 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4734 application.SendNotification();
4735 application.Render();
4737 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4740 DevelTextEditor::SelectText(textEditor, 0, 2);
4742 application.SendNotification();
4743 application.Render();
4745 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4746 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4748 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4749 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4752 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4754 application.SendNotification();
4755 application.Render();
4757 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4759 // Test Cut from the middle
4762 DevelTextEditor::SelectText(textEditor, 1, 3);
4764 application.SendNotification();
4765 application.Render();
4767 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4768 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4770 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4771 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4774 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4776 application.SendNotification();
4777 application.Render();
4779 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4781 // Test Cut from the end
4784 DevelTextEditor::SelectText(textEditor, 1, 2);
4786 application.SendNotification();
4787 application.Render();
4789 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4790 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4792 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4793 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4796 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4798 application.SendNotification();
4799 application.Render();
4801 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4806 int UtcDaliTextEditorPasteText(void)
4808 ToolkitTestApplication application;
4809 tet_infoline(" UtcDaliTextEditorPasteText ");
4811 TextEditor editor = TextEditor::New();
4812 DALI_TEST_CHECK(editor);
4814 application.GetScene().Add(editor);
4816 std::string cutText = "";
4817 std::string copiedText = "";
4819 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4820 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4821 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4822 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4823 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4825 // Avoid a crash when core load gl resources.
4826 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4828 // Render and notify
4829 application.SendNotification();
4830 application.Render();
4832 // Tap on the text editor
4833 TestGenerateTap(application, 3.0f, 25.0f);
4835 // Render and notify
4836 application.SendNotification();
4837 application.Render();
4839 // Move to second line of the text.
4840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4842 // Render and notify
4843 application.SendNotification();
4844 application.Render();
4846 // Select some text in the right of the current cursor position
4847 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4848 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4849 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4850 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4852 // Render and notify
4853 application.SendNotification();
4854 application.Render();
4856 // Cut the selected text
4857 cutText = DevelTextEditor::CutText(editor);
4859 // Render and notify
4860 application.SendNotification();
4861 application.Render();
4863 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4864 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4866 // Select some text in the left of the current cursor position
4867 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4868 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4869 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4870 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4872 // Render and notify
4873 application.SendNotification();
4874 application.Render();
4876 // Copy the selected text
4877 copiedText = DevelTextEditor::CopyText(editor);
4879 // Render and notify
4880 application.SendNotification();
4881 application.Render();
4883 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4884 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4886 // Move the cursor to the third line
4887 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4888 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4890 // Render and notify
4891 application.SendNotification();
4892 application.Render();
4894 // Paste the selected text at the current cursor position
4895 DevelTextEditor::PasteText(editor);
4897 // Render and notify
4898 application.SendNotification();
4899 application.Render();
4901 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4906 int UtcDaliTextEditorLineSpacing(void)
4908 ToolkitTestApplication application;
4909 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4911 TextEditor textEditor = TextEditor::New();
4912 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4913 application.GetScene().Add(textEditor);
4914 application.SendNotification();
4915 application.Render();
4917 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4918 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4920 Vector3 sizeBefore = textEditor.GetNaturalSize();
4922 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4924 //add 20 for each line 20 * 3
4925 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4930 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4932 //Only for test coverage
4933 ToolkitTestApplication application;
4934 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4936 TextEditor textEditor = TextEditor::New();
4937 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4938 application.GetScene().Add(textEditor);
4939 application.SendNotification();
4940 application.Render();
4942 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4943 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4945 application.SendNotification();
4946 application.Render();
4948 DevelTextEditor::SelectWholeText(textEditor);
4950 application.SendNotification();
4951 application.Render();
4953 DevelTextEditor::SelectNone(textEditor);
4954 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4956 application.SendNotification();
4957 application.Render();
4959 DevelTextEditor::SelectWholeText(textEditor);
4961 application.SendNotification();
4962 application.Render();
4964 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4969 int UtcDaliTextEditorMinLineSize(void)
4971 ToolkitTestApplication application;
4972 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4974 TextEditor textEditor = TextEditor::New();
4975 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4976 application.GetScene().Add(textEditor);
4977 application.SendNotification();
4978 application.Render();
4980 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4981 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4983 Vector3 sizeBefore = textEditor.GetNaturalSize();
4985 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4987 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4990 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4995 int utcDaliTextEditorCursorPositionChangedSignal(void)
4997 ToolkitTestApplication application;
4998 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
5000 TextEditor editor = TextEditor::New();
5001 DALI_TEST_CHECK(editor);
5003 application.GetScene().Add(editor);
5005 // connect to the selection changed signal.
5006 ConnectionTracker* testTracker = new ConnectionTracker();
5007 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
5008 bool cursorPositionChangedSignal = false;
5009 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
5011 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5012 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5013 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5014 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5015 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5017 // Avoid a crash when core load gl resources.
5018 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5020 // Render and notify
5021 application.SendNotification();
5022 application.Render();
5024 editor.SetKeyInputFocus();
5026 // Tap on the text editor
5027 TestGenerateTap(application, 3.0f, 25.0f);
5029 // Render and notify
5030 application.SendNotification();
5031 application.Render();
5033 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5034 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
5036 gCursorPositionChangedCallbackCalled = false;
5039 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5041 // Render and notify
5042 application.SendNotification();
5043 application.Render();
5045 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5046 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5048 gCursorPositionChangedCallbackCalled = false;
5051 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5053 // Render and notify
5054 application.SendNotification();
5055 application.Render();
5057 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5058 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5060 gCursorPositionChangedCallbackCalled = false;
5062 //delete one character
5063 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5065 // Render and notify
5066 application.SendNotification();
5067 application.Render();
5069 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5070 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5072 gCursorPositionChangedCallbackCalled = false;
5074 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5076 // Render and notify
5077 application.SendNotification();
5078 application.Render();
5080 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5081 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5083 gCursorPositionChangedCallbackCalled = false;
5085 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5087 // Render and notify
5088 application.SendNotification();
5089 application.Render();
5091 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5092 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5097 int utcDaliTextEditorGeometryEllipsisStart(void)
5099 ToolkitTestApplication application;
5100 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5102 TextEditor editor = TextEditor::New();
5103 DALI_TEST_CHECK(editor);
5105 application.GetScene().Add(editor);
5107 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5108 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5109 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5110 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5111 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5112 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5113 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5114 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5115 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
5116 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
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(38, 0));
5140 expectedSizes.PushBack(Vector2(21, 25));
5142 expectedPositions.PushBack(Vector2(-1, 25));
5143 expectedSizes.PushBack(Vector2(53, 25));
5145 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5150 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5152 ToolkitTestApplication application;
5153 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
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::MIDDLE);
5168 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
5169 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
5170 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5172 // Avoid a crash when core load gl resources.
5173 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5175 // Render and notify
5176 application.SendNotification();
5177 application.Render();
5179 unsigned int expectedCount = 2;
5180 unsigned int startIndex = 0;
5181 unsigned int endIndex = 24;
5183 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5184 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5186 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5187 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5189 Vector<Vector2> expectedSizes;
5190 Vector<Vector2> expectedPositions;
5192 expectedPositions.PushBack(Vector2(-1, 0));
5193 expectedSizes.PushBack(Vector2(26, 25));
5195 expectedPositions.PushBack(Vector2(-1, 25));
5196 expectedSizes.PushBack(Vector2(53, 25));
5198 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5203 int utcDaliTextEditorGeometryEllipsisEnd(void)
5205 ToolkitTestApplication application;
5206 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5208 TextEditor editor = TextEditor::New();
5209 DALI_TEST_CHECK(editor);
5211 application.GetScene().Add(editor);
5213 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5214 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5215 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5216 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5217 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5218 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5219 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5220 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5221 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
5222 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
5223 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5225 // Avoid a crash when core load gl resources.
5226 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5228 // Render and notify
5229 application.SendNotification();
5230 application.Render();
5232 unsigned int expectedCount = 2;
5233 unsigned int startIndex = 0;
5234 unsigned int endIndex = 24;
5236 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5237 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5239 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5240 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5242 Vector<Vector2> expectedSizes;
5243 Vector<Vector2> expectedPositions;
5245 expectedPositions.PushBack(Vector2(-1, 0));
5246 expectedSizes.PushBack(Vector2(60, 25));
5248 expectedPositions.PushBack(Vector2(-1, 25));
5249 expectedSizes.PushBack(Vector2(39, 25));
5251 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5256 int utcDaliTextEditorGeometryRTL(void)
5258 ToolkitTestApplication application;
5259 tet_infoline(" utcDaliTextEditorGeometryRTL");
5261 TextEditor editor = TextEditor::New();
5262 DALI_TEST_CHECK(editor);
5264 application.GetScene().Add(editor);
5266 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5267 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5268 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5269 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5270 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5271 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
5272 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
5273 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5275 // Avoid a crash when core load gl resources.
5276 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5278 // Render and notify
5279 application.SendNotification();
5280 application.Render();
5282 unsigned int expectedCount = 4;
5283 unsigned int startIndex = 3;
5284 unsigned int endIndex = 24;
5286 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5287 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5289 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5290 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5292 Vector<Vector2> expectedSizes;
5293 Vector<Vector2> expectedPositions;
5295 expectedPositions.PushBack(Vector2(25, 0));
5296 expectedSizes.PushBack(Vector2(34, 25));
5298 expectedPositions.PushBack(Vector2(-1, 25));
5299 expectedSizes.PushBack(Vector2(53, 25));
5301 expectedPositions.PushBack(Vector2(-1, 50));
5302 expectedSizes.PushBack(Vector2(60, 25));
5304 expectedPositions.PushBack(Vector2(63, 75));
5305 expectedSizes.PushBack(Vector2(37, 25));
5307 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5312 int utcDaliTextEditorGeometryGlyphMiddle(void)
5314 ToolkitTestApplication application;
5315 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5317 TextEditor editor = TextEditor::New();
5318 DALI_TEST_CHECK(editor);
5320 application.GetScene().Add(editor);
5322 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5323 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5324 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5325 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5326 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5327 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5329 // Avoid a crash when core load gl resources.
5330 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5332 // Render and notify
5333 application.SendNotification();
5334 application.Render();
5336 unsigned int expectedCount = 1;
5337 unsigned int startIndex = 1;
5338 unsigned int endIndex = 13;
5340 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5341 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5343 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5344 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5346 Vector<Vector2> expectedSizes;
5347 Vector<Vector2> expectedPositions;
5349 expectedPositions.PushBack(Vector2(6, 0));
5350 expectedSizes.PushBack(Vector2(125, 25));
5352 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5357 int utcDaliTextEditorGeometryOneGlyph(void)
5359 ToolkitTestApplication application;
5360 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5362 TextEditor label = TextEditor::New();
5363 DALI_TEST_CHECK(label);
5365 application.GetScene().Add(label);
5367 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5368 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5369 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5370 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5371 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5372 label.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, true);
5373 label.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
5374 label.SetProperty(TextEditor::Property::TEXT, "H");
5376 // Avoid a crash when core load gl resources.
5377 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5379 // Render and notify
5380 application.SendNotification();
5381 application.Render();
5383 unsigned int expectedCount = 1;
5384 unsigned int startIndex = 0;
5385 unsigned int endIndex = 0;
5387 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5388 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5390 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5391 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5393 Vector<Vector2> expectedSizes;
5394 Vector<Vector2> expectedPositions;
5396 expectedPositions.PushBack(Vector2(-2, 0));
5397 expectedSizes.PushBack(Vector2(16, 25));
5399 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5404 int utcDaliTextEditorGeometryNullPtr(void)
5406 ToolkitTestApplication application;
5407 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5409 TextEditor editor = TextEditor::New();
5410 DALI_TEST_CHECK(editor);
5412 application.GetScene().Add(editor);
5414 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5415 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5416 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5417 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5418 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5419 editor.SetProperty(TextEditor::Property::TEXT, "");
5421 // Avoid a crash when core load gl resources.
5422 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5424 unsigned int expectedCount = 0;
5425 unsigned int startIndex = 0;
5426 unsigned int endIndex = 0;
5428 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5429 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5431 // Render and notify
5432 application.SendNotification();
5433 application.Render();
5435 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5436 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5441 int utcDaliTextEditorSelectionClearedSignal(void)
5443 ToolkitTestApplication application;
5444 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5446 TextEditor editor = TextEditor::New();
5447 DALI_TEST_CHECK(editor);
5449 application.GetScene().Add(editor);
5451 // connect to the selection changed signal.
5452 ConnectionTracker* testTracker = new ConnectionTracker();
5453 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5454 bool selectionClearedSignal = false;
5455 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5457 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5458 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5459 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5460 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5461 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5463 // Avoid a crash when core load gl resources.
5464 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5466 // Render and notify
5467 application.SendNotification();
5468 application.Render();
5470 // Tap on the text editor
5471 TestGenerateTap(application, 3.0f, 25.0f);
5473 // Render and notify
5474 application.SendNotification();
5475 application.Render();
5477 // Move to second line of the text & Select some text in the right of the current cursor position
5478 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5479 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5482 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5484 // Render and notify
5485 application.SendNotification();
5486 application.Render();
5488 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5490 // Render and notify
5491 application.SendNotification();
5492 application.Render();
5494 // Tap on the text editor
5495 TestGenerateTap(application, 3.0f, 25.0f);
5497 // Render and notify
5498 application.SendNotification();
5499 application.Render();
5501 gSelectionClearedCallbackCalled = false;
5503 // Move to second line of the text & select.
5504 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5505 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5508 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5510 // Render and notify
5511 application.SendNotification();
5512 application.Render();
5514 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5516 gSelectionClearedCallbackCalled = false;
5518 // Render and notify
5519 application.SendNotification();
5520 application.Render();
5522 // Move to second line of the text & select.
5523 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5524 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5526 // replace C with selected text
5527 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5529 // Render and notify
5530 application.SendNotification();
5531 application.Render();
5533 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5535 gSelectionClearedCallbackCalled = false;
5537 // Render and notify
5538 application.SendNotification();
5539 application.Render();
5541 DevelTextEditor::SelectText(editor, 1, 3);
5543 // Render and notify
5544 application.SendNotification();
5545 application.Render();
5547 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5549 // Render and notify
5550 application.SendNotification();
5551 application.Render();
5553 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5555 gSelectionClearedCallbackCalled = false;
5557 DevelTextEditor::SelectText(editor, 1, 3);
5559 // Render and notify
5560 application.SendNotification();
5561 application.Render();
5564 DevelTextEditor::SelectNone(editor);
5566 // Render and notify
5567 application.SendNotification();
5568 application.Render();
5570 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5575 int utcDaliTextEditorSelectionStartedSignal(void)
5577 ToolkitTestApplication application;
5578 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5580 TextEditor editor = TextEditor::New();
5581 DALI_TEST_CHECK(editor);
5583 application.GetScene().Add(editor);
5585 // connect to the selection changed signal.
5586 ConnectionTracker* testTracker = new ConnectionTracker();
5587 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5588 bool selectionStartedSignal = false;
5589 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5591 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5592 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5593 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5594 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5595 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5597 // Avoid a crash when core load gl resources.
5598 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5600 // Render and notify
5601 application.SendNotification();
5602 application.Render();
5604 // Tap on the text editor
5605 TestGenerateTap(application, 3.0f, 25.0f);
5607 // Render and notify
5608 application.SendNotification();
5609 application.Render();
5611 // Move to second line of the text & Select some text in the right of the current cursor position
5612 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5613 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5615 // Render and notify
5616 application.SendNotification();
5617 application.Render();
5619 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5622 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5624 // Render and notify
5625 application.SendNotification();
5626 application.Render();
5628 gSelectionStartedCallbackCalled = false;
5630 DevelTextEditor::SelectText(editor, 1, 3);
5632 // Render and notify
5633 application.SendNotification();
5634 application.Render();
5636 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5641 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5643 ToolkitTestApplication application;
5644 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5646 // Checks if the actor is created.
5648 TextEditor editor = TextEditor::New();
5649 DALI_TEST_CHECK(editor);
5651 application.GetScene().Add(editor);
5653 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5654 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5655 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5656 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5657 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5658 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5659 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5660 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5662 // Avoid a crash when core load gl resources.
5663 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5665 // Render and notify
5666 application.SendNotification();
5667 application.Render();
5669 // Tap on the text editor
5670 TestGenerateTap(application, 3.0f, 25.0f);
5672 // Render and notify
5673 application.SendNotification();
5674 application.Render();
5676 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5677 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5679 application.SendNotification();
5680 application.Render();
5682 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5683 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5688 int utcDaliTextEditorSelectionChangedSignal(void)
5690 ToolkitTestApplication application;
5691 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5693 TextEditor editor = TextEditor::New();
5694 DALI_TEST_CHECK(editor);
5696 application.GetScene().Add(editor);
5698 // connect to the selection changed signal.
5699 ConnectionTracker* testTracker = new ConnectionTracker();
5700 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5701 bool selectionChangedSignal = false;
5702 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5704 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5705 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5706 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5707 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5708 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5710 // Avoid a crash when core load gl resources.
5711 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5713 // Render and notify
5714 application.SendNotification();
5715 application.Render();
5717 // Tap on the text editor
5718 TestGenerateTap(application, 3.0f, 25.0f);
5720 // Render and notify
5721 application.SendNotification();
5722 application.Render();
5724 // Move to second line of the text.
5725 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5727 // Render and notify
5728 application.SendNotification();
5729 application.Render();
5731 // Select some text in the right of the current cursor position
5732 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5733 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5735 // Render and notify
5736 application.SendNotification();
5737 application.Render();
5739 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5740 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5742 gSelectionChangedCallbackCalled = false;
5744 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5746 // Render and notify
5747 application.SendNotification();
5748 application.Render();
5750 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5751 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5752 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5754 gSelectionChangedCallbackCalled = false;
5756 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5758 // Render and notify
5759 application.SendNotification();
5760 application.Render();
5762 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5763 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5764 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5766 gSelectionChangedCallbackCalled = false;
5767 editor.SetKeyInputFocus();
5769 // Render and notify
5770 application.SendNotification();
5771 application.Render();
5773 DevelTextEditor::SelectText(editor, 0, 5);
5775 application.SendNotification();
5776 application.Render();
5778 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5779 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5781 gSelectionChangedCallbackCalled = false;
5783 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5785 // Render and notify
5786 application.SendNotification();
5787 application.Render();
5789 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5790 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5791 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5793 gSelectionChangedCallbackCalled = false;
5796 DevelTextEditor::SelectWholeText(editor);
5798 // Render and notify
5799 application.SendNotification();
5800 application.Render();
5802 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5803 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5805 gSelectionChangedCallbackCalled = false;
5808 DevelTextEditor::SelectNone(editor);
5810 // Render and notify
5811 application.SendNotification();
5812 application.Render();
5814 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5815 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5816 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5821 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5823 ToolkitTestApplication application;
5824 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5826 TextEditor textEditor = TextEditor::New();
5827 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5828 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5829 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5830 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5832 application.GetScene().Add(textEditor);
5833 application.SendNotification();
5834 application.Render();
5836 Property::Map strikethroughMapSet;
5837 Property::Map strikethroughMapGet;
5839 strikethroughMapSet.Insert("enable", true);
5840 strikethroughMapSet.Insert("color", Color::RED);
5841 strikethroughMapSet.Insert("height", 2.0f);
5843 // Check the strikethrough property
5844 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5845 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5846 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5847 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5848 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5850 // Render and notify
5851 application.SendNotification();
5852 application.Render();
5854 strikethroughMapSet.Clear();
5855 strikethroughMapGet.Clear();
5860 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5862 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5863 //DaliException on vector: "Iterator not inside vector"
5865 ToolkitTestApplication application;
5866 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5868 TextEditor editor = TextEditor::New();
5869 DALI_TEST_CHECK(editor);
5871 application.GetScene().Add(editor);
5873 // Avoid a crash when core load gl resources.
5874 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5876 //Set multilines text
5877 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5878 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5879 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5881 //Set ResizePolicy to NaturalSize
5882 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5884 // Render and notify
5885 application.SendNotification();
5886 application.Render();
5888 // Create a tap event to touch the text editor.
5889 TestGenerateTap(application, 5.0f, 5.0f);
5891 // Render and notify
5892 application.SendNotification();
5893 application.Render();
5895 // Set currsor and add character (in first line)
5896 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5897 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5898 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5900 // Render and notify
5901 application.SendNotification();
5902 application.Render();
5904 //Check the changed text and cursor position
5905 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5906 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5908 // Render and notify
5909 application.SendNotification();
5910 application.Render();
5915 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5917 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5918 //DaliException on vector: "Iterator not inside vector"
5920 ToolkitTestApplication application;
5921 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5923 TextEditor editor = TextEditor::New();
5924 DALI_TEST_CHECK(editor);
5926 application.GetScene().Add(editor);
5928 // Avoid a crash when core load gl resources.
5929 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5931 //Set multilines text
5932 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5933 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5934 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5936 //Set ResizePolicy to NaturalSize
5937 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5940 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5941 application.SendNotification();
5942 application.Render();
5944 // Set focus and remove character
5945 editor.SetKeyInputFocus();
5946 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5948 // Render and notify
5949 application.SendNotification();
5950 application.Render();
5952 //Check the changed text and cursor position
5953 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5954 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5956 // Render and notify
5957 application.SendNotification();
5958 application.Render();
5963 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5965 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5966 //DaliException on vector: "Iterator not inside vector"
5968 ToolkitTestApplication application;
5969 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5971 TextEditor editor = TextEditor::New();
5972 DALI_TEST_CHECK(editor);
5974 application.GetScene().Add(editor);
5976 // Avoid a crash when core load gl resources.
5977 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5979 //Set multilines text
5980 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5981 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5982 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5984 //Set ResizePolicy to NaturalSize
5985 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5987 //Select text at initialization (before the first render)
5988 DevelTextEditor::SelectText(editor, 3, 5);
5990 // Render and notify
5991 application.SendNotification();
5992 application.Render();
5995 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5996 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));
5998 // Render and notify
5999 application.SendNotification();
6000 application.Render();
6002 //Check the changed text and cursor position
6003 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
6004 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6006 // Render and notify
6007 application.SendNotification();
6008 application.Render();
6013 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
6015 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
6016 //DaliException on vector: "Iterator not inside vector"
6018 ToolkitTestApplication application;
6019 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
6021 TextEditor editor = TextEditor::New();
6022 DALI_TEST_CHECK(editor);
6024 application.GetScene().Add(editor);
6026 // Avoid a crash when core load gl resources.
6027 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6029 //Set multilines text
6030 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
6031 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6032 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6034 //Set ResizePolicy to NaturalSize
6035 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
6038 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
6039 application.SendNotification();
6040 application.Render();
6042 // Set focus and double enter (new line)
6043 editor.SetKeyInputFocus();
6044 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6045 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6047 // Render and notify
6048 application.SendNotification();
6049 application.Render();
6051 //Check the changed text and cursor position
6052 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
6053 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
6055 // Render and notify
6056 application.SendNotification();
6057 application.Render();
6062 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
6064 ToolkitTestApplication application;
6065 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
6066 TextEditor textEditor = TextEditor::New();
6067 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
6068 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6069 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6070 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6072 application.GetScene().Add(textEditor);
6073 application.SendNotification();
6074 application.Render();
6076 Property::Map underlineMapSet;
6077 Property::Map underlineMapGet;
6079 underlineMapSet.Insert("enable", true);
6080 underlineMapSet.Insert("color", Color::RED);
6081 underlineMapSet.Insert("height", 1);
6082 underlineMapSet.Insert("type", Text::Underline::SOLID);
6083 underlineMapSet.Insert("dashWidth", 2);
6084 underlineMapSet.Insert("dashGap", 1);
6086 // Check the underline property
6087 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6089 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6090 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6091 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6093 // Render and notify
6094 application.SendNotification();
6095 application.Render();
6097 underlineMapSet.Clear();
6098 underlineMapGet.Clear();
6100 underlineMapSet.Insert("enable", true);
6101 underlineMapSet.Insert("color", Color::BLUE);
6102 underlineMapSet.Insert("height", 1);
6103 underlineMapSet.Insert("type", Text::Underline::DASHED);
6104 underlineMapSet.Insert("dashWidth", 4);
6105 underlineMapSet.Insert("dashGap", 2);
6107 // Check the dashed underline property
6108 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6110 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6111 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6112 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6114 // Render and notify
6115 application.SendNotification();
6116 application.Render();
6118 underlineMapSet.Clear();
6119 underlineMapGet.Clear();
6121 underlineMapSet.Insert("enable", true);
6122 underlineMapSet.Insert("color", Color::BLUE);
6123 underlineMapSet.Insert("height", 1);
6124 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6125 underlineMapSet.Insert("dashWidth", 4);
6126 underlineMapSet.Insert("dashGap", 2);
6128 // Check the dashed underline property
6129 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6131 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6132 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6133 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6135 // Render and notify
6136 application.SendNotification();
6137 application.Render();
6139 underlineMapSet.Clear();
6140 underlineMapGet.Clear();
6145 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6147 ToolkitTestApplication application;
6148 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6150 TextEditor textEditor1 = TextEditor::New();
6151 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6152 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6153 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6154 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6156 Property::Map underlineMapSet1;
6157 Property::Map underlineMapGet1;
6159 underlineMapSet1.Insert("enable", true);
6160 underlineMapSet1.Insert("color", Color::RED);
6161 underlineMapSet1.Insert("height", 1);
6162 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6163 underlineMapSet1.Insert("dashWidth", 2);
6164 underlineMapSet1.Insert("dashGap", 1);
6166 // Check the underline property
6167 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6169 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6170 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6171 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6173 application.GetScene().Add(textEditor1);
6174 application.SendNotification();
6175 application.Render();
6177 TextEditor textEditor2 = TextEditor::New();
6178 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6179 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6180 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6181 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6183 Property::Map underlineMapSet2;
6184 Property::Map underlineMapGet2;
6186 underlineMapSet2.Insert("enable", true);
6187 underlineMapSet2.Insert("color", Color::BLUE);
6188 underlineMapSet2.Insert("height", 1);
6189 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6190 underlineMapSet2.Insert("dashWidth", 4);
6191 underlineMapSet2.Insert("dashGap", 2);
6193 // Check the dashed underline property
6194 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6196 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6197 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6198 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6200 application.GetScene().Add(textEditor2);
6201 application.SendNotification();
6202 application.Render();
6204 TextEditor textEditor3 = TextEditor::New();
6205 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6206 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6207 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6208 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6210 Property::Map underlineMapSet3;
6211 Property::Map underlineMapGet3;
6213 underlineMapSet3.Insert("enable", true);
6214 underlineMapSet3.Insert("color", Color::BLUE);
6215 underlineMapSet3.Insert("height", 1);
6216 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6217 underlineMapSet3.Insert("dashWidth", 4);
6218 underlineMapSet3.Insert("dashGap", 2);
6220 // Check the dashed underline property
6221 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6223 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6224 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6225 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6227 application.GetScene().Add(textEditor3);
6228 application.SendNotification();
6229 application.Render();
6234 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6236 ToolkitTestApplication application;
6237 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6239 TextEditor textEditor1 = TextEditor::New();
6240 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6241 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6242 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6243 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6245 Property::Map underlineMapSet1;
6246 Property::Map underlineMapGet1;
6248 underlineMapSet1.Insert("enable", true);
6249 underlineMapSet1.Insert("color", Color::RED);
6250 underlineMapSet1.Insert("height", 1);
6251 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6252 underlineMapSet1.Insert("dashWidth", 2);
6253 underlineMapSet1.Insert("dashGap", 1);
6255 // Check the underline property
6256 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6257 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6259 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6260 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6261 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6263 application.GetScene().Add(textEditor1);
6265 application.SendNotification();
6266 application.Render();
6271 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6273 ToolkitTestApplication application;
6274 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6276 TextEditor editor = TextEditor::New();
6277 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6278 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6279 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6280 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6281 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6282 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6284 TextEditor editorSingleLineParagraph = TextEditor::New();
6285 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6286 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6287 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");
6288 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6289 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6290 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6292 TextEditor editorMultiLineParagraph = TextEditor::New();
6293 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6294 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6295 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");
6296 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6297 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6298 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6300 application.GetScene().Add(editor);
6301 application.GetScene().Add(editorSingleLineParagraph);
6302 application.GetScene().Add(editorMultiLineParagraph);
6303 application.SendNotification();
6304 application.Render();
6306 Vector3 naturalSize = editor.GetNaturalSize();
6307 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6308 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6310 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6312 //no effect of relative line size for paragraph with single line
6313 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6315 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6320 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6322 ToolkitTestApplication application;
6323 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6325 TextEditor editor = TextEditor::New();
6326 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6327 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6328 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6330 application.GetScene().Add(editor);
6331 application.SendNotification();
6332 application.Render();
6334 Vector3 naturalSize = editor.GetNaturalSize();
6336 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6338 application.SendNotification();
6339 application.Render();
6341 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6343 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6345 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6347 application.SendNotification();
6348 application.Render();
6350 relativeNaturalSize = editor.GetNaturalSize();
6352 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6356 int UtcDaliTextEditorCharacterSpacing(void)
6358 ToolkitTestApplication application;
6359 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6361 TextEditor textEditor = TextEditor::New();
6363 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6365 application.GetScene().Add(textEditor);
6366 application.SendNotification();
6367 application.Render();
6369 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6370 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6371 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6373 application.SendNotification();
6374 application.Render();
6379 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6381 ToolkitTestApplication application;
6382 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6384 TextEditor editor = TextEditor::New();
6386 float lineSpacing = -20.f;
6388 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6389 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6390 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6391 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6393 application.GetScene().Add(editor);
6394 application.SendNotification();
6395 application.Render();
6397 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6398 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6400 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6401 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6403 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6404 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6406 application.SendNotification();
6407 application.Render();
6412 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6414 ToolkitTestApplication application;
6415 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6417 TextEditor editor = TextEditor::New();
6418 DALI_TEST_CHECK(editor);
6420 application.GetScene().Add(editor);
6422 std::string cutText = "";
6423 std::string copiedText = "";
6425 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6426 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6427 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6428 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6429 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6430 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6431 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6433 // Render and notify
6434 application.SendNotification();
6435 application.Render();
6437 // Tap on the text editor
6438 TestGenerateTap(application, 1.0f, 1.0f);
6440 // Render and notify
6441 application.SendNotification();
6442 application.Render();
6444 // Move to second line of the text.
6445 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6447 // Render and notify
6448 application.SendNotification();
6449 application.Render();
6451 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6456 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6458 ToolkitTestApplication application;
6459 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6461 TextEditor editor = TextEditor::New();
6463 float lineSpacing = -20.f;
6465 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6466 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6467 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6468 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6469 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6471 application.GetScene().Add(editor);
6472 application.SendNotification();
6473 application.Render();
6475 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6477 int lineCount = sizeList.Size();
6478 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6480 application.SendNotification();
6481 application.Render();
6486 int UtcDaliToolkitTexteditorParagraphTag(void)
6488 ToolkitTestApplication application;
6489 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6490 TextEditor editorNewlineSeparator = TextEditor::New();
6491 TextEditor editorParagraphTag = TextEditor::New();
6492 DALI_TEST_CHECK(editorNewlineSeparator);
6493 DALI_TEST_CHECK(editorParagraphTag);
6495 application.GetScene().Add(editorNewlineSeparator);
6496 application.GetScene().Add(editorParagraphTag);
6498 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6499 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6500 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6501 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6502 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6503 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6505 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6506 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6507 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6508 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6509 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6511 application.SendNotification();
6512 application.Render();
6514 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6515 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6517 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6519 application.SendNotification();
6520 application.Render();
6525 //Handle Emoji clustering for cursor handling
6526 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6528 ToolkitTestApplication application;
6529 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6530 TextEditor textEditor = TextEditor::New();
6531 DALI_TEST_CHECK(textEditor);
6533 application.GetScene().Add(textEditor);
6535 // Avoid a crash when core load gl resources.
6536 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6538 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6539 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6541 // Render and notify
6542 application.SendNotification();
6543 application.Render();
6546 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6547 application.SendNotification();
6548 application.Render();
6550 // Set focus and remove Emoji
6551 textEditor.SetKeyInputFocus();
6552 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6554 //Check the changed text and cursor position
6555 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6556 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6558 // Render and notify
6559 application.SendNotification();
6560 application.Render();
6565 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6567 ToolkitTestApplication application;
6568 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6569 TextEditor textEditor = TextEditor::New();
6570 DALI_TEST_CHECK(textEditor);
6572 application.GetScene().Add(textEditor);
6574 // Avoid a crash when core load gl resources.
6575 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6577 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6578 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6580 // Render and notify
6581 application.SendNotification();
6582 application.Render();
6585 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6586 application.SendNotification();
6587 application.Render();
6589 // Set focus and remove Emoji
6590 textEditor.SetKeyInputFocus();
6591 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6593 //Check the changed text and cursor position
6594 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6595 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6597 // Render and notify
6598 application.SendNotification();
6599 application.Render();
6604 int utcDaliTextEditorPanGesturePropagation(void)
6606 ToolkitTestApplication application;
6607 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6609 Actor actor = Actor::New();
6610 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6611 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6612 application.GetScene().Add(actor);
6614 TextEditor editor = TextEditor::New();
6615 DALI_TEST_CHECK(editor);
6617 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6618 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6620 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6621 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6622 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6626 // Render and notify
6627 application.SendNotification();
6628 application.Render();
6631 GestureReceivedFunctor functor(data);
6633 PanGestureDetector detector = PanGestureDetector::New();
6634 detector.Attach(actor);
6635 detector.DetectedSignal().Connect(&application, functor);
6637 // Tap first to get the focus.
6638 TestGenerateTap(application, 3.0f, 25.0f, 100);
6640 // Render and notify
6641 application.SendNotification();
6642 application.Render();
6644 // Pan the text editor
6645 uint32_t time = 100;
6646 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6647 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6648 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6649 application.SendNotification();
6650 application.Render();
6652 // The text scrolls because there is text that is scrolling.
6653 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6656 // Set the size large enough to prevent scrolling.
6657 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6659 // Render and notify
6660 application.SendNotification();
6661 application.Render();
6664 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6665 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6666 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6668 // Because scrolling is not possible, the pan gesture is propagated.
6669 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6675 int utcDaliTextEditorGetTextBoundingRectangle(void)
6677 ToolkitTestApplication application;
6678 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6680 TextEditor editor = TextEditor::New();
6681 DALI_TEST_CHECK(editor);
6683 application.GetScene().Add(editor);
6685 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6686 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6687 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6688 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6689 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6691 // Avoid a crash when core load gl resources.
6692 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6694 // Render and notify
6695 application.SendNotification();
6696 application.Render();
6698 unsigned int startIndex = 0;
6699 unsigned int endIndex = 15;
6701 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6702 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6704 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6709 int utcDaliTextEditorRemoveFrontInset(void)
6711 ToolkitTestApplication application;
6712 tet_infoline(" utcDaliTextEditorRemoveFrontInset");
6713 TextEditor editor = TextEditor::New();
6714 DALI_TEST_CHECK(editor);
6716 application.GetScene().Add(editor);
6717 application.SendNotification();
6718 application.Render();
6720 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveFrontInset(editor)); // default value is false.
6721 DevelTextEditor::SetRemoveFrontInset(editor, true);
6722 DALI_TEST_CHECK(DevelTextEditor::IsRemoveFrontInset(editor));
6726 int utcDaliTextEditorRemoveBackInset(void)
6728 ToolkitTestApplication application;
6729 tet_infoline(" utcDaliTextEditorRemoveBackInset");
6730 TextEditor editor = TextEditor::New();
6731 DALI_TEST_CHECK(editor);
6733 application.GetScene().Add(editor);
6734 application.SendNotification();
6735 application.Render();
6737 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveBackInset(editor)); // default value is false.
6738 DevelTextEditor::SetRemoveBackInset(editor, true);
6739 DALI_TEST_CHECK(DevelTextEditor::IsRemoveBackInset(editor));