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 Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
121 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
123 const float RENDER_FRAME_INTERVAL = 16.66f;
125 const unsigned int DEFAULT_FONT_SIZE = 1152u;
126 const std::string DEFAULT_FONT_DIR("/resources/fonts");
128 const int KEY_A_CODE = 38;
129 const int KEY_D_CODE = 40;
130 const int KEY_C_CODE = 54;
131 const int KEY_V_CODE = 55;
132 const int KEY_X_CODE = 53;
133 const int KEY_WHITE_SPACE_CODE = 65;
135 const int KEY_SHIFT_MODIFIER = 257;
136 const int KEY_CONTROL_MODIFIER = 258;
138 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
139 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
140 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
142 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
144 static bool gSelectionChangedCallbackCalled;
145 static uint32_t oldSelectionStart;
146 static uint32_t oldSelectionEnd;
147 static bool gSelectionClearedCallbackCalled;
148 static bool gSelectionStartedCallbackCalled;
149 static bool gAnchorClickedCallBackCalled;
150 static bool gAnchorClickedCallBackNotCalled;
151 static bool gTextChangedCallBackCalled;
152 static bool gInputFilteredAcceptedCallbackCalled;
153 static bool gInputFilteredRejectedCallbackCalled;
154 static bool gInputStyleChangedCallbackCalled;
155 static bool gMaxCharactersCallBackCalled;
156 static bool gCursorPositionChangedCallbackCalled;
157 static uint32_t oldCursorPos;
158 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
160 struct CallbackFunctor
162 CallbackFunctor(bool* callbackFlag)
163 : mCallbackFlag(callbackFlag)
169 *mCallbackFlag = true;
174 static void TestSelectionStartedCallback(TextEditor control)
176 tet_infoline(" TestSelectionStartedCallback");
178 gSelectionStartedCallbackCalled = true;
181 static void TestSelectionClearedCallback(TextEditor control)
183 tet_infoline(" TestSelectionClearedCallback");
185 gSelectionClearedCallbackCalled = true;
188 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
190 tet_infoline(" TestSelectionChangedCallback");
192 gSelectionChangedCallbackCalled = true;
193 oldSelectionStart = oldStart;
194 oldSelectionEnd = oldEnd;
197 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
199 tet_infoline(" TestAnchorClickedCallback");
201 gAnchorClickedCallBackNotCalled = false;
203 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
205 gAnchorClickedCallBackCalled = true;
209 static void TestCursorPositionChangedCallback(TextEditor control, unsigned int oldPos)
211 tet_infoline(" TestCursorPositionChangedCallback");
213 gCursorPositionChangedCallbackCalled = true;
214 oldCursorPos = oldPos;
217 static void TestTextChangedCallback(TextEditor control)
219 tet_infoline(" TestTextChangedCallback");
221 gTextChangedCallBackCalled = true;
224 static void TestInputStyleChangedCallback(TextEditor control, TextEditor::InputStyle::Mask mask)
226 tet_infoline(" TestInputStyleChangedCallback");
228 gInputStyleChangedCallbackCalled = true;
229 gInputStyleMask = mask;
232 static void TestMaxLengthReachedCallback(TextEditor control)
234 tet_infoline(" TestMaxLengthReachedCallback");
236 gMaxCharactersCallBackCalled = true;
239 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
241 tet_infoline(" TestInputFilteredCallback");
243 if(type == Toolkit::InputFilter::Property::ACCEPTED)
245 gInputFilteredAcceptedCallbackCalled = true;
247 else if(type == Toolkit::InputFilter::Property::REJECTED)
249 gInputFilteredRejectedCallbackCalled = true;
253 // Generate a KeyEvent to send to Core.
254 Integration::KeyEvent GenerateKey(const std::string& keyName,
255 const std::string& logicalKey,
256 const std::string& keyString,
259 unsigned long timeStamp,
260 const Integration::KeyEvent::State& keyState,
261 const std::string& compose = "",
262 const std::string& deviceName = DEFAULT_DEVICE_NAME,
263 const Device::Class::Type& deviceClass = Device::Class::NONE,
264 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
266 return Integration::KeyEvent(keyName,
279 Dali::Integration::Point GetPointDownInside(Vector2& pos)
281 Dali::Integration::Point point;
282 point.SetState(PointState::DOWN);
283 point.SetScreenPosition(pos);
287 Dali::Integration::Point GetPointUpInside(Vector2& pos)
289 Dali::Integration::Point point;
290 point.SetState(PointState::UP);
291 point.SetScreenPosition(pos);
295 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
297 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
299 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
301 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
303 Property::Value* valueSet = NULL;
304 if(valueGet.first.type == Property::Key::INDEX)
306 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
310 // Get Key is a string so searching Set Map for a string key
311 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
316 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
318 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
321 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
323 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
326 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
328 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
331 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
333 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
336 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
338 Vector2 vector2Get = valueGet.second.Get<Vector2>();
339 Vector2 vector2Set = valueSet->Get<Vector2>();
340 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
343 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
345 Vector4 vector4Get = valueGet.second.Get<Vector4>();
346 Vector4 vector4Set = valueSet->Get<Vector4>();
347 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);
353 if(valueGet.first.type == Property::Key::INDEX)
355 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
359 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
369 class ScrollStateChangeCallback : public Dali::ConnectionTracker
372 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
373 : mStartedCalled(startedCalled),
374 mFinishedCalled(finishedCalled)
378 void Callback(TextEditor editor, TextEditor::Scroll::Type type)
380 if(type == TextEditor::Scroll::STARTED)
382 mStartedCalled = true;
384 else if(type == TextEditor::Scroll::FINISHED)
386 mFinishedCalled = true;
390 bool& mStartedCalled;
391 bool& mFinishedCalled;
394 // Stores data that is populated in the callback and will be read by the test cases
398 : functorCalled(false),
399 voidFunctorCalled(false),
406 functorCalled = false;
407 voidFunctorCalled = false;
409 receivedGesture.Reset();
415 bool voidFunctorCalled;
416 PanGesture receivedGesture;
420 // Functor that sets the data when called
421 struct GestureReceivedFunctor
423 GestureReceivedFunctor(SignalData& data)
428 void operator()(Actor actor, const PanGesture& pan)
430 signalData.functorCalled = true;
431 signalData.receivedGesture = pan;
432 signalData.pannedActor = actor;
437 signalData.voidFunctorCalled = true;
440 SignalData& signalData;
445 int UtcDaliToolkitTextEditorConstructorP(void)
447 ToolkitTestApplication application;
448 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
449 TextEditor textEditor;
450 DALI_TEST_CHECK(!textEditor);
454 int UtcDaliToolkitTextEditorNewP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextEditorNewP");
458 TextEditor textEditor = TextEditor::New();
459 DALI_TEST_CHECK(textEditor);
463 int UtcDaliToolkitTextEditorDownCastP(void)
465 ToolkitTestApplication application;
466 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
467 TextEditor textEditor1 = TextEditor::New();
468 BaseHandle object(textEditor1);
470 TextEditor textEditor2 = TextEditor::DownCast(object);
471 DALI_TEST_CHECK(textEditor2);
473 TextEditor textEditor3 = DownCast<TextEditor>(object);
474 DALI_TEST_CHECK(textEditor3);
478 int UtcDaliToolkitTextEditorDownCastN(void)
480 ToolkitTestApplication application;
481 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
482 BaseHandle uninitializedObject;
483 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
484 DALI_TEST_CHECK(!textEditor1);
486 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
487 DALI_TEST_CHECK(!textEditor2);
491 int UtcDaliToolkitTextEditorCopyConstructorP(void)
493 ToolkitTestApplication application;
494 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
495 TextEditor textEditor = TextEditor::New();
496 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
498 TextEditor copy(textEditor);
499 DALI_TEST_CHECK(copy);
500 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
504 int UtcDaliTextEditorMoveConstructor(void)
506 ToolkitTestApplication application;
508 TextEditor textEditor = TextEditor::New();
509 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
510 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
512 TextEditor moved = std::move(textEditor);
513 DALI_TEST_CHECK(moved);
514 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
515 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
516 DALI_TEST_CHECK(!textEditor);
521 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
523 ToolkitTestApplication application;
524 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
525 TextEditor textEditor = TextEditor::New();
526 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
528 TextEditor copy = textEditor;
529 DALI_TEST_CHECK(copy);
530 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
534 int UtcDaliTextEditorMoveAssignment(void)
536 ToolkitTestApplication application;
538 TextEditor textEditor = TextEditor::New();
539 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
540 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
543 moved = std::move(textEditor);
544 DALI_TEST_CHECK(moved);
545 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
546 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
547 DALI_TEST_CHECK(!textEditor);
552 int UtcDaliTextEditorNewP(void)
554 ToolkitTestApplication application;
555 tet_infoline(" UtcDaliToolkitTextEditorNewP");
556 TextEditor textEditor = TextEditor::New();
557 DALI_TEST_CHECK(textEditor);
561 // Positive test case for a method
562 int UtcDaliTextEditorGetPropertyP(void)
564 ToolkitTestApplication application;
565 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
566 TextEditor editor = TextEditor::New();
567 DALI_TEST_CHECK(editor);
569 // Check Property Indices are correct
570 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
571 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
572 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
574 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
575 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
576 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
577 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
578 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
579 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
580 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
581 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
582 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
583 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
584 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
585 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
586 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
587 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
588 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
589 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
590 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
591 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
592 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
593 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
594 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
595 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
596 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
597 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
598 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
599 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
601 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
602 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
603 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
604 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
605 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
606 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
607 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
608 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
609 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
610 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
611 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
612 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
613 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
614 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
615 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
616 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
617 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
618 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
619 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
620 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
621 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
622 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
623 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
624 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
625 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
626 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
627 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
628 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
629 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
630 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
631 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
632 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
633 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
634 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
635 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
636 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
641 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
644 Property::Map imageMap;
645 imageMap[mapKey] = mapValue;
647 editor.SetProperty(property, imageMap);
648 Property::Value propValue = editor.GetProperty(property);
649 Property::Map* resultMap = propValue.GetMap();
651 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
659 // Positive test case for a method
660 int UtcDaliTextEditorSetPropertyP(void)
662 ToolkitTestApplication application;
663 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
664 TextEditor editor = TextEditor::New();
665 DALI_TEST_CHECK(editor);
666 application.GetScene().Add(editor);
668 // Note - we can't check the defaults since the stylesheets are platform-specific
670 // Check the render backend property.
671 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
672 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
674 // Check text property.
675 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
676 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
678 // Check text's color property
679 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
680 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
682 // Check font properties.
683 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
684 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
686 Property::Map fontStyleMapSet;
687 Property::Map fontStyleMapGet;
688 Property::Value* slantValue = NULL;
690 fontStyleMapSet.Insert("weight", "bold");
691 fontStyleMapSet.Insert("width", "condensed");
692 fontStyleMapSet.Insert("slant", "italic");
694 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
695 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
696 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
697 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
699 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
700 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
702 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
703 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
704 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
706 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
707 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
708 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
711 fontStyleMapSet.Clear();
712 fontStyleMapSet.Insert("weight", "normal");
713 fontStyleMapSet.Insert("slant", "oblique");
714 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
715 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
716 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
717 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
719 fontStyleMapSet.Clear();
720 fontStyleMapSet.Insert("slant", "roman");
721 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
722 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
724 // Replace 'roman' for 'normal'.
725 slantValue = fontStyleMapGet.Find("slant");
726 if(NULL != slantValue)
728 if("normal" == slantValue->Get<std::string>())
730 fontStyleMapGet["slant"] = "roman";
733 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
734 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
736 fontStyleMapSet.Clear();
738 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
739 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
740 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
741 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
743 // Check that the Alignment properties can be correctly set
744 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
745 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
747 // Check that the Alignment properties can be correctly set
748 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
749 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
750 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
751 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
752 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
753 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
755 // Check scroll properties.
756 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
757 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
758 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
759 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
761 // Check cursor properties
762 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
763 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
764 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
765 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
767 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
768 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
769 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
770 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
771 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
772 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
773 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
774 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
776 // Check handle images
777 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
778 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
779 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
780 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
781 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
783 // Check handle images
784 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
785 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
786 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
787 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
788 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
789 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
791 // Check the selection popup style
792 const Vector2 popupMaxSize(200.0f, 300.0f);
793 const Vector2 optionDividerSize(30.0f, 5.0f);
794 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
795 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
797 Property::Map selectionPopupStyle;
798 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
799 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
800 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
801 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
803 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
805 Property::Map selectionPopupStyleGet;
806 selectionPopupStyleGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::SELECTION_POPUP_STYLE);
808 Property::Value* popupValue;
809 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
810 DALI_TEST_CHECK(NULL != popupValue);
813 Vector2 popupMaxSizeGet;
814 popupValue->Get(popupMaxSizeGet);
815 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
818 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
819 DALI_TEST_CHECK(NULL != popupValue);
822 Vector2 optionDividerSizeGet;
823 popupValue->Get(optionDividerSizeGet);
824 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
827 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
828 DALI_TEST_CHECK(NULL != popupValue);
831 Vector4 optionDividerPaddingGet;
832 popupValue->Get(optionDividerPaddingGet);
833 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
836 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
837 DALI_TEST_CHECK(NULL != popupValue);
840 Vector4 labelPaddingGet;
841 popupValue->Get(labelPaddingGet);
842 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
845 // Reset selection popup style
846 selectionPopupStyle.Clear();
847 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
849 // Check the highlight color
850 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
851 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
853 // Decoration bounding box
854 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
855 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
857 // Check the enable markup property.
858 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
859 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
860 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
862 // Check input color property.
863 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
864 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
866 // Check input font properties.
867 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
868 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
870 fontStyleMapSet.Clear();
871 fontStyleMapSet.Insert("weight", "bold");
872 fontStyleMapSet.Insert("width", "condensed");
873 fontStyleMapSet.Insert("slant", "italic");
875 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
876 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
877 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
878 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
880 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
881 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
883 // Reset input font style.
884 fontStyleMapSet.Clear();
885 fontStyleMapSet.Insert("weight", "normal");
886 fontStyleMapSet.Insert("slant", "oblique");
888 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
889 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
890 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
891 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
893 fontStyleMapSet.Clear();
894 fontStyleMapSet.Insert("slant", "roman");
896 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
897 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
899 // Replace 'roman' for 'normal'.
900 slantValue = fontStyleMapGet.Find("slant");
901 if(NULL != slantValue)
903 if("normal" == slantValue->Get<std::string>())
905 fontStyleMapGet["slant"] = "roman";
908 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
909 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
911 fontStyleMapSet.Clear();
913 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
914 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
915 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
916 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
918 // Check the line spacing property
919 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
920 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
921 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
923 // Check the input line spacing property
924 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
925 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
926 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
928 // Check the underline property
930 Property::Map underlineMapSet;
931 Property::Map underlineMapGet;
933 underlineMapSet.Insert("enable", true);
934 underlineMapSet.Insert("color", Color::RED);
935 underlineMapSet.Insert("height", 1);
936 underlineMapSet.Insert("type", Text::Underline::SOLID);
937 underlineMapSet.Insert("dashWidth", 5);
938 underlineMapSet.Insert("dashGap", 3);
940 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
942 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
943 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
944 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
946 application.SendNotification();
947 application.Render();
949 // Check the dashed underline property
951 underlineMapSet.Clear();
952 underlineMapGet.Clear();
954 underlineMapSet.Insert("enable", true);
955 underlineMapSet.Insert("color", Color::RED);
956 underlineMapSet.Insert("height", 1);
957 underlineMapSet.Insert("type", Text::Underline::DASHED);
958 underlineMapSet.Insert("dashWidth", 5);
959 underlineMapSet.Insert("dashGap", 3);
961 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
963 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
964 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
965 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
967 application.SendNotification();
968 application.Render();
970 underlineMapSet.Clear();
971 underlineMapGet.Clear();
973 // Check the double underline property
975 underlineMapSet.Clear();
976 underlineMapGet.Clear();
978 underlineMapSet.Insert("enable", true);
979 underlineMapSet.Insert("color", Color::RED);
980 underlineMapSet.Insert("height", 1);
981 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
982 underlineMapSet.Insert("dashWidth", 5);
983 underlineMapSet.Insert("dashGap", 3);
985 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
987 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
988 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
989 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
991 application.SendNotification();
992 application.Render();
994 underlineMapSet.Clear();
995 underlineMapGet.Clear();
997 // Check the input underline property
998 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
999 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1001 // Check the shadow property
1002 Property::Map shadowMapSet;
1003 Property::Map shadowMapGet;
1005 shadowMapSet.Insert("color", Color::GREEN);
1006 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1007 shadowMapSet.Insert("blurRadius", 3.0f);
1009 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
1011 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
1012 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1013 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1015 // Check the input shadow property
1016 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
1017 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1019 // Check the emboss property
1020 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
1021 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1023 // Check the input emboss property
1024 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
1025 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1027 // Check the outline property
1029 // Test string type first
1030 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1031 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
1032 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1034 // Then test the property map type
1035 Property::Map outlineMapSet;
1036 Property::Map outlineMapGet;
1038 outlineMapSet["color"] = Color::RED;
1039 outlineMapSet["width"] = 2.0f;
1041 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1043 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1044 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1045 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1047 // Check the input outline property
1048 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1049 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1051 // Check the smooth scroll property
1052 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1053 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1054 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1056 // Check the smooth scroll duration property
1057 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1058 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1060 // Check the scroll bar property
1061 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1062 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1063 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1065 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1066 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1067 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1068 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1070 // Check the pixel size of font
1071 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1072 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1074 // Check placeholder text properties.
1075 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1076 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1078 // Check placeholder text's color property.
1079 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1080 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1082 // Check the enable selection property
1083 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1084 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1086 // Check the placeholder property with pixel size
1087 Property::Map placeholderPixelSizeMapSet;
1088 Property::Map placeholderPixelSizeMapGet;
1089 Property::Map placeholderFontstyleMap;
1090 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1091 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1092 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1093 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1094 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1096 placeholderFontstyleMap.Insert("weight", "bold");
1097 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1098 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1100 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1101 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1103 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1104 Property::Map placeholderConversionMap;
1105 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1106 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1107 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1108 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1109 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1110 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1112 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1114 // Check the placeholder property with point size
1115 Property::Map placeholderMapSet;
1116 Property::Map placeholderMapGet;
1117 placeholderMapSet["text"] = "Setting Placeholder Text";
1118 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1119 placeholderMapSet["color"] = Color::RED;
1120 placeholderMapSet["fontFamily"] = "Arial";
1121 placeholderMapSet["pointSize"] = 12.0f;
1122 // Check the placeholder font style property
1123 placeholderFontstyleMap.Clear();
1125 placeholderFontstyleMap.Insert("weight", "bold");
1126 placeholderFontstyleMap.Insert("width", "condensed");
1127 placeholderFontstyleMap.Insert("slant", "italic");
1128 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1129 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1131 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1132 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1134 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1135 placeholderConversionMap.Clear();
1136 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1137 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1138 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1139 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1140 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1141 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1142 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1144 // Reset font style.
1145 placeholderFontstyleMap.Clear();
1146 placeholderFontstyleMap.Insert("weight", "normal");
1147 placeholderFontstyleMap.Insert("slant", "oblique");
1148 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1149 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1151 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1152 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1153 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1154 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1156 placeholderFontstyleMap.Clear();
1157 placeholderFontstyleMap.Insert("slant", "roman");
1158 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1159 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1161 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1163 placeholderFontstyleMap.Clear();
1164 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1166 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1167 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1168 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1169 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1170 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1172 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1173 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1175 // Check handle color
1176 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1177 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1179 // Test the ENABLE_GRAB_HANDLE_POPUP property
1180 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1181 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1183 // Check the input method setting
1184 Property::Map propertyMap;
1185 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1186 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1187 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1188 int inputVariation = 1;
1189 propertyMap["PANEL_LAYOUT"] = panelLayout;
1190 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1191 propertyMap["BUTTON_ACTION"] = buttonAction;
1192 propertyMap["VARIATION"] = inputVariation;
1193 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1195 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1197 DALI_TEST_CHECK(value.Get(map));
1200 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1201 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1204 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1205 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1208 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1209 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1212 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1213 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1215 // Check the input filter property
1216 Property::Map inputFilterMapSet;
1217 Property::Map inputFilterMapGet;
1218 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1219 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1221 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1223 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1224 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1227 inputFilterMapSet.Clear();
1228 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1230 // Check the strikethrough property
1232 Property::Map strikethroughMapSet;
1233 Property::Map strikethroughMapGet;
1235 application.SendNotification();
1236 application.Render();
1238 // Check the input strikethrough property
1240 strikethroughMapSet.Clear();
1241 strikethroughMapGet.Clear();
1242 strikethroughMapSet.Insert("enable", true);
1243 strikethroughMapSet.Insert("color", Color::BLUE);
1244 strikethroughMapSet.Insert("height", 2.0f);
1246 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1248 application.SendNotification();
1249 application.Render();
1251 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1253 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1254 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1256 // Check the input strikethrough property
1257 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1258 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1260 application.SendNotification();
1261 application.Render();
1263 // Check the line size property
1264 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1265 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1266 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1271 // Positive Atlas Text Renderer test
1272 int utcDaliTextEditorAtlasRenderP(void)
1274 ToolkitTestApplication application;
1275 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1276 StyleManager styleManager = StyleManager::Get();
1277 styleManager.ApplyDefaultTheme();
1278 TextEditor editor = TextEditor::New();
1279 DALI_TEST_CHECK(editor);
1281 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1283 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1285 application.GetScene().Add(editor);
1289 // Render some text with the shared atlas backend
1290 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1291 application.SendNotification();
1292 application.Render();
1296 tet_result(TET_FAIL);
1301 // Positive test for the anchorClicked signal.
1302 int utcDaliTextEditorAnchorClickedP(void)
1304 ToolkitTestApplication application;
1305 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1306 TextEditor editor = TextEditor::New();
1307 DALI_TEST_CHECK(editor);
1309 application.GetScene().Add(editor);
1311 // connect to the anchor clicked signal.
1312 ConnectionTracker* testTracker = new ConnectionTracker();
1313 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1314 bool anchorClickedSignal = false;
1315 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1317 gAnchorClickedCallBackCalled = false;
1318 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1319 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1320 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1321 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1322 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1324 application.SendNotification();
1325 application.Render();
1326 editor.SetKeyInputFocus();
1328 // Create a tap event to touch the text editor.
1329 TestGenerateTap(application, 5.0f, 5.0f);
1330 application.SendNotification();
1331 application.Render();
1333 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1334 DALI_TEST_CHECK(anchorClickedSignal);
1336 gAnchorClickedCallBackNotCalled = true;
1337 // Tap the outside of anchor, callback should not be called.
1338 TestGenerateTap(application, 150.f, 100.f);
1339 application.SendNotification();
1340 application.Render();
1342 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1347 // Positive test for the textChanged signal.
1348 int utcDaliTextEditorTextChangedP(void)
1350 ToolkitTestApplication application;
1351 tet_infoline(" utcDaliTextEditorTextChangedP");
1352 TextEditor editor = TextEditor::New();
1353 DALI_TEST_CHECK(editor);
1355 application.GetScene().Add(editor);
1357 // connect to the text changed signal.
1358 ConnectionTracker* testTracker = new ConnectionTracker();
1359 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1360 bool textChangedSignal = false;
1361 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1363 gTextChangedCallBackCalled = false;
1364 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1365 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1366 DALI_TEST_CHECK(textChangedSignal);
1368 application.SendNotification();
1369 editor.SetKeyInputFocus();
1371 gTextChangedCallBackCalled = false;
1372 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1373 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1376 editor.SetProperty(TextField::Property::TEXT, "");
1378 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1379 gTextChangedCallBackCalled = false;
1380 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1381 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1383 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1384 gTextChangedCallBackCalled = false;
1385 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1386 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1391 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1393 ToolkitTestApplication application;
1394 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1395 TextEditor editor = TextEditor::New();
1396 DALI_TEST_CHECK(editor);
1398 application.GetScene().Add(editor);
1400 // connect to the text changed signal.
1401 ConnectionTracker* testTracker = new ConnectionTracker();
1402 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1403 bool textChangedSignal = false;
1404 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1406 // get InputMethodContext
1408 InputMethodContext::EventData imfEvent;
1409 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1411 editor.SetKeyInputFocus();
1412 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1415 gTextChangedCallBackCalled = false;
1416 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1417 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1418 application.SendNotification();
1419 application.Render();
1420 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1421 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1423 gTextChangedCallBackCalled = false;
1424 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1425 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1426 application.SendNotification();
1427 application.Render();
1428 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1429 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1431 gTextChangedCallBackCalled = false;
1432 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1433 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1434 application.SendNotification();
1435 application.Render();
1436 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1437 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1439 gTextChangedCallBackCalled = false;
1440 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1441 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1442 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1444 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1445 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1446 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1448 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1449 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1450 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1452 application.SendNotification();
1453 application.Render();
1454 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1455 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1460 int utcDaliTextEditorInputStyleChanged01(void)
1462 // The text-editor emits signals when the input style changes. These changes of style are
1463 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1464 // can't be emitted during the size negotiation as the callbacks may update the UI.
1465 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1466 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1467 ToolkitTestApplication application;
1468 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1472 char* pathNamePtr = get_current_dir_name();
1473 const std::string pathName(pathNamePtr);
1476 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1477 fontClient.SetDpi(93u, 93u);
1479 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1480 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1482 TextEditor editor = TextEditor::New();
1483 DALI_TEST_CHECK(editor);
1485 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1486 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1487 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1489 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1490 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1492 // connect to the text changed signal.
1493 ConnectionTracker* testTracker = new ConnectionTracker();
1494 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1495 bool inputStyleChangedSignal = false;
1496 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1498 application.GetScene().Add(editor);
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Executes the idle callbacks added by the text control on the change of input style.
1505 application.RunIdles();
1507 gInputStyleChangedCallbackCalled = false;
1508 gInputStyleMask = TextEditor::InputStyle::NONE;
1509 inputStyleChangedSignal = false;
1511 // Create a tap event to touch the text editor.
1512 TestGenerateTap(application, 18.0f, 25.0f);
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Executes the idle callbacks added by the text control on the change of input style.
1519 application.RunIdles();
1521 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1522 if(gInputStyleChangedCallbackCalled)
1524 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1526 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1527 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1529 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1530 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1532 DALI_TEST_CHECK(inputStyleChangedSignal);
1534 gInputStyleChangedCallbackCalled = false;
1535 gInputStyleMask = TextEditor::InputStyle::NONE;
1536 inputStyleChangedSignal = false;
1538 // Create a tap event to touch the text editor.
1539 TestGenerateTap(application, 30.0f, 25.0f);
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Executes the idle callbacks added by the text control on the change of input style.
1546 application.RunIdles();
1548 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
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, 43.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 if(gInputStyleChangedCallbackCalled)
1568 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1570 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1571 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1573 DALI_TEST_CHECK(inputStyleChangedSignal);
1575 gInputStyleChangedCallbackCalled = false;
1576 gInputStyleMask = TextEditor::InputStyle::NONE;
1577 inputStyleChangedSignal = false;
1579 // Create a tap event to touch the text editor.
1580 TestGenerateTap(application, 88.0f, 25.0f);
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Executes the idle callbacks added by the text control on the change of input style.
1587 application.RunIdles();
1589 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1590 if(gInputStyleChangedCallbackCalled)
1592 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1594 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1595 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1597 Property::Map fontStyleMapSet;
1598 Property::Map fontStyleMapGet;
1600 fontStyleMapSet.Insert("weight", "bold");
1602 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1603 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1604 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1606 DALI_TEST_CHECK(inputStyleChangedSignal);
1608 gInputStyleChangedCallbackCalled = false;
1609 gInputStyleMask = TextEditor::InputStyle::NONE;
1610 inputStyleChangedSignal = false;
1612 // Create a tap event to touch the text editor.
1613 TestGenerateTap(application, 115.0f, 25.0f);
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Executes the idle callbacks added by the text control on the change of input style.
1620 application.RunIdles();
1622 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
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, 164.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 if(gInputStyleChangedCallbackCalled)
1642 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1644 Property::Map fontStyleMapSet;
1645 Property::Map fontStyleMapGet;
1647 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1648 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1649 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1651 DALI_TEST_CHECK(inputStyleChangedSignal);
1653 gInputStyleChangedCallbackCalled = false;
1654 gInputStyleMask = TextEditor::InputStyle::NONE;
1655 inputStyleChangedSignal = false;
1657 // Create a tap event to touch the text editor.
1658 TestGenerateTap(application, 191.0f, 25.0f);
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1664 // Executes the idle callbacks added by the text control on the change of input style.
1665 application.RunIdles();
1667 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1668 DALI_TEST_CHECK(!inputStyleChangedSignal);
1673 int utcDaliTextEditorInputStyleChanged02(void)
1675 // The text-editor emits signals when the input style changes. These changes of style are
1676 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1677 // can't be emitted during the size negotiation as the callbacks may update the UI.
1678 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1679 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1680 ToolkitTestApplication application;
1681 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1685 char* pathNamePtr = get_current_dir_name();
1686 const std::string pathName(pathNamePtr);
1689 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1690 fontClient.SetDpi(93u, 93u);
1692 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1693 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1695 TextEditor editor = TextEditor::New();
1696 DALI_TEST_CHECK(editor);
1698 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1699 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1700 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1702 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1703 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>");
1705 // connect to the text changed signal.
1706 ConnectionTracker* testTracker = new ConnectionTracker();
1707 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1708 bool inputStyleChangedSignal = false;
1709 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1711 application.GetScene().Add(editor);
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1717 // Executes the idle callbacks added by the text control on the change of input style.
1718 application.RunIdles();
1720 gInputStyleChangedCallbackCalled = false;
1721 gInputStyleMask = TextEditor::InputStyle::NONE;
1722 inputStyleChangedSignal = false;
1724 // Create a tap event to touch the text editor.
1725 TestGenerateTap(application, 53.0f, 25.0f, 100);
1726 TestGenerateTap(application, 53.0f, 25.0f, 200);
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Executes the idle callbacks added by the text control on the change of input style.
1733 application.RunIdles();
1735 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1736 if(gInputStyleChangedCallbackCalled)
1738 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1739 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1740 TextEditor::InputStyle::POINT_SIZE |
1741 TextEditor::InputStyle::COLOR),
1744 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1745 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1747 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1748 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1750 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1751 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1753 DALI_TEST_CHECK(inputStyleChangedSignal);
1755 gInputStyleChangedCallbackCalled = false;
1756 gInputStyleMask = TextEditor::InputStyle::NONE;
1757 inputStyleChangedSignal = false;
1759 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // Executes the idle callbacks added by the text control on the change of input style.
1766 application.RunIdles();
1768 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1769 if(gInputStyleChangedCallbackCalled)
1771 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1772 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1775 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1776 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1778 DALI_TEST_CHECK(inputStyleChangedSignal);
1780 gInputStyleChangedCallbackCalled = false;
1781 gInputStyleMask = TextEditor::InputStyle::NONE;
1782 inputStyleChangedSignal = false;
1784 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 // Executes the idle callbacks added by the text control on the change of input style.
1791 application.RunIdles();
1793 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1794 DALI_TEST_CHECK(!inputStyleChangedSignal);
1796 gInputStyleChangedCallbackCalled = false;
1797 gInputStyleMask = TextEditor::InputStyle::NONE;
1798 inputStyleChangedSignal = false;
1800 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 // Executes the idle callbacks added by the text control on the change of input style.
1807 application.RunIdles();
1809 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1810 if(gInputStyleChangedCallbackCalled)
1812 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1813 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1816 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1817 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1819 DALI_TEST_CHECK(inputStyleChangedSignal);
1821 gInputStyleChangedCallbackCalled = false;
1822 gInputStyleMask = TextEditor::InputStyle::NONE;
1823 inputStyleChangedSignal = false;
1825 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1827 Property::Map fontStyleMapSet;
1828 fontStyleMapSet.Insert("weight", "thin");
1829 fontStyleMapSet.Insert("width", "condensed");
1830 fontStyleMapSet.Insert("slant", "italic");
1832 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1833 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1834 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1836 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1837 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1838 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1839 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1840 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1842 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 // Executes the idle callbacks added by the text control on the change of input style.
1849 application.RunIdles();
1851 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1852 DALI_TEST_CHECK(!inputStyleChangedSignal);
1854 // Create a tap event to touch the text editor.
1855 TestGenerateTap(application, 63.0f, 25.0f, 900);
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 // Executes the idle callbacks added by the text control on the change of input style.
1862 application.RunIdles();
1864 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1865 if(gInputStyleChangedCallbackCalled)
1867 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1868 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1869 TextEditor::InputStyle::POINT_SIZE |
1870 TextEditor::InputStyle::FONT_STYLE |
1871 TextEditor::InputStyle::LINE_SPACING |
1872 TextEditor::InputStyle::UNDERLINE |
1873 TextEditor::InputStyle::SHADOW |
1874 TextEditor::InputStyle::EMBOSS |
1875 TextEditor::InputStyle::OUTLINE),
1878 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1879 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1881 DALI_TEST_CHECK(inputStyleChangedSignal);
1883 gInputStyleChangedCallbackCalled = false;
1884 gInputStyleMask = TextEditor::InputStyle::NONE;
1885 inputStyleChangedSignal = false;
1887 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1889 fontStyleMapSet.Clear();
1890 fontStyleMapSet.Insert("weight", "black");
1891 fontStyleMapSet.Insert("width", "expanded");
1892 fontStyleMapSet.Insert("slant", "oblique");
1894 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1896 // Create a tap event to touch the text editor.
1897 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 // Executes the idle callbacks added by the text control on the change of input style.
1904 application.RunIdles();
1906 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1907 if(gInputStyleChangedCallbackCalled)
1909 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1910 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1911 TextEditor::InputStyle::POINT_SIZE |
1912 TextEditor::InputStyle::FONT_STYLE),
1915 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1916 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1918 DALI_TEST_CHECK(inputStyleChangedSignal);
1923 int utcDaliTextEditorInputStyleChanged03(void)
1925 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1926 ToolkitTestApplication application;
1927 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1931 char* pathNamePtr = get_current_dir_name();
1932 const std::string pathName(pathNamePtr);
1935 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1936 fontClient.SetDpi(93u, 93u);
1938 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1939 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1941 TextEditor editor = TextEditor::New();
1942 DALI_TEST_CHECK(editor);
1944 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1945 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1946 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1948 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1949 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1951 // connect to the text changed signal.
1952 ConnectionTracker* testTracker = new ConnectionTracker();
1953 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1954 bool inputStyleChangedSignal = false;
1955 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1957 application.GetScene().Add(editor);
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 // Executes the idle callbacks added by the text control on the change of input style.
1964 application.RunIdles();
1966 gInputStyleChangedCallbackCalled = false;
1967 gInputStyleMask = TextEditor::InputStyle::NONE;
1968 inputStyleChangedSignal = false;
1970 // Create a tap event to touch the text editor.
1971 TestGenerateTap(application, 18.0f, 25.0f);
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 // Executes the idle callbacks added by the text control on the change of input style.
1978 application.RunIdles();
1980 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1981 if(gInputStyleChangedCallbackCalled)
1983 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1985 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1986 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1988 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1989 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1991 DALI_TEST_CHECK(inputStyleChangedSignal);
1993 gInputStyleChangedCallbackCalled = false;
1994 gInputStyleMask = TextEditor::InputStyle::NONE;
1995 inputStyleChangedSignal = false;
1997 // Create a tap event to touch the text editor.
1998 TestGenerateTap(application, 30.0f, 25.0f);
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 // Executes the idle callbacks added by the text control on the change of input style.
2005 application.RunIdles();
2007 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
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, 43.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 if(gInputStyleChangedCallbackCalled)
2027 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2029 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2030 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2032 DALI_TEST_CHECK(inputStyleChangedSignal);
2034 gInputStyleChangedCallbackCalled = false;
2035 gInputStyleMask = TextEditor::InputStyle::NONE;
2036 inputStyleChangedSignal = false;
2038 // Make AddIdle return false.
2039 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2041 // Create a tap event to touch the text editor.
2042 TestGenerateTap(application, 88.0f, 25.0f);
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 // Execute the idle callbacks.
2049 // And check whether we didn't change of input style.
2050 application.RunIdles();
2052 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2053 DALI_TEST_CHECK(!inputStyleChangedSignal);
2055 gInputStyleChangedCallbackCalled = false;
2056 gInputStyleMask = TextEditor::InputStyle::NONE;
2057 inputStyleChangedSignal = false;
2059 // Create a tap event to touch the text editor.
2060 TestGenerateTap(application, 115.0f, 25.0f);
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 // Execute the idle callbacks.
2067 // And check whether we didn't change of input style.
2068 application.RunIdles();
2070 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2071 DALI_TEST_CHECK(!inputStyleChangedSignal);
2073 gInputStyleChangedCallbackCalled = false;
2074 gInputStyleMask = TextEditor::InputStyle::NONE;
2075 inputStyleChangedSignal = false;
2077 // Revert AddIdle return true.
2078 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2080 // Create a tap event to touch the text editor.
2081 TestGenerateTap(application, 164.0f, 25.0f);
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 // Executes the idle callbacks added by the text control on the change of input style.
2088 application.RunIdles();
2090 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2091 if(gInputStyleChangedCallbackCalled)
2093 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2095 Property::Map fontStyleMapSet;
2096 Property::Map fontStyleMapGet;
2098 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2099 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2100 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2102 DALI_TEST_CHECK(inputStyleChangedSignal);
2104 gInputStyleChangedCallbackCalled = false;
2105 gInputStyleMask = TextEditor::InputStyle::NONE;
2106 inputStyleChangedSignal = false;
2108 // Create a tap event to touch the text editor.
2109 TestGenerateTap(application, 191.0f, 25.0f);
2111 // Render and notify
2112 application.SendNotification();
2113 application.Render();
2115 // Executes the idle callbacks added by the text control on the change of input style.
2116 application.RunIdles();
2118 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2119 DALI_TEST_CHECK(!inputStyleChangedSignal);
2124 int utcDaliTextEditorEvent01(void)
2126 ToolkitTestApplication application;
2127 tet_infoline(" utcDaliTextEditorEvent01");
2129 // Creates a tap event. After creating a tap event the text editor should
2130 // have the focus and add text with key events should be possible.
2132 TextEditor editor = TextEditor::New();
2133 DALI_TEST_CHECK(editor);
2135 application.GetScene().Add(editor);
2137 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2138 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2139 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2141 // Avoid a crash when core load gl resources.
2142 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 // Add a key event but as the text editor has not the focus it should do nothing.
2149 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2157 // Create a tap event to touch the text editor.
2158 TestGenerateTap(application, 150.0f, 25.0f);
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Now the text editor has the focus, so it can handle the key events.
2165 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
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("aa"), TEST_LOCATION);
2174 // Create a second text editor and send key events to it.
2175 TextEditor editor2 = TextEditor::New();
2177 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2178 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2179 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2180 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2182 application.GetScene().Add(editor2);
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2188 // Create a tap event on the second text editor.
2189 TestGenerateTap(application, 150.0f, 125.0f);
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 // The second text editor has the focus. It should handle the key events.
2196 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2197 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Check the text has been added to the second text editor.
2204 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2209 int utcDaliTextEditorEvent02(void)
2211 ToolkitTestApplication application;
2212 tet_infoline(" utcDaliTextEditorEvent02");
2214 // Checks if the right number of actors are created.
2216 TextEditor editor = TextEditor::New();
2217 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2218 DALI_TEST_CHECK(editor);
2220 application.GetScene().Add(editor);
2222 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2223 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2224 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2226 // Avoid a crash when core load gl resources.
2227 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2233 // Check there are the expected number of children (the stencil).
2234 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2236 Actor stencil = editor.GetChildAt(0u);
2238 // Create a tap event to touch the text editor.
2239 TestGenerateTap(application, 150.0f, 25.0f, 100);
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2245 Actor layer = editor.GetChildAt(2u);
2246 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2247 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2249 // Now the text editor has the focus, so it can handle the key events.
2250 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2251 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2253 // Render and notify
2254 application.SendNotification();
2255 application.Render();
2257 // Checks the cursor and the renderer have been created.
2258 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2259 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2261 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2262 DALI_TEST_CHECK(cursor);
2264 // The stencil actor has a container with all the actors which contain the text renderers.
2265 Actor container = stencil.GetChildAt(0u);
2266 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2268 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2269 DALI_TEST_CHECK(renderer);
2272 // Move the cursor and check the position changes.
2273 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2275 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2284 DALI_TEST_CHECK(position2.x < position1.x);
2286 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2287 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2295 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2297 // Send some taps and check the cursor positions.
2299 // Try to tap at the beginning.
2300 TestGenerateTap(application, 1.0f, 25.0f, 700);
2302 // Render and notify
2303 application.SendNotification();
2304 application.Render();
2306 // Cursor position should be the same than position1.
2307 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2309 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2311 // Tap away from the start position.
2312 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2320 DALI_TEST_CHECK(position5.x > position4.x);
2322 // Remove all the text.
2323 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2324 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2325 editor.SetProperty(TextEditor::Property::TEXT, "");
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Cursor position should be the same than position2.
2332 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2334 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2336 // Should not be a renderer, there is only a clipped cursor.
2337 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2342 int utcDaliTextEditorEvent03(void)
2344 ToolkitTestApplication application;
2345 tet_infoline(" utcDaliTextEditorEvent03");
2347 // Checks if the highlight actor is created.
2349 TextEditor editor = TextEditor::New();
2350 DALI_TEST_CHECK(editor);
2352 application.GetScene().Add(editor);
2354 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2355 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2356 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2357 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2358 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2360 // Avoid a crash when core load gl resources.
2361 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 // Send some taps and check text controller with clipboard window
2368 Dali::Clipboard clipboard = Clipboard::Get();
2369 clipboard.ShowClipboard();
2370 TestGenerateTap(application, 3.0f, 25.0f, 100);
2371 clipboard.HideClipboard();
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 // Tap first to get the focus.
2378 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // Double tap to select a word.
2385 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // The stencil actor should have two actors: the renderer and the highlight actor.
2392 Actor stencil = editor.GetChildAt(0u);
2394 // Highlight needs to be drawn before text, so should come first in child order
2395 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2396 DALI_TEST_CHECK(highlight);
2398 // The stencil actor has a container with all the actors which contain the text renderers.
2399 Actor container = stencil.GetChildAt(1u);
2400 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2402 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2403 DALI_TEST_CHECK(renderer);
2406 // Double tap out of bounds
2407 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2408 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2410 // Render and notify
2411 application.SendNotification();
2412 application.Render();
2414 // The stencil actor should have one actors: the renderer actor.
2415 stencil = editor.GetChildAt(0u);
2417 // The stencil actor has a container with all the actors which contain the text renderers.
2418 container = stencil.GetChildAt(0u);
2419 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2421 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2422 DALI_TEST_CHECK(renderer);
2426 TestGenerateLongPress(application, 1.0f, 25.0f);
2428 // Render and notify
2429 application.SendNotification();
2430 application.Render();
2433 TestGenerateMiniPan(application);
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2442 int utcDaliTextEditorEvent04(void)
2444 ToolkitTestApplication application;
2445 tet_infoline(" utcDaliTextEditorEvent04");
2447 // Checks if the highlight actor is created.
2449 TextEditor editor = TextEditor::New();
2450 DALI_TEST_CHECK(editor);
2452 application.GetScene().Add(editor);
2454 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2455 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2456 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2457 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2458 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2460 // Avoid a crash when core load gl resources.
2461 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // Tap on the text editor
2468 TestGenerateTap(application, 3.0f, 25.0f);
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // Move at the end of the text.
2475 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2476 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 for(unsigned int index = 0u; index < 10u; ++index)
2484 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2485 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2493 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2495 // Render and notify
2496 application.SendNotification();
2497 application.Render();
2499 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2501 // Add some key events
2502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 for(unsigned int index = 0u; index < 10u; ++index)
2511 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2512 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2514 // Render and notify
2515 application.SendNotification();
2516 application.Render();
2520 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 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 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2531 int utcDaliTextEditorEvent05(void)
2533 ToolkitTestApplication application;
2534 tet_infoline(" utcDaliTextEditorEvent05");
2536 // Checks if the highlight actor is created.
2538 TextEditor editor = TextEditor::New();
2539 DALI_TEST_CHECK(editor);
2541 application.GetScene().Add(editor);
2543 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2544 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2545 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2546 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2547 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2548 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2549 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2550 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2551 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2552 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2554 // Avoid a crash when core load gl resources.
2555 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 // Tap on the text editor
2562 TestGenerateTap(application, 3.0f, 25.0f);
2564 // Render and notify
2565 application.SendNotification();
2566 application.Render();
2568 // Move at the end of the text.
2569 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2570 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2572 // Render and notify
2573 application.SendNotification();
2574 application.Render();
2576 for(unsigned int index = 0u; index < 10u; ++index)
2579 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Modify duration after scroll is enabled
2586 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2588 // Continuous scroll left to increase coverage
2589 for(unsigned int index = 0u; index < 10u; ++index)
2591 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2593 // Render and notify
2594 application.SendNotification();
2595 application.Render();
2597 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2598 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2599 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2600 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2601 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2603 // Press Escape to increase coverage
2604 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2605 application.SendNotification();
2606 application.Render();
2608 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2613 int utcDaliTextEditorEvent06(void)
2615 ToolkitTestApplication application;
2616 tet_infoline(" utcDaliTextEditorEvent06");
2618 // Checks if the highlight actor is created.
2620 TextEditor editor = TextEditor::New();
2621 DALI_TEST_CHECK(editor);
2623 application.GetScene().Add(editor);
2625 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2626 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2627 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2628 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2629 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2631 // Avoid a crash when core load gl resources.
2632 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2638 // Tap on the text editor
2639 TestGenerateTap(application, 3.0f, 25.0f);
2641 // Render and notify
2642 application.SendNotification();
2643 application.Render();
2645 // Move to seconds line of the text.
2646 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2648 // Render and notify
2649 application.SendNotification();
2650 application.Render();
2652 float layoutHeight = editor.GetHeightForWidth(100.f);
2654 // Add another script characters ( glyph height is defferent )
2655 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2656 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2658 // Delete characters
2659 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2660 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2662 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2664 // Render and notify
2665 application.SendNotification();
2666 application.Render();
2668 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2671 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2672 application.SendNotification();
2673 application.Render();
2675 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2676 application.SendNotification();
2677 application.Render();
2679 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2680 application.SendNotification();
2681 application.Render();
2683 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2684 application.SendNotification();
2685 application.Render();
2687 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2688 application.SendNotification();
2689 application.Render();
2691 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2692 application.SendNotification();
2693 application.Render();
2695 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2696 application.SendNotification();
2697 application.Render();
2702 int utcDaliTextEditorEvent07(void)
2704 ToolkitTestApplication application;
2705 tet_infoline(" utcDaliTextEditorEvent07");
2707 // Checks if the highlight actor is created.
2709 TextEditor editor = TextEditor::New();
2710 DALI_TEST_CHECK(editor);
2712 application.GetScene().Add(editor);
2714 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2715 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2716 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2717 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2718 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2720 // Avoid a crash when core load gl resources.
2721 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2723 // Render and notify
2724 application.SendNotification();
2725 application.Render();
2727 // Tap on the text editor
2728 TestGenerateTap(application, 3.0f, 25.0f);
2730 // Render and notify
2731 application.SendNotification();
2732 application.Render();
2734 // Move to second line of the text.
2735 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2737 // Render and notify
2738 application.SendNotification();
2739 application.Render();
2741 // Select some text in the right of the current cursor position
2742 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2743 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2744 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2745 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2747 // Render and notify
2748 application.SendNotification();
2749 application.Render();
2751 // Cut the selected text
2752 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2753 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));
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2761 // Select some text in the left of the current cursor position
2762 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2763 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2764 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2765 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2767 // Render and notify
2768 application.SendNotification();
2769 application.Render();
2771 // Copy the selected text
2772 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2773 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));
2775 // Render and notify
2776 application.SendNotification();
2777 application.Render();
2779 // Move the cursor to the third line
2780 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2783 // Render and notify
2784 application.SendNotification();
2785 application.Render();
2787 // Paste the selected text at the current cursor position
2788 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2789 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));
2791 // Render and notify
2792 application.SendNotification();
2793 application.Render();
2795 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2797 // Disable Shift Selection
2798 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2800 // Test to select some text in the right of the current cursor position
2801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2803 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2804 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2806 // Render and notify
2807 application.SendNotification();
2808 application.Render();
2810 // Cut the selected text
2811 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2812 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));
2814 // Render and notify
2815 application.SendNotification();
2816 application.Render();
2818 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2819 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2821 // Test to select some text in the left of the current cursor position
2822 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2823 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2824 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2825 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2827 // Render and notify
2828 application.SendNotification();
2829 application.Render();
2831 // Copy the selected text
2832 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2833 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));
2835 // Render and notify
2836 application.SendNotification();
2837 application.Render();
2839 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2840 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2843 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));
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2849 // replace text with "c"
2850 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2852 // Render and notify
2853 application.SendNotification();
2854 application.Render();
2857 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2860 DevelTextEditor::SelectWholeText(editor);
2862 // Render and notify
2863 application.SendNotification();
2864 application.Render();
2866 // Copy the selected text using logical keys
2867 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2868 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2870 // Render and notify
2871 application.SendNotification();
2872 application.Render();
2875 DevelTextEditor::SelectNone(editor);
2877 // Render and notify
2878 application.SendNotification();
2879 application.Render();
2881 // Paste the selected using logical keys
2882 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2883 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2886 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2888 // select all using logical keys
2889 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2890 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2892 // Render and notify
2893 application.SendNotification();
2894 application.Render();
2896 // cut text using logical keys
2897 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2898 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2900 // Render and notify
2901 application.SendNotification();
2902 application.Render();
2905 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2910 int utcDaliTextEditorEvent08(void)
2912 ToolkitTestApplication application;
2913 tet_infoline(" utcDaliTextEditorEvent08");
2915 // Checks if the highlight actor is released correctly.
2917 TextEditor editor = TextEditor::New();
2918 DALI_TEST_CHECK(editor);
2920 application.GetScene().Add(editor);
2922 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2923 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2924 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2925 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2926 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2928 // Avoid a crash when core load gl resources.
2929 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2931 // Render and notify
2932 application.SendNotification();
2933 application.Render();
2935 // Tap on the text editor
2936 TestGenerateTap(application, 3.0f, 25.0f);
2938 // Render and notify
2939 application.SendNotification();
2940 application.Render();
2942 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2943 // Test to select some text in the left of the current cursor position
2944 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2945 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2946 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2947 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 // Test to the left selection handle position and the right selection handle position
2954 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2955 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2956 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2957 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2959 // Render and notify
2960 application.SendNotification();
2961 application.Render();
2963 // Test to select full text in the left of the current cursor position
2964 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2965 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2966 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2967 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2968 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2969 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2971 // Render and notify
2972 application.SendNotification();
2973 application.Render();
2975 // Test to release the current full text selection
2976 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2977 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2979 // Render and notify
2980 application.SendNotification();
2981 application.Render();
2983 // Test to move the current cursor position correctly
2984 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2986 // Render and notify
2987 application.SendNotification();
2988 application.Render();
2991 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2993 // Render and notify
2994 application.SendNotification();
2995 application.Render();
2997 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2999 // Test to select some text in the right of the current cursor position
3000 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3001 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3002 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3004 // Render and notify
3005 application.SendNotification();
3006 application.Render();
3008 // Test the cursor position with right arrow key
3009 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3011 // Render and notify
3012 application.SendNotification();
3013 application.Render();
3016 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3018 // Render and notify
3019 application.SendNotification();
3020 application.Render();
3022 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3024 // Test to select some text in the left of the current cursor position
3025 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3026 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3027 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3028 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3029 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3031 // Render and notify
3032 application.SendNotification();
3033 application.Render();
3035 // Test the cursor position with left arrow key
3036 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3038 // Render and notify
3039 application.SendNotification();
3040 application.Render();
3043 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 // Render and notify
3046 application.SendNotification();
3047 application.Render();
3049 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3051 // Test to select some text in the right of the current cursor position
3052 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3053 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3054 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3055 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3057 // Render and notify
3058 application.SendNotification();
3059 application.Render();
3061 // Test the cursor position with left arrow key
3062 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3064 // Render and notify
3065 application.SendNotification();
3066 application.Render();
3069 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3071 // Render and notify
3072 application.SendNotification();
3073 application.Render();
3075 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3077 // Test to select some text in the left of the current cursor position
3078 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3079 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3080 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3081 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3083 // Render and notify
3084 application.SendNotification();
3085 application.Render();
3087 // Test the cursor position with right arrow key
3088 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3090 // Render and notify
3091 application.SendNotification();
3092 application.Render();
3095 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3097 // Render and notify
3098 application.SendNotification();
3099 application.Render();
3101 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3106 int utcDaliTextEditorHandles(void)
3108 ToolkitTestApplication application;
3109 tet_infoline(" utcDaliTextEditorHandles");
3111 TextEditor editor = TextEditor::New();
3112 DALI_TEST_CHECK(editor);
3114 application.GetScene().Add(editor);
3116 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3117 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3118 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3119 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3121 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3122 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3123 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3124 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3126 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3127 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3128 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3130 // Avoid a crash when core load gl resources.
3131 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3133 // Render and notify
3134 application.SendNotification();
3135 application.Render();
3137 // Tap first to get the focus.
3138 TestGenerateTap(application, 3.0f, 25.0f, 100);
3140 // Render and notify
3141 application.SendNotification();
3142 application.Render();
3144 // Tap to create the grab handle.
3145 TestGenerateTap(application, 3.0f, 25.0f, 700);
3147 // Render and notify
3148 application.SendNotification();
3149 application.Render();
3151 // Get the active layer where the text's decoration is added.
3152 Actor activeLayer = editor.GetChildAt(1u);
3154 // Get the handle's actor.
3155 Actor handle = activeLayer.GetChildAt(0u);
3156 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3158 // Render and notify
3159 application.SendNotification();
3160 application.Render();
3162 // Touch the grab handle to set it as pressed.
3163 Vector2 touchPos(10.0f, 50.0f);
3164 Dali::Integration::TouchEvent event;
3165 event = Dali::Integration::TouchEvent();
3166 event.AddPoint(GetPointDownInside(touchPos));
3167 application.ProcessEvent(event);
3169 // Render and notify
3170 application.SendNotification();
3171 application.Render();
3173 // Pan the grab handle
3174 uint32_t time = 100;
3175 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3176 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3177 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3178 application.SendNotification();
3179 application.Render();
3181 // Release the grab handle.
3182 event = Dali::Integration::TouchEvent();
3183 event.AddPoint(GetPointUpInside(touchPos));
3184 application.ProcessEvent(event);
3186 // Render and notify
3187 application.SendNotification();
3188 application.Render();
3190 // Tap first to get the focus.
3191 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3193 // Render and notify
3194 application.SendNotification();
3195 application.Render();
3197 // Double tap to select a word and create the selection handles.
3198 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3200 // Render and notify
3201 application.SendNotification();
3202 application.Render();
3204 touchPos = Vector2(10.0f, 50.0f);
3206 // Touch the left selection handle to set it as pressed.
3207 event = Dali::Integration::TouchEvent();
3208 event.AddPoint(GetPointDownInside(touchPos));
3209 application.ProcessEvent(event);
3211 // Render and notify
3212 application.SendNotification();
3213 application.Render();
3215 // Release the left selection handle.
3216 event = Dali::Integration::TouchEvent();
3217 event.AddPoint(GetPointUpInside(touchPos));
3218 application.ProcessEvent(event);
3220 // Render and notify
3221 application.SendNotification();
3222 application.Render();
3227 int utcDaliTextEditorUnderPropertyStringP(void)
3229 ToolkitTestApplication application;
3230 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3231 TextEditor editor = TextEditor::New();
3232 DALI_TEST_CHECK(editor);
3234 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3236 application.GetScene().Add(editor);
3238 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3239 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3241 tet_infoline("Set underline settings with a map");
3242 // Check the input underline property
3243 Property::Map underlineMapSet;
3244 Property::Map underlineMapGet;
3245 underlineMapSet.Insert("enable", true);
3246 underlineMapSet.Insert("color", Color::BLUE);
3247 underlineMapSet.Insert("height", 1);
3248 underlineMapSet.Insert("type", Text::Underline::SOLID);
3249 underlineMapSet.Insert("dashWidth", 2);
3250 underlineMapSet.Insert("dashGap", 1);
3252 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3253 editor.SetProperty(TextEditor::Property::TEXT, "text");
3254 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3255 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3256 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3258 application.SendNotification();
3259 application.Render();
3261 underlineMapSet.Clear();
3262 underlineMapGet.Clear();
3264 tet_infoline("Set dashed underline settings with a map");
3265 // Check the input underline property
3266 underlineMapSet.Clear();
3267 underlineMapGet.Clear();
3268 underlineMapSet.Insert("enable", true);
3269 underlineMapSet.Insert("color", Color::BLUE);
3270 underlineMapSet.Insert("height", 1);
3271 underlineMapSet.Insert("type", Text::Underline::DASHED);
3272 underlineMapSet.Insert("dashWidth", 5);
3273 underlineMapSet.Insert("dashGap", 3);
3275 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3276 editor.SetProperty(TextEditor::Property::TEXT, "text");
3277 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3278 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3279 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3281 // Check the input underline property
3282 underlineMapSet.Clear();
3283 underlineMapGet.Clear();
3284 underlineMapSet.Insert("enable", true);
3285 underlineMapSet.Insert("color", Color::BLUE);
3286 underlineMapSet.Insert("height", 1);
3287 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3288 underlineMapSet.Insert("dashWidth", 5);
3289 underlineMapSet.Insert("dashGap", 3);
3291 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3292 editor.SetProperty(TextEditor::Property::TEXT, "text");
3293 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3294 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3295 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3297 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3298 editor.SetProperty(TextEditor::Property::TEXT, "text");
3299 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3300 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3301 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3303 application.SendNotification();
3304 application.Render();
3306 underlineMapSet.Clear();
3307 underlineMapGet.Clear();
3309 tet_infoline("Set underline settings with a string");
3310 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3311 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3314 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3316 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3317 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3318 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3319 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3321 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3326 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3328 ToolkitTestApplication application;
3329 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3330 TextEditor editor = TextEditor::New();
3331 DALI_TEST_CHECK(editor);
3333 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3335 application.GetScene().Add(editor);
3337 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3338 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3340 tet_infoline("Set strikethrough settings with a map");
3341 // Check the input strikethrough property
3342 Property::Map strikethroughMapSet;
3343 Property::Map strikethroughMapGet;
3344 strikethroughMapSet.Insert("enable", true);
3345 strikethroughMapSet.Insert("color", Color::BLUE);
3346 strikethroughMapSet.Insert("height", 2.0f);
3348 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3349 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3350 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3351 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3353 tet_infoline("Set strikethrough settings with a string");
3354 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3355 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3358 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3360 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3361 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3362 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3363 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3365 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3370 int utcDaliTextEditorShadowPropertyStringP(void)
3372 ToolkitTestApplication application;
3373 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3375 TextEditor editor = TextEditor::New();
3377 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3379 application.GetScene().Add(editor);
3381 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3383 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3387 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3392 int utcDaliTextEditorFontStylePropertyStringP(void)
3394 ToolkitTestApplication application;
3395 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3397 TextEditor editor = TextEditor::New();
3399 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3401 application.GetScene().Add(editor);
3403 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3405 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3409 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3414 int utcDaliTextEditorGetPropertyLinecountP(void)
3416 ToolkitTestApplication application;
3418 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3422 TextEditor editor = TextEditor::New();
3423 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3424 editor.SetProperty(TextEditor::Property::TEXT,
3425 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3427 application.GetScene().Add(editor);
3429 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3430 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3431 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3433 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3434 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3435 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3440 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3442 ToolkitTestApplication application;
3443 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3445 TextEditor editor = TextEditor::New();
3446 DALI_TEST_CHECK(editor);
3448 application.GetScene().Add(editor);
3450 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3451 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3452 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3453 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3454 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3455 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3457 bool startedCalled = false;
3458 bool finishedCalled = false;
3460 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3461 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3463 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3465 // Render and notify
3466 application.SendNotification();
3467 application.Render();
3469 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3470 application.SendNotification();
3471 application.Render(6000);
3473 application.SendNotification();
3474 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3475 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3480 int UtcDaliToolkitTextEditorTextWrapMode(void)
3482 ToolkitTestApplication application;
3483 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3487 TextEditor editor = TextEditor::New();
3488 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3489 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3491 application.GetScene().Add(editor);
3493 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3494 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3496 application.SendNotification();
3497 application.Render();
3499 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3500 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3502 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3503 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3505 application.SendNotification();
3506 application.Render();
3508 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3509 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3511 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3512 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3514 application.SendNotification();
3515 application.Render();
3517 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3518 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3520 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3521 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3523 application.SendNotification();
3524 application.Render();
3526 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3527 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3532 int UtcDaliTextEditorSetPaddingProperty(void)
3534 ToolkitTestApplication application;
3535 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3537 TextEditor editor = TextEditor::New();
3538 DALI_TEST_CHECK(editor);
3539 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3540 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3541 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3542 application.GetScene().Add(editor);
3544 application.SendNotification();
3545 application.Render();
3547 Vector3 originalSize = editor.GetNaturalSize();
3549 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3551 application.SendNotification();
3552 application.Render();
3554 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3556 Vector3 paddingAddedSize = editor.GetNaturalSize();
3558 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3560 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3565 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3567 ToolkitTestApplication application;
3568 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3570 TextEditor editor = TextEditor::New();
3571 DALI_TEST_CHECK(editor);
3572 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3573 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3574 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3575 application.GetScene().Add(editor);
3577 application.SendNotification();
3578 application.Render();
3580 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3581 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3583 // Check the enable shift selection property
3584 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3585 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3587 application.SendNotification();
3588 application.Render();
3593 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3595 ToolkitTestApplication application;
3596 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3598 TextEditor editor = TextEditor::New();
3599 DALI_TEST_CHECK(editor);
3600 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3601 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3602 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3603 application.GetScene().Add(editor);
3605 application.SendNotification();
3606 application.Render();
3608 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3609 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3611 // Check the enable grab handle property
3612 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3613 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3615 application.SendNotification();
3616 application.Render();
3621 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3623 ToolkitTestApplication application;
3624 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3626 TextEditor editor = TextEditor::New();
3627 DALI_TEST_CHECK(editor);
3628 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3629 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3630 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3631 application.GetScene().Add(editor);
3633 application.SendNotification();
3634 application.Render();
3636 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3637 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3639 // Check the disable match system language direction property
3640 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3641 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3643 application.SendNotification();
3644 application.Render();
3649 int UtcDaliTextEditorGetInputMethodContext(void)
3651 ToolkitTestApplication application;
3652 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3654 TextEditor editor = TextEditor::New();
3655 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3660 int utcDaliTextEditorMaxCharactersReached(void)
3662 ToolkitTestApplication application;
3663 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3665 TextEditor editor = TextEditor::New();
3666 DALI_TEST_CHECK(editor);
3668 application.GetScene().Add(editor);
3670 const int maxNumberOfCharacters = 1;
3671 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3672 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3674 editor.SetKeyInputFocus();
3676 // connect to the text changed signal.
3677 ConnectionTracker* testTracker = new ConnectionTracker();
3678 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3679 bool maxLengthReachedSignal = false;
3680 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3682 gMaxCharactersCallBackCalled = false;
3684 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3685 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3687 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3688 DALI_TEST_CHECK(maxLengthReachedSignal);
3693 int utcDaliTextEditorInputFiltered(void)
3695 ToolkitTestApplication application;
3696 tet_infoline(" utcDaliTextEditorInputFiltered");
3697 TextEditor editor = TextEditor::New();
3698 DALI_TEST_CHECK(editor);
3700 application.GetScene().Add(editor);
3702 Property::Map inputFilter;
3704 // Only digit is accepted.
3705 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3707 // Set input filter to TextEditor.
3708 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3710 editor.SetKeyInputFocus();
3712 // connect to the input filtered signal.
3713 ConnectionTracker* testTracker = new ConnectionTracker();
3714 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3715 bool inputFilteredSignal = false;
3716 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3718 gInputFilteredAcceptedCallbackCalled = false;
3720 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3722 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3723 DALI_TEST_CHECK(inputFilteredSignal);
3725 // Word is rejected.
3726 inputFilter[InputFilter::Property::ACCEPTED] = "";
3727 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3729 // Set input filter to TextEditor.
3730 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3732 editor.SetKeyInputFocus();
3734 inputFilteredSignal = false;
3735 gInputFilteredRejectedCallbackCalled = 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);
3745 int UtcDaliTextEditorSelectWholeText(void)
3747 ToolkitTestApplication application;
3748 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3750 TextEditor textEditor = TextEditor::New();
3752 application.GetScene().Add(textEditor);
3754 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3755 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3756 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3758 // Avoid a crash when core load gl resources.
3759 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3761 application.SendNotification();
3762 application.Render();
3764 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3766 DevelTextEditor::SelectWholeText(textEditor);
3768 application.SendNotification();
3769 application.Render();
3771 // Nothing should have been selected. The number of children is still 1
3772 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3774 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3776 application.SendNotification();
3777 application.Render();
3779 DevelTextEditor::SelectWholeText(textEditor);
3781 application.SendNotification();
3782 application.Render();
3784 // Should be 2 children, the stencil and the layer
3785 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3787 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3788 Actor stencil = textEditor.GetChildAt(0u);
3790 // The highlight actor is drawn first, so is the first actor in the list
3791 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3792 DALI_TEST_CHECK(highlight);
3797 int UtcDaliTextEditorSelectText(void)
3799 ToolkitTestApplication application;
3800 tet_infoline(" UtcDaliTextEditorSelectText ");
3802 TextEditor textEditor = TextEditor::New();
3804 application.GetScene().Add(textEditor);
3806 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3807 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3808 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3810 // Avoid a crash when core load gl resources.
3811 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3813 application.SendNotification();
3814 application.Render();
3816 DevelTextEditor::SelectText(textEditor, 0, 5);
3818 application.SendNotification();
3819 application.Render();
3821 // Nothing is selected
3822 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3823 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3825 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3827 application.SendNotification();
3828 application.Render();
3830 DevelTextEditor::SelectText(textEditor, 0, 5);
3832 application.SendNotification();
3833 application.Render();
3835 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3836 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3838 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3839 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3841 // world is selected
3842 DevelTextEditor::SelectText(textEditor, 6, 11);
3844 application.SendNotification();
3845 application.Render();
3847 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3848 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3850 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3851 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3856 int UtcDaliTextEditorSelectNone(void)
3858 ToolkitTestApplication application;
3859 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3861 TextEditor textEditor = TextEditor::New();
3863 application.GetScene().Add(textEditor);
3865 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3866 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3867 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3869 // Avoid a crash when core load gl resources.
3870 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3872 application.SendNotification();
3873 application.Render();
3875 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3877 application.SendNotification();
3878 application.Render();
3880 // Nothing is selected
3881 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3882 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3884 DevelTextEditor::SelectWholeText(textEditor);
3886 application.SendNotification();
3887 application.Render();
3889 // whole text is selected
3890 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3891 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3893 DevelTextEditor::SelectNone(textEditor);
3895 application.SendNotification();
3896 application.Render();
3898 // Nothing is selected
3899 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3900 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3905 int UtcDaliTextEditorSelectRange(void)
3907 ToolkitTestApplication application;
3908 tet_infoline("utcDaliTextEditorSelectRange");
3910 TextEditor textEditor = TextEditor::New();
3911 DALI_TEST_CHECK(textEditor);
3913 application.GetScene().Add(textEditor);
3915 // Avoid a crash when core load gl resources.
3916 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3918 application.SendNotification();
3919 application.Render();
3921 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3923 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3924 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3926 // Hello is selected
3927 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3928 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3930 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3931 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3936 int UtcDaliTextEditorEnableEditing(void)
3938 ToolkitTestApplication application;
3939 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3941 TextEditor textEditor = TextEditor::New();
3943 application.GetScene().Add(textEditor);
3945 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3946 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3947 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3949 // Avoid a crash when core load gl resources.
3950 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3952 application.SendNotification();
3953 application.Render();
3955 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3956 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3958 textEditor.SetKeyInputFocus();
3959 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3960 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3962 // Render and notify
3963 application.SendNotification();
3964 application.Render();
3966 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3967 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3969 textEditor.SetKeyInputFocus();
3970 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3971 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3973 // Render and notify
3974 application.SendNotification();
3975 application.Render();
3977 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3978 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3980 // Check the user interaction enabled and for coverage
3981 DevelTextEditor::SelectWholeText(textEditor);
3983 // Render and notify
3984 application.SendNotification();
3985 application.Render();
3987 textEditor.SetKeyInputFocus();
3988 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3989 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3991 // Render and notify
3992 application.SendNotification();
3993 application.Render();
3995 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3996 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4001 int UtcDaliTextEditorScrolling(void)
4003 ToolkitTestApplication application;
4004 tet_infoline(" UtcDaliTextEditorScrolling ");
4006 TextEditor textEditor = TextEditor::New();
4007 DALI_TEST_CHECK(textEditor);
4009 application.GetScene().Add(textEditor);
4011 // Avoid a crash when core load gl resources.
4012 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4014 application.SendNotification();
4015 application.Render();
4017 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4018 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4019 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4020 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4022 application.SendNotification();
4023 application.Render();
4025 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4026 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4028 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4030 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4031 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4033 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4035 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4036 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4038 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4039 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4041 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4042 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4047 int UtcDaliToolkitTextEditorFontSizeScale(void)
4049 ToolkitTestApplication application;
4050 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4052 TextEditor textEditor = TextEditor::New();
4053 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4054 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4055 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4057 TextEditor textEditorScaled = TextEditor::New();
4058 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4059 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4060 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4061 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4063 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4065 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4066 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4067 nonScaledSize = textEditor.GetNaturalSize();
4069 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4070 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4071 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4072 scaledSize = textEditorScaled.GetNaturalSize();
4074 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4079 int UtcDaliTextEditorPrimaryCursorPosition(void)
4081 ToolkitTestApplication application;
4082 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4084 TextEditor textEditor = TextEditor::New();
4086 application.GetScene().Add(textEditor);
4088 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4089 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4090 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4091 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4093 // Avoid a crash when core load gl resources.
4094 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4096 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4097 application.SendNotification();
4098 application.Render();
4099 textEditor.SetKeyInputFocus();
4101 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4103 // Render and notify
4104 application.SendNotification();
4105 application.Render();
4107 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4108 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4113 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4115 ToolkitTestApplication application;
4116 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4118 TextEditor textEditor = TextEditor::New();
4119 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4120 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4121 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4122 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4123 application.GetScene().Add(textEditor);
4125 application.SendNotification();
4126 application.Render();
4129 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4130 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4132 textEditor.GetNaturalSize();
4134 // Create a tap event to touch the text editor.
4135 TestGenerateTap(application, 18.0f, 25.0f);
4137 application.SendNotification();
4138 application.Render();
4140 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4141 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4146 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4148 ToolkitTestApplication application;
4150 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4152 int lineCountBefore = 0;
4153 int lineCountAfter = 0;
4155 // Create a text editor
4156 TextEditor textEditor = TextEditor::New();
4157 //Set very large font-size using point-size
4158 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4159 //Specify font-family
4160 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4162 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4163 //Set text longer than width of textEditor
4164 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4166 application.GetScene().Add(textEditor);
4168 application.SendNotification();
4169 application.Render();
4171 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
4172 //GetHeightForWidth is a retrieval method which should not modify object
4173 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4174 textEditor.GetHeightForWidth(200.f);
4176 //This is to simulate focus into text editor after calling GetHeightForWidth
4177 //Create a tap event to touch the text editor.
4178 TestGenerateTap(application, 18.0f, 25.0f);
4180 application.SendNotification();
4181 application.Render();
4183 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4185 //The LineCount must not be changed when calling GetHeightForWidth.
4186 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4191 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4193 ToolkitTestApplication application;
4195 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
4197 int lineCountBefore = 0;
4198 int lineCountAfter = 0;
4200 // Create a text editor
4201 TextEditor textEditor = TextEditor::New();
4202 //Set very large font-size using point-size
4203 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4204 //Specify font-family
4205 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4207 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4208 //Set text longer than width of textEditor
4209 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4210 //Set line wrap mode Character
4211 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4213 application.GetScene().Add(textEditor);
4215 application.SendNotification();
4216 application.Render();
4218 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4219 //GetHeightForWidth is a retrieval method which should not modify object
4220 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4221 textEditor.GetHeightForWidth(200.f);
4223 //This is to simulate focus into text editor after calling GetHeightForWidth
4224 //Create a tap event to touch the text editor.
4225 TestGenerateTap(application, 18.0f, 25.0f);
4227 application.SendNotification();
4228 application.Render();
4230 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4232 //The LineCount must not be changed when calling GetHeightForWidth.
4233 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4238 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4240 ToolkitTestApplication application;
4242 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4244 int lineCountBefore = 0;
4245 int lineCountAfter = 0;
4247 // Create a text editor
4248 TextEditor textEditor = TextEditor::New();
4249 //Set very large font-size using point-size
4250 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4251 //Specify font-family
4252 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4254 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4255 //Set text longer than width of textEditor
4256 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4257 //Set line wrap mode Character
4258 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4260 application.GetScene().Add(textEditor);
4262 application.SendNotification();
4263 application.Render();
4265 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4267 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4268 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4270 // When the text changed, the Line-count should be updated according to new text.
4271 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4272 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4273 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4278 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4280 ToolkitTestApplication application;
4282 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4284 int lineCountBefore = 0;
4285 int lineCountAfter = 0;
4287 // Create a text editor
4288 TextEditor textEditor = TextEditor::New();
4289 //Set very large font-size using point-size
4290 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4291 //Specify font-family
4292 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4294 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4295 //Set text longer than width of textEditor
4296 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4298 application.GetScene().Add(textEditor);
4300 application.SendNotification();
4301 application.Render();
4303 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4304 //GetNaturalSize is a retrieval method which should not modify object
4305 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4306 textEditor.GetNaturalSize();
4308 //This is to simulate focus into text editor after calling GetNaturalSize
4309 //Create a tap event to touch the text editor.
4310 TestGenerateTap(application, 18.0f, 25.0f);
4312 application.SendNotification();
4313 application.Render();
4315 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4317 //The LineCount must not be changed when calling GetNaturalSize.
4318 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4323 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4325 ToolkitTestApplication application;
4327 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4329 int lineCountBefore = 0;
4330 int lineCountAfter = 0;
4332 // Create a text editor
4333 TextEditor textEditor = TextEditor::New();
4334 //Set very large font-size using point-size
4335 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4336 //Specify font-family
4337 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4339 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4340 //Set text longer than width of textEditor
4341 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4342 //Set line wrap mode Character
4343 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4345 application.GetScene().Add(textEditor);
4347 application.SendNotification();
4348 application.Render();
4350 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4351 //GetNaturalSize is a retrieval method which should not modify object
4352 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4353 textEditor.GetNaturalSize();
4355 //This is to simulate focus into text editor after calling GetNaturalSize
4356 //Create a tap event to touch the text editor.
4357 TestGenerateTap(application, 18.0f, 25.0f);
4359 application.SendNotification();
4360 application.Render();
4362 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4364 //The LineCount must not be changed when calling GetNaturalSize.
4365 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4370 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4372 ToolkitTestApplication application;
4373 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4375 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4376 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4377 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4379 // Create a text editor
4380 TextEditor textEditor = TextEditor::New();
4382 //Set size to avoid automatic eliding
4383 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4384 //Set very large font-size using point-size
4385 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4386 //Specify font-family
4387 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4388 //Set text to check if appear or not
4389 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4391 application.GetScene().Add(textEditor);
4393 application.SendNotification();
4394 application.Render();
4395 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4396 Vector3 naturalSize = textEditor.GetNaturalSize();
4398 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4399 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4404 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4406 ToolkitTestApplication application;
4407 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4409 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4410 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4411 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4413 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4414 // Create a text editor
4415 TextEditor textEditor = TextEditor::New();
4416 //Set size to avoid automatic eliding
4417 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4418 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4419 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4421 const int numberOfCases = 6;
4422 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4424 for(int index = 0; index < numberOfCases; index++)
4426 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4427 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4428 application.GetScene().Add(textEditor);
4429 application.SendNotification();
4430 application.Render();
4431 naturalSize = textEditor.GetNaturalSize();
4432 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4433 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4439 int UtcDaliTextEditorHyphenWrapMode(void)
4441 ToolkitTestApplication application;
4442 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4445 TextEditor textEditor = TextEditor::New();
4447 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4449 application.GetScene().Add(textEditor);
4450 application.SendNotification();
4451 application.Render();
4453 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4454 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4455 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4457 application.SendNotification();
4458 application.Render();
4460 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4466 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4468 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4469 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4470 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4472 application.SendNotification();
4473 application.Render();
4475 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4482 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4487 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4489 ToolkitTestApplication application;
4490 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4491 TextEditor textEditor = TextEditor::New();
4493 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4494 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4496 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4497 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4498 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4500 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4501 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4502 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4504 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4505 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4506 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4508 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4509 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4510 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4512 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4513 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4514 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4516 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4517 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4518 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4520 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4521 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4522 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4524 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4525 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4526 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4528 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4529 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4530 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4532 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4533 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4534 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4536 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4537 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4538 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4540 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4541 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4542 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4547 int UtcDaliTextEditorCopyText(void)
4549 ToolkitTestApplication application;
4550 tet_infoline(" UtcDaliTextEditorCopyText ");
4552 TextEditor textEditor = TextEditor::New();
4554 std::string selectedText = "";
4555 std::string copiedText = "";
4557 application.GetScene().Add(textEditor);
4559 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4560 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4561 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4563 // Avoid a crash when core load gl resources.
4564 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4566 application.SendNotification();
4567 application.Render();
4569 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4571 application.SendNotification();
4572 application.Render();
4574 // Hello is selected
4575 DevelTextEditor::SelectText(textEditor, 0, 5);
4577 application.SendNotification();
4578 application.Render();
4580 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4581 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4583 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4584 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4587 copiedText = DevelTextEditor::CopyText(textEditor);
4588 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4590 // world is selected
4591 DevelTextEditor::SelectText(textEditor, 6, 11);
4593 application.SendNotification();
4594 application.Render();
4596 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4597 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4599 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4600 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4603 copiedText = DevelTextEditor::CopyText(textEditor);
4604 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4606 // "lo wo" is selected
4607 DevelTextEditor::SelectText(textEditor, 3, 8);
4609 application.SendNotification();
4610 application.Render();
4612 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4613 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4615 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4616 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4618 // "lo wo" is copied
4619 copiedText = DevelTextEditor::CopyText(textEditor);
4620 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4625 int UtcDaliTextEditorCutText(void)
4627 ToolkitTestApplication application;
4628 tet_infoline(" UtcDaliTextEditorCutText ");
4630 TextEditor textEditor = TextEditor::New();
4632 std::string selectedText = "";
4634 application.GetScene().Add(textEditor);
4636 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4637 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4638 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4640 // Avoid a crash when core load gl resources.
4641 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4643 application.SendNotification();
4644 application.Render();
4646 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4648 application.SendNotification();
4649 application.Render();
4651 // Hello is selected
4652 DevelTextEditor::SelectText(textEditor, 0, 5);
4654 application.SendNotification();
4655 application.Render();
4657 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4658 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4660 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4661 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4664 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4666 application.SendNotification();
4667 application.Render();
4669 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4672 DevelTextEditor::SelectText(textEditor, 0, 2);
4674 application.SendNotification();
4675 application.Render();
4677 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4678 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4680 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4681 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4684 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4686 application.SendNotification();
4687 application.Render();
4689 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4691 // Test Cut from the middle
4694 DevelTextEditor::SelectText(textEditor, 1, 3);
4696 application.SendNotification();
4697 application.Render();
4699 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4700 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4702 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4703 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4706 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4708 application.SendNotification();
4709 application.Render();
4711 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4713 // Test Cut from the end
4716 DevelTextEditor::SelectText(textEditor, 1, 2);
4718 application.SendNotification();
4719 application.Render();
4721 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4722 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4724 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4725 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4728 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4730 application.SendNotification();
4731 application.Render();
4733 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4738 int UtcDaliTextEditorPasteText(void)
4740 ToolkitTestApplication application;
4741 tet_infoline(" UtcDaliTextEditorPasteText ");
4743 TextEditor editor = TextEditor::New();
4744 DALI_TEST_CHECK(editor);
4746 application.GetScene().Add(editor);
4748 std::string cutText = "";
4749 std::string copiedText = "";
4751 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4752 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4753 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4754 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4755 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4757 // Avoid a crash when core load gl resources.
4758 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4760 // Render and notify
4761 application.SendNotification();
4762 application.Render();
4764 // Tap on the text editor
4765 TestGenerateTap(application, 3.0f, 25.0f);
4767 // Render and notify
4768 application.SendNotification();
4769 application.Render();
4771 // Move to second line of the text.
4772 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4774 // Render and notify
4775 application.SendNotification();
4776 application.Render();
4778 // Select some text in the right of the current cursor position
4779 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4780 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4782 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4784 // Render and notify
4785 application.SendNotification();
4786 application.Render();
4788 // Cut the selected text
4789 cutText = DevelTextEditor::CutText(editor);
4791 // Render and notify
4792 application.SendNotification();
4793 application.Render();
4795 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4796 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4798 // Select some text in the left of the current cursor position
4799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4800 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4804 // Render and notify
4805 application.SendNotification();
4806 application.Render();
4808 // Copy the selected text
4809 copiedText = DevelTextEditor::CopyText(editor);
4811 // Render and notify
4812 application.SendNotification();
4813 application.Render();
4815 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4816 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4818 // Move the cursor to the third line
4819 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4822 // Render and notify
4823 application.SendNotification();
4824 application.Render();
4826 // Paste the selected text at the current cursor position
4827 DevelTextEditor::PasteText(editor);
4829 // Render and notify
4830 application.SendNotification();
4831 application.Render();
4833 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4838 int UtcDaliTextEditorLineSpacing(void)
4840 ToolkitTestApplication application;
4841 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4843 TextEditor textEditor = TextEditor::New();
4844 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4845 application.GetScene().Add(textEditor);
4846 application.SendNotification();
4847 application.Render();
4849 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4850 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4852 Vector3 sizeBefore = textEditor.GetNaturalSize();
4854 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4856 //add 20 for each line 20 * 3
4857 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4862 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4864 //Only for test coverage
4865 ToolkitTestApplication application;
4866 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4868 TextEditor textEditor = TextEditor::New();
4869 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4870 application.GetScene().Add(textEditor);
4871 application.SendNotification();
4872 application.Render();
4874 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4875 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4877 application.SendNotification();
4878 application.Render();
4880 DevelTextEditor::SelectWholeText(textEditor);
4882 application.SendNotification();
4883 application.Render();
4885 DevelTextEditor::SelectNone(textEditor);
4886 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4888 application.SendNotification();
4889 application.Render();
4891 DevelTextEditor::SelectWholeText(textEditor);
4893 application.SendNotification();
4894 application.Render();
4896 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4901 int UtcDaliTextEditorMinLineSize(void)
4903 ToolkitTestApplication application;
4904 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4906 TextEditor textEditor = TextEditor::New();
4907 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4908 application.GetScene().Add(textEditor);
4909 application.SendNotification();
4910 application.Render();
4912 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4913 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4915 Vector3 sizeBefore = textEditor.GetNaturalSize();
4917 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4919 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4922 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4927 int utcDaliTextEditorCursorPositionChangedSignal(void)
4929 ToolkitTestApplication application;
4930 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4932 TextEditor editor = TextEditor::New();
4933 DALI_TEST_CHECK(editor);
4935 application.GetScene().Add(editor);
4937 // connect to the selection changed signal.
4938 ConnectionTracker* testTracker = new ConnectionTracker();
4939 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4940 bool cursorPositionChangedSignal = false;
4941 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4943 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4944 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4945 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4946 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4947 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4949 // Avoid a crash when core load gl resources.
4950 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4952 // Render and notify
4953 application.SendNotification();
4954 application.Render();
4956 editor.SetKeyInputFocus();
4958 // Tap on the text editor
4959 TestGenerateTap(application, 3.0f, 25.0f);
4961 // Render and notify
4962 application.SendNotification();
4963 application.Render();
4965 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4966 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4968 gCursorPositionChangedCallbackCalled = false;
4971 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4973 // Render and notify
4974 application.SendNotification();
4975 application.Render();
4977 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4978 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4980 gCursorPositionChangedCallbackCalled = false;
4983 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4985 // Render and notify
4986 application.SendNotification();
4987 application.Render();
4989 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4990 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4992 gCursorPositionChangedCallbackCalled = false;
4994 //delete one character
4995 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4997 // Render and notify
4998 application.SendNotification();
4999 application.Render();
5001 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5002 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5004 gCursorPositionChangedCallbackCalled = false;
5006 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5008 // Render and notify
5009 application.SendNotification();
5010 application.Render();
5012 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5013 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5015 gCursorPositionChangedCallbackCalled = false;
5017 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5019 // Render and notify
5020 application.SendNotification();
5021 application.Render();
5023 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5024 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5029 int utcDaliTextEditorGeometryEllipsisStart(void)
5031 ToolkitTestApplication application;
5032 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5034 TextEditor editor = TextEditor::New();
5035 DALI_TEST_CHECK(editor);
5037 application.GetScene().Add(editor);
5039 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5040 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5041 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5042 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5043 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5044 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5045 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5046 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5047 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5049 // Avoid a crash when core load gl resources.
5050 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5052 // Render and notify
5053 application.SendNotification();
5054 application.Render();
5056 unsigned int expectedCount = 2;
5057 unsigned int startIndex = 0;
5058 unsigned int endIndex = 24;
5060 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5061 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5063 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5064 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5066 Vector<Vector2> expectedSizes;
5067 Vector<Vector2> expectedPositions;
5069 expectedPositions.PushBack(Vector2(38, 0));
5070 expectedSizes.PushBack(Vector2(21, 25));
5072 expectedPositions.PushBack(Vector2(-1, 25));
5073 expectedSizes.PushBack(Vector2(53, 25));
5075 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5080 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5082 ToolkitTestApplication application;
5083 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
5085 TextEditor editor = TextEditor::New();
5086 DALI_TEST_CHECK(editor);
5088 application.GetScene().Add(editor);
5090 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5091 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5092 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5093 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5094 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5095 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5096 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5097 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
5098 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5100 // Avoid a crash when core load gl resources.
5101 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5103 // Render and notify
5104 application.SendNotification();
5105 application.Render();
5107 unsigned int expectedCount = 2;
5108 unsigned int startIndex = 0;
5109 unsigned int endIndex = 24;
5111 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5112 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5114 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5115 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5117 Vector<Vector2> expectedSizes;
5118 Vector<Vector2> expectedPositions;
5120 expectedPositions.PushBack(Vector2(-1, 0));
5121 expectedSizes.PushBack(Vector2(26, 25));
5123 expectedPositions.PushBack(Vector2(-1, 25));
5124 expectedSizes.PushBack(Vector2(53, 25));
5126 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5131 int utcDaliTextEditorGeometryEllipsisEnd(void)
5133 ToolkitTestApplication application;
5134 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5136 TextEditor editor = TextEditor::New();
5137 DALI_TEST_CHECK(editor);
5139 application.GetScene().Add(editor);
5141 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5142 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5143 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5144 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5145 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5146 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5147 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5148 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5149 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5151 // Avoid a crash when core load gl resources.
5152 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5154 // Render and notify
5155 application.SendNotification();
5156 application.Render();
5158 unsigned int expectedCount = 2;
5159 unsigned int startIndex = 0;
5160 unsigned int endIndex = 24;
5162 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5163 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5165 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5166 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5168 Vector<Vector2> expectedSizes;
5169 Vector<Vector2> expectedPositions;
5171 expectedPositions.PushBack(Vector2(-1, 0));
5172 expectedSizes.PushBack(Vector2(60, 25));
5174 expectedPositions.PushBack(Vector2(-1, 25));
5175 expectedSizes.PushBack(Vector2(39, 25));
5177 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5182 int utcDaliTextEditorGeometryRTL(void)
5184 ToolkitTestApplication application;
5185 tet_infoline(" utcDaliTextEditorGeometryRTL");
5187 TextEditor editor = TextEditor::New();
5188 DALI_TEST_CHECK(editor);
5190 application.GetScene().Add(editor);
5192 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5193 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5194 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5195 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5196 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5197 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5199 // Avoid a crash when core load gl resources.
5200 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5202 // Render and notify
5203 application.SendNotification();
5204 application.Render();
5206 unsigned int expectedCount = 4;
5207 unsigned int startIndex = 3;
5208 unsigned int endIndex = 24;
5210 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5211 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5213 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5214 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5216 Vector<Vector2> expectedSizes;
5217 Vector<Vector2> expectedPositions;
5219 expectedPositions.PushBack(Vector2(25, 0));
5220 expectedSizes.PushBack(Vector2(34, 25));
5222 expectedPositions.PushBack(Vector2(-1, 25));
5223 expectedSizes.PushBack(Vector2(53, 25));
5225 expectedPositions.PushBack(Vector2(-1, 50));
5226 expectedSizes.PushBack(Vector2(60, 25));
5228 expectedPositions.PushBack(Vector2(63, 75));
5229 expectedSizes.PushBack(Vector2(37, 25));
5231 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5236 int utcDaliTextEditorGeometryGlyphMiddle(void)
5238 ToolkitTestApplication application;
5239 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5241 TextEditor editor = TextEditor::New();
5242 DALI_TEST_CHECK(editor);
5244 application.GetScene().Add(editor);
5246 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5247 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5248 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5249 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5250 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5251 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5253 // Avoid a crash when core load gl resources.
5254 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5256 // Render and notify
5257 application.SendNotification();
5258 application.Render();
5260 unsigned int expectedCount = 1;
5261 unsigned int startIndex = 1;
5262 unsigned int endIndex = 13;
5264 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5265 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5267 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5268 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5270 Vector<Vector2> expectedSizes;
5271 Vector<Vector2> expectedPositions;
5273 expectedPositions.PushBack(Vector2(6, 0));
5274 expectedSizes.PushBack(Vector2(125, 25));
5276 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5281 int utcDaliTextEditorGeometryOneGlyph(void)
5283 ToolkitTestApplication application;
5284 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5286 TextEditor label = TextEditor::New();
5287 DALI_TEST_CHECK(label);
5289 application.GetScene().Add(label);
5291 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5292 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5293 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5294 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5295 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5296 label.SetProperty(TextEditor::Property::TEXT, "H");
5298 // Avoid a crash when core load gl resources.
5299 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5301 // Render and notify
5302 application.SendNotification();
5303 application.Render();
5305 unsigned int expectedCount = 1;
5306 unsigned int startIndex = 0;
5307 unsigned int endIndex = 0;
5309 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5310 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5312 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5313 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5315 Vector<Vector2> expectedSizes;
5316 Vector<Vector2> expectedPositions;
5318 expectedPositions.PushBack(Vector2(-2, 0));
5319 expectedSizes.PushBack(Vector2(16, 25));
5321 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5326 int utcDaliTextEditorGeometryNullPtr(void)
5328 ToolkitTestApplication application;
5329 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5331 TextEditor editor = TextEditor::New();
5332 DALI_TEST_CHECK(editor);
5334 application.GetScene().Add(editor);
5336 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5337 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5338 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5339 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5340 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5341 editor.SetProperty(TextEditor::Property::TEXT, "");
5343 // Avoid a crash when core load gl resources.
5344 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5346 unsigned int expectedCount = 0;
5347 unsigned int startIndex = 0;
5348 unsigned int endIndex = 0;
5350 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5351 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5353 // Render and notify
5354 application.SendNotification();
5355 application.Render();
5357 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5358 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5363 int utcDaliTextEditorSelectionClearedSignal(void)
5365 ToolkitTestApplication application;
5366 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5368 TextEditor editor = TextEditor::New();
5369 DALI_TEST_CHECK(editor);
5371 application.GetScene().Add(editor);
5373 // connect to the selection changed signal.
5374 ConnectionTracker* testTracker = new ConnectionTracker();
5375 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5376 bool selectionClearedSignal = false;
5377 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5379 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5380 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5381 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5382 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5383 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5385 // Avoid a crash when core load gl resources.
5386 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5388 // Render and notify
5389 application.SendNotification();
5390 application.Render();
5392 // Tap on the text editor
5393 TestGenerateTap(application, 3.0f, 25.0f);
5395 // Render and notify
5396 application.SendNotification();
5397 application.Render();
5399 // Move to second line of the text & Select some text in the right of the current cursor position
5400 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5401 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5404 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5406 // Render and notify
5407 application.SendNotification();
5408 application.Render();
5410 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5412 // Render and notify
5413 application.SendNotification();
5414 application.Render();
5416 // Tap on the text editor
5417 TestGenerateTap(application, 3.0f, 25.0f);
5419 // Render and notify
5420 application.SendNotification();
5421 application.Render();
5423 gSelectionClearedCallbackCalled = false;
5425 // Move to second line of the text & select.
5426 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5427 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5430 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5432 // Render and notify
5433 application.SendNotification();
5434 application.Render();
5436 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5438 gSelectionClearedCallbackCalled = false;
5440 // Render and notify
5441 application.SendNotification();
5442 application.Render();
5444 // Move to second line of the text & select.
5445 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5446 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5448 // replace C with selected text
5449 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5451 // Render and notify
5452 application.SendNotification();
5453 application.Render();
5455 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5457 gSelectionClearedCallbackCalled = false;
5459 // Render and notify
5460 application.SendNotification();
5461 application.Render();
5463 DevelTextEditor::SelectText(editor, 1, 3);
5465 // Render and notify
5466 application.SendNotification();
5467 application.Render();
5469 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5471 // Render and notify
5472 application.SendNotification();
5473 application.Render();
5475 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5477 gSelectionClearedCallbackCalled = false;
5479 DevelTextEditor::SelectText(editor, 1, 3);
5481 // Render and notify
5482 application.SendNotification();
5483 application.Render();
5486 DevelTextEditor::SelectNone(editor);
5488 // Render and notify
5489 application.SendNotification();
5490 application.Render();
5492 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5497 int utcDaliTextEditorSelectionStartedSignal(void)
5499 ToolkitTestApplication application;
5500 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5502 TextEditor editor = TextEditor::New();
5503 DALI_TEST_CHECK(editor);
5505 application.GetScene().Add(editor);
5507 // connect to the selection changed signal.
5508 ConnectionTracker* testTracker = new ConnectionTracker();
5509 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5510 bool selectionStartedSignal = false;
5511 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5513 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5514 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5515 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5516 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5517 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5519 // Avoid a crash when core load gl resources.
5520 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5522 // Render and notify
5523 application.SendNotification();
5524 application.Render();
5526 // Tap on the text editor
5527 TestGenerateTap(application, 3.0f, 25.0f);
5529 // Render and notify
5530 application.SendNotification();
5531 application.Render();
5533 // Move to second line of the text & Select some text in the right of the current cursor position
5534 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5535 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5537 // Render and notify
5538 application.SendNotification();
5539 application.Render();
5541 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5544 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5546 // Render and notify
5547 application.SendNotification();
5548 application.Render();
5550 gSelectionStartedCallbackCalled = false;
5552 DevelTextEditor::SelectText(editor, 1, 3);
5554 // Render and notify
5555 application.SendNotification();
5556 application.Render();
5558 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5563 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5565 ToolkitTestApplication application;
5566 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5568 // Checks if the actor is created.
5570 TextEditor editor = TextEditor::New();
5571 DALI_TEST_CHECK(editor);
5573 application.GetScene().Add(editor);
5575 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5576 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5577 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5578 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5579 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5580 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5581 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5582 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5584 // Avoid a crash when core load gl resources.
5585 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5587 // Render and notify
5588 application.SendNotification();
5589 application.Render();
5591 // Tap on the text editor
5592 TestGenerateTap(application, 3.0f, 25.0f);
5594 // Render and notify
5595 application.SendNotification();
5596 application.Render();
5598 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5599 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5601 application.SendNotification();
5602 application.Render();
5604 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5605 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5610 int utcDaliTextEditorSelectionChangedSignal(void)
5612 ToolkitTestApplication application;
5613 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5615 TextEditor editor = TextEditor::New();
5616 DALI_TEST_CHECK(editor);
5618 application.GetScene().Add(editor);
5620 // connect to the selection changed signal.
5621 ConnectionTracker* testTracker = new ConnectionTracker();
5622 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5623 bool selectionChangedSignal = false;
5624 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5626 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5627 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5628 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5629 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5630 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5632 // Avoid a crash when core load gl resources.
5633 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5635 // Render and notify
5636 application.SendNotification();
5637 application.Render();
5639 // Tap on the text editor
5640 TestGenerateTap(application, 3.0f, 25.0f);
5642 // Render and notify
5643 application.SendNotification();
5644 application.Render();
5646 // Move to second line of the text.
5647 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5649 // Render and notify
5650 application.SendNotification();
5651 application.Render();
5653 // Select some text in the right of the current cursor position
5654 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5655 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5657 // Render and notify
5658 application.SendNotification();
5659 application.Render();
5661 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5662 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5664 gSelectionChangedCallbackCalled = false;
5666 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5668 // Render and notify
5669 application.SendNotification();
5670 application.Render();
5672 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5673 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5674 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5676 gSelectionChangedCallbackCalled = false;
5678 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5680 // Render and notify
5681 application.SendNotification();
5682 application.Render();
5684 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5685 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5686 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5688 gSelectionChangedCallbackCalled = false;
5689 editor.SetKeyInputFocus();
5691 // Render and notify
5692 application.SendNotification();
5693 application.Render();
5695 DevelTextEditor::SelectText(editor, 0, 5);
5697 application.SendNotification();
5698 application.Render();
5700 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5701 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5703 gSelectionChangedCallbackCalled = false;
5705 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5707 // Render and notify
5708 application.SendNotification();
5709 application.Render();
5711 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5712 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5713 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5715 gSelectionChangedCallbackCalled = false;
5718 DevelTextEditor::SelectWholeText(editor);
5720 // Render and notify
5721 application.SendNotification();
5722 application.Render();
5724 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5725 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5727 gSelectionChangedCallbackCalled = false;
5730 DevelTextEditor::SelectNone(editor);
5732 // Render and notify
5733 application.SendNotification();
5734 application.Render();
5736 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5737 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5738 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5743 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5745 ToolkitTestApplication application;
5746 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5748 TextEditor textEditor = TextEditor::New();
5749 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5750 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5751 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5752 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5754 application.GetScene().Add(textEditor);
5755 application.SendNotification();
5756 application.Render();
5758 Property::Map strikethroughMapSet;
5759 Property::Map strikethroughMapGet;
5761 strikethroughMapSet.Insert("enable", true);
5762 strikethroughMapSet.Insert("color", Color::RED);
5763 strikethroughMapSet.Insert("height", 2.0f);
5765 // Check the strikethrough property
5766 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5767 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5768 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5769 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5770 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5772 // Render and notify
5773 application.SendNotification();
5774 application.Render();
5776 strikethroughMapSet.Clear();
5777 strikethroughMapGet.Clear();
5782 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5784 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5785 //DaliException on vector: "Iterator not inside vector"
5787 ToolkitTestApplication application;
5788 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5790 TextEditor editor = TextEditor::New();
5791 DALI_TEST_CHECK(editor);
5793 application.GetScene().Add(editor);
5795 // Avoid a crash when core load gl resources.
5796 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5798 //Set multilines text
5799 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5800 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5801 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5803 //Set ResizePolicy to NaturalSize
5804 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5806 // Render and notify
5807 application.SendNotification();
5808 application.Render();
5810 // Create a tap event to touch the text editor.
5811 TestGenerateTap(application, 5.0f, 5.0f);
5813 // Render and notify
5814 application.SendNotification();
5815 application.Render();
5817 // Set currsor and add character (in first line)
5818 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5819 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5820 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5822 // Render and notify
5823 application.SendNotification();
5824 application.Render();
5826 //Check the changed text and cursor position
5827 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5828 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5830 // Render and notify
5831 application.SendNotification();
5832 application.Render();
5837 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5839 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5840 //DaliException on vector: "Iterator not inside vector"
5842 ToolkitTestApplication application;
5843 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5845 TextEditor editor = TextEditor::New();
5846 DALI_TEST_CHECK(editor);
5848 application.GetScene().Add(editor);
5850 // Avoid a crash when core load gl resources.
5851 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5853 //Set multilines text
5854 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5855 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5856 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5858 //Set ResizePolicy to NaturalSize
5859 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5862 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5863 application.SendNotification();
5864 application.Render();
5866 // Set focus and remove character
5867 editor.SetKeyInputFocus();
5868 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5870 // Render and notify
5871 application.SendNotification();
5872 application.Render();
5874 //Check the changed text and cursor position
5875 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5876 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5878 // Render and notify
5879 application.SendNotification();
5880 application.Render();
5885 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5887 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5888 //DaliException on vector: "Iterator not inside vector"
5890 ToolkitTestApplication application;
5891 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5893 TextEditor editor = TextEditor::New();
5894 DALI_TEST_CHECK(editor);
5896 application.GetScene().Add(editor);
5898 // Avoid a crash when core load gl resources.
5899 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5901 //Set multilines text
5902 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5903 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5904 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5906 //Set ResizePolicy to NaturalSize
5907 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5909 //Select text at initialization (before the first render)
5910 DevelTextEditor::SelectText(editor, 3, 5);
5912 // Render and notify
5913 application.SendNotification();
5914 application.Render();
5917 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5918 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));
5920 // Render and notify
5921 application.SendNotification();
5922 application.Render();
5924 //Check the changed text and cursor position
5925 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5926 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5928 // Render and notify
5929 application.SendNotification();
5930 application.Render();
5935 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5937 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5938 //DaliException on vector: "Iterator not inside vector"
5940 ToolkitTestApplication application;
5941 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5943 TextEditor editor = TextEditor::New();
5944 DALI_TEST_CHECK(editor);
5946 application.GetScene().Add(editor);
5948 // Avoid a crash when core load gl resources.
5949 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5951 //Set multilines text
5952 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5953 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5954 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5956 //Set ResizePolicy to NaturalSize
5957 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5960 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5961 application.SendNotification();
5962 application.Render();
5964 // Set focus and double enter (new line)
5965 editor.SetKeyInputFocus();
5966 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5967 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5969 // Render and notify
5970 application.SendNotification();
5971 application.Render();
5973 //Check the changed text and cursor position
5974 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5975 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5977 // Render and notify
5978 application.SendNotification();
5979 application.Render();
5984 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5986 ToolkitTestApplication application;
5987 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5988 TextEditor textEditor = TextEditor::New();
5989 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5990 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5991 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5992 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5994 application.GetScene().Add(textEditor);
5995 application.SendNotification();
5996 application.Render();
5998 Property::Map underlineMapSet;
5999 Property::Map underlineMapGet;
6001 underlineMapSet.Insert("enable", true);
6002 underlineMapSet.Insert("color", Color::RED);
6003 underlineMapSet.Insert("height", 1);
6004 underlineMapSet.Insert("type", Text::Underline::SOLID);
6005 underlineMapSet.Insert("dashWidth", 2);
6006 underlineMapSet.Insert("dashGap", 1);
6008 // Check the underline property
6009 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6011 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6012 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6013 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6015 // Render and notify
6016 application.SendNotification();
6017 application.Render();
6019 underlineMapSet.Clear();
6020 underlineMapGet.Clear();
6022 underlineMapSet.Insert("enable", true);
6023 underlineMapSet.Insert("color", Color::BLUE);
6024 underlineMapSet.Insert("height", 1);
6025 underlineMapSet.Insert("type", Text::Underline::DASHED);
6026 underlineMapSet.Insert("dashWidth", 4);
6027 underlineMapSet.Insert("dashGap", 2);
6029 // Check the dashed underline property
6030 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6032 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6033 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6034 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6036 // Render and notify
6037 application.SendNotification();
6038 application.Render();
6040 underlineMapSet.Clear();
6041 underlineMapGet.Clear();
6043 underlineMapSet.Insert("enable", true);
6044 underlineMapSet.Insert("color", Color::BLUE);
6045 underlineMapSet.Insert("height", 1);
6046 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6047 underlineMapSet.Insert("dashWidth", 4);
6048 underlineMapSet.Insert("dashGap", 2);
6050 // Check the dashed underline property
6051 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6053 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6054 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6055 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6057 // Render and notify
6058 application.SendNotification();
6059 application.Render();
6061 underlineMapSet.Clear();
6062 underlineMapGet.Clear();
6067 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6069 ToolkitTestApplication application;
6070 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6072 TextEditor textEditor1 = TextEditor::New();
6073 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6074 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6075 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6076 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6078 Property::Map underlineMapSet1;
6079 Property::Map underlineMapGet1;
6081 underlineMapSet1.Insert("enable", true);
6082 underlineMapSet1.Insert("color", Color::RED);
6083 underlineMapSet1.Insert("height", 1);
6084 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6085 underlineMapSet1.Insert("dashWidth", 2);
6086 underlineMapSet1.Insert("dashGap", 1);
6088 // Check the underline property
6089 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6091 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6092 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6093 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6095 application.GetScene().Add(textEditor1);
6096 application.SendNotification();
6097 application.Render();
6099 TextEditor textEditor2 = TextEditor::New();
6100 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6101 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6102 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6103 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6105 Property::Map underlineMapSet2;
6106 Property::Map underlineMapGet2;
6108 underlineMapSet2.Insert("enable", true);
6109 underlineMapSet2.Insert("color", Color::BLUE);
6110 underlineMapSet2.Insert("height", 1);
6111 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6112 underlineMapSet2.Insert("dashWidth", 4);
6113 underlineMapSet2.Insert("dashGap", 2);
6115 // Check the dashed underline property
6116 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6118 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6119 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6120 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6122 application.GetScene().Add(textEditor2);
6123 application.SendNotification();
6124 application.Render();
6126 TextEditor textEditor3 = TextEditor::New();
6127 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6128 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6129 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6130 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6132 Property::Map underlineMapSet3;
6133 Property::Map underlineMapGet3;
6135 underlineMapSet3.Insert("enable", true);
6136 underlineMapSet3.Insert("color", Color::BLUE);
6137 underlineMapSet3.Insert("height", 1);
6138 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6139 underlineMapSet3.Insert("dashWidth", 4);
6140 underlineMapSet3.Insert("dashGap", 2);
6142 // Check the dashed underline property
6143 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6145 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6146 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6147 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6149 application.GetScene().Add(textEditor3);
6150 application.SendNotification();
6151 application.Render();
6156 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6158 ToolkitTestApplication application;
6159 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6161 TextEditor textEditor1 = TextEditor::New();
6162 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6163 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6164 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6165 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6167 Property::Map underlineMapSet1;
6168 Property::Map underlineMapGet1;
6170 underlineMapSet1.Insert("enable", true);
6171 underlineMapSet1.Insert("color", Color::RED);
6172 underlineMapSet1.Insert("height", 1);
6173 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6174 underlineMapSet1.Insert("dashWidth", 2);
6175 underlineMapSet1.Insert("dashGap", 1);
6177 // Check the underline property
6178 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6179 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6181 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6182 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6183 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6185 application.GetScene().Add(textEditor1);
6187 application.SendNotification();
6188 application.Render();
6193 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6195 ToolkitTestApplication application;
6196 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6198 TextEditor editor = TextEditor::New();
6199 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6200 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6201 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6202 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6203 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6204 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6206 TextEditor editorSingleLineParagraph = TextEditor::New();
6207 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6208 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6209 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");
6210 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6211 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6212 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6214 TextEditor editorMultiLineParagraph = TextEditor::New();
6215 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6216 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6217 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");
6218 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6219 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6220 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6222 application.GetScene().Add(editor);
6223 application.GetScene().Add(editorSingleLineParagraph);
6224 application.GetScene().Add(editorMultiLineParagraph);
6225 application.SendNotification();
6226 application.Render();
6228 Vector3 naturalSize = editor.GetNaturalSize();
6229 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6230 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6232 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6234 //no effect of relative line size for paragraph with single line
6235 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6237 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6242 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6244 ToolkitTestApplication application;
6245 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6247 TextEditor editor = TextEditor::New();
6248 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6249 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6250 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6252 application.GetScene().Add(editor);
6253 application.SendNotification();
6254 application.Render();
6256 Vector3 naturalSize = editor.GetNaturalSize();
6258 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6260 application.SendNotification();
6261 application.Render();
6263 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6265 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6267 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6269 application.SendNotification();
6270 application.Render();
6272 relativeNaturalSize = editor.GetNaturalSize();
6274 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6278 int UtcDaliTextEditorCharacterSpacing(void)
6280 ToolkitTestApplication application;
6281 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6283 TextEditor textEditor = TextEditor::New();
6285 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6287 application.GetScene().Add(textEditor);
6288 application.SendNotification();
6289 application.Render();
6291 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6292 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6293 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6295 application.SendNotification();
6296 application.Render();
6301 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6303 ToolkitTestApplication application;
6304 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6306 TextEditor editor = TextEditor::New();
6308 float lineSpacing = -20.f;
6310 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6311 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6312 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6313 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6315 application.GetScene().Add(editor);
6316 application.SendNotification();
6317 application.Render();
6319 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6320 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6322 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6323 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6325 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6326 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6328 application.SendNotification();
6329 application.Render();
6334 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6336 ToolkitTestApplication application;
6337 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6339 TextEditor editor = TextEditor::New();
6340 DALI_TEST_CHECK(editor);
6342 application.GetScene().Add(editor);
6344 std::string cutText = "";
6345 std::string copiedText = "";
6347 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6348 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6349 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6350 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6351 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6352 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6353 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6355 // Render and notify
6356 application.SendNotification();
6357 application.Render();
6359 // Tap on the text editor
6360 TestGenerateTap(application, 1.0f, 1.0f);
6362 // Render and notify
6363 application.SendNotification();
6364 application.Render();
6366 // Move to second line of the text.
6367 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6369 // Render and notify
6370 application.SendNotification();
6371 application.Render();
6373 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6378 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6380 ToolkitTestApplication application;
6381 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6383 TextEditor editor = TextEditor::New();
6385 float lineSpacing = -20.f;
6387 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6388 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6389 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6390 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6391 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6393 application.GetScene().Add(editor);
6394 application.SendNotification();
6395 application.Render();
6397 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6399 int lineCount = sizeList.Size();
6400 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6402 application.SendNotification();
6403 application.Render();
6408 int UtcDaliToolkitTexteditorParagraphTag(void)
6410 ToolkitTestApplication application;
6411 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6412 TextEditor editorNewlineSeparator = TextEditor::New();
6413 TextEditor editorParagraphTag = TextEditor::New();
6414 DALI_TEST_CHECK(editorNewlineSeparator);
6415 DALI_TEST_CHECK(editorParagraphTag);
6417 application.GetScene().Add(editorNewlineSeparator);
6418 application.GetScene().Add(editorParagraphTag);
6420 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6421 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6422 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6423 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6424 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6425 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6427 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6428 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6429 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6430 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6431 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6433 application.SendNotification();
6434 application.Render();
6436 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6437 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6439 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6441 application.SendNotification();
6442 application.Render();
6447 //Handle Emoji clustering for cursor handling
6448 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6450 ToolkitTestApplication application;
6451 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6452 TextEditor textEditor = TextEditor::New();
6453 DALI_TEST_CHECK(textEditor);
6455 application.GetScene().Add(textEditor);
6457 // Avoid a crash when core load gl resources.
6458 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6460 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6461 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6463 // Render and notify
6464 application.SendNotification();
6465 application.Render();
6468 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6469 application.SendNotification();
6470 application.Render();
6472 // Set focus and remove Emoji
6473 textEditor.SetKeyInputFocus();
6474 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6476 //Check the changed text and cursor position
6477 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6478 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6480 // Render and notify
6481 application.SendNotification();
6482 application.Render();
6487 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6489 ToolkitTestApplication application;
6490 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6491 TextEditor textEditor = TextEditor::New();
6492 DALI_TEST_CHECK(textEditor);
6494 application.GetScene().Add(textEditor);
6496 // Avoid a crash when core load gl resources.
6497 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6499 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6500 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6502 // Render and notify
6503 application.SendNotification();
6504 application.Render();
6507 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6508 application.SendNotification();
6509 application.Render();
6511 // Set focus and remove Emoji
6512 textEditor.SetKeyInputFocus();
6513 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6515 //Check the changed text and cursor position
6516 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6517 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6519 // Render and notify
6520 application.SendNotification();
6521 application.Render();
6526 int utcDaliTextEditorPanGesturePropagation(void)
6528 ToolkitTestApplication application;
6529 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6531 Actor actor = Actor::New();
6532 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6533 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6534 application.GetScene().Add(actor);
6536 TextEditor editor = TextEditor::New();
6537 DALI_TEST_CHECK(editor);
6539 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6540 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6542 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6543 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6544 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6548 // Render and notify
6549 application.SendNotification();
6550 application.Render();
6553 GestureReceivedFunctor functor(data);
6555 PanGestureDetector detector = PanGestureDetector::New();
6556 detector.Attach(actor);
6557 detector.DetectedSignal().Connect(&application, functor);
6559 // Tap first to get the focus.
6560 TestGenerateTap(application, 3.0f, 25.0f, 100);
6562 // Render and notify
6563 application.SendNotification();
6564 application.Render();
6566 // Pan the text editor
6567 uint32_t time = 100;
6568 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6569 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6570 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6571 application.SendNotification();
6572 application.Render();
6574 // The text scrolls because there is text that is scrolling.
6575 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6578 // Set the size large enough to prevent scrolling.
6579 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6581 // Render and notify
6582 application.SendNotification();
6583 application.Render();
6586 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6587 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6588 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6590 // Because scrolling is not possible, the pan gesture is propagated.
6591 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6597 int utcDaliTextEditorGetTextBoundingRectangle(void)
6599 ToolkitTestApplication application;
6600 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6602 TextEditor editor = TextEditor::New();
6603 DALI_TEST_CHECK(editor);
6605 application.GetScene().Add(editor);
6607 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6608 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6609 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6610 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6611 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6613 // Avoid a crash when core load gl resources.
6614 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6616 // Render and notify
6617 application.SendNotification();
6618 application.Render();
6620 unsigned int startIndex = 0;
6621 unsigned int endIndex = 15;
6623 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6624 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6626 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);