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;
1046 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1048 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1049 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1050 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1052 // Check the input outline property
1053 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1054 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1056 // Check the smooth scroll property
1057 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1058 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1059 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1061 // Check the smooth scroll duration property
1062 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1063 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1065 // Check the scroll bar property
1066 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1067 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1068 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1070 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1071 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1072 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1073 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1075 // Check the pixel size of font
1076 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1077 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1079 // Check placeholder text properties.
1080 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1081 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1083 // Check placeholder text's color property.
1084 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1085 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1087 // Check the enable selection property
1088 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1089 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1091 // Check the placeholder property with pixel size
1092 Property::Map placeholderPixelSizeMapSet;
1093 Property::Map placeholderPixelSizeMapGet;
1094 Property::Map placeholderFontstyleMap;
1095 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1096 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1097 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1098 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1099 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1101 placeholderFontstyleMap.Insert("weight", "bold");
1102 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1103 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1105 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1106 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1108 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1109 Property::Map placeholderConversionMap;
1110 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1111 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1112 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1113 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1114 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1115 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1117 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1119 // Check the placeholder property with point size
1120 Property::Map placeholderMapSet;
1121 Property::Map placeholderMapGet;
1122 placeholderMapSet["text"] = "Setting Placeholder Text";
1123 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1124 placeholderMapSet["color"] = Color::RED;
1125 placeholderMapSet["fontFamily"] = "Arial";
1126 placeholderMapSet["pointSize"] = 12.0f;
1127 // Check the placeholder font style property
1128 placeholderFontstyleMap.Clear();
1130 placeholderFontstyleMap.Insert("weight", "bold");
1131 placeholderFontstyleMap.Insert("width", "condensed");
1132 placeholderFontstyleMap.Insert("slant", "italic");
1133 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1134 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1136 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1137 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1139 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1140 placeholderConversionMap.Clear();
1141 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1142 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1143 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1144 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1145 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1146 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1147 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1149 // Reset font style.
1150 placeholderFontstyleMap.Clear();
1151 placeholderFontstyleMap.Insert("weight", "normal");
1152 placeholderFontstyleMap.Insert("slant", "oblique");
1153 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1154 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1156 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1157 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1158 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1159 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1161 placeholderFontstyleMap.Clear();
1162 placeholderFontstyleMap.Insert("slant", "roman");
1163 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1164 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1166 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1168 placeholderFontstyleMap.Clear();
1169 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1171 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1172 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1173 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1174 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1175 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1177 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1178 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1180 // Check handle color
1181 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1182 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1184 // Test the ENABLE_GRAB_HANDLE_POPUP property
1185 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1186 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1188 // Check the input method setting
1189 Property::Map propertyMap;
1190 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1191 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1192 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1193 int inputVariation = 1;
1194 propertyMap["PANEL_LAYOUT"] = panelLayout;
1195 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1196 propertyMap["BUTTON_ACTION"] = buttonAction;
1197 propertyMap["VARIATION"] = inputVariation;
1198 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1200 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1202 DALI_TEST_CHECK(value.Get(map));
1205 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1206 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1209 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1210 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1213 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1214 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1217 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1218 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1220 // Check the input filter property
1221 Property::Map inputFilterMapSet;
1222 Property::Map inputFilterMapGet;
1223 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1224 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1226 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1228 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1229 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1232 inputFilterMapSet.Clear();
1233 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1235 // Check the strikethrough property
1237 Property::Map strikethroughMapSet;
1238 Property::Map strikethroughMapGet;
1240 application.SendNotification();
1241 application.Render();
1243 // Check the input strikethrough property
1245 strikethroughMapSet.Clear();
1246 strikethroughMapGet.Clear();
1247 strikethroughMapSet.Insert("enable", true);
1248 strikethroughMapSet.Insert("color", Color::BLUE);
1249 strikethroughMapSet.Insert("height", 2.0f);
1251 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1253 application.SendNotification();
1254 application.Render();
1256 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1258 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1259 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1261 // Check the input strikethrough property
1262 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1263 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1265 application.SendNotification();
1266 application.Render();
1268 // Check the line size property
1269 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1270 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1271 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1273 // Check Remove Front/Back Inset Property
1274 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1275 editor.SetProperty(DevelTextEditor::Property::REMOVE_FRONT_INSET, false);
1276 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_FRONT_INSET));
1278 DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1279 editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, false);
1280 DALI_TEST_CHECK(!editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
1282 application.SendNotification();
1283 application.Render();
1288 // Positive Atlas Text Renderer test
1289 int utcDaliTextEditorAtlasRenderP(void)
1291 ToolkitTestApplication application;
1292 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1293 StyleManager styleManager = StyleManager::Get();
1294 styleManager.ApplyDefaultTheme();
1295 TextEditor editor = TextEditor::New();
1296 DALI_TEST_CHECK(editor);
1298 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1300 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1302 application.GetScene().Add(editor);
1306 // Render some text with the shared atlas backend
1307 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1308 application.SendNotification();
1309 application.Render();
1313 tet_result(TET_FAIL);
1318 // Positive test for the anchorClicked signal.
1319 int utcDaliTextEditorAnchorClickedP(void)
1321 ToolkitTestApplication application;
1322 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1323 TextEditor editor = TextEditor::New();
1324 DALI_TEST_CHECK(editor);
1326 application.GetScene().Add(editor);
1328 // connect to the anchor clicked signal.
1329 ConnectionTracker* testTracker = new ConnectionTracker();
1330 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1331 bool anchorClickedSignal = false;
1332 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1334 gAnchorClickedCallBackCalled = false;
1335 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1336 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1337 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1338 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1339 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1341 application.SendNotification();
1342 application.Render();
1343 editor.SetKeyInputFocus();
1345 // Create a tap event to touch the text editor.
1346 TestGenerateTap(application, 5.0f, 5.0f);
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1351 DALI_TEST_CHECK(anchorClickedSignal);
1353 gAnchorClickedCallBackNotCalled = true;
1354 // Tap the outside of anchor, callback should not be called.
1355 TestGenerateTap(application, 150.f, 100.f);
1356 application.SendNotification();
1357 application.Render();
1359 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1364 // Positive test for the textChanged signal.
1365 int utcDaliTextEditorTextChangedP(void)
1367 ToolkitTestApplication application;
1368 tet_infoline(" utcDaliTextEditorTextChangedP");
1369 TextEditor editor = TextEditor::New();
1370 DALI_TEST_CHECK(editor);
1372 application.GetScene().Add(editor);
1374 // connect to the text changed signal.
1375 ConnectionTracker* testTracker = new ConnectionTracker();
1376 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1377 bool textChangedSignal = false;
1378 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1380 gTextChangedCallBackCalled = false;
1381 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1382 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1383 DALI_TEST_CHECK(textChangedSignal);
1385 application.SendNotification();
1386 editor.SetKeyInputFocus();
1388 gTextChangedCallBackCalled = false;
1389 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1390 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1393 editor.SetProperty(TextField::Property::TEXT, "");
1395 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1396 gTextChangedCallBackCalled = false;
1397 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1398 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1400 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1401 gTextChangedCallBackCalled = false;
1402 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1403 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1408 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1410 ToolkitTestApplication application;
1411 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1412 TextEditor editor = TextEditor::New();
1413 DALI_TEST_CHECK(editor);
1415 application.GetScene().Add(editor);
1417 // connect to the text changed signal.
1418 ConnectionTracker* testTracker = new ConnectionTracker();
1419 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1420 bool textChangedSignal = false;
1421 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1423 // get InputMethodContext
1425 InputMethodContext::EventData imfEvent;
1426 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1428 editor.SetKeyInputFocus();
1429 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1432 gTextChangedCallBackCalled = false;
1433 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1434 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1435 application.SendNotification();
1436 application.Render();
1437 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1438 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1440 gTextChangedCallBackCalled = false;
1441 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1442 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1443 application.SendNotification();
1444 application.Render();
1445 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1446 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1448 gTextChangedCallBackCalled = false;
1449 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1450 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1451 application.SendNotification();
1452 application.Render();
1453 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1454 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1456 gTextChangedCallBackCalled = false;
1457 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1458 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1459 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1461 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1462 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1463 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1465 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1466 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1467 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1469 application.SendNotification();
1470 application.Render();
1471 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1472 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1477 int utcDaliTextEditorInputStyleChanged01(void)
1479 // The text-editor emits signals when the input style changes. These changes of style are
1480 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1481 // can't be emitted during the size negotiation as the callbacks may update the UI.
1482 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1483 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1484 ToolkitTestApplication application;
1485 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1489 char* pathNamePtr = get_current_dir_name();
1490 const std::string pathName(pathNamePtr);
1493 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1494 fontClient.SetDpi(93u, 93u);
1496 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1497 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1499 TextEditor editor = TextEditor::New();
1500 DALI_TEST_CHECK(editor);
1502 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1503 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1504 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1506 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1507 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1509 // connect to the text changed signal.
1510 ConnectionTracker* testTracker = new ConnectionTracker();
1511 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1512 bool inputStyleChangedSignal = false;
1513 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1515 application.GetScene().Add(editor);
1517 // Render and notify
1518 application.SendNotification();
1519 application.Render();
1521 // Executes the idle callbacks added by the text control on the change of input style.
1522 application.RunIdles();
1524 gInputStyleChangedCallbackCalled = false;
1525 gInputStyleMask = TextEditor::InputStyle::NONE;
1526 inputStyleChangedSignal = false;
1528 // Create a tap event to touch the text editor.
1529 TestGenerateTap(application, 18.0f, 25.0f);
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Executes the idle callbacks added by the text control on the change of input style.
1536 application.RunIdles();
1538 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1539 if(gInputStyleChangedCallbackCalled)
1541 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1543 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1544 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1546 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1547 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1549 DALI_TEST_CHECK(inputStyleChangedSignal);
1551 gInputStyleChangedCallbackCalled = false;
1552 gInputStyleMask = TextEditor::InputStyle::NONE;
1553 inputStyleChangedSignal = false;
1555 // Create a tap event to touch the text editor.
1556 TestGenerateTap(application, 30.0f, 25.0f);
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Executes the idle callbacks added by the text control on the change of input style.
1563 application.RunIdles();
1565 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1566 DALI_TEST_CHECK(!inputStyleChangedSignal);
1568 gInputStyleChangedCallbackCalled = false;
1569 gInputStyleMask = TextEditor::InputStyle::NONE;
1570 inputStyleChangedSignal = false;
1572 // Create a tap event to touch the text editor.
1573 TestGenerateTap(application, 43.0f, 25.0f);
1575 // Render and notify
1576 application.SendNotification();
1577 application.Render();
1579 // Executes the idle callbacks added by the text control on the change of input style.
1580 application.RunIdles();
1582 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1583 if(gInputStyleChangedCallbackCalled)
1585 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1587 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1588 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1590 DALI_TEST_CHECK(inputStyleChangedSignal);
1592 gInputStyleChangedCallbackCalled = false;
1593 gInputStyleMask = TextEditor::InputStyle::NONE;
1594 inputStyleChangedSignal = false;
1596 // Create a tap event to touch the text editor.
1597 TestGenerateTap(application, 88.0f, 25.0f);
1599 // Render and notify
1600 application.SendNotification();
1601 application.Render();
1603 // Executes the idle callbacks added by the text control on the change of input style.
1604 application.RunIdles();
1606 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1607 if(gInputStyleChangedCallbackCalled)
1609 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1611 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1612 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1614 Property::Map fontStyleMapSet;
1615 Property::Map fontStyleMapGet;
1617 fontStyleMapSet.Insert("weight", "bold");
1619 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1620 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1621 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1623 DALI_TEST_CHECK(inputStyleChangedSignal);
1625 gInputStyleChangedCallbackCalled = false;
1626 gInputStyleMask = TextEditor::InputStyle::NONE;
1627 inputStyleChangedSignal = false;
1629 // Create a tap event to touch the text editor.
1630 TestGenerateTap(application, 115.0f, 25.0f);
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Executes the idle callbacks added by the text control on the change of input style.
1637 application.RunIdles();
1639 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1640 DALI_TEST_CHECK(!inputStyleChangedSignal);
1642 gInputStyleChangedCallbackCalled = false;
1643 gInputStyleMask = TextEditor::InputStyle::NONE;
1644 inputStyleChangedSignal = false;
1646 // Create a tap event to touch the text editor.
1647 TestGenerateTap(application, 164.0f, 25.0f);
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Executes the idle callbacks added by the text control on the change of input style.
1654 application.RunIdles();
1656 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1657 if(gInputStyleChangedCallbackCalled)
1659 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1661 Property::Map fontStyleMapSet;
1662 Property::Map fontStyleMapGet;
1664 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1665 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1666 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1668 DALI_TEST_CHECK(inputStyleChangedSignal);
1670 gInputStyleChangedCallbackCalled = false;
1671 gInputStyleMask = TextEditor::InputStyle::NONE;
1672 inputStyleChangedSignal = false;
1674 // Create a tap event to touch the text editor.
1675 TestGenerateTap(application, 191.0f, 25.0f);
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // Executes the idle callbacks added by the text control on the change of input style.
1682 application.RunIdles();
1684 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1685 DALI_TEST_CHECK(!inputStyleChangedSignal);
1690 int utcDaliTextEditorInputStyleChanged02(void)
1692 // The text-editor emits signals when the input style changes. These changes of style are
1693 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1694 // can't be emitted during the size negotiation as the callbacks may update the UI.
1695 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1696 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1697 ToolkitTestApplication application;
1698 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1702 char* pathNamePtr = get_current_dir_name();
1703 const std::string pathName(pathNamePtr);
1706 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1707 fontClient.SetDpi(93u, 93u);
1709 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1710 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1712 TextEditor editor = TextEditor::New();
1713 DALI_TEST_CHECK(editor);
1715 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1716 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1717 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1719 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1720 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>");
1722 // connect to the text changed signal.
1723 ConnectionTracker* testTracker = new ConnectionTracker();
1724 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1725 bool inputStyleChangedSignal = false;
1726 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1728 application.GetScene().Add(editor);
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Executes the idle callbacks added by the text control on the change of input style.
1735 application.RunIdles();
1737 gInputStyleChangedCallbackCalled = false;
1738 gInputStyleMask = TextEditor::InputStyle::NONE;
1739 inputStyleChangedSignal = false;
1741 // Create a tap event to touch the text editor.
1742 TestGenerateTap(application, 53.0f, 25.0f, 100);
1743 TestGenerateTap(application, 53.0f, 25.0f, 200);
1745 // Render and notify
1746 application.SendNotification();
1747 application.Render();
1749 // Executes the idle callbacks added by the text control on the change of input style.
1750 application.RunIdles();
1752 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1753 if(gInputStyleChangedCallbackCalled)
1755 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1756 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1757 TextEditor::InputStyle::POINT_SIZE |
1758 TextEditor::InputStyle::COLOR),
1761 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1762 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1764 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1765 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1767 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1768 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1770 DALI_TEST_CHECK(inputStyleChangedSignal);
1772 gInputStyleChangedCallbackCalled = false;
1773 gInputStyleMask = TextEditor::InputStyle::NONE;
1774 inputStyleChangedSignal = false;
1776 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Executes the idle callbacks added by the text control on the change of input style.
1783 application.RunIdles();
1785 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1786 if(gInputStyleChangedCallbackCalled)
1788 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1789 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1792 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1793 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1795 DALI_TEST_CHECK(inputStyleChangedSignal);
1797 gInputStyleChangedCallbackCalled = false;
1798 gInputStyleMask = TextEditor::InputStyle::NONE;
1799 inputStyleChangedSignal = false;
1801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // Executes the idle callbacks added by the text control on the change of input style.
1808 application.RunIdles();
1810 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1811 DALI_TEST_CHECK(!inputStyleChangedSignal);
1813 gInputStyleChangedCallbackCalled = false;
1814 gInputStyleMask = TextEditor::InputStyle::NONE;
1815 inputStyleChangedSignal = false;
1817 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 // Executes the idle callbacks added by the text control on the change of input style.
1824 application.RunIdles();
1826 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1827 if(gInputStyleChangedCallbackCalled)
1829 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1830 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1833 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1834 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1836 DALI_TEST_CHECK(inputStyleChangedSignal);
1838 gInputStyleChangedCallbackCalled = false;
1839 gInputStyleMask = TextEditor::InputStyle::NONE;
1840 inputStyleChangedSignal = false;
1842 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1844 Property::Map fontStyleMapSet;
1845 fontStyleMapSet.Insert("weight", "thin");
1846 fontStyleMapSet.Insert("width", "condensed");
1847 fontStyleMapSet.Insert("slant", "italic");
1849 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1850 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1851 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1853 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1854 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1855 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1856 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1857 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1859 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 // Executes the idle callbacks added by the text control on the change of input style.
1866 application.RunIdles();
1868 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1869 DALI_TEST_CHECK(!inputStyleChangedSignal);
1871 // Create a tap event to touch the text editor.
1872 TestGenerateTap(application, 63.0f, 25.0f, 900);
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 // Executes the idle callbacks added by the text control on the change of input style.
1879 application.RunIdles();
1881 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1882 if(gInputStyleChangedCallbackCalled)
1884 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1885 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1886 TextEditor::InputStyle::POINT_SIZE |
1887 TextEditor::InputStyle::FONT_STYLE |
1888 TextEditor::InputStyle::LINE_SPACING |
1889 TextEditor::InputStyle::UNDERLINE |
1890 TextEditor::InputStyle::SHADOW |
1891 TextEditor::InputStyle::EMBOSS |
1892 TextEditor::InputStyle::OUTLINE),
1895 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1896 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1898 DALI_TEST_CHECK(inputStyleChangedSignal);
1900 gInputStyleChangedCallbackCalled = false;
1901 gInputStyleMask = TextEditor::InputStyle::NONE;
1902 inputStyleChangedSignal = false;
1904 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1906 fontStyleMapSet.Clear();
1907 fontStyleMapSet.Insert("weight", "black");
1908 fontStyleMapSet.Insert("width", "expanded");
1909 fontStyleMapSet.Insert("slant", "oblique");
1911 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1913 // Create a tap event to touch the text editor.
1914 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 // Executes the idle callbacks added by the text control on the change of input style.
1921 application.RunIdles();
1923 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1924 if(gInputStyleChangedCallbackCalled)
1926 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1927 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1928 TextEditor::InputStyle::POINT_SIZE |
1929 TextEditor::InputStyle::FONT_STYLE),
1932 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1933 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1935 DALI_TEST_CHECK(inputStyleChangedSignal);
1940 int utcDaliTextEditorInputStyleChanged03(void)
1942 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1943 ToolkitTestApplication application;
1944 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1948 char* pathNamePtr = get_current_dir_name();
1949 const std::string pathName(pathNamePtr);
1952 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1953 fontClient.SetDpi(93u, 93u);
1955 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1956 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1958 TextEditor editor = TextEditor::New();
1959 DALI_TEST_CHECK(editor);
1961 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1962 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1963 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1965 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1966 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1968 // connect to the text changed signal.
1969 ConnectionTracker* testTracker = new ConnectionTracker();
1970 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1971 bool inputStyleChangedSignal = false;
1972 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1974 application.GetScene().Add(editor);
1976 // Render and notify
1977 application.SendNotification();
1978 application.Render();
1980 // Executes the idle callbacks added by the text control on the change of input style.
1981 application.RunIdles();
1983 gInputStyleChangedCallbackCalled = false;
1984 gInputStyleMask = TextEditor::InputStyle::NONE;
1985 inputStyleChangedSignal = false;
1987 // Create a tap event to touch the text editor.
1988 TestGenerateTap(application, 18.0f, 25.0f);
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1994 // Executes the idle callbacks added by the text control on the change of input style.
1995 application.RunIdles();
1997 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1998 if(gInputStyleChangedCallbackCalled)
2000 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
2002 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
2003 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2005 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
2006 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2008 DALI_TEST_CHECK(inputStyleChangedSignal);
2010 gInputStyleChangedCallbackCalled = false;
2011 gInputStyleMask = TextEditor::InputStyle::NONE;
2012 inputStyleChangedSignal = false;
2014 // Create a tap event to touch the text editor.
2015 TestGenerateTap(application, 30.0f, 25.0f);
2017 // Render and notify
2018 application.SendNotification();
2019 application.Render();
2021 // Executes the idle callbacks added by the text control on the change of input style.
2022 application.RunIdles();
2024 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2025 DALI_TEST_CHECK(!inputStyleChangedSignal);
2027 gInputStyleChangedCallbackCalled = false;
2028 gInputStyleMask = TextEditor::InputStyle::NONE;
2029 inputStyleChangedSignal = false;
2031 // Create a tap event to touch the text editor.
2032 TestGenerateTap(application, 43.0f, 25.0f);
2034 // Render and notify
2035 application.SendNotification();
2036 application.Render();
2038 // Executes the idle callbacks added by the text control on the change of input style.
2039 application.RunIdles();
2041 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2042 if(gInputStyleChangedCallbackCalled)
2044 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2046 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2047 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2049 DALI_TEST_CHECK(inputStyleChangedSignal);
2051 gInputStyleChangedCallbackCalled = false;
2052 gInputStyleMask = TextEditor::InputStyle::NONE;
2053 inputStyleChangedSignal = false;
2055 // Make AddIdle return false.
2056 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2058 // Create a tap event to touch the text editor.
2059 TestGenerateTap(application, 88.0f, 25.0f);
2061 // Render and notify
2062 application.SendNotification();
2063 application.Render();
2065 // Execute the idle callbacks.
2066 // And check whether we didn't change of input style.
2067 application.RunIdles();
2069 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2070 DALI_TEST_CHECK(!inputStyleChangedSignal);
2072 gInputStyleChangedCallbackCalled = false;
2073 gInputStyleMask = TextEditor::InputStyle::NONE;
2074 inputStyleChangedSignal = false;
2076 // Create a tap event to touch the text editor.
2077 TestGenerateTap(application, 115.0f, 25.0f);
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 // Execute the idle callbacks.
2084 // And check whether we didn't change of input style.
2085 application.RunIdles();
2087 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2088 DALI_TEST_CHECK(!inputStyleChangedSignal);
2090 gInputStyleChangedCallbackCalled = false;
2091 gInputStyleMask = TextEditor::InputStyle::NONE;
2092 inputStyleChangedSignal = false;
2094 // Revert AddIdle return true.
2095 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2097 // Create a tap event to touch the text editor.
2098 TestGenerateTap(application, 164.0f, 25.0f);
2100 // Render and notify
2101 application.SendNotification();
2102 application.Render();
2104 // Executes the idle callbacks added by the text control on the change of input style.
2105 application.RunIdles();
2107 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2108 if(gInputStyleChangedCallbackCalled)
2110 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2112 Property::Map fontStyleMapSet;
2113 Property::Map fontStyleMapGet;
2115 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2116 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2117 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
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, 191.0f, 25.0f);
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 // Executes the idle callbacks added by the text control on the change of input style.
2133 application.RunIdles();
2135 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2136 DALI_TEST_CHECK(!inputStyleChangedSignal);
2141 int utcDaliTextEditorEvent01(void)
2143 ToolkitTestApplication application;
2144 tet_infoline(" utcDaliTextEditorEvent01");
2146 // Creates a tap event. After creating a tap event the text editor should
2147 // have the focus and add text with key events should be possible.
2149 TextEditor editor = TextEditor::New();
2150 DALI_TEST_CHECK(editor);
2152 application.GetScene().Add(editor);
2154 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2155 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2156 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2158 // Avoid a crash when core load gl resources.
2159 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2161 // Render and notify
2162 application.SendNotification();
2163 application.Render();
2165 // Add a key event but as the text editor has not the focus it should do nothing.
2166 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2174 // Create a tap event to touch the text editor.
2175 TestGenerateTap(application, 150.0f, 25.0f);
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Now the text editor has the focus, so it can handle the key events.
2182 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2183 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2189 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2191 // Create a second text editor and send key events to it.
2192 TextEditor editor2 = TextEditor::New();
2194 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2195 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2196 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2197 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2199 application.GetScene().Add(editor2);
2201 // Render and notify
2202 application.SendNotification();
2203 application.Render();
2205 // Create a tap event on the second text editor.
2206 TestGenerateTap(application, 150.0f, 125.0f);
2208 // Render and notify
2209 application.SendNotification();
2210 application.Render();
2212 // The second text editor has the focus. It should handle the key events.
2213 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2214 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2216 // Render and notify
2217 application.SendNotification();
2218 application.Render();
2220 // Check the text has been added to the second text editor.
2221 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2226 int utcDaliTextEditorEvent02(void)
2228 ToolkitTestApplication application;
2229 tet_infoline(" utcDaliTextEditorEvent02");
2231 // Checks if the right number of actors are created.
2233 TextEditor editor = TextEditor::New();
2234 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2235 DALI_TEST_CHECK(editor);
2237 application.GetScene().Add(editor);
2239 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2240 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2241 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2243 // Avoid a crash when core load gl resources.
2244 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2246 // Render and notify
2247 application.SendNotification();
2248 application.Render();
2250 // Check there are the expected number of children (the stencil).
2251 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2253 Actor stencil = editor.GetChildAt(0u);
2255 // Create a tap event to touch the text editor.
2256 TestGenerateTap(application, 150.0f, 25.0f, 100);
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 Actor layer = editor.GetChildAt(2u);
2263 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2264 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2266 // Now the text editor has the focus, so it can handle the key events.
2267 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2268 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2270 // Render and notify
2271 application.SendNotification();
2272 application.Render();
2274 // Checks the cursor and the renderer have been created.
2275 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2276 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2278 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2279 DALI_TEST_CHECK(cursor);
2281 // The stencil actor has a container with all the actors which contain the text renderers.
2282 Actor container = stencil.GetChildAt(0u);
2283 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2285 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2286 DALI_TEST_CHECK(renderer);
2289 // Move the cursor and check the position changes.
2290 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2292 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2293 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2301 DALI_TEST_CHECK(position2.x < position1.x);
2303 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2304 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2312 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2314 // Send some taps and check the cursor positions.
2316 // Try to tap at the beginning.
2317 TestGenerateTap(application, 1.0f, 25.0f, 700);
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // Cursor position should be the same than position1.
2324 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2326 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2328 // Tap away from the start position.
2329 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2337 DALI_TEST_CHECK(position5.x > position4.x);
2339 // Remove all the text.
2340 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2341 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2342 editor.SetProperty(TextEditor::Property::TEXT, "");
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Cursor position should be the same than position2.
2349 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2351 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2353 // Should not be a renderer, there is only a clipped cursor.
2354 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2359 int utcDaliTextEditorEvent03(void)
2361 ToolkitTestApplication application;
2362 tet_infoline(" utcDaliTextEditorEvent03");
2364 // Checks if the highlight actor is created.
2366 TextEditor editor = TextEditor::New();
2367 DALI_TEST_CHECK(editor);
2369 application.GetScene().Add(editor);
2371 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2372 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2373 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2374 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2375 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2377 // Avoid a crash when core load gl resources.
2378 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // Send some taps and check text controller with clipboard window
2385 Dali::Clipboard clipboard = Clipboard::Get();
2386 clipboard.ShowClipboard();
2387 TestGenerateTap(application, 3.0f, 25.0f, 100);
2388 clipboard.HideClipboard();
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Tap first to get the focus.
2395 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // Double tap to select a word.
2402 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // The stencil actor should have two actors: the renderer and the highlight actor.
2409 Actor stencil = editor.GetChildAt(0u);
2411 // Highlight needs to be drawn before text, so should come first in child order
2412 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2413 DALI_TEST_CHECK(highlight);
2415 // The stencil actor has a container with all the actors which contain the text renderers.
2416 Actor container = stencil.GetChildAt(1u);
2417 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2419 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2420 DALI_TEST_CHECK(renderer);
2423 // Double tap out of bounds
2424 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2425 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // The stencil actor should have one actors: the renderer actor.
2432 stencil = editor.GetChildAt(0u);
2434 // The stencil actor has a container with all the actors which contain the text renderers.
2435 container = stencil.GetChildAt(0u);
2436 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2438 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2439 DALI_TEST_CHECK(renderer);
2443 TestGenerateLongPress(application, 1.0f, 25.0f);
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2450 TestGenerateMiniPan(application);
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2459 int utcDaliTextEditorEvent04(void)
2461 ToolkitTestApplication application;
2462 tet_infoline(" utcDaliTextEditorEvent04");
2464 // Checks if the highlight actor is created.
2466 TextEditor editor = TextEditor::New();
2467 DALI_TEST_CHECK(editor);
2469 application.GetScene().Add(editor);
2471 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2472 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2473 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2474 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2475 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2477 // Avoid a crash when core load gl resources.
2478 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2484 // Tap on the text editor
2485 TestGenerateTap(application, 3.0f, 25.0f);
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2491 // Move at the end of the text.
2492 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2493 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2495 // Render and notify
2496 application.SendNotification();
2497 application.Render();
2499 for(unsigned int index = 0u; index < 10u; ++index)
2501 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2504 // Render and notify
2505 application.SendNotification();
2506 application.Render();
2510 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2516 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2518 // Add some key events
2519 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2520 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 for(unsigned int index = 0u; index < 10u; ++index)
2528 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2529 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2537 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2548 int utcDaliTextEditorEvent05(void)
2550 ToolkitTestApplication application;
2551 tet_infoline(" utcDaliTextEditorEvent05");
2553 // Checks if the highlight actor is created.
2555 TextEditor editor = TextEditor::New();
2556 DALI_TEST_CHECK(editor);
2558 application.GetScene().Add(editor);
2560 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2561 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2562 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2563 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2564 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2565 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2566 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2567 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2568 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2569 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2571 // Avoid a crash when core load gl resources.
2572 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Tap on the text editor
2579 TestGenerateTap(application, 3.0f, 25.0f);
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Move at the end of the text.
2586 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2587 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2589 // Render and notify
2590 application.SendNotification();
2591 application.Render();
2593 for(unsigned int index = 0u; index < 10u; ++index)
2596 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2598 // Render and notify
2599 application.SendNotification();
2600 application.Render();
2602 // Modify duration after scroll is enabled
2603 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2605 // Continuous scroll left to increase coverage
2606 for(unsigned int index = 0u; index < 10u; ++index)
2608 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2614 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2615 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2616 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2617 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2618 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2620 // Press Escape to increase coverage
2621 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2622 application.SendNotification();
2623 application.Render();
2625 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2630 int utcDaliTextEditorEvent06(void)
2632 ToolkitTestApplication application;
2633 tet_infoline(" utcDaliTextEditorEvent06");
2635 // Checks if the highlight actor is created.
2637 TextEditor editor = TextEditor::New();
2638 DALI_TEST_CHECK(editor);
2640 application.GetScene().Add(editor);
2642 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2643 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2644 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2645 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2646 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2648 // Avoid a crash when core load gl resources.
2649 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2655 // Tap on the text editor
2656 TestGenerateTap(application, 3.0f, 25.0f);
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 // Move to seconds line of the text.
2663 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2665 // Render and notify
2666 application.SendNotification();
2667 application.Render();
2669 float layoutHeight = editor.GetHeightForWidth(100.f);
2671 // Add another script characters ( glyph height is defferent )
2672 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2673 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2675 // Delete characters
2676 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2677 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2679 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2681 // Render and notify
2682 application.SendNotification();
2683 application.Render();
2685 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2688 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2689 application.SendNotification();
2690 application.Render();
2692 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2693 application.SendNotification();
2694 application.Render();
2696 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2697 application.SendNotification();
2698 application.Render();
2700 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2701 application.SendNotification();
2702 application.Render();
2704 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2705 application.SendNotification();
2706 application.Render();
2708 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2709 application.SendNotification();
2710 application.Render();
2712 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2713 application.SendNotification();
2714 application.Render();
2719 int utcDaliTextEditorEvent07(void)
2721 ToolkitTestApplication application;
2722 tet_infoline(" utcDaliTextEditorEvent07");
2724 // Checks if the highlight actor is created.
2726 TextEditor editor = TextEditor::New();
2727 DALI_TEST_CHECK(editor);
2729 application.GetScene().Add(editor);
2731 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2732 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2733 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2734 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2735 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2737 // Avoid a crash when core load gl resources.
2738 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2740 // Render and notify
2741 application.SendNotification();
2742 application.Render();
2744 // Tap on the text editor
2745 TestGenerateTap(application, 3.0f, 25.0f);
2747 // Render and notify
2748 application.SendNotification();
2749 application.Render();
2751 // Move to second line of the text.
2752 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2754 // Render and notify
2755 application.SendNotification();
2756 application.Render();
2758 // Select some text in the right of the current cursor position
2759 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2760 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2761 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2762 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2768 // Cut the selected text
2769 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2770 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));
2772 // Render and notify
2773 application.SendNotification();
2774 application.Render();
2776 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2778 // Select some text in the left of the current cursor position
2779 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2780 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2782 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 // Copy the selected text
2789 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2790 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));
2792 // Render and notify
2793 application.SendNotification();
2794 application.Render();
2796 // Move the cursor to the third line
2797 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2798 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2800 // Render and notify
2801 application.SendNotification();
2802 application.Render();
2804 // Paste the selected text at the current cursor position
2805 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2806 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));
2808 // Render and notify
2809 application.SendNotification();
2810 application.Render();
2812 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2814 // Disable Shift Selection
2815 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2817 // Test to select some text in the right of the current cursor position
2818 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2821 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2823 // Render and notify
2824 application.SendNotification();
2825 application.Render();
2827 // Cut the selected text
2828 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2829 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));
2831 // Render and notify
2832 application.SendNotification();
2833 application.Render();
2835 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2836 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2838 // Test to select some text in the left of the current cursor position
2839 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2841 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2842 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2844 // Render and notify
2845 application.SendNotification();
2846 application.Render();
2848 // Copy the selected text
2849 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2850 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));
2852 // Render and notify
2853 application.SendNotification();
2854 application.Render();
2856 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2857 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2860 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));
2862 // Render and notify
2863 application.SendNotification();
2864 application.Render();
2866 // replace text with "c"
2867 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 // Render and notify
2870 application.SendNotification();
2871 application.Render();
2874 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2877 DevelTextEditor::SelectWholeText(editor);
2879 // Render and notify
2880 application.SendNotification();
2881 application.Render();
2883 // Copy the selected text using logical keys
2884 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2885 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2887 // Render and notify
2888 application.SendNotification();
2889 application.Render();
2892 DevelTextEditor::SelectNone(editor);
2894 // Render and notify
2895 application.SendNotification();
2896 application.Render();
2898 // Paste the selected using logical keys
2899 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2900 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2903 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2905 // select all using logical keys
2906 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2907 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2909 // Render and notify
2910 application.SendNotification();
2911 application.Render();
2913 // cut text using logical keys
2914 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2915 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2917 // Render and notify
2918 application.SendNotification();
2919 application.Render();
2922 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2927 int utcDaliTextEditorEvent08(void)
2929 ToolkitTestApplication application;
2930 tet_infoline(" utcDaliTextEditorEvent08");
2932 // Checks if the highlight actor is released correctly.
2934 TextEditor editor = TextEditor::New();
2935 DALI_TEST_CHECK(editor);
2937 application.GetScene().Add(editor);
2939 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2940 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2941 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2942 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2943 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2945 // Avoid a crash when core load gl resources.
2946 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2948 // Render and notify
2949 application.SendNotification();
2950 application.Render();
2952 // Tap on the text editor
2953 TestGenerateTap(application, 3.0f, 25.0f);
2955 // Render and notify
2956 application.SendNotification();
2957 application.Render();
2959 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2960 // Test to select some text in the left of the current cursor position
2961 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2962 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2963 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2964 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2966 // Render and notify
2967 application.SendNotification();
2968 application.Render();
2970 // Test to the left selection handle position and the right selection handle position
2971 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2972 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2973 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2974 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2976 // Render and notify
2977 application.SendNotification();
2978 application.Render();
2980 // Test to select full text in the left of the current cursor position
2981 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2982 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2983 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2984 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2985 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2986 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2988 // Render and notify
2989 application.SendNotification();
2990 application.Render();
2992 // Test to release the current full text selection
2993 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2994 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2996 // Render and notify
2997 application.SendNotification();
2998 application.Render();
3000 // Test to move the current cursor position correctly
3001 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3003 // Render and notify
3004 application.SendNotification();
3005 application.Render();
3008 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3016 // Test to select some text in the right of the current cursor position
3017 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3018 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3019 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3021 // Render and notify
3022 application.SendNotification();
3023 application.Render();
3025 // Test the cursor position with right arrow key
3026 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3033 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3035 // Render and notify
3036 application.SendNotification();
3037 application.Render();
3039 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3041 // Test to select some text in the left of the current cursor position
3042 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3043 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3044 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3046 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3048 // Render and notify
3049 application.SendNotification();
3050 application.Render();
3052 // Test the cursor position with left arrow key
3053 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3055 // Render and notify
3056 application.SendNotification();
3057 application.Render();
3060 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3062 // Render and notify
3063 application.SendNotification();
3064 application.Render();
3066 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3068 // Test to select some text in the right of the current cursor position
3069 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3070 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3071 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3072 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3074 // Render and notify
3075 application.SendNotification();
3076 application.Render();
3078 // Test the cursor position with left arrow key
3079 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3081 // Render and notify
3082 application.SendNotification();
3083 application.Render();
3086 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3088 // Render and notify
3089 application.SendNotification();
3090 application.Render();
3092 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3094 // Test to select some text in the left of the current cursor position
3095 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3096 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3097 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3098 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3100 // Render and notify
3101 application.SendNotification();
3102 application.Render();
3104 // Test the cursor position with right arrow key
3105 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3107 // Render and notify
3108 application.SendNotification();
3109 application.Render();
3112 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3114 // Render and notify
3115 application.SendNotification();
3116 application.Render();
3118 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3123 int utcDaliTextEditorHandles(void)
3125 ToolkitTestApplication application;
3126 tet_infoline(" utcDaliTextEditorHandles");
3128 TextEditor editor = TextEditor::New();
3129 DALI_TEST_CHECK(editor);
3131 application.GetScene().Add(editor);
3133 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3134 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3135 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3136 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3138 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3139 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3140 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3141 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3143 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3144 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3145 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3147 // Avoid a crash when core load gl resources.
3148 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3150 // Render and notify
3151 application.SendNotification();
3152 application.Render();
3154 // Tap first to get the focus.
3155 TestGenerateTap(application, 3.0f, 25.0f, 100);
3157 // Render and notify
3158 application.SendNotification();
3159 application.Render();
3161 // Tap to create the grab handle.
3162 TestGenerateTap(application, 3.0f, 25.0f, 700);
3164 // Render and notify
3165 application.SendNotification();
3166 application.Render();
3168 // Get the active layer where the text's decoration is added.
3169 Actor activeLayer = editor.GetChildAt(1u);
3171 // Get the handle's actor.
3172 Actor handle = activeLayer.GetChildAt(0u);
3173 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3175 // Render and notify
3176 application.SendNotification();
3177 application.Render();
3179 // Touch the grab handle to set it as pressed.
3180 Vector2 touchPos(10.0f, 50.0f);
3181 Dali::Integration::TouchEvent event;
3182 event = Dali::Integration::TouchEvent();
3183 event.AddPoint(GetPointDownInside(touchPos));
3184 application.ProcessEvent(event);
3186 // Render and notify
3187 application.SendNotification();
3188 application.Render();
3190 // Pan the grab handle
3191 uint32_t time = 100;
3192 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3193 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3194 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3195 application.SendNotification();
3196 application.Render();
3198 // Release the grab handle.
3199 event = Dali::Integration::TouchEvent();
3200 event.AddPoint(GetPointUpInside(touchPos));
3201 application.ProcessEvent(event);
3203 // Render and notify
3204 application.SendNotification();
3205 application.Render();
3207 // Tap first to get the focus.
3208 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3210 // Render and notify
3211 application.SendNotification();
3212 application.Render();
3214 // Double tap to select a word and create the selection handles.
3215 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3217 // Render and notify
3218 application.SendNotification();
3219 application.Render();
3221 touchPos = Vector2(10.0f, 50.0f);
3223 // Touch the left selection handle to set it as pressed.
3224 event = Dali::Integration::TouchEvent();
3225 event.AddPoint(GetPointDownInside(touchPos));
3226 application.ProcessEvent(event);
3228 // Render and notify
3229 application.SendNotification();
3230 application.Render();
3232 // Release the left selection handle.
3233 event = Dali::Integration::TouchEvent();
3234 event.AddPoint(GetPointUpInside(touchPos));
3235 application.ProcessEvent(event);
3237 // Render and notify
3238 application.SendNotification();
3239 application.Render();
3244 int utcDaliTextEditorUnderPropertyStringP(void)
3246 ToolkitTestApplication application;
3247 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3248 TextEditor editor = TextEditor::New();
3249 DALI_TEST_CHECK(editor);
3251 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3253 application.GetScene().Add(editor);
3255 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3256 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3258 tet_infoline("Set underline settings with a map");
3259 // Check the input underline property
3260 Property::Map underlineMapSet;
3261 Property::Map underlineMapGet;
3262 underlineMapSet.Insert("enable", true);
3263 underlineMapSet.Insert("color", Color::BLUE);
3264 underlineMapSet.Insert("height", 1);
3265 underlineMapSet.Insert("type", Text::Underline::SOLID);
3266 underlineMapSet.Insert("dashWidth", 2);
3267 underlineMapSet.Insert("dashGap", 1);
3269 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3270 editor.SetProperty(TextEditor::Property::TEXT, "text");
3271 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3272 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3273 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3275 application.SendNotification();
3276 application.Render();
3278 underlineMapSet.Clear();
3279 underlineMapGet.Clear();
3281 tet_infoline("Set dashed underline settings with a map");
3282 // Check the input underline property
3283 underlineMapSet.Clear();
3284 underlineMapGet.Clear();
3285 underlineMapSet.Insert("enable", true);
3286 underlineMapSet.Insert("color", Color::BLUE);
3287 underlineMapSet.Insert("height", 1);
3288 underlineMapSet.Insert("type", Text::Underline::DASHED);
3289 underlineMapSet.Insert("dashWidth", 5);
3290 underlineMapSet.Insert("dashGap", 3);
3292 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3293 editor.SetProperty(TextEditor::Property::TEXT, "text");
3294 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3295 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3296 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3298 // Check the input underline property
3299 underlineMapSet.Clear();
3300 underlineMapGet.Clear();
3301 underlineMapSet.Insert("enable", true);
3302 underlineMapSet.Insert("color", Color::BLUE);
3303 underlineMapSet.Insert("height", 1);
3304 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3305 underlineMapSet.Insert("dashWidth", 5);
3306 underlineMapSet.Insert("dashGap", 3);
3308 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3309 editor.SetProperty(TextEditor::Property::TEXT, "text");
3310 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3311 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3312 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3314 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3315 editor.SetProperty(TextEditor::Property::TEXT, "text");
3316 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3317 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3318 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3320 application.SendNotification();
3321 application.Render();
3323 underlineMapSet.Clear();
3324 underlineMapGet.Clear();
3326 tet_infoline("Set underline settings with a string");
3327 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3328 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3331 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3333 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3334 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3335 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3336 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3338 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3343 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3345 ToolkitTestApplication application;
3346 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3347 TextEditor editor = TextEditor::New();
3348 DALI_TEST_CHECK(editor);
3350 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3352 application.GetScene().Add(editor);
3354 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3355 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3357 tet_infoline("Set strikethrough settings with a map");
3358 // Check the input strikethrough property
3359 Property::Map strikethroughMapSet;
3360 Property::Map strikethroughMapGet;
3361 strikethroughMapSet.Insert("enable", true);
3362 strikethroughMapSet.Insert("color", Color::BLUE);
3363 strikethroughMapSet.Insert("height", 2.0f);
3365 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3366 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3367 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3368 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3370 tet_infoline("Set strikethrough settings with a string");
3371 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3372 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3375 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3377 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3378 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3379 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3380 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3382 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3387 int utcDaliTextEditorShadowPropertyStringP(void)
3389 ToolkitTestApplication application;
3390 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3392 TextEditor editor = TextEditor::New();
3394 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3396 application.GetScene().Add(editor);
3398 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3400 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3404 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3409 int utcDaliTextEditorFontStylePropertyStringP(void)
3411 ToolkitTestApplication application;
3412 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3414 TextEditor editor = TextEditor::New();
3416 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3418 application.GetScene().Add(editor);
3420 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3422 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3426 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3431 int utcDaliTextEditorGetPropertyLinecountP(void)
3433 ToolkitTestApplication application;
3435 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3439 TextEditor editor = TextEditor::New();
3440 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3441 editor.SetProperty(TextEditor::Property::TEXT,
3442 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3444 application.GetScene().Add(editor);
3446 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3447 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3448 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3450 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3451 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3452 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3457 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3459 ToolkitTestApplication application;
3460 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3462 TextEditor editor = TextEditor::New();
3463 DALI_TEST_CHECK(editor);
3465 application.GetScene().Add(editor);
3467 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3468 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3469 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3470 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3471 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3472 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3474 bool startedCalled = false;
3475 bool finishedCalled = false;
3477 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3478 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3480 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3482 // Render and notify
3483 application.SendNotification();
3484 application.Render();
3486 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3487 application.SendNotification();
3488 application.Render(6000);
3490 application.SendNotification();
3491 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3492 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3497 int UtcDaliToolkitTextEditorTextWrapMode(void)
3499 ToolkitTestApplication application;
3500 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3504 TextEditor editor = TextEditor::New();
3505 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3506 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3508 application.GetScene().Add(editor);
3510 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3511 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3513 application.SendNotification();
3514 application.Render();
3516 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3517 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3519 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3520 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3522 application.SendNotification();
3523 application.Render();
3525 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3526 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3528 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3529 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3531 application.SendNotification();
3532 application.Render();
3534 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3535 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3537 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3538 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3540 application.SendNotification();
3541 application.Render();
3543 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3544 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3549 int UtcDaliTextEditorSetPaddingProperty(void)
3551 ToolkitTestApplication application;
3552 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3554 TextEditor editor = TextEditor::New();
3555 DALI_TEST_CHECK(editor);
3556 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3557 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3558 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3559 application.GetScene().Add(editor);
3561 application.SendNotification();
3562 application.Render();
3564 Vector3 originalSize = editor.GetNaturalSize();
3566 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3568 application.SendNotification();
3569 application.Render();
3571 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3573 Vector3 paddingAddedSize = editor.GetNaturalSize();
3575 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3577 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3582 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3584 ToolkitTestApplication application;
3585 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3587 TextEditor editor = TextEditor::New();
3588 DALI_TEST_CHECK(editor);
3589 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3590 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3591 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3592 application.GetScene().Add(editor);
3594 application.SendNotification();
3595 application.Render();
3597 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3598 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3600 // Check the enable shift selection property
3601 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3602 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3604 application.SendNotification();
3605 application.Render();
3610 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3612 ToolkitTestApplication application;
3613 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3615 TextEditor editor = TextEditor::New();
3616 DALI_TEST_CHECK(editor);
3617 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3618 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3619 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3620 application.GetScene().Add(editor);
3622 application.SendNotification();
3623 application.Render();
3625 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3626 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3628 // Check the enable grab handle property
3629 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3630 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3632 application.SendNotification();
3633 application.Render();
3638 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3640 ToolkitTestApplication application;
3641 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3643 TextEditor editor = TextEditor::New();
3644 DALI_TEST_CHECK(editor);
3645 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3646 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3647 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3648 application.GetScene().Add(editor);
3650 application.SendNotification();
3651 application.Render();
3653 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3654 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3656 // Check the disable match system language direction property
3657 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3658 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3660 application.SendNotification();
3661 application.Render();
3666 int UtcDaliTextEditorGetInputMethodContext(void)
3668 ToolkitTestApplication application;
3669 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3671 TextEditor editor = TextEditor::New();
3672 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3677 int utcDaliTextEditorMaxCharactersReached(void)
3679 ToolkitTestApplication application;
3680 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3682 TextEditor editor = TextEditor::New();
3683 DALI_TEST_CHECK(editor);
3685 application.GetScene().Add(editor);
3687 const int maxNumberOfCharacters = 1;
3688 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3689 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3691 editor.SetKeyInputFocus();
3693 // connect to the text changed signal.
3694 ConnectionTracker* testTracker = new ConnectionTracker();
3695 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3696 bool maxLengthReachedSignal = false;
3697 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3699 gMaxCharactersCallBackCalled = false;
3701 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3702 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3704 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3705 DALI_TEST_CHECK(maxLengthReachedSignal);
3710 int utcDaliTextEditorInputFiltered(void)
3712 ToolkitTestApplication application;
3713 tet_infoline(" utcDaliTextEditorInputFiltered");
3714 TextEditor editor = TextEditor::New();
3715 DALI_TEST_CHECK(editor);
3717 application.GetScene().Add(editor);
3719 Property::Map inputFilter;
3721 // Only digit is accepted.
3722 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3724 // Set input filter to TextEditor.
3725 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3727 editor.SetKeyInputFocus();
3729 // connect to the input filtered signal.
3730 ConnectionTracker* testTracker = new ConnectionTracker();
3731 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3732 bool inputFilteredSignal = false;
3733 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3735 gInputFilteredAcceptedCallbackCalled = false;
3737 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3739 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3740 DALI_TEST_CHECK(inputFilteredSignal);
3742 // Word is rejected.
3743 inputFilter[InputFilter::Property::ACCEPTED] = "";
3744 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3746 // Set input filter to TextEditor.
3747 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3749 editor.SetKeyInputFocus();
3751 inputFilteredSignal = false;
3752 gInputFilteredRejectedCallbackCalled = false;
3754 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3756 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3757 DALI_TEST_CHECK(inputFilteredSignal);
3762 int UtcDaliTextEditorSelectWholeText(void)
3764 ToolkitTestApplication application;
3765 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3767 TextEditor textEditor = TextEditor::New();
3769 application.GetScene().Add(textEditor);
3771 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3772 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3773 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3775 // Avoid a crash when core load gl resources.
3776 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3778 application.SendNotification();
3779 application.Render();
3781 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3783 DevelTextEditor::SelectWholeText(textEditor);
3785 application.SendNotification();
3786 application.Render();
3788 // Nothing should have been selected. The number of children is still 1
3789 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3791 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3793 application.SendNotification();
3794 application.Render();
3796 DevelTextEditor::SelectWholeText(textEditor);
3798 application.SendNotification();
3799 application.Render();
3801 // Should be 2 children, the stencil and the layer
3802 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3804 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3805 Actor stencil = textEditor.GetChildAt(0u);
3807 // The highlight actor is drawn first, so is the first actor in the list
3808 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3809 DALI_TEST_CHECK(highlight);
3814 int UtcDaliTextEditorSelectText(void)
3816 ToolkitTestApplication application;
3817 tet_infoline(" UtcDaliTextEditorSelectText ");
3819 TextEditor textEditor = TextEditor::New();
3821 application.GetScene().Add(textEditor);
3823 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3824 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3825 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3827 // Avoid a crash when core load gl resources.
3828 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3830 application.SendNotification();
3831 application.Render();
3833 DevelTextEditor::SelectText(textEditor, 0, 5);
3835 application.SendNotification();
3836 application.Render();
3838 // Nothing is selected
3839 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3840 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3842 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3844 application.SendNotification();
3845 application.Render();
3847 DevelTextEditor::SelectText(textEditor, 0, 5);
3849 application.SendNotification();
3850 application.Render();
3852 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3853 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3855 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3856 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3858 // world is selected
3859 DevelTextEditor::SelectText(textEditor, 6, 11);
3861 application.SendNotification();
3862 application.Render();
3864 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3865 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3867 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3868 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3873 int UtcDaliTextEditorSelectNone(void)
3875 ToolkitTestApplication application;
3876 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3878 TextEditor textEditor = TextEditor::New();
3880 application.GetScene().Add(textEditor);
3882 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3883 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3884 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3886 // Avoid a crash when core load gl resources.
3887 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3889 application.SendNotification();
3890 application.Render();
3892 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3894 application.SendNotification();
3895 application.Render();
3897 // Nothing is selected
3898 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3899 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3901 DevelTextEditor::SelectWholeText(textEditor);
3903 application.SendNotification();
3904 application.Render();
3906 // whole text is selected
3907 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3908 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3910 DevelTextEditor::SelectNone(textEditor);
3912 application.SendNotification();
3913 application.Render();
3915 // Nothing is selected
3916 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3917 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3922 int UtcDaliTextEditorSelectRange(void)
3924 ToolkitTestApplication application;
3925 tet_infoline("utcDaliTextEditorSelectRange");
3927 TextEditor textEditor = TextEditor::New();
3928 DALI_TEST_CHECK(textEditor);
3930 application.GetScene().Add(textEditor);
3932 // Avoid a crash when core load gl resources.
3933 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3935 application.SendNotification();
3936 application.Render();
3938 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3940 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3941 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3943 // Hello is selected
3944 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3945 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3947 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3948 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3953 int UtcDaliTextEditorEnableEditing(void)
3955 ToolkitTestApplication application;
3956 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3958 TextEditor textEditor = TextEditor::New();
3960 application.GetScene().Add(textEditor);
3962 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3963 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3964 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3966 // Avoid a crash when core load gl resources.
3967 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3969 application.SendNotification();
3970 application.Render();
3972 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3973 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3975 textEditor.SetKeyInputFocus();
3976 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3977 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3979 // Render and notify
3980 application.SendNotification();
3981 application.Render();
3983 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3984 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3986 textEditor.SetKeyInputFocus();
3987 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3988 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3990 // Render and notify
3991 application.SendNotification();
3992 application.Render();
3994 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3995 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3997 // Check the user interaction enabled and for coverage
3998 DevelTextEditor::SelectWholeText(textEditor);
4000 // Render and notify
4001 application.SendNotification();
4002 application.Render();
4004 textEditor.SetKeyInputFocus();
4005 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4006 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4008 // Render and notify
4009 application.SendNotification();
4010 application.Render();
4012 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4013 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4018 int UtcDaliTextEditorScrolling(void)
4020 ToolkitTestApplication application;
4021 tet_infoline(" UtcDaliTextEditorScrolling ");
4023 TextEditor textEditor = TextEditor::New();
4024 DALI_TEST_CHECK(textEditor);
4026 application.GetScene().Add(textEditor);
4028 // Avoid a crash when core load gl resources.
4029 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4031 application.SendNotification();
4032 application.Render();
4034 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4035 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4036 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4037 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4039 application.SendNotification();
4040 application.Render();
4042 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4043 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4045 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4047 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4048 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4050 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4052 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4053 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4055 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4056 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4058 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4059 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4064 int UtcDaliToolkitTextEditorFontSizeScale(void)
4066 ToolkitTestApplication application;
4067 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4069 TextEditor textEditor = TextEditor::New();
4070 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4071 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4072 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4074 TextEditor textEditorScaled = TextEditor::New();
4075 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4076 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4077 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4078 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4080 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4082 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4083 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4084 nonScaledSize = textEditor.GetNaturalSize();
4086 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4087 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4088 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4089 scaledSize = textEditorScaled.GetNaturalSize();
4091 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4096 int UtcDaliTextEditorPrimaryCursorPosition(void)
4098 ToolkitTestApplication application;
4099 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4101 TextEditor textEditor = TextEditor::New();
4103 application.GetScene().Add(textEditor);
4105 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4106 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4107 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4108 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4110 // Avoid a crash when core load gl resources.
4111 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4113 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4114 application.SendNotification();
4115 application.Render();
4116 textEditor.SetKeyInputFocus();
4118 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4120 // Render and notify
4121 application.SendNotification();
4122 application.Render();
4124 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4125 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4130 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4132 ToolkitTestApplication application;
4133 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4135 TextEditor textEditor = TextEditor::New();
4136 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4137 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4138 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4139 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4140 application.GetScene().Add(textEditor);
4142 application.SendNotification();
4143 application.Render();
4146 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4147 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4149 textEditor.GetNaturalSize();
4151 // Create a tap event to touch the text editor.
4152 TestGenerateTap(application, 18.0f, 25.0f);
4154 application.SendNotification();
4155 application.Render();
4157 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4158 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4163 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4165 ToolkitTestApplication application;
4167 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4169 int lineCountBefore = 0;
4170 int lineCountAfter = 0;
4172 // Create a text editor
4173 TextEditor textEditor = TextEditor::New();
4174 //Set very large font-size using point-size
4175 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4176 //Specify font-family
4177 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4179 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4180 //Set text longer than width of textEditor
4181 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4183 application.GetScene().Add(textEditor);
4185 application.SendNotification();
4186 application.Render();
4188 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
4189 //GetHeightForWidth is a retrieval method which should not modify object
4190 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4191 textEditor.GetHeightForWidth(200.f);
4193 //This is to simulate focus into text editor after calling GetHeightForWidth
4194 //Create a tap event to touch the text editor.
4195 TestGenerateTap(application, 18.0f, 25.0f);
4197 application.SendNotification();
4198 application.Render();
4200 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4202 //The LineCount must not be changed when calling GetHeightForWidth.
4203 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4208 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4210 ToolkitTestApplication application;
4212 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
4214 int lineCountBefore = 0;
4215 int lineCountAfter = 0;
4217 // Create a text editor
4218 TextEditor textEditor = TextEditor::New();
4219 //Set very large font-size using point-size
4220 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4221 //Specify font-family
4222 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4224 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4225 //Set text longer than width of textEditor
4226 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4227 //Set line wrap mode Character
4228 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4230 application.GetScene().Add(textEditor);
4232 application.SendNotification();
4233 application.Render();
4235 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4236 //GetHeightForWidth is a retrieval method which should not modify object
4237 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4238 textEditor.GetHeightForWidth(200.f);
4240 //This is to simulate focus into text editor after calling GetHeightForWidth
4241 //Create a tap event to touch the text editor.
4242 TestGenerateTap(application, 18.0f, 25.0f);
4244 application.SendNotification();
4245 application.Render();
4247 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4249 //The LineCount must not be changed when calling GetHeightForWidth.
4250 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4255 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4257 ToolkitTestApplication application;
4259 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4261 int lineCountBefore = 0;
4262 int lineCountAfter = 0;
4264 // Create a text editor
4265 TextEditor textEditor = TextEditor::New();
4266 //Set very large font-size using point-size
4267 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4268 //Specify font-family
4269 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4271 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4272 //Set text longer than width of textEditor
4273 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4274 //Set line wrap mode Character
4275 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4277 application.GetScene().Add(textEditor);
4279 application.SendNotification();
4280 application.Render();
4282 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4284 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4285 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4287 // When the text changed, the Line-count should be updated according to new text.
4288 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4289 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4290 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4295 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4297 ToolkitTestApplication application;
4299 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4301 int lineCountBefore = 0;
4302 int lineCountAfter = 0;
4304 // Create a text editor
4305 TextEditor textEditor = TextEditor::New();
4306 //Set very large font-size using point-size
4307 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4308 //Specify font-family
4309 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4311 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4312 //Set text longer than width of textEditor
4313 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4315 application.GetScene().Add(textEditor);
4317 application.SendNotification();
4318 application.Render();
4320 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4321 //GetNaturalSize is a retrieval method which should not modify object
4322 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4323 textEditor.GetNaturalSize();
4325 //This is to simulate focus into text editor after calling GetNaturalSize
4326 //Create a tap event to touch the text editor.
4327 TestGenerateTap(application, 18.0f, 25.0f);
4329 application.SendNotification();
4330 application.Render();
4332 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4334 //The LineCount must not be changed when calling GetNaturalSize.
4335 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4340 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4342 ToolkitTestApplication application;
4344 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4346 int lineCountBefore = 0;
4347 int lineCountAfter = 0;
4349 // Create a text editor
4350 TextEditor textEditor = TextEditor::New();
4351 //Set very large font-size using point-size
4352 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4353 //Specify font-family
4354 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4356 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4357 //Set text longer than width of textEditor
4358 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4359 //Set line wrap mode Character
4360 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4362 application.GetScene().Add(textEditor);
4364 application.SendNotification();
4365 application.Render();
4367 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4368 //GetNaturalSize is a retrieval method which should not modify object
4369 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4370 textEditor.GetNaturalSize();
4372 //This is to simulate focus into text editor after calling GetNaturalSize
4373 //Create a tap event to touch the text editor.
4374 TestGenerateTap(application, 18.0f, 25.0f);
4376 application.SendNotification();
4377 application.Render();
4379 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4381 //The LineCount must not be changed when calling GetNaturalSize.
4382 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4387 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4389 ToolkitTestApplication application;
4390 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4392 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4393 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4394 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4396 // Create a text editor
4397 TextEditor textEditor = TextEditor::New();
4399 //Set size to avoid automatic eliding
4400 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4401 //Set very large font-size using point-size
4402 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4403 //Specify font-family
4404 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4405 //Set text to check if appear or not
4406 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4408 application.GetScene().Add(textEditor);
4410 application.SendNotification();
4411 application.Render();
4412 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4413 Vector3 naturalSize = textEditor.GetNaturalSize();
4415 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4416 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4421 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4423 ToolkitTestApplication application;
4424 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4426 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4427 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4428 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4430 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4431 // Create a text editor
4432 TextEditor textEditor = TextEditor::New();
4433 //Set size to avoid automatic eliding
4434 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4435 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4436 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4438 const int numberOfCases = 6;
4439 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4441 for(int index = 0; index < numberOfCases; index++)
4443 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4444 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4445 application.GetScene().Add(textEditor);
4446 application.SendNotification();
4447 application.Render();
4448 naturalSize = textEditor.GetNaturalSize();
4449 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4450 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4456 int UtcDaliTextEditorHyphenWrapMode(void)
4458 ToolkitTestApplication application;
4459 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4462 TextEditor textEditor = TextEditor::New();
4464 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4466 application.GetScene().Add(textEditor);
4467 application.SendNotification();
4468 application.Render();
4470 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4471 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4472 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4474 application.SendNotification();
4475 application.Render();
4477 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4483 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4485 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4486 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4487 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4489 application.SendNotification();
4490 application.Render();
4492 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4499 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4504 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4506 ToolkitTestApplication application;
4507 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4508 TextEditor textEditor = TextEditor::New();
4510 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4511 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4513 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4514 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4515 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4517 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4518 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4519 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4521 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4522 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4523 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4525 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4526 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4527 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4529 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4530 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4531 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4533 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4534 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4535 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4537 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4538 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4539 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4541 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4542 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4543 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4545 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4546 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4547 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4549 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4550 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4551 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4553 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4554 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4555 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4557 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4558 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4559 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4564 int UtcDaliTextEditorCopyText(void)
4566 ToolkitTestApplication application;
4567 tet_infoline(" UtcDaliTextEditorCopyText ");
4569 TextEditor textEditor = TextEditor::New();
4571 std::string selectedText = "";
4572 std::string copiedText = "";
4574 application.GetScene().Add(textEditor);
4576 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4577 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4578 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4580 // Avoid a crash when core load gl resources.
4581 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4583 application.SendNotification();
4584 application.Render();
4586 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4588 application.SendNotification();
4589 application.Render();
4591 // Hello is selected
4592 DevelTextEditor::SelectText(textEditor, 0, 5);
4594 application.SendNotification();
4595 application.Render();
4597 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4598 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4600 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4601 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4604 copiedText = DevelTextEditor::CopyText(textEditor);
4605 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4607 // world is selected
4608 DevelTextEditor::SelectText(textEditor, 6, 11);
4610 application.SendNotification();
4611 application.Render();
4613 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4614 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4616 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4617 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4620 copiedText = DevelTextEditor::CopyText(textEditor);
4621 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4623 // "lo wo" is selected
4624 DevelTextEditor::SelectText(textEditor, 3, 8);
4626 application.SendNotification();
4627 application.Render();
4629 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4630 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4632 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4633 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4635 // "lo wo" is copied
4636 copiedText = DevelTextEditor::CopyText(textEditor);
4637 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4642 int UtcDaliTextEditorCutText(void)
4644 ToolkitTestApplication application;
4645 tet_infoline(" UtcDaliTextEditorCutText ");
4647 TextEditor textEditor = TextEditor::New();
4649 std::string selectedText = "";
4651 application.GetScene().Add(textEditor);
4653 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4654 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4655 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4657 // Avoid a crash when core load gl resources.
4658 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4660 application.SendNotification();
4661 application.Render();
4663 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4665 application.SendNotification();
4666 application.Render();
4668 // Hello is selected
4669 DevelTextEditor::SelectText(textEditor, 0, 5);
4671 application.SendNotification();
4672 application.Render();
4674 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4675 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4677 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4678 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4681 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4683 application.SendNotification();
4684 application.Render();
4686 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4689 DevelTextEditor::SelectText(textEditor, 0, 2);
4691 application.SendNotification();
4692 application.Render();
4694 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4695 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4697 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4698 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4701 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4703 application.SendNotification();
4704 application.Render();
4706 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4708 // Test Cut from the middle
4711 DevelTextEditor::SelectText(textEditor, 1, 3);
4713 application.SendNotification();
4714 application.Render();
4716 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4717 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4719 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4720 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4723 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4725 application.SendNotification();
4726 application.Render();
4728 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4730 // Test Cut from the end
4733 DevelTextEditor::SelectText(textEditor, 1, 2);
4735 application.SendNotification();
4736 application.Render();
4738 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4739 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4741 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4742 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4745 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4747 application.SendNotification();
4748 application.Render();
4750 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4755 int UtcDaliTextEditorPasteText(void)
4757 ToolkitTestApplication application;
4758 tet_infoline(" UtcDaliTextEditorPasteText ");
4760 TextEditor editor = TextEditor::New();
4761 DALI_TEST_CHECK(editor);
4763 application.GetScene().Add(editor);
4765 std::string cutText = "";
4766 std::string copiedText = "";
4768 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4769 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4770 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4771 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4772 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4774 // Avoid a crash when core load gl resources.
4775 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4777 // Render and notify
4778 application.SendNotification();
4779 application.Render();
4781 // Tap on the text editor
4782 TestGenerateTap(application, 3.0f, 25.0f);
4784 // Render and notify
4785 application.SendNotification();
4786 application.Render();
4788 // Move to second line of the text.
4789 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4791 // Render and notify
4792 application.SendNotification();
4793 application.Render();
4795 // Select some text in the right of the current cursor position
4796 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4797 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4798 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4801 // Render and notify
4802 application.SendNotification();
4803 application.Render();
4805 // Cut the selected text
4806 cutText = DevelTextEditor::CutText(editor);
4808 // Render and notify
4809 application.SendNotification();
4810 application.Render();
4812 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4813 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4815 // Select some text in the left of the current cursor position
4816 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4817 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4818 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4821 // Render and notify
4822 application.SendNotification();
4823 application.Render();
4825 // Copy the selected text
4826 copiedText = DevelTextEditor::CopyText(editor);
4828 // Render and notify
4829 application.SendNotification();
4830 application.Render();
4832 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4833 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4835 // Move the cursor to the third line
4836 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4837 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4839 // Render and notify
4840 application.SendNotification();
4841 application.Render();
4843 // Paste the selected text at the current cursor position
4844 DevelTextEditor::PasteText(editor);
4846 // Render and notify
4847 application.SendNotification();
4848 application.Render();
4850 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4855 int UtcDaliTextEditorLineSpacing(void)
4857 ToolkitTestApplication application;
4858 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4860 TextEditor textEditor = TextEditor::New();
4861 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4862 application.GetScene().Add(textEditor);
4863 application.SendNotification();
4864 application.Render();
4866 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4867 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4869 Vector3 sizeBefore = textEditor.GetNaturalSize();
4871 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4873 //add 20 for each line 20 * 3
4874 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4879 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4881 //Only for test coverage
4882 ToolkitTestApplication application;
4883 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4885 TextEditor textEditor = TextEditor::New();
4886 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4887 application.GetScene().Add(textEditor);
4888 application.SendNotification();
4889 application.Render();
4891 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4892 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4894 application.SendNotification();
4895 application.Render();
4897 DevelTextEditor::SelectWholeText(textEditor);
4899 application.SendNotification();
4900 application.Render();
4902 DevelTextEditor::SelectNone(textEditor);
4903 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4905 application.SendNotification();
4906 application.Render();
4908 DevelTextEditor::SelectWholeText(textEditor);
4910 application.SendNotification();
4911 application.Render();
4913 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4918 int UtcDaliTextEditorMinLineSize(void)
4920 ToolkitTestApplication application;
4921 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4923 TextEditor textEditor = TextEditor::New();
4924 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4925 application.GetScene().Add(textEditor);
4926 application.SendNotification();
4927 application.Render();
4929 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4930 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4932 Vector3 sizeBefore = textEditor.GetNaturalSize();
4934 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4936 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4939 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4944 int utcDaliTextEditorCursorPositionChangedSignal(void)
4946 ToolkitTestApplication application;
4947 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4949 TextEditor editor = TextEditor::New();
4950 DALI_TEST_CHECK(editor);
4952 application.GetScene().Add(editor);
4954 // connect to the selection changed signal.
4955 ConnectionTracker* testTracker = new ConnectionTracker();
4956 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4957 bool cursorPositionChangedSignal = false;
4958 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4960 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4961 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4962 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4963 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4964 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4966 // Avoid a crash when core load gl resources.
4967 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4969 // Render and notify
4970 application.SendNotification();
4971 application.Render();
4973 editor.SetKeyInputFocus();
4975 // Tap on the text editor
4976 TestGenerateTap(application, 3.0f, 25.0f);
4978 // Render and notify
4979 application.SendNotification();
4980 application.Render();
4982 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4983 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4985 gCursorPositionChangedCallbackCalled = false;
4988 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4990 // Render and notify
4991 application.SendNotification();
4992 application.Render();
4994 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4995 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4997 gCursorPositionChangedCallbackCalled = false;
5000 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5002 // Render and notify
5003 application.SendNotification();
5004 application.Render();
5006 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5007 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5009 gCursorPositionChangedCallbackCalled = false;
5011 //delete one character
5012 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5014 // Render and notify
5015 application.SendNotification();
5016 application.Render();
5018 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5019 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5021 gCursorPositionChangedCallbackCalled = false;
5023 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5025 // Render and notify
5026 application.SendNotification();
5027 application.Render();
5029 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5030 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5032 gCursorPositionChangedCallbackCalled = false;
5034 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5036 // Render and notify
5037 application.SendNotification();
5038 application.Render();
5040 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5041 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5046 int utcDaliTextEditorGeometryEllipsisStart(void)
5048 ToolkitTestApplication application;
5049 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5051 TextEditor editor = TextEditor::New();
5052 DALI_TEST_CHECK(editor);
5054 application.GetScene().Add(editor);
5056 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5057 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5058 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5059 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5060 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5061 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5062 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5063 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5064 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5066 // Avoid a crash when core load gl resources.
5067 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5069 // Render and notify
5070 application.SendNotification();
5071 application.Render();
5073 unsigned int expectedCount = 2;
5074 unsigned int startIndex = 0;
5075 unsigned int endIndex = 24;
5077 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5078 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5080 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5081 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5083 Vector<Vector2> expectedSizes;
5084 Vector<Vector2> expectedPositions;
5086 expectedPositions.PushBack(Vector2(38, 0));
5087 expectedSizes.PushBack(Vector2(21, 25));
5089 expectedPositions.PushBack(Vector2(-1, 25));
5090 expectedSizes.PushBack(Vector2(53, 25));
5092 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5097 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5099 ToolkitTestApplication application;
5100 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
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::MIDDLE);
5115 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5117 // Avoid a crash when core load gl resources.
5118 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5120 // Render and notify
5121 application.SendNotification();
5122 application.Render();
5124 unsigned int expectedCount = 2;
5125 unsigned int startIndex = 0;
5126 unsigned int endIndex = 24;
5128 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5129 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5131 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5132 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5134 Vector<Vector2> expectedSizes;
5135 Vector<Vector2> expectedPositions;
5137 expectedPositions.PushBack(Vector2(-1, 0));
5138 expectedSizes.PushBack(Vector2(26, 25));
5140 expectedPositions.PushBack(Vector2(-1, 25));
5141 expectedSizes.PushBack(Vector2(53, 25));
5143 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5148 int utcDaliTextEditorGeometryEllipsisEnd(void)
5150 ToolkitTestApplication application;
5151 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5153 TextEditor editor = TextEditor::New();
5154 DALI_TEST_CHECK(editor);
5156 application.GetScene().Add(editor);
5158 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5159 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5160 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5161 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5162 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5163 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5164 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5165 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5166 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5168 // Avoid a crash when core load gl resources.
5169 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5171 // Render and notify
5172 application.SendNotification();
5173 application.Render();
5175 unsigned int expectedCount = 2;
5176 unsigned int startIndex = 0;
5177 unsigned int endIndex = 24;
5179 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5180 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5182 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5183 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5185 Vector<Vector2> expectedSizes;
5186 Vector<Vector2> expectedPositions;
5188 expectedPositions.PushBack(Vector2(-1, 0));
5189 expectedSizes.PushBack(Vector2(60, 25));
5191 expectedPositions.PushBack(Vector2(-1, 25));
5192 expectedSizes.PushBack(Vector2(39, 25));
5194 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5199 int utcDaliTextEditorGeometryRTL(void)
5201 ToolkitTestApplication application;
5202 tet_infoline(" utcDaliTextEditorGeometryRTL");
5204 TextEditor editor = TextEditor::New();
5205 DALI_TEST_CHECK(editor);
5207 application.GetScene().Add(editor);
5209 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5210 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5211 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5212 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5213 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5214 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5216 // Avoid a crash when core load gl resources.
5217 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5219 // Render and notify
5220 application.SendNotification();
5221 application.Render();
5223 unsigned int expectedCount = 4;
5224 unsigned int startIndex = 3;
5225 unsigned int endIndex = 24;
5227 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5228 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5230 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5231 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5233 Vector<Vector2> expectedSizes;
5234 Vector<Vector2> expectedPositions;
5236 expectedPositions.PushBack(Vector2(25, 0));
5237 expectedSizes.PushBack(Vector2(34, 25));
5239 expectedPositions.PushBack(Vector2(-1, 25));
5240 expectedSizes.PushBack(Vector2(53, 25));
5242 expectedPositions.PushBack(Vector2(-1, 50));
5243 expectedSizes.PushBack(Vector2(60, 25));
5245 expectedPositions.PushBack(Vector2(63, 75));
5246 expectedSizes.PushBack(Vector2(37, 25));
5248 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5253 int utcDaliTextEditorGeometryGlyphMiddle(void)
5255 ToolkitTestApplication application;
5256 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5258 TextEditor editor = TextEditor::New();
5259 DALI_TEST_CHECK(editor);
5261 application.GetScene().Add(editor);
5263 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5264 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5265 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5266 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5267 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5268 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5270 // Avoid a crash when core load gl resources.
5271 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5273 // Render and notify
5274 application.SendNotification();
5275 application.Render();
5277 unsigned int expectedCount = 1;
5278 unsigned int startIndex = 1;
5279 unsigned int endIndex = 13;
5281 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5282 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5284 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5285 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5287 Vector<Vector2> expectedSizes;
5288 Vector<Vector2> expectedPositions;
5290 expectedPositions.PushBack(Vector2(6, 0));
5291 expectedSizes.PushBack(Vector2(125, 25));
5293 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5298 int utcDaliTextEditorGeometryOneGlyph(void)
5300 ToolkitTestApplication application;
5301 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5303 TextEditor label = TextEditor::New();
5304 DALI_TEST_CHECK(label);
5306 application.GetScene().Add(label);
5308 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5309 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5310 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5311 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5312 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5313 label.SetProperty(TextEditor::Property::TEXT, "H");
5315 // Avoid a crash when core load gl resources.
5316 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5318 // Render and notify
5319 application.SendNotification();
5320 application.Render();
5322 unsigned int expectedCount = 1;
5323 unsigned int startIndex = 0;
5324 unsigned int endIndex = 0;
5326 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5327 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5329 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5330 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5332 Vector<Vector2> expectedSizes;
5333 Vector<Vector2> expectedPositions;
5335 expectedPositions.PushBack(Vector2(-2, 0));
5336 expectedSizes.PushBack(Vector2(16, 25));
5338 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5343 int utcDaliTextEditorGeometryNullPtr(void)
5345 ToolkitTestApplication application;
5346 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5348 TextEditor editor = TextEditor::New();
5349 DALI_TEST_CHECK(editor);
5351 application.GetScene().Add(editor);
5353 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5354 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5355 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5356 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5357 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5358 editor.SetProperty(TextEditor::Property::TEXT, "");
5360 // Avoid a crash when core load gl resources.
5361 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5363 unsigned int expectedCount = 0;
5364 unsigned int startIndex = 0;
5365 unsigned int endIndex = 0;
5367 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5368 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5370 // Render and notify
5371 application.SendNotification();
5372 application.Render();
5374 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5375 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5380 int utcDaliTextEditorSelectionClearedSignal(void)
5382 ToolkitTestApplication application;
5383 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5385 TextEditor editor = TextEditor::New();
5386 DALI_TEST_CHECK(editor);
5388 application.GetScene().Add(editor);
5390 // connect to the selection changed signal.
5391 ConnectionTracker* testTracker = new ConnectionTracker();
5392 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5393 bool selectionClearedSignal = false;
5394 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5396 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5397 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5398 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5399 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5400 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5402 // Avoid a crash when core load gl resources.
5403 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5405 // Render and notify
5406 application.SendNotification();
5407 application.Render();
5409 // Tap on the text editor
5410 TestGenerateTap(application, 3.0f, 25.0f);
5412 // Render and notify
5413 application.SendNotification();
5414 application.Render();
5416 // Move to second line of the text & Select some text in the right of the current cursor position
5417 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5418 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5421 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5423 // Render and notify
5424 application.SendNotification();
5425 application.Render();
5427 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5429 // Render and notify
5430 application.SendNotification();
5431 application.Render();
5433 // Tap on the text editor
5434 TestGenerateTap(application, 3.0f, 25.0f);
5436 // Render and notify
5437 application.SendNotification();
5438 application.Render();
5440 gSelectionClearedCallbackCalled = false;
5442 // Move to second line of the text & select.
5443 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5444 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5447 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5449 // Render and notify
5450 application.SendNotification();
5451 application.Render();
5453 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5455 gSelectionClearedCallbackCalled = false;
5457 // Render and notify
5458 application.SendNotification();
5459 application.Render();
5461 // Move to second line of the text & select.
5462 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5463 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5465 // replace C with selected text
5466 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5468 // Render and notify
5469 application.SendNotification();
5470 application.Render();
5472 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5474 gSelectionClearedCallbackCalled = false;
5476 // Render and notify
5477 application.SendNotification();
5478 application.Render();
5480 DevelTextEditor::SelectText(editor, 1, 3);
5482 // Render and notify
5483 application.SendNotification();
5484 application.Render();
5486 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5488 // Render and notify
5489 application.SendNotification();
5490 application.Render();
5492 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5494 gSelectionClearedCallbackCalled = false;
5496 DevelTextEditor::SelectText(editor, 1, 3);
5498 // Render and notify
5499 application.SendNotification();
5500 application.Render();
5503 DevelTextEditor::SelectNone(editor);
5505 // Render and notify
5506 application.SendNotification();
5507 application.Render();
5509 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5514 int utcDaliTextEditorSelectionStartedSignal(void)
5516 ToolkitTestApplication application;
5517 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5519 TextEditor editor = TextEditor::New();
5520 DALI_TEST_CHECK(editor);
5522 application.GetScene().Add(editor);
5524 // connect to the selection changed signal.
5525 ConnectionTracker* testTracker = new ConnectionTracker();
5526 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5527 bool selectionStartedSignal = false;
5528 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5530 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5531 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5532 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5533 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5534 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5536 // Avoid a crash when core load gl resources.
5537 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5539 // Render and notify
5540 application.SendNotification();
5541 application.Render();
5543 // Tap on the text editor
5544 TestGenerateTap(application, 3.0f, 25.0f);
5546 // Render and notify
5547 application.SendNotification();
5548 application.Render();
5550 // Move to second line of the text & Select some text in the right of the current cursor position
5551 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5552 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5554 // Render and notify
5555 application.SendNotification();
5556 application.Render();
5558 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5561 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5563 // Render and notify
5564 application.SendNotification();
5565 application.Render();
5567 gSelectionStartedCallbackCalled = false;
5569 DevelTextEditor::SelectText(editor, 1, 3);
5571 // Render and notify
5572 application.SendNotification();
5573 application.Render();
5575 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5580 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5582 ToolkitTestApplication application;
5583 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5585 // Checks if the actor is created.
5587 TextEditor editor = TextEditor::New();
5588 DALI_TEST_CHECK(editor);
5590 application.GetScene().Add(editor);
5592 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5593 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5594 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5595 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5596 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5597 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5598 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5599 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5601 // Avoid a crash when core load gl resources.
5602 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5604 // Render and notify
5605 application.SendNotification();
5606 application.Render();
5608 // Tap on the text editor
5609 TestGenerateTap(application, 3.0f, 25.0f);
5611 // Render and notify
5612 application.SendNotification();
5613 application.Render();
5615 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5616 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5618 application.SendNotification();
5619 application.Render();
5621 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5622 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5627 int utcDaliTextEditorSelectionChangedSignal(void)
5629 ToolkitTestApplication application;
5630 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5632 TextEditor editor = TextEditor::New();
5633 DALI_TEST_CHECK(editor);
5635 application.GetScene().Add(editor);
5637 // connect to the selection changed signal.
5638 ConnectionTracker* testTracker = new ConnectionTracker();
5639 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5640 bool selectionChangedSignal = false;
5641 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5643 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5644 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5645 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5646 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5647 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5649 // Avoid a crash when core load gl resources.
5650 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5652 // Render and notify
5653 application.SendNotification();
5654 application.Render();
5656 // Tap on the text editor
5657 TestGenerateTap(application, 3.0f, 25.0f);
5659 // Render and notify
5660 application.SendNotification();
5661 application.Render();
5663 // Move to second line of the text.
5664 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5666 // Render and notify
5667 application.SendNotification();
5668 application.Render();
5670 // Select some text in the right of the current cursor position
5671 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5672 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5674 // Render and notify
5675 application.SendNotification();
5676 application.Render();
5678 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5679 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5681 gSelectionChangedCallbackCalled = false;
5683 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5685 // Render and notify
5686 application.SendNotification();
5687 application.Render();
5689 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5690 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5691 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5693 gSelectionChangedCallbackCalled = false;
5695 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5697 // Render and notify
5698 application.SendNotification();
5699 application.Render();
5701 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5702 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5703 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5705 gSelectionChangedCallbackCalled = false;
5706 editor.SetKeyInputFocus();
5708 // Render and notify
5709 application.SendNotification();
5710 application.Render();
5712 DevelTextEditor::SelectText(editor, 0, 5);
5714 application.SendNotification();
5715 application.Render();
5717 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5718 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5720 gSelectionChangedCallbackCalled = false;
5722 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5724 // Render and notify
5725 application.SendNotification();
5726 application.Render();
5728 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5729 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5730 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5732 gSelectionChangedCallbackCalled = false;
5735 DevelTextEditor::SelectWholeText(editor);
5737 // Render and notify
5738 application.SendNotification();
5739 application.Render();
5741 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5742 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5744 gSelectionChangedCallbackCalled = false;
5747 DevelTextEditor::SelectNone(editor);
5749 // Render and notify
5750 application.SendNotification();
5751 application.Render();
5753 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5754 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5755 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5760 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5762 ToolkitTestApplication application;
5763 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5765 TextEditor textEditor = TextEditor::New();
5766 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5767 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5768 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5769 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5771 application.GetScene().Add(textEditor);
5772 application.SendNotification();
5773 application.Render();
5775 Property::Map strikethroughMapSet;
5776 Property::Map strikethroughMapGet;
5778 strikethroughMapSet.Insert("enable", true);
5779 strikethroughMapSet.Insert("color", Color::RED);
5780 strikethroughMapSet.Insert("height", 2.0f);
5782 // Check the strikethrough property
5783 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5784 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5785 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5786 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5787 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5789 // Render and notify
5790 application.SendNotification();
5791 application.Render();
5793 strikethroughMapSet.Clear();
5794 strikethroughMapGet.Clear();
5799 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5801 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5802 //DaliException on vector: "Iterator not inside vector"
5804 ToolkitTestApplication application;
5805 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5807 TextEditor editor = TextEditor::New();
5808 DALI_TEST_CHECK(editor);
5810 application.GetScene().Add(editor);
5812 // Avoid a crash when core load gl resources.
5813 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5815 //Set multilines text
5816 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5817 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5818 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5820 //Set ResizePolicy to NaturalSize
5821 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5823 // Render and notify
5824 application.SendNotification();
5825 application.Render();
5827 // Create a tap event to touch the text editor.
5828 TestGenerateTap(application, 5.0f, 5.0f);
5830 // Render and notify
5831 application.SendNotification();
5832 application.Render();
5834 // Set currsor and add character (in first line)
5835 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5836 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5837 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5839 // Render and notify
5840 application.SendNotification();
5841 application.Render();
5843 //Check the changed text and cursor position
5844 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5845 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5847 // Render and notify
5848 application.SendNotification();
5849 application.Render();
5854 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5856 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5857 //DaliException on vector: "Iterator not inside vector"
5859 ToolkitTestApplication application;
5860 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5862 TextEditor editor = TextEditor::New();
5863 DALI_TEST_CHECK(editor);
5865 application.GetScene().Add(editor);
5867 // Avoid a crash when core load gl resources.
5868 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5870 //Set multilines text
5871 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5872 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5873 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5875 //Set ResizePolicy to NaturalSize
5876 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5879 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5880 application.SendNotification();
5881 application.Render();
5883 // Set focus and remove character
5884 editor.SetKeyInputFocus();
5885 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5887 // Render and notify
5888 application.SendNotification();
5889 application.Render();
5891 //Check the changed text and cursor position
5892 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5893 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5895 // Render and notify
5896 application.SendNotification();
5897 application.Render();
5902 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5904 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5905 //DaliException on vector: "Iterator not inside vector"
5907 ToolkitTestApplication application;
5908 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5910 TextEditor editor = TextEditor::New();
5911 DALI_TEST_CHECK(editor);
5913 application.GetScene().Add(editor);
5915 // Avoid a crash when core load gl resources.
5916 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5918 //Set multilines text
5919 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5920 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5921 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5923 //Set ResizePolicy to NaturalSize
5924 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5926 //Select text at initialization (before the first render)
5927 DevelTextEditor::SelectText(editor, 3, 5);
5929 // Render and notify
5930 application.SendNotification();
5931 application.Render();
5934 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5935 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));
5937 // Render and notify
5938 application.SendNotification();
5939 application.Render();
5941 //Check the changed text and cursor position
5942 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5943 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5945 // Render and notify
5946 application.SendNotification();
5947 application.Render();
5952 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5954 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5955 //DaliException on vector: "Iterator not inside vector"
5957 ToolkitTestApplication application;
5958 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5960 TextEditor editor = TextEditor::New();
5961 DALI_TEST_CHECK(editor);
5963 application.GetScene().Add(editor);
5965 // Avoid a crash when core load gl resources.
5966 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5968 //Set multilines text
5969 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5970 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5971 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5973 //Set ResizePolicy to NaturalSize
5974 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5977 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5978 application.SendNotification();
5979 application.Render();
5981 // Set focus and double enter (new line)
5982 editor.SetKeyInputFocus();
5983 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5984 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5986 // Render and notify
5987 application.SendNotification();
5988 application.Render();
5990 //Check the changed text and cursor position
5991 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5992 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5994 // Render and notify
5995 application.SendNotification();
5996 application.Render();
6001 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
6003 ToolkitTestApplication application;
6004 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
6005 TextEditor textEditor = TextEditor::New();
6006 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
6007 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6008 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6009 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6011 application.GetScene().Add(textEditor);
6012 application.SendNotification();
6013 application.Render();
6015 Property::Map underlineMapSet;
6016 Property::Map underlineMapGet;
6018 underlineMapSet.Insert("enable", true);
6019 underlineMapSet.Insert("color", Color::RED);
6020 underlineMapSet.Insert("height", 1);
6021 underlineMapSet.Insert("type", Text::Underline::SOLID);
6022 underlineMapSet.Insert("dashWidth", 2);
6023 underlineMapSet.Insert("dashGap", 1);
6025 // Check the underline property
6026 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6028 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6029 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6030 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6032 // Render and notify
6033 application.SendNotification();
6034 application.Render();
6036 underlineMapSet.Clear();
6037 underlineMapGet.Clear();
6039 underlineMapSet.Insert("enable", true);
6040 underlineMapSet.Insert("color", Color::BLUE);
6041 underlineMapSet.Insert("height", 1);
6042 underlineMapSet.Insert("type", Text::Underline::DASHED);
6043 underlineMapSet.Insert("dashWidth", 4);
6044 underlineMapSet.Insert("dashGap", 2);
6046 // Check the dashed underline property
6047 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6049 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6050 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6051 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6053 // Render and notify
6054 application.SendNotification();
6055 application.Render();
6057 underlineMapSet.Clear();
6058 underlineMapGet.Clear();
6060 underlineMapSet.Insert("enable", true);
6061 underlineMapSet.Insert("color", Color::BLUE);
6062 underlineMapSet.Insert("height", 1);
6063 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6064 underlineMapSet.Insert("dashWidth", 4);
6065 underlineMapSet.Insert("dashGap", 2);
6067 // Check the dashed underline property
6068 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6070 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6071 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6072 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6074 // Render and notify
6075 application.SendNotification();
6076 application.Render();
6078 underlineMapSet.Clear();
6079 underlineMapGet.Clear();
6084 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6086 ToolkitTestApplication application;
6087 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6089 TextEditor textEditor1 = TextEditor::New();
6090 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6091 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6092 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6093 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6095 Property::Map underlineMapSet1;
6096 Property::Map underlineMapGet1;
6098 underlineMapSet1.Insert("enable", true);
6099 underlineMapSet1.Insert("color", Color::RED);
6100 underlineMapSet1.Insert("height", 1);
6101 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6102 underlineMapSet1.Insert("dashWidth", 2);
6103 underlineMapSet1.Insert("dashGap", 1);
6105 // Check the underline property
6106 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6108 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6109 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6110 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6112 application.GetScene().Add(textEditor1);
6113 application.SendNotification();
6114 application.Render();
6116 TextEditor textEditor2 = TextEditor::New();
6117 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6118 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6119 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6120 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6122 Property::Map underlineMapSet2;
6123 Property::Map underlineMapGet2;
6125 underlineMapSet2.Insert("enable", true);
6126 underlineMapSet2.Insert("color", Color::BLUE);
6127 underlineMapSet2.Insert("height", 1);
6128 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6129 underlineMapSet2.Insert("dashWidth", 4);
6130 underlineMapSet2.Insert("dashGap", 2);
6132 // Check the dashed underline property
6133 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6135 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6136 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6137 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6139 application.GetScene().Add(textEditor2);
6140 application.SendNotification();
6141 application.Render();
6143 TextEditor textEditor3 = TextEditor::New();
6144 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6145 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6146 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6147 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6149 Property::Map underlineMapSet3;
6150 Property::Map underlineMapGet3;
6152 underlineMapSet3.Insert("enable", true);
6153 underlineMapSet3.Insert("color", Color::BLUE);
6154 underlineMapSet3.Insert("height", 1);
6155 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6156 underlineMapSet3.Insert("dashWidth", 4);
6157 underlineMapSet3.Insert("dashGap", 2);
6159 // Check the dashed underline property
6160 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6162 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6163 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6164 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6166 application.GetScene().Add(textEditor3);
6167 application.SendNotification();
6168 application.Render();
6173 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6175 ToolkitTestApplication application;
6176 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6178 TextEditor textEditor1 = TextEditor::New();
6179 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6180 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6181 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6182 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6184 Property::Map underlineMapSet1;
6185 Property::Map underlineMapGet1;
6187 underlineMapSet1.Insert("enable", true);
6188 underlineMapSet1.Insert("color", Color::RED);
6189 underlineMapSet1.Insert("height", 1);
6190 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6191 underlineMapSet1.Insert("dashWidth", 2);
6192 underlineMapSet1.Insert("dashGap", 1);
6194 // Check the underline property
6195 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6196 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6198 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6199 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6200 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6202 application.GetScene().Add(textEditor1);
6204 application.SendNotification();
6205 application.Render();
6210 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6212 ToolkitTestApplication application;
6213 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6215 TextEditor editor = TextEditor::New();
6216 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6217 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6218 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6219 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6220 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6221 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6223 TextEditor editorSingleLineParagraph = TextEditor::New();
6224 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6225 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6226 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");
6227 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6228 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6229 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6231 TextEditor editorMultiLineParagraph = TextEditor::New();
6232 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6233 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6234 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");
6235 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6236 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6237 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6239 application.GetScene().Add(editor);
6240 application.GetScene().Add(editorSingleLineParagraph);
6241 application.GetScene().Add(editorMultiLineParagraph);
6242 application.SendNotification();
6243 application.Render();
6245 Vector3 naturalSize = editor.GetNaturalSize();
6246 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6247 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6249 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6251 //no effect of relative line size for paragraph with single line
6252 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6254 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6259 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6261 ToolkitTestApplication application;
6262 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6264 TextEditor editor = TextEditor::New();
6265 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6266 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6267 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6269 application.GetScene().Add(editor);
6270 application.SendNotification();
6271 application.Render();
6273 Vector3 naturalSize = editor.GetNaturalSize();
6275 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6277 application.SendNotification();
6278 application.Render();
6280 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6282 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6284 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6286 application.SendNotification();
6287 application.Render();
6289 relativeNaturalSize = editor.GetNaturalSize();
6291 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6295 int UtcDaliTextEditorCharacterSpacing(void)
6297 ToolkitTestApplication application;
6298 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6300 TextEditor textEditor = TextEditor::New();
6302 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6304 application.GetScene().Add(textEditor);
6305 application.SendNotification();
6306 application.Render();
6308 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6309 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6310 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6312 application.SendNotification();
6313 application.Render();
6318 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6320 ToolkitTestApplication application;
6321 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6323 TextEditor editor = TextEditor::New();
6325 float lineSpacing = -20.f;
6327 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6328 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6329 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6330 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6332 application.GetScene().Add(editor);
6333 application.SendNotification();
6334 application.Render();
6336 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6337 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6339 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6340 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6342 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6343 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6345 application.SendNotification();
6346 application.Render();
6351 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6353 ToolkitTestApplication application;
6354 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6356 TextEditor editor = TextEditor::New();
6357 DALI_TEST_CHECK(editor);
6359 application.GetScene().Add(editor);
6361 std::string cutText = "";
6362 std::string copiedText = "";
6364 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6365 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6366 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6367 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6368 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6369 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6370 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6372 // Render and notify
6373 application.SendNotification();
6374 application.Render();
6376 // Tap on the text editor
6377 TestGenerateTap(application, 1.0f, 1.0f);
6379 // Render and notify
6380 application.SendNotification();
6381 application.Render();
6383 // Move to second line of the text.
6384 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6386 // Render and notify
6387 application.SendNotification();
6388 application.Render();
6390 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6395 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6397 ToolkitTestApplication application;
6398 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6400 TextEditor editor = TextEditor::New();
6402 float lineSpacing = -20.f;
6404 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6405 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6406 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6407 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6408 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6410 application.GetScene().Add(editor);
6411 application.SendNotification();
6412 application.Render();
6414 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6416 int lineCount = sizeList.Size();
6417 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6419 application.SendNotification();
6420 application.Render();
6425 int UtcDaliToolkitTexteditorParagraphTag(void)
6427 ToolkitTestApplication application;
6428 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6429 TextEditor editorNewlineSeparator = TextEditor::New();
6430 TextEditor editorParagraphTag = TextEditor::New();
6431 DALI_TEST_CHECK(editorNewlineSeparator);
6432 DALI_TEST_CHECK(editorParagraphTag);
6434 application.GetScene().Add(editorNewlineSeparator);
6435 application.GetScene().Add(editorParagraphTag);
6437 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6438 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6439 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6440 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6441 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6442 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6444 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6445 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6446 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6447 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6448 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6450 application.SendNotification();
6451 application.Render();
6453 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6454 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6456 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6458 application.SendNotification();
6459 application.Render();
6464 //Handle Emoji clustering for cursor handling
6465 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6467 ToolkitTestApplication application;
6468 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6469 TextEditor textEditor = TextEditor::New();
6470 DALI_TEST_CHECK(textEditor);
6472 application.GetScene().Add(textEditor);
6474 // Avoid a crash when core load gl resources.
6475 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6477 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6478 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6480 // Render and notify
6481 application.SendNotification();
6482 application.Render();
6485 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6486 application.SendNotification();
6487 application.Render();
6489 // Set focus and remove Emoji
6490 textEditor.SetKeyInputFocus();
6491 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6493 //Check the changed text and cursor position
6494 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6495 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6497 // Render and notify
6498 application.SendNotification();
6499 application.Render();
6504 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6506 ToolkitTestApplication application;
6507 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6508 TextEditor textEditor = TextEditor::New();
6509 DALI_TEST_CHECK(textEditor);
6511 application.GetScene().Add(textEditor);
6513 // Avoid a crash when core load gl resources.
6514 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6516 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6517 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6519 // Render and notify
6520 application.SendNotification();
6521 application.Render();
6524 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6525 application.SendNotification();
6526 application.Render();
6528 // Set focus and remove Emoji
6529 textEditor.SetKeyInputFocus();
6530 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6532 //Check the changed text and cursor position
6533 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6534 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6536 // Render and notify
6537 application.SendNotification();
6538 application.Render();
6543 int utcDaliTextEditorPanGesturePropagation(void)
6545 ToolkitTestApplication application;
6546 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6548 Actor actor = Actor::New();
6549 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6550 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6551 application.GetScene().Add(actor);
6553 TextEditor editor = TextEditor::New();
6554 DALI_TEST_CHECK(editor);
6556 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6557 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6559 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6560 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6561 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6565 // Render and notify
6566 application.SendNotification();
6567 application.Render();
6570 GestureReceivedFunctor functor(data);
6572 PanGestureDetector detector = PanGestureDetector::New();
6573 detector.Attach(actor);
6574 detector.DetectedSignal().Connect(&application, functor);
6576 // Tap first to get the focus.
6577 TestGenerateTap(application, 3.0f, 25.0f, 100);
6579 // Render and notify
6580 application.SendNotification();
6581 application.Render();
6583 // Pan the text editor
6584 uint32_t time = 100;
6585 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6586 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6587 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6588 application.SendNotification();
6589 application.Render();
6591 // The text scrolls because there is text that is scrolling.
6592 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6595 // Set the size large enough to prevent scrolling.
6596 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6598 // Render and notify
6599 application.SendNotification();
6600 application.Render();
6603 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6604 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6605 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6607 // Because scrolling is not possible, the pan gesture is propagated.
6608 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6614 int utcDaliTextEditorGetTextBoundingRectangle(void)
6616 ToolkitTestApplication application;
6617 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6619 TextEditor editor = TextEditor::New();
6620 DALI_TEST_CHECK(editor);
6622 application.GetScene().Add(editor);
6624 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6625 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6626 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6627 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6628 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6630 // Avoid a crash when core load gl resources.
6631 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6633 // Render and notify
6634 application.SendNotification();
6635 application.Render();
6637 unsigned int startIndex = 0;
6638 unsigned int endIndex = 15;
6640 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6641 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6643 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6648 int utcDaliTextEditorRemoveFrontInset(void)
6650 ToolkitTestApplication application;
6651 tet_infoline(" utcDaliTextEditorRemoveFrontInset");
6652 TextEditor editor = TextEditor::New();
6653 DALI_TEST_CHECK(editor);
6654 application.GetScene().Add(editor);
6655 application.SendNotification();
6656 application.Render();
6657 DevelTextEditor::SetRemoveFrontInset(editor, false);
6658 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveFrontInset(editor));
6661 int utcDaliTextEditorRemoveBackInset(void)
6663 ToolkitTestApplication application;
6664 tet_infoline(" utcDaliTextEditorRemoveBackInset");
6665 TextEditor editor = TextEditor::New();
6666 DALI_TEST_CHECK(editor);
6667 application.GetScene().Add(editor);
6668 application.SendNotification();
6669 application.Render();
6670 DevelTextEditor::SetRemoveBackInset(editor, false);
6671 DALI_TEST_CHECK(!DevelTextEditor::IsRemoveBackInset(editor));