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;
1040 outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
1042 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1044 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1045 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1046 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1048 // Check the input outline property
1049 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1050 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1052 // Check the smooth scroll property
1053 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1054 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1055 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1057 // Check the smooth scroll duration property
1058 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1059 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1061 // Check the scroll bar property
1062 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1063 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1064 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1066 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1067 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1068 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1069 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1071 // Check the pixel size of font
1072 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1073 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1075 // Check placeholder text properties.
1076 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1077 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1079 // Check placeholder text's color property.
1080 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1081 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1083 // Check the enable selection property
1084 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1085 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1087 // Check the placeholder property with pixel size
1088 Property::Map placeholderPixelSizeMapSet;
1089 Property::Map placeholderPixelSizeMapGet;
1090 Property::Map placeholderFontstyleMap;
1091 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1092 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1093 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1094 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1095 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1097 placeholderFontstyleMap.Insert("weight", "bold");
1098 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1099 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1101 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1102 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1104 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1105 Property::Map placeholderConversionMap;
1106 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1107 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1108 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1109 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1110 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1111 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1113 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1115 // Check the placeholder property with point size
1116 Property::Map placeholderMapSet;
1117 Property::Map placeholderMapGet;
1118 placeholderMapSet["text"] = "Setting Placeholder Text";
1119 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1120 placeholderMapSet["color"] = Color::RED;
1121 placeholderMapSet["fontFamily"] = "Arial";
1122 placeholderMapSet["pointSize"] = 12.0f;
1123 // Check the placeholder font style property
1124 placeholderFontstyleMap.Clear();
1126 placeholderFontstyleMap.Insert("weight", "bold");
1127 placeholderFontstyleMap.Insert("width", "condensed");
1128 placeholderFontstyleMap.Insert("slant", "italic");
1129 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1130 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1132 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1133 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1135 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1136 placeholderConversionMap.Clear();
1137 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1138 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1139 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1140 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1141 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1142 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1143 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1145 // Reset font style.
1146 placeholderFontstyleMap.Clear();
1147 placeholderFontstyleMap.Insert("weight", "normal");
1148 placeholderFontstyleMap.Insert("slant", "oblique");
1149 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1150 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1152 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1153 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1154 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1155 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1157 placeholderFontstyleMap.Clear();
1158 placeholderFontstyleMap.Insert("slant", "roman");
1159 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1160 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1162 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1164 placeholderFontstyleMap.Clear();
1165 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1167 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1168 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1169 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1170 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1171 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1173 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1174 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1176 // Check handle color
1177 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1178 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1180 // Test the ENABLE_GRAB_HANDLE_POPUP property
1181 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1182 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1184 // Check the input method setting
1185 Property::Map propertyMap;
1186 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1187 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1188 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1189 int inputVariation = 1;
1190 propertyMap["PANEL_LAYOUT"] = panelLayout;
1191 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1192 propertyMap["BUTTON_ACTION"] = buttonAction;
1193 propertyMap["VARIATION"] = inputVariation;
1194 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1196 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1198 DALI_TEST_CHECK(value.Get(map));
1201 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1202 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1205 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1206 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1209 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1210 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1213 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1214 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1216 // Check the input filter property
1217 Property::Map inputFilterMapSet;
1218 Property::Map inputFilterMapGet;
1219 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1220 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1222 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1224 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1225 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1228 inputFilterMapSet.Clear();
1229 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1231 // Check the strikethrough property
1233 Property::Map strikethroughMapSet;
1234 Property::Map strikethroughMapGet;
1236 application.SendNotification();
1237 application.Render();
1239 // Check the input strikethrough property
1241 strikethroughMapSet.Clear();
1242 strikethroughMapGet.Clear();
1243 strikethroughMapSet.Insert("enable", true);
1244 strikethroughMapSet.Insert("color", Color::BLUE);
1245 strikethroughMapSet.Insert("height", 2.0f);
1247 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1249 application.SendNotification();
1250 application.Render();
1252 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1254 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1255 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1257 // Check the input strikethrough property
1258 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1259 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1261 application.SendNotification();
1262 application.Render();
1264 // Check the line size property
1265 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1266 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1267 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1272 // Positive Atlas Text Renderer test
1273 int utcDaliTextEditorAtlasRenderP(void)
1275 ToolkitTestApplication application;
1276 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1277 StyleManager styleManager = StyleManager::Get();
1278 styleManager.ApplyDefaultTheme();
1279 TextEditor editor = TextEditor::New();
1280 DALI_TEST_CHECK(editor);
1282 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1284 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1286 application.GetScene().Add(editor);
1290 // Render some text with the shared atlas backend
1291 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1292 application.SendNotification();
1293 application.Render();
1297 tet_result(TET_FAIL);
1302 // Positive test for the anchorClicked signal.
1303 int utcDaliTextEditorAnchorClickedP(void)
1305 ToolkitTestApplication application;
1306 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1307 TextEditor editor = TextEditor::New();
1308 DALI_TEST_CHECK(editor);
1310 application.GetScene().Add(editor);
1312 // connect to the anchor clicked signal.
1313 ConnectionTracker* testTracker = new ConnectionTracker();
1314 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1315 bool anchorClickedSignal = false;
1316 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1318 gAnchorClickedCallBackCalled = false;
1319 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1320 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1321 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1322 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1323 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1325 application.SendNotification();
1326 application.Render();
1327 editor.SetKeyInputFocus();
1329 // Create a tap event to touch the text editor.
1330 TestGenerateTap(application, 5.0f, 5.0f);
1331 application.SendNotification();
1332 application.Render();
1334 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1335 DALI_TEST_CHECK(anchorClickedSignal);
1337 gAnchorClickedCallBackNotCalled = true;
1338 // Tap the outside of anchor, callback should not be called.
1339 TestGenerateTap(application, 150.f, 100.f);
1340 application.SendNotification();
1341 application.Render();
1343 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1348 // Positive test for the textChanged signal.
1349 int utcDaliTextEditorTextChangedP(void)
1351 ToolkitTestApplication application;
1352 tet_infoline(" utcDaliTextEditorTextChangedP");
1353 TextEditor editor = TextEditor::New();
1354 DALI_TEST_CHECK(editor);
1356 application.GetScene().Add(editor);
1358 // connect to the text changed signal.
1359 ConnectionTracker* testTracker = new ConnectionTracker();
1360 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1361 bool textChangedSignal = false;
1362 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1364 gTextChangedCallBackCalled = false;
1365 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1366 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1367 DALI_TEST_CHECK(textChangedSignal);
1369 application.SendNotification();
1370 editor.SetKeyInputFocus();
1372 gTextChangedCallBackCalled = false;
1373 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1374 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1377 editor.SetProperty(TextField::Property::TEXT, "");
1379 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1380 gTextChangedCallBackCalled = false;
1381 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1382 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1384 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1385 gTextChangedCallBackCalled = false;
1386 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1387 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1392 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1394 ToolkitTestApplication application;
1395 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1396 TextEditor editor = TextEditor::New();
1397 DALI_TEST_CHECK(editor);
1399 application.GetScene().Add(editor);
1401 // connect to the text changed signal.
1402 ConnectionTracker* testTracker = new ConnectionTracker();
1403 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1404 bool textChangedSignal = false;
1405 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1407 // get InputMethodContext
1409 InputMethodContext::EventData imfEvent;
1410 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1412 editor.SetKeyInputFocus();
1413 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1416 gTextChangedCallBackCalled = false;
1417 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1418 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1419 application.SendNotification();
1420 application.Render();
1421 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1422 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1424 gTextChangedCallBackCalled = false;
1425 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1426 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1427 application.SendNotification();
1428 application.Render();
1429 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1430 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1432 gTextChangedCallBackCalled = false;
1433 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1434 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1435 application.SendNotification();
1436 application.Render();
1437 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1438 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1440 gTextChangedCallBackCalled = false;
1441 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1442 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1443 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1445 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1446 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1447 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1449 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1450 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1451 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1453 application.SendNotification();
1454 application.Render();
1455 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1456 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1461 int utcDaliTextEditorInputStyleChanged01(void)
1463 // The text-editor emits signals when the input style changes. These changes of style are
1464 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1465 // can't be emitted during the size negotiation as the callbacks may update the UI.
1466 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1467 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1468 ToolkitTestApplication application;
1469 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1473 char* pathNamePtr = get_current_dir_name();
1474 const std::string pathName(pathNamePtr);
1477 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1478 fontClient.SetDpi(93u, 93u);
1480 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1481 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1483 TextEditor editor = TextEditor::New();
1484 DALI_TEST_CHECK(editor);
1486 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1487 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1488 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1490 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1491 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1493 // connect to the text changed signal.
1494 ConnectionTracker* testTracker = new ConnectionTracker();
1495 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1496 bool inputStyleChangedSignal = false;
1497 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1499 application.GetScene().Add(editor);
1501 // Render and notify
1502 application.SendNotification();
1503 application.Render();
1505 // Executes the idle callbacks added by the text control on the change of input style.
1506 application.RunIdles();
1508 gInputStyleChangedCallbackCalled = false;
1509 gInputStyleMask = TextEditor::InputStyle::NONE;
1510 inputStyleChangedSignal = false;
1512 // Create a tap event to touch the text editor.
1513 TestGenerateTap(application, 18.0f, 25.0f);
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 // Executes the idle callbacks added by the text control on the change of input style.
1520 application.RunIdles();
1522 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1523 if(gInputStyleChangedCallbackCalled)
1525 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1527 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1528 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1530 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1531 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1533 DALI_TEST_CHECK(inputStyleChangedSignal);
1535 gInputStyleChangedCallbackCalled = false;
1536 gInputStyleMask = TextEditor::InputStyle::NONE;
1537 inputStyleChangedSignal = false;
1539 // Create a tap event to touch the text editor.
1540 TestGenerateTap(application, 30.0f, 25.0f);
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Executes the idle callbacks added by the text control on the change of input style.
1547 application.RunIdles();
1549 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1550 DALI_TEST_CHECK(!inputStyleChangedSignal);
1552 gInputStyleChangedCallbackCalled = false;
1553 gInputStyleMask = TextEditor::InputStyle::NONE;
1554 inputStyleChangedSignal = false;
1556 // Create a tap event to touch the text editor.
1557 TestGenerateTap(application, 43.0f, 25.0f);
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Executes the idle callbacks added by the text control on the change of input style.
1564 application.RunIdles();
1566 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1567 if(gInputStyleChangedCallbackCalled)
1569 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1571 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1572 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1574 DALI_TEST_CHECK(inputStyleChangedSignal);
1576 gInputStyleChangedCallbackCalled = false;
1577 gInputStyleMask = TextEditor::InputStyle::NONE;
1578 inputStyleChangedSignal = false;
1580 // Create a tap event to touch the text editor.
1581 TestGenerateTap(application, 88.0f, 25.0f);
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Executes the idle callbacks added by the text control on the change of input style.
1588 application.RunIdles();
1590 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1591 if(gInputStyleChangedCallbackCalled)
1593 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1595 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1596 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1598 Property::Map fontStyleMapSet;
1599 Property::Map fontStyleMapGet;
1601 fontStyleMapSet.Insert("weight", "bold");
1603 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1604 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1605 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1607 DALI_TEST_CHECK(inputStyleChangedSignal);
1609 gInputStyleChangedCallbackCalled = false;
1610 gInputStyleMask = TextEditor::InputStyle::NONE;
1611 inputStyleChangedSignal = false;
1613 // Create a tap event to touch the text editor.
1614 TestGenerateTap(application, 115.0f, 25.0f);
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Executes the idle callbacks added by the text control on the change of input style.
1621 application.RunIdles();
1623 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1624 DALI_TEST_CHECK(!inputStyleChangedSignal);
1626 gInputStyleChangedCallbackCalled = false;
1627 gInputStyleMask = TextEditor::InputStyle::NONE;
1628 inputStyleChangedSignal = false;
1630 // Create a tap event to touch the text editor.
1631 TestGenerateTap(application, 164.0f, 25.0f);
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Executes the idle callbacks added by the text control on the change of input style.
1638 application.RunIdles();
1640 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1641 if(gInputStyleChangedCallbackCalled)
1643 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1645 Property::Map fontStyleMapSet;
1646 Property::Map fontStyleMapGet;
1648 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1649 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1650 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1652 DALI_TEST_CHECK(inputStyleChangedSignal);
1654 gInputStyleChangedCallbackCalled = false;
1655 gInputStyleMask = TextEditor::InputStyle::NONE;
1656 inputStyleChangedSignal = false;
1658 // Create a tap event to touch the text editor.
1659 TestGenerateTap(application, 191.0f, 25.0f);
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 // Executes the idle callbacks added by the text control on the change of input style.
1666 application.RunIdles();
1668 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1669 DALI_TEST_CHECK(!inputStyleChangedSignal);
1674 int utcDaliTextEditorInputStyleChanged02(void)
1676 // The text-editor emits signals when the input style changes. These changes of style are
1677 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1678 // can't be emitted during the size negotiation as the callbacks may update the UI.
1679 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1680 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1681 ToolkitTestApplication application;
1682 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1686 char* pathNamePtr = get_current_dir_name();
1687 const std::string pathName(pathNamePtr);
1690 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1691 fontClient.SetDpi(93u, 93u);
1693 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1694 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1696 TextEditor editor = TextEditor::New();
1697 DALI_TEST_CHECK(editor);
1699 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1700 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1701 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1703 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1704 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>");
1706 // connect to the text changed signal.
1707 ConnectionTracker* testTracker = new ConnectionTracker();
1708 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1709 bool inputStyleChangedSignal = false;
1710 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1712 application.GetScene().Add(editor);
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Executes the idle callbacks added by the text control on the change of input style.
1719 application.RunIdles();
1721 gInputStyleChangedCallbackCalled = false;
1722 gInputStyleMask = TextEditor::InputStyle::NONE;
1723 inputStyleChangedSignal = false;
1725 // Create a tap event to touch the text editor.
1726 TestGenerateTap(application, 53.0f, 25.0f, 100);
1727 TestGenerateTap(application, 53.0f, 25.0f, 200);
1729 // Render and notify
1730 application.SendNotification();
1731 application.Render();
1733 // Executes the idle callbacks added by the text control on the change of input style.
1734 application.RunIdles();
1736 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1737 if(gInputStyleChangedCallbackCalled)
1739 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1740 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1741 TextEditor::InputStyle::POINT_SIZE |
1742 TextEditor::InputStyle::COLOR),
1745 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1746 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1748 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1749 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1751 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1752 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1754 DALI_TEST_CHECK(inputStyleChangedSignal);
1756 gInputStyleChangedCallbackCalled = false;
1757 gInputStyleMask = TextEditor::InputStyle::NONE;
1758 inputStyleChangedSignal = false;
1760 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 // Executes the idle callbacks added by the text control on the change of input style.
1767 application.RunIdles();
1769 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1770 if(gInputStyleChangedCallbackCalled)
1772 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1773 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1776 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1777 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1779 DALI_TEST_CHECK(inputStyleChangedSignal);
1781 gInputStyleChangedCallbackCalled = false;
1782 gInputStyleMask = TextEditor::InputStyle::NONE;
1783 inputStyleChangedSignal = false;
1785 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 // Executes the idle callbacks added by the text control on the change of input style.
1792 application.RunIdles();
1794 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1795 DALI_TEST_CHECK(!inputStyleChangedSignal);
1797 gInputStyleChangedCallbackCalled = false;
1798 gInputStyleMask = TextEditor::InputStyle::NONE;
1799 inputStyleChangedSignal = false;
1801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // Executes the idle callbacks added by the text control on the change of input style.
1808 application.RunIdles();
1810 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1811 if(gInputStyleChangedCallbackCalled)
1813 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1814 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1817 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1818 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1820 DALI_TEST_CHECK(inputStyleChangedSignal);
1822 gInputStyleChangedCallbackCalled = false;
1823 gInputStyleMask = TextEditor::InputStyle::NONE;
1824 inputStyleChangedSignal = false;
1826 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1828 Property::Map fontStyleMapSet;
1829 fontStyleMapSet.Insert("weight", "thin");
1830 fontStyleMapSet.Insert("width", "condensed");
1831 fontStyleMapSet.Insert("slant", "italic");
1833 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1834 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1835 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1837 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1838 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1839 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1840 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1841 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1843 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Executes the idle callbacks added by the text control on the change of input style.
1850 application.RunIdles();
1852 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1853 DALI_TEST_CHECK(!inputStyleChangedSignal);
1855 // Create a tap event to touch the text editor.
1856 TestGenerateTap(application, 63.0f, 25.0f, 900);
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 // Executes the idle callbacks added by the text control on the change of input style.
1863 application.RunIdles();
1865 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1866 if(gInputStyleChangedCallbackCalled)
1868 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1869 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1870 TextEditor::InputStyle::POINT_SIZE |
1871 TextEditor::InputStyle::FONT_STYLE |
1872 TextEditor::InputStyle::LINE_SPACING |
1873 TextEditor::InputStyle::UNDERLINE |
1874 TextEditor::InputStyle::SHADOW |
1875 TextEditor::InputStyle::EMBOSS |
1876 TextEditor::InputStyle::OUTLINE),
1879 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1880 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1882 DALI_TEST_CHECK(inputStyleChangedSignal);
1884 gInputStyleChangedCallbackCalled = false;
1885 gInputStyleMask = TextEditor::InputStyle::NONE;
1886 inputStyleChangedSignal = false;
1888 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1890 fontStyleMapSet.Clear();
1891 fontStyleMapSet.Insert("weight", "black");
1892 fontStyleMapSet.Insert("width", "expanded");
1893 fontStyleMapSet.Insert("slant", "oblique");
1895 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1897 // Create a tap event to touch the text editor.
1898 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 // Executes the idle callbacks added by the text control on the change of input style.
1905 application.RunIdles();
1907 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1908 if(gInputStyleChangedCallbackCalled)
1910 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1911 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1912 TextEditor::InputStyle::POINT_SIZE |
1913 TextEditor::InputStyle::FONT_STYLE),
1916 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1917 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1919 DALI_TEST_CHECK(inputStyleChangedSignal);
1924 int utcDaliTextEditorInputStyleChanged03(void)
1926 // Test InputStyleCahnged signal emitted even if AddIdle failed.
1927 ToolkitTestApplication application;
1928 tet_infoline(" utcDaliTextEditorInputStyleChanged03");
1932 char* pathNamePtr = get_current_dir_name();
1933 const std::string pathName(pathNamePtr);
1936 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1937 fontClient.SetDpi(93u, 93u);
1939 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1940 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1942 TextEditor editor = TextEditor::New();
1943 DALI_TEST_CHECK(editor);
1945 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1946 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1947 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1949 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1950 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1952 // connect to the text changed signal.
1953 ConnectionTracker* testTracker = new ConnectionTracker();
1954 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1955 bool inputStyleChangedSignal = false;
1956 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1958 application.GetScene().Add(editor);
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1964 // Executes the idle callbacks added by the text control on the change of input style.
1965 application.RunIdles();
1967 gInputStyleChangedCallbackCalled = false;
1968 gInputStyleMask = TextEditor::InputStyle::NONE;
1969 inputStyleChangedSignal = false;
1971 // Create a tap event to touch the text editor.
1972 TestGenerateTap(application, 18.0f, 25.0f);
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 // Executes the idle callbacks added by the text control on the change of input style.
1979 application.RunIdles();
1981 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1982 if(gInputStyleChangedCallbackCalled)
1984 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1986 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1987 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1989 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1990 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1992 DALI_TEST_CHECK(inputStyleChangedSignal);
1994 gInputStyleChangedCallbackCalled = false;
1995 gInputStyleMask = TextEditor::InputStyle::NONE;
1996 inputStyleChangedSignal = false;
1998 // Create a tap event to touch the text editor.
1999 TestGenerateTap(application, 30.0f, 25.0f);
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2005 // Executes the idle callbacks added by the text control on the change of input style.
2006 application.RunIdles();
2008 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2009 DALI_TEST_CHECK(!inputStyleChangedSignal);
2011 gInputStyleChangedCallbackCalled = false;
2012 gInputStyleMask = TextEditor::InputStyle::NONE;
2013 inputStyleChangedSignal = false;
2015 // Create a tap event to touch the text editor.
2016 TestGenerateTap(application, 43.0f, 25.0f);
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Executes the idle callbacks added by the text control on the change of input style.
2023 application.RunIdles();
2025 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2026 if(gInputStyleChangedCallbackCalled)
2028 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
2030 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
2031 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2033 DALI_TEST_CHECK(inputStyleChangedSignal);
2035 gInputStyleChangedCallbackCalled = false;
2036 gInputStyleMask = TextEditor::InputStyle::NONE;
2037 inputStyleChangedSignal = false;
2039 // Make AddIdle return false.
2040 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2042 // Create a tap event to touch the text editor.
2043 TestGenerateTap(application, 88.0f, 25.0f);
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Execute the idle callbacks.
2050 // And check whether we didn't change of input style.
2051 application.RunIdles();
2053 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2054 DALI_TEST_CHECK(!inputStyleChangedSignal);
2056 gInputStyleChangedCallbackCalled = false;
2057 gInputStyleMask = TextEditor::InputStyle::NONE;
2058 inputStyleChangedSignal = false;
2060 // Create a tap event to touch the text editor.
2061 TestGenerateTap(application, 115.0f, 25.0f);
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 // Execute the idle callbacks.
2068 // And check whether we didn't change of input style.
2069 application.RunIdles();
2071 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2072 DALI_TEST_CHECK(!inputStyleChangedSignal);
2074 gInputStyleChangedCallbackCalled = false;
2075 gInputStyleMask = TextEditor::InputStyle::NONE;
2076 inputStyleChangedSignal = false;
2078 // Revert AddIdle return true.
2079 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2081 // Create a tap event to touch the text editor.
2082 TestGenerateTap(application, 164.0f, 25.0f);
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 // Executes the idle callbacks added by the text control on the change of input style.
2089 application.RunIdles();
2091 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2092 if(gInputStyleChangedCallbackCalled)
2094 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
2096 Property::Map fontStyleMapSet;
2097 Property::Map fontStyleMapGet;
2099 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
2100 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2101 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2103 DALI_TEST_CHECK(inputStyleChangedSignal);
2105 gInputStyleChangedCallbackCalled = false;
2106 gInputStyleMask = TextEditor::InputStyle::NONE;
2107 inputStyleChangedSignal = false;
2109 // Create a tap event to touch the text editor.
2110 TestGenerateTap(application, 191.0f, 25.0f);
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Executes the idle callbacks added by the text control on the change of input style.
2117 application.RunIdles();
2119 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2120 DALI_TEST_CHECK(!inputStyleChangedSignal);
2125 int utcDaliTextEditorEvent01(void)
2127 ToolkitTestApplication application;
2128 tet_infoline(" utcDaliTextEditorEvent01");
2130 // Creates a tap event. After creating a tap event the text editor should
2131 // have the focus and add text with key events should be possible.
2133 TextEditor editor = TextEditor::New();
2134 DALI_TEST_CHECK(editor);
2136 application.GetScene().Add(editor);
2138 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2139 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2140 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2142 // Avoid a crash when core load gl resources.
2143 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 // Add a key event but as the text editor has not the focus it should do nothing.
2150 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2152 // Render and notify
2153 application.SendNotification();
2154 application.Render();
2156 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
2158 // Create a tap event to touch the text editor.
2159 TestGenerateTap(application, 150.0f, 25.0f);
2161 // Render and notify
2162 application.SendNotification();
2163 application.Render();
2165 // Now the text editor has the focus, so it can handle the key events.
2166 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2167 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2175 // Create a second text editor and send key events to it.
2176 TextEditor editor2 = TextEditor::New();
2178 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2179 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2180 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2181 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
2183 application.GetScene().Add(editor2);
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2189 // Create a tap event on the second text editor.
2190 TestGenerateTap(application, 150.0f, 125.0f);
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // The second text editor has the focus. It should handle the key events.
2197 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2198 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2200 // Render and notify
2201 application.SendNotification();
2202 application.Render();
2204 // Check the text has been added to the second text editor.
2205 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2210 int utcDaliTextEditorEvent02(void)
2212 ToolkitTestApplication application;
2213 tet_infoline(" utcDaliTextEditorEvent02");
2215 // Checks if the right number of actors are created.
2217 TextEditor editor = TextEditor::New();
2218 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2219 DALI_TEST_CHECK(editor);
2221 application.GetScene().Add(editor);
2223 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2224 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2225 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2227 // Avoid a crash when core load gl resources.
2228 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2234 // Check there are the expected number of children (the stencil).
2235 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2237 Actor stencil = editor.GetChildAt(0u);
2239 // Create a tap event to touch the text editor.
2240 TestGenerateTap(application, 150.0f, 25.0f, 100);
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 Actor layer = editor.GetChildAt(2u);
2247 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2248 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2250 // Now the text editor has the focus, so it can handle the key events.
2251 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2252 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Checks the cursor and the renderer have been created.
2259 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2260 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2262 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2263 DALI_TEST_CHECK(cursor);
2265 // The stencil actor has a container with all the actors which contain the text renderers.
2266 Actor container = stencil.GetChildAt(0u);
2267 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2269 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2270 DALI_TEST_CHECK(renderer);
2273 // Move the cursor and check the position changes.
2274 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2277 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2285 DALI_TEST_CHECK(position2.x < position1.x);
2287 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2288 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2290 // Render and notify
2291 application.SendNotification();
2292 application.Render();
2294 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2296 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2298 // Send some taps and check the cursor positions.
2300 // Try to tap at the beginning.
2301 TestGenerateTap(application, 1.0f, 25.0f, 700);
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 // Cursor position should be the same than position1.
2308 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2310 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2312 // Tap away from the start position.
2313 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2321 DALI_TEST_CHECK(position5.x > position4.x);
2323 // Remove all the text.
2324 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2325 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2326 editor.SetProperty(TextEditor::Property::TEXT, "");
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Cursor position should be the same than position2.
2333 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2335 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2337 // Should not be a renderer, there is only a clipped cursor.
2338 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2343 int utcDaliTextEditorEvent03(void)
2345 ToolkitTestApplication application;
2346 tet_infoline(" utcDaliTextEditorEvent03");
2348 // Checks if the highlight actor is created.
2350 TextEditor editor = TextEditor::New();
2351 DALI_TEST_CHECK(editor);
2353 application.GetScene().Add(editor);
2355 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2356 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2357 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2358 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2359 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2361 // Avoid a crash when core load gl resources.
2362 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2368 // Send some taps and check text controller with clipboard window
2369 Dali::Clipboard clipboard = Clipboard::Get();
2370 clipboard.ShowClipboard();
2371 TestGenerateTap(application, 3.0f, 25.0f, 100);
2372 clipboard.HideClipboard();
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 // Tap first to get the focus.
2379 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 // Double tap to select a word.
2386 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2388 // Render and notify
2389 application.SendNotification();
2390 application.Render();
2392 // The stencil actor should have two actors: the renderer and the highlight actor.
2393 Actor stencil = editor.GetChildAt(0u);
2395 // Highlight needs to be drawn before text, so should come first in child order
2396 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2397 DALI_TEST_CHECK(highlight);
2399 // The stencil actor has a container with all the actors which contain the text renderers.
2400 Actor container = stencil.GetChildAt(1u);
2401 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2403 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2404 DALI_TEST_CHECK(renderer);
2407 // Double tap out of bounds
2408 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2409 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // The stencil actor should have one actors: the renderer actor.
2416 stencil = editor.GetChildAt(0u);
2418 // The stencil actor has a container with all the actors which contain the text renderers.
2419 container = stencil.GetChildAt(0u);
2420 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2422 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2423 DALI_TEST_CHECK(renderer);
2427 TestGenerateLongPress(application, 1.0f, 25.0f);
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2434 TestGenerateMiniPan(application);
2436 // Render and notify
2437 application.SendNotification();
2438 application.Render();
2443 int utcDaliTextEditorEvent04(void)
2445 ToolkitTestApplication application;
2446 tet_infoline(" utcDaliTextEditorEvent04");
2448 // Checks if the highlight actor is created.
2450 TextEditor editor = TextEditor::New();
2451 DALI_TEST_CHECK(editor);
2453 application.GetScene().Add(editor);
2455 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2456 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2457 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2458 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2459 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2461 // Avoid a crash when core load gl resources.
2462 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // Tap on the text editor
2469 TestGenerateTap(application, 3.0f, 25.0f);
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 // Move at the end of the text.
2476 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2477 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 for(unsigned int index = 0u; index < 10u; ++index)
2485 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2486 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2488 // Render and notify
2489 application.SendNotification();
2490 application.Render();
2494 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2502 // Add some key events
2503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2504 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 for(unsigned int index = 0u; index < 10u; ++index)
2512 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2513 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2521 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2532 int utcDaliTextEditorEvent05(void)
2534 ToolkitTestApplication application;
2535 tet_infoline(" utcDaliTextEditorEvent05");
2537 // Checks if the highlight actor is created.
2539 TextEditor editor = TextEditor::New();
2540 DALI_TEST_CHECK(editor);
2542 application.GetScene().Add(editor);
2544 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2545 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2546 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2547 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2548 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2549 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2550 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2551 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2552 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2553 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2555 // Avoid a crash when core load gl resources.
2556 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 // Tap on the text editor
2563 TestGenerateTap(application, 3.0f, 25.0f);
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 // Move at the end of the text.
2570 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 for(unsigned int index = 0u; index < 10u; ++index)
2580 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 // Modify duration after scroll is enabled
2587 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2589 // Continuous scroll left to increase coverage
2590 for(unsigned int index = 0u; index < 10u; ++index)
2592 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2594 // Render and notify
2595 application.SendNotification();
2596 application.Render();
2598 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2599 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2600 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2601 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2602 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2604 // Press Escape to increase coverage
2605 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2606 application.SendNotification();
2607 application.Render();
2609 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2614 int utcDaliTextEditorEvent06(void)
2616 ToolkitTestApplication application;
2617 tet_infoline(" utcDaliTextEditorEvent06");
2619 // Checks if the highlight actor is created.
2621 TextEditor editor = TextEditor::New();
2622 DALI_TEST_CHECK(editor);
2624 application.GetScene().Add(editor);
2626 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2627 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2628 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2629 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2630 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2632 // Avoid a crash when core load gl resources.
2633 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2639 // Tap on the text editor
2640 TestGenerateTap(application, 3.0f, 25.0f);
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2646 // Move to seconds line of the text.
2647 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2649 // Render and notify
2650 application.SendNotification();
2651 application.Render();
2653 float layoutHeight = editor.GetHeightForWidth(100.f);
2655 // Add another script characters ( glyph height is defferent )
2656 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2657 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2659 // Delete characters
2660 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2661 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2663 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2665 // Render and notify
2666 application.SendNotification();
2667 application.Render();
2669 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2672 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2673 application.SendNotification();
2674 application.Render();
2676 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2677 application.SendNotification();
2678 application.Render();
2680 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2681 application.SendNotification();
2682 application.Render();
2684 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2685 application.SendNotification();
2686 application.Render();
2688 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2689 application.SendNotification();
2690 application.Render();
2692 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2693 application.SendNotification();
2694 application.Render();
2696 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2697 application.SendNotification();
2698 application.Render();
2703 int utcDaliTextEditorEvent07(void)
2705 ToolkitTestApplication application;
2706 tet_infoline(" utcDaliTextEditorEvent07");
2708 // Checks if the highlight actor is created.
2710 TextEditor editor = TextEditor::New();
2711 DALI_TEST_CHECK(editor);
2713 application.GetScene().Add(editor);
2715 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2716 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2717 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2718 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2719 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2721 // Avoid a crash when core load gl resources.
2722 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2728 // Tap on the text editor
2729 TestGenerateTap(application, 3.0f, 25.0f);
2731 // Render and notify
2732 application.SendNotification();
2733 application.Render();
2735 // Move to second line of the text.
2736 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2738 // Render and notify
2739 application.SendNotification();
2740 application.Render();
2742 // Select some text in the right of the current cursor position
2743 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2746 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2748 // Render and notify
2749 application.SendNotification();
2750 application.Render();
2752 // Cut the selected text
2753 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2754 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));
2756 // Render and notify
2757 application.SendNotification();
2758 application.Render();
2760 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2762 // Select some text in the left of the current cursor position
2763 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2766 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2768 // Render and notify
2769 application.SendNotification();
2770 application.Render();
2772 // Copy the selected text
2773 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2774 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));
2776 // Render and notify
2777 application.SendNotification();
2778 application.Render();
2780 // Move the cursor to the third line
2781 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2782 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 // Paste the selected text at the current cursor position
2789 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2790 application.ProcessEvent(GenerateKey("v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2792 // Render and notify
2793 application.SendNotification();
2794 application.Render();
2796 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2798 // Disable Shift Selection
2799 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2801 // Test to select some text in the right of the current cursor position
2802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2805 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2807 // Render and notify
2808 application.SendNotification();
2809 application.Render();
2811 // Cut the selected text
2812 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2813 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));
2815 // Render and notify
2816 application.SendNotification();
2817 application.Render();
2819 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2820 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2822 // Test to select some text in the left of the current cursor position
2823 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2826 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 // Copy the selected text
2833 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2834 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));
2836 // Render and notify
2837 application.SendNotification();
2838 application.Render();
2840 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2841 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2844 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));
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 // replace text with "c"
2851 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2853 // Render and notify
2854 application.SendNotification();
2855 application.Render();
2858 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2861 DevelTextEditor::SelectWholeText(editor);
2863 // Render and notify
2864 application.SendNotification();
2865 application.Render();
2867 // Copy the selected text using logical keys
2868 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2871 // Render and notify
2872 application.SendNotification();
2873 application.Render();
2876 DevelTextEditor::SelectNone(editor);
2878 // Render and notify
2879 application.SendNotification();
2880 application.Render();
2882 // Paste the selected using logical keys
2883 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2884 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2887 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2889 // select all using logical keys
2890 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2891 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2893 // Render and notify
2894 application.SendNotification();
2895 application.Render();
2897 // cut text using logical keys
2898 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2899 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2901 // Render and notify
2902 application.SendNotification();
2903 application.Render();
2906 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2911 int utcDaliTextEditorEvent08(void)
2913 ToolkitTestApplication application;
2914 tet_infoline(" utcDaliTextEditorEvent08");
2916 // Checks if the highlight actor is released correctly.
2918 TextEditor editor = TextEditor::New();
2919 DALI_TEST_CHECK(editor);
2921 application.GetScene().Add(editor);
2923 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2924 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2925 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2926 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2927 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2929 // Avoid a crash when core load gl resources.
2930 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2932 // Render and notify
2933 application.SendNotification();
2934 application.Render();
2936 // Tap on the text editor
2937 TestGenerateTap(application, 3.0f, 25.0f);
2939 // Render and notify
2940 application.SendNotification();
2941 application.Render();
2943 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2944 // Test to select some text in the left of the current cursor position
2945 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2948 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2950 // Render and notify
2951 application.SendNotification();
2952 application.Render();
2954 // Test to the left selection handle position and the right selection handle position
2955 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2958 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2960 // Render and notify
2961 application.SendNotification();
2962 application.Render();
2964 // Test to select full text in the left of the current cursor position
2965 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2970 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2972 // Render and notify
2973 application.SendNotification();
2974 application.Render();
2976 // Test to release the current full text selection
2977 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2978 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2980 // Render and notify
2981 application.SendNotification();
2982 application.Render();
2984 // Test to move the current cursor position correctly
2985 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2987 // Render and notify
2988 application.SendNotification();
2989 application.Render();
2992 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2994 // Render and notify
2995 application.SendNotification();
2996 application.Render();
2998 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3000 // Test to select some text in the right of the current cursor position
3001 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3003 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3005 // Render and notify
3006 application.SendNotification();
3007 application.Render();
3009 // Test the cursor position with right arrow key
3010 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3017 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3019 // Render and notify
3020 application.SendNotification();
3021 application.Render();
3023 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3025 // Test to select some text in the left of the current cursor position
3026 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3030 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3032 // Render and notify
3033 application.SendNotification();
3034 application.Render();
3036 // Test the cursor position with left arrow key
3037 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3039 // Render and notify
3040 application.SendNotification();
3041 application.Render();
3044 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3046 // Render and notify
3047 application.SendNotification();
3048 application.Render();
3050 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3052 // Test to select some text in the right of the current cursor position
3053 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3056 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3058 // Render and notify
3059 application.SendNotification();
3060 application.Render();
3062 // Test the cursor position with left arrow key
3063 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3065 // Render and notify
3066 application.SendNotification();
3067 application.Render();
3070 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3072 // Render and notify
3073 application.SendNotification();
3074 application.Render();
3076 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3078 // Test to select some text in the left of the current cursor position
3079 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
3082 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3084 // Render and notify
3085 application.SendNotification();
3086 application.Render();
3088 // Test the cursor position with right arrow key
3089 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3091 // Render and notify
3092 application.SendNotification();
3093 application.Render();
3096 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3098 // Render and notify
3099 application.SendNotification();
3100 application.Render();
3102 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
3107 int utcDaliTextEditorHandles(void)
3109 ToolkitTestApplication application;
3110 tet_infoline(" utcDaliTextEditorHandles");
3112 TextEditor editor = TextEditor::New();
3113 DALI_TEST_CHECK(editor);
3115 application.GetScene().Add(editor);
3117 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
3118 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3119 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
3120 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
3122 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3123 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
3124 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3125 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
3127 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
3128 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3129 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3131 // Avoid a crash when core load gl resources.
3132 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3134 // Render and notify
3135 application.SendNotification();
3136 application.Render();
3138 // Tap first to get the focus.
3139 TestGenerateTap(application, 3.0f, 25.0f, 100);
3141 // Render and notify
3142 application.SendNotification();
3143 application.Render();
3145 // Tap to create the grab handle.
3146 TestGenerateTap(application, 3.0f, 25.0f, 700);
3148 // Render and notify
3149 application.SendNotification();
3150 application.Render();
3152 // Get the active layer where the text's decoration is added.
3153 Actor activeLayer = editor.GetChildAt(1u);
3155 // Get the handle's actor.
3156 Actor handle = activeLayer.GetChildAt(0u);
3157 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3159 // Render and notify
3160 application.SendNotification();
3161 application.Render();
3163 // Touch the grab handle to set it as pressed.
3164 Vector2 touchPos(10.0f, 50.0f);
3165 Dali::Integration::TouchEvent event;
3166 event = Dali::Integration::TouchEvent();
3167 event.AddPoint(GetPointDownInside(touchPos));
3168 application.ProcessEvent(event);
3170 // Render and notify
3171 application.SendNotification();
3172 application.Render();
3174 // Pan the grab handle
3175 uint32_t time = 100;
3176 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
3177 TestMovePan(application, Vector2(10.0f, 30.0f), time);
3178 TestEndPan(application, Vector2(10.0f, 50.0f), time);
3179 application.SendNotification();
3180 application.Render();
3182 // Release the grab handle.
3183 event = Dali::Integration::TouchEvent();
3184 event.AddPoint(GetPointUpInside(touchPos));
3185 application.ProcessEvent(event);
3187 // Render and notify
3188 application.SendNotification();
3189 application.Render();
3191 // Tap first to get the focus.
3192 TestGenerateTap(application, 3.0f, 25.0f, 1400);
3194 // Render and notify
3195 application.SendNotification();
3196 application.Render();
3198 // Double tap to select a word and create the selection handles.
3199 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3201 // Render and notify
3202 application.SendNotification();
3203 application.Render();
3205 touchPos = Vector2(10.0f, 50.0f);
3207 // Touch the left selection handle to set it as pressed.
3208 event = Dali::Integration::TouchEvent();
3209 event.AddPoint(GetPointDownInside(touchPos));
3210 application.ProcessEvent(event);
3212 // Render and notify
3213 application.SendNotification();
3214 application.Render();
3216 // Release the left selection handle.
3217 event = Dali::Integration::TouchEvent();
3218 event.AddPoint(GetPointUpInside(touchPos));
3219 application.ProcessEvent(event);
3221 // Render and notify
3222 application.SendNotification();
3223 application.Render();
3228 int utcDaliTextEditorUnderPropertyStringP(void)
3230 ToolkitTestApplication application;
3231 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3232 TextEditor editor = TextEditor::New();
3233 DALI_TEST_CHECK(editor);
3235 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3237 application.GetScene().Add(editor);
3239 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3240 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3242 tet_infoline("Set underline settings with a map");
3243 // Check the input underline property
3244 Property::Map underlineMapSet;
3245 Property::Map underlineMapGet;
3246 underlineMapSet.Insert("enable", true);
3247 underlineMapSet.Insert("color", Color::BLUE);
3248 underlineMapSet.Insert("height", 1);
3249 underlineMapSet.Insert("type", Text::Underline::SOLID);
3250 underlineMapSet.Insert("dashWidth", 2);
3251 underlineMapSet.Insert("dashGap", 1);
3253 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3254 editor.SetProperty(TextEditor::Property::TEXT, "text");
3255 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3256 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3257 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3259 application.SendNotification();
3260 application.Render();
3262 underlineMapSet.Clear();
3263 underlineMapGet.Clear();
3265 tet_infoline("Set dashed underline settings with a map");
3266 // Check the input underline property
3267 underlineMapSet.Clear();
3268 underlineMapGet.Clear();
3269 underlineMapSet.Insert("enable", true);
3270 underlineMapSet.Insert("color", Color::BLUE);
3271 underlineMapSet.Insert("height", 1);
3272 underlineMapSet.Insert("type", Text::Underline::DASHED);
3273 underlineMapSet.Insert("dashWidth", 5);
3274 underlineMapSet.Insert("dashGap", 3);
3276 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3277 editor.SetProperty(TextEditor::Property::TEXT, "text");
3278 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3279 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3280 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3282 // Check the input underline property
3283 underlineMapSet.Clear();
3284 underlineMapGet.Clear();
3285 underlineMapSet.Insert("enable", true);
3286 underlineMapSet.Insert("color", Color::BLUE);
3287 underlineMapSet.Insert("height", 1);
3288 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3289 underlineMapSet.Insert("dashWidth", 5);
3290 underlineMapSet.Insert("dashGap", 3);
3292 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3293 editor.SetProperty(TextEditor::Property::TEXT, "text");
3294 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3295 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3296 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3298 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3299 editor.SetProperty(TextEditor::Property::TEXT, "text");
3300 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3301 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3302 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3304 application.SendNotification();
3305 application.Render();
3307 underlineMapSet.Clear();
3308 underlineMapGet.Clear();
3310 tet_infoline("Set underline settings with a string");
3311 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3312 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3315 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3317 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3318 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3319 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3320 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3322 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3327 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3329 ToolkitTestApplication application;
3330 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3331 TextEditor editor = TextEditor::New();
3332 DALI_TEST_CHECK(editor);
3334 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3336 application.GetScene().Add(editor);
3338 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3339 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3341 tet_infoline("Set strikethrough settings with a map");
3342 // Check the input strikethrough property
3343 Property::Map strikethroughMapSet;
3344 Property::Map strikethroughMapGet;
3345 strikethroughMapSet.Insert("enable", true);
3346 strikethroughMapSet.Insert("color", Color::BLUE);
3347 strikethroughMapSet.Insert("height", 2.0f);
3349 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3350 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3351 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3352 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3354 tet_infoline("Set strikethrough settings with a string");
3355 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3356 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3359 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3361 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3362 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3363 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3364 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3366 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3371 int utcDaliTextEditorShadowPropertyStringP(void)
3373 ToolkitTestApplication application;
3374 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3376 TextEditor editor = TextEditor::New();
3378 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3380 application.GetScene().Add(editor);
3382 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3384 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3388 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3393 int utcDaliTextEditorFontStylePropertyStringP(void)
3395 ToolkitTestApplication application;
3396 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3398 TextEditor editor = TextEditor::New();
3400 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3402 application.GetScene().Add(editor);
3404 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3406 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3410 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3415 int utcDaliTextEditorGetPropertyLinecountP(void)
3417 ToolkitTestApplication application;
3419 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3423 TextEditor editor = TextEditor::New();
3424 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3425 editor.SetProperty(TextEditor::Property::TEXT,
3426 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3428 application.GetScene().Add(editor);
3430 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3431 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3432 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3434 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3435 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3436 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3441 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3443 ToolkitTestApplication application;
3444 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3446 TextEditor editor = TextEditor::New();
3447 DALI_TEST_CHECK(editor);
3449 application.GetScene().Add(editor);
3451 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3452 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3453 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3454 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3455 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3456 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3458 bool startedCalled = false;
3459 bool finishedCalled = false;
3461 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3462 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3464 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3466 // Render and notify
3467 application.SendNotification();
3468 application.Render();
3470 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3471 application.SendNotification();
3472 application.Render(6000);
3474 application.SendNotification();
3475 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3476 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3481 int UtcDaliToolkitTextEditorTextWrapMode(void)
3483 ToolkitTestApplication application;
3484 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3488 TextEditor editor = TextEditor::New();
3489 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3490 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3492 application.GetScene().Add(editor);
3494 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3495 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3497 application.SendNotification();
3498 application.Render();
3500 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3501 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3503 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3504 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3506 application.SendNotification();
3507 application.Render();
3509 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3510 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3512 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3513 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3515 application.SendNotification();
3516 application.Render();
3518 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3519 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3521 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3522 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3524 application.SendNotification();
3525 application.Render();
3527 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3528 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3533 int UtcDaliTextEditorSetPaddingProperty(void)
3535 ToolkitTestApplication application;
3536 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3538 TextEditor editor = TextEditor::New();
3539 DALI_TEST_CHECK(editor);
3540 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3541 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3542 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3543 application.GetScene().Add(editor);
3545 application.SendNotification();
3546 application.Render();
3548 Vector3 originalSize = editor.GetNaturalSize();
3550 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3552 application.SendNotification();
3553 application.Render();
3555 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3557 Vector3 paddingAddedSize = editor.GetNaturalSize();
3559 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3561 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3566 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3568 ToolkitTestApplication application;
3569 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3571 TextEditor editor = TextEditor::New();
3572 DALI_TEST_CHECK(editor);
3573 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3574 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3575 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3576 application.GetScene().Add(editor);
3578 application.SendNotification();
3579 application.Render();
3581 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3582 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3584 // Check the enable shift selection property
3585 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3586 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3588 application.SendNotification();
3589 application.Render();
3594 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3596 ToolkitTestApplication application;
3597 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3599 TextEditor editor = TextEditor::New();
3600 DALI_TEST_CHECK(editor);
3601 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3602 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3603 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3604 application.GetScene().Add(editor);
3606 application.SendNotification();
3607 application.Render();
3609 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3610 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3612 // Check the enable grab handle property
3613 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3614 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3616 application.SendNotification();
3617 application.Render();
3622 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3624 ToolkitTestApplication application;
3625 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3627 TextEditor editor = TextEditor::New();
3628 DALI_TEST_CHECK(editor);
3629 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3630 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3631 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3632 application.GetScene().Add(editor);
3634 application.SendNotification();
3635 application.Render();
3637 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3638 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3640 // Check the disable match system language direction property
3641 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3642 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3644 application.SendNotification();
3645 application.Render();
3650 int UtcDaliTextEditorGetInputMethodContext(void)
3652 ToolkitTestApplication application;
3653 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3655 TextEditor editor = TextEditor::New();
3656 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3661 int utcDaliTextEditorMaxCharactersReached(void)
3663 ToolkitTestApplication application;
3664 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3666 TextEditor editor = TextEditor::New();
3667 DALI_TEST_CHECK(editor);
3669 application.GetScene().Add(editor);
3671 const int maxNumberOfCharacters = 1;
3672 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3673 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3675 editor.SetKeyInputFocus();
3677 // connect to the text changed signal.
3678 ConnectionTracker* testTracker = new ConnectionTracker();
3679 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3680 bool maxLengthReachedSignal = false;
3681 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3683 gMaxCharactersCallBackCalled = false;
3685 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3686 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3688 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3689 DALI_TEST_CHECK(maxLengthReachedSignal);
3694 int utcDaliTextEditorInputFiltered(void)
3696 ToolkitTestApplication application;
3697 tet_infoline(" utcDaliTextEditorInputFiltered");
3698 TextEditor editor = TextEditor::New();
3699 DALI_TEST_CHECK(editor);
3701 application.GetScene().Add(editor);
3703 Property::Map inputFilter;
3705 // Only digit is accepted.
3706 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3708 // Set input filter to TextEditor.
3709 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3711 editor.SetKeyInputFocus();
3713 // connect to the input filtered signal.
3714 ConnectionTracker* testTracker = new ConnectionTracker();
3715 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3716 bool inputFilteredSignal = false;
3717 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3719 gInputFilteredAcceptedCallbackCalled = false;
3721 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3723 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3724 DALI_TEST_CHECK(inputFilteredSignal);
3726 // Word is rejected.
3727 inputFilter[InputFilter::Property::ACCEPTED] = "";
3728 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3730 // Set input filter to TextEditor.
3731 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3733 editor.SetKeyInputFocus();
3735 inputFilteredSignal = false;
3736 gInputFilteredRejectedCallbackCalled = false;
3738 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3740 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3741 DALI_TEST_CHECK(inputFilteredSignal);
3746 int UtcDaliTextEditorSelectWholeText(void)
3748 ToolkitTestApplication application;
3749 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3751 TextEditor textEditor = TextEditor::New();
3753 application.GetScene().Add(textEditor);
3755 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3756 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3757 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3759 // Avoid a crash when core load gl resources.
3760 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3762 application.SendNotification();
3763 application.Render();
3765 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3767 DevelTextEditor::SelectWholeText(textEditor);
3769 application.SendNotification();
3770 application.Render();
3772 // Nothing should have been selected. The number of children is still 1
3773 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3775 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3777 application.SendNotification();
3778 application.Render();
3780 DevelTextEditor::SelectWholeText(textEditor);
3782 application.SendNotification();
3783 application.Render();
3785 // Should be 2 children, the stencil and the layer
3786 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3788 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3789 Actor stencil = textEditor.GetChildAt(0u);
3791 // The highlight actor is drawn first, so is the first actor in the list
3792 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3793 DALI_TEST_CHECK(highlight);
3798 int UtcDaliTextEditorSelectText(void)
3800 ToolkitTestApplication application;
3801 tet_infoline(" UtcDaliTextEditorSelectText ");
3803 TextEditor textEditor = TextEditor::New();
3805 application.GetScene().Add(textEditor);
3807 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3808 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3809 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3811 // Avoid a crash when core load gl resources.
3812 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3814 application.SendNotification();
3815 application.Render();
3817 DevelTextEditor::SelectText(textEditor, 0, 5);
3819 application.SendNotification();
3820 application.Render();
3822 // Nothing is selected
3823 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3824 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3826 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3828 application.SendNotification();
3829 application.Render();
3831 DevelTextEditor::SelectText(textEditor, 0, 5);
3833 application.SendNotification();
3834 application.Render();
3836 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3837 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3839 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3840 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3842 // world is selected
3843 DevelTextEditor::SelectText(textEditor, 6, 11);
3845 application.SendNotification();
3846 application.Render();
3848 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3849 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3851 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3852 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3857 int UtcDaliTextEditorSelectNone(void)
3859 ToolkitTestApplication application;
3860 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3862 TextEditor textEditor = TextEditor::New();
3864 application.GetScene().Add(textEditor);
3866 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3867 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3868 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3870 // Avoid a crash when core load gl resources.
3871 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3873 application.SendNotification();
3874 application.Render();
3876 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3878 application.SendNotification();
3879 application.Render();
3881 // Nothing is selected
3882 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3883 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3885 DevelTextEditor::SelectWholeText(textEditor);
3887 application.SendNotification();
3888 application.Render();
3890 // whole text is selected
3891 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3892 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3894 DevelTextEditor::SelectNone(textEditor);
3896 application.SendNotification();
3897 application.Render();
3899 // Nothing is selected
3900 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3901 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3906 int UtcDaliTextEditorSelectRange(void)
3908 ToolkitTestApplication application;
3909 tet_infoline("utcDaliTextEditorSelectRange");
3911 TextEditor textEditor = TextEditor::New();
3912 DALI_TEST_CHECK(textEditor);
3914 application.GetScene().Add(textEditor);
3916 // Avoid a crash when core load gl resources.
3917 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3919 application.SendNotification();
3920 application.Render();
3922 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3924 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3925 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3927 // Hello is selected
3928 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3929 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3931 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3932 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3937 int UtcDaliTextEditorEnableEditing(void)
3939 ToolkitTestApplication application;
3940 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3942 TextEditor textEditor = TextEditor::New();
3944 application.GetScene().Add(textEditor);
3946 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3947 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3948 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3950 // Avoid a crash when core load gl resources.
3951 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3953 application.SendNotification();
3954 application.Render();
3956 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3957 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3959 textEditor.SetKeyInputFocus();
3960 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3961 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3963 // Render and notify
3964 application.SendNotification();
3965 application.Render();
3967 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3968 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3970 textEditor.SetKeyInputFocus();
3971 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3972 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3974 // Render and notify
3975 application.SendNotification();
3976 application.Render();
3978 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3979 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3981 // Check the user interaction enabled and for coverage
3982 DevelTextEditor::SelectWholeText(textEditor);
3984 // Render and notify
3985 application.SendNotification();
3986 application.Render();
3988 textEditor.SetKeyInputFocus();
3989 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3990 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3992 // Render and notify
3993 application.SendNotification();
3994 application.Render();
3996 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3997 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4002 int UtcDaliTextEditorScrolling(void)
4004 ToolkitTestApplication application;
4005 tet_infoline(" UtcDaliTextEditorScrolling ");
4007 TextEditor textEditor = TextEditor::New();
4008 DALI_TEST_CHECK(textEditor);
4010 application.GetScene().Add(textEditor);
4012 // Avoid a crash when core load gl resources.
4013 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4015 application.SendNotification();
4016 application.Render();
4018 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
4019 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
4020 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
4021 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
4023 application.SendNotification();
4024 application.Render();
4026 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4027 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4029 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
4031 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
4032 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4034 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
4036 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
4037 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4039 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
4040 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
4042 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4043 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
4048 int UtcDaliToolkitTextEditorFontSizeScale(void)
4050 ToolkitTestApplication application;
4051 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
4053 TextEditor textEditor = TextEditor::New();
4054 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
4055 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4056 Vector3 nonScaledSize = textEditor.GetNaturalSize();
4058 TextEditor textEditorScaled = TextEditor::New();
4059 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
4060 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4061 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4062 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
4064 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4066 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
4067 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
4068 nonScaledSize = textEditor.GetNaturalSize();
4070 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
4071 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
4072 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
4073 scaledSize = textEditorScaled.GetNaturalSize();
4075 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4080 int UtcDaliTextEditorPrimaryCursorPosition(void)
4082 ToolkitTestApplication application;
4083 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
4085 TextEditor textEditor = TextEditor::New();
4087 application.GetScene().Add(textEditor);
4089 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
4090 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4091 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4092 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4094 // Avoid a crash when core load gl resources.
4095 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4097 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4098 application.SendNotification();
4099 application.Render();
4100 textEditor.SetKeyInputFocus();
4102 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4104 // Render and notify
4105 application.SendNotification();
4106 application.Render();
4108 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4109 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4114 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
4116 ToolkitTestApplication application;
4117 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
4119 TextEditor textEditor = TextEditor::New();
4120 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
4121 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4122 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4123 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4124 application.GetScene().Add(textEditor);
4126 application.SendNotification();
4127 application.Render();
4130 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4131 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4133 textEditor.GetNaturalSize();
4135 // Create a tap event to touch the text editor.
4136 TestGenerateTap(application, 18.0f, 25.0f);
4138 application.SendNotification();
4139 application.Render();
4141 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4142 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
4147 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
4149 ToolkitTestApplication application;
4151 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
4153 int lineCountBefore = 0;
4154 int lineCountAfter = 0;
4156 // Create a text editor
4157 TextEditor textEditor = TextEditor::New();
4158 //Set very large font-size using point-size
4159 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4160 //Specify font-family
4161 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4163 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4164 //Set text longer than width of textEditor
4165 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4167 application.GetScene().Add(textEditor);
4169 application.SendNotification();
4170 application.Render();
4172 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
4173 //GetHeightForWidth is a retrieval method which should not modify object
4174 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4175 textEditor.GetHeightForWidth(200.f);
4177 //This is to simulate focus into text editor after calling GetHeightForWidth
4178 //Create a tap event to touch the text editor.
4179 TestGenerateTap(application, 18.0f, 25.0f);
4181 application.SendNotification();
4182 application.Render();
4184 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4186 //The LineCount must not be changed when calling GetHeightForWidth.
4187 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4192 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
4194 ToolkitTestApplication application;
4196 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
4198 int lineCountBefore = 0;
4199 int lineCountAfter = 0;
4201 // Create a text editor
4202 TextEditor textEditor = TextEditor::New();
4203 //Set very large font-size using point-size
4204 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4205 //Specify font-family
4206 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4208 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4209 //Set text longer than width of textEditor
4210 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4211 //Set line wrap mode Character
4212 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4214 application.GetScene().Add(textEditor);
4216 application.SendNotification();
4217 application.Render();
4219 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4220 //GetHeightForWidth is a retrieval method which should not modify object
4221 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4222 textEditor.GetHeightForWidth(200.f);
4224 //This is to simulate focus into text editor after calling GetHeightForWidth
4225 //Create a tap event to touch the text editor.
4226 TestGenerateTap(application, 18.0f, 25.0f);
4228 application.SendNotification();
4229 application.Render();
4231 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4233 //The LineCount must not be changed when calling GetHeightForWidth.
4234 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4239 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4241 ToolkitTestApplication application;
4243 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4245 int lineCountBefore = 0;
4246 int lineCountAfter = 0;
4248 // Create a text editor
4249 TextEditor textEditor = TextEditor::New();
4250 //Set very large font-size using point-size
4251 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4252 //Specify font-family
4253 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4255 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4256 //Set text longer than width of textEditor
4257 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4258 //Set line wrap mode Character
4259 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4261 application.GetScene().Add(textEditor);
4263 application.SendNotification();
4264 application.Render();
4266 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4268 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4269 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4271 // When the text changed, the Line-count should be updated according to new text.
4272 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4273 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4274 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4279 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4281 ToolkitTestApplication application;
4283 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4285 int lineCountBefore = 0;
4286 int lineCountAfter = 0;
4288 // Create a text editor
4289 TextEditor textEditor = TextEditor::New();
4290 //Set very large font-size using point-size
4291 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4292 //Specify font-family
4293 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4295 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4296 //Set text longer than width of textEditor
4297 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4299 application.GetScene().Add(textEditor);
4301 application.SendNotification();
4302 application.Render();
4304 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4305 //GetNaturalSize is a retrieval method which should not modify object
4306 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4307 textEditor.GetNaturalSize();
4309 //This is to simulate focus into text editor after calling GetNaturalSize
4310 //Create a tap event to touch the text editor.
4311 TestGenerateTap(application, 18.0f, 25.0f);
4313 application.SendNotification();
4314 application.Render();
4316 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4318 //The LineCount must not be changed when calling GetNaturalSize.
4319 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4324 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4326 ToolkitTestApplication application;
4328 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4330 int lineCountBefore = 0;
4331 int lineCountAfter = 0;
4333 // Create a text editor
4334 TextEditor textEditor = TextEditor::New();
4335 //Set very large font-size using point-size
4336 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4337 //Specify font-family
4338 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4340 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4341 //Set text longer than width of textEditor
4342 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4343 //Set line wrap mode Character
4344 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4346 application.GetScene().Add(textEditor);
4348 application.SendNotification();
4349 application.Render();
4351 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4352 //GetNaturalSize is a retrieval method which should not modify object
4353 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4354 textEditor.GetNaturalSize();
4356 //This is to simulate focus into text editor after calling GetNaturalSize
4357 //Create a tap event to touch the text editor.
4358 TestGenerateTap(application, 18.0f, 25.0f);
4360 application.SendNotification();
4361 application.Render();
4363 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4365 //The LineCount must not be changed when calling GetNaturalSize.
4366 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4371 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4373 ToolkitTestApplication application;
4374 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4376 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4377 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4378 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4380 // Create a text editor
4381 TextEditor textEditor = TextEditor::New();
4383 //Set size to avoid automatic eliding
4384 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4385 //Set very large font-size using point-size
4386 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4387 //Specify font-family
4388 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4389 //Set text to check if appear or not
4390 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4392 application.GetScene().Add(textEditor);
4394 application.SendNotification();
4395 application.Render();
4396 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4397 Vector3 naturalSize = textEditor.GetNaturalSize();
4399 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4400 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4405 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4407 ToolkitTestApplication application;
4408 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4410 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4411 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4412 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4414 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4415 // Create a text editor
4416 TextEditor textEditor = TextEditor::New();
4417 //Set size to avoid automatic eliding
4418 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4419 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4420 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4422 const int numberOfCases = 6;
4423 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4425 for(int index = 0; index < numberOfCases; index++)
4427 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4428 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4429 application.GetScene().Add(textEditor);
4430 application.SendNotification();
4431 application.Render();
4432 naturalSize = textEditor.GetNaturalSize();
4433 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4434 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4440 int UtcDaliTextEditorHyphenWrapMode(void)
4442 ToolkitTestApplication application;
4443 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4446 TextEditor textEditor = TextEditor::New();
4448 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4450 application.GetScene().Add(textEditor);
4451 application.SendNotification();
4452 application.Render();
4454 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4455 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4456 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4458 application.SendNotification();
4459 application.Render();
4461 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4467 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4469 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4470 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4471 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4473 application.SendNotification();
4474 application.Render();
4476 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4483 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4488 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4490 ToolkitTestApplication application;
4491 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4492 TextEditor textEditor = TextEditor::New();
4494 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4495 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4497 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4498 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4499 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4501 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4502 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4503 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4505 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4506 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4507 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4509 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4510 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4511 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4513 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4514 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4515 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4517 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4518 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4519 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4521 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4522 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4523 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4525 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4526 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4527 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4529 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4530 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4531 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4533 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4534 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4535 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4537 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4538 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4539 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4541 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4542 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4543 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4548 int UtcDaliTextEditorCopyText(void)
4550 ToolkitTestApplication application;
4551 tet_infoline(" UtcDaliTextEditorCopyText ");
4553 TextEditor textEditor = TextEditor::New();
4555 std::string selectedText = "";
4556 std::string copiedText = "";
4558 application.GetScene().Add(textEditor);
4560 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4561 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4562 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4564 // Avoid a crash when core load gl resources.
4565 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4567 application.SendNotification();
4568 application.Render();
4570 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4572 application.SendNotification();
4573 application.Render();
4575 // Hello is selected
4576 DevelTextEditor::SelectText(textEditor, 0, 5);
4578 application.SendNotification();
4579 application.Render();
4581 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4582 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4584 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4585 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4588 copiedText = DevelTextEditor::CopyText(textEditor);
4589 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4591 // world is selected
4592 DevelTextEditor::SelectText(textEditor, 6, 11);
4594 application.SendNotification();
4595 application.Render();
4597 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4598 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4600 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4601 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4604 copiedText = DevelTextEditor::CopyText(textEditor);
4605 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4607 // "lo wo" is selected
4608 DevelTextEditor::SelectText(textEditor, 3, 8);
4610 application.SendNotification();
4611 application.Render();
4613 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4614 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4616 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4617 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4619 // "lo wo" is copied
4620 copiedText = DevelTextEditor::CopyText(textEditor);
4621 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4626 int UtcDaliTextEditorCutText(void)
4628 ToolkitTestApplication application;
4629 tet_infoline(" UtcDaliTextEditorCutText ");
4631 TextEditor textEditor = TextEditor::New();
4633 std::string selectedText = "";
4635 application.GetScene().Add(textEditor);
4637 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4638 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4639 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4641 // Avoid a crash when core load gl resources.
4642 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4644 application.SendNotification();
4645 application.Render();
4647 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4649 application.SendNotification();
4650 application.Render();
4652 // Hello is selected
4653 DevelTextEditor::SelectText(textEditor, 0, 5);
4655 application.SendNotification();
4656 application.Render();
4658 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4659 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4661 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4662 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4665 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4667 application.SendNotification();
4668 application.Render();
4670 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4673 DevelTextEditor::SelectText(textEditor, 0, 2);
4675 application.SendNotification();
4676 application.Render();
4678 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4679 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4681 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4682 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4685 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4687 application.SendNotification();
4688 application.Render();
4690 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4692 // Test Cut from the middle
4695 DevelTextEditor::SelectText(textEditor, 1, 3);
4697 application.SendNotification();
4698 application.Render();
4700 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4701 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4703 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4704 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4707 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4709 application.SendNotification();
4710 application.Render();
4712 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4714 // Test Cut from the end
4717 DevelTextEditor::SelectText(textEditor, 1, 2);
4719 application.SendNotification();
4720 application.Render();
4722 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4723 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4725 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4726 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4729 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4731 application.SendNotification();
4732 application.Render();
4734 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4739 int UtcDaliTextEditorPasteText(void)
4741 ToolkitTestApplication application;
4742 tet_infoline(" UtcDaliTextEditorPasteText ");
4744 TextEditor editor = TextEditor::New();
4745 DALI_TEST_CHECK(editor);
4747 application.GetScene().Add(editor);
4749 std::string cutText = "";
4750 std::string copiedText = "";
4752 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4753 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4754 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4755 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4756 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4758 // Avoid a crash when core load gl resources.
4759 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4761 // Render and notify
4762 application.SendNotification();
4763 application.Render();
4765 // Tap on the text editor
4766 TestGenerateTap(application, 3.0f, 25.0f);
4768 // Render and notify
4769 application.SendNotification();
4770 application.Render();
4772 // Move to second line of the text.
4773 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4775 // Render and notify
4776 application.SendNotification();
4777 application.Render();
4779 // Select some text in the right of the current cursor position
4780 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
4783 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4785 // Render and notify
4786 application.SendNotification();
4787 application.Render();
4789 // Cut the selected text
4790 cutText = DevelTextEditor::CutText(editor);
4792 // Render and notify
4793 application.SendNotification();
4794 application.Render();
4796 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4797 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4799 // Select some text in the left of the current cursor position
4800 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
4803 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4805 // Render and notify
4806 application.SendNotification();
4807 application.Render();
4809 // Copy the selected text
4810 copiedText = DevelTextEditor::CopyText(editor);
4812 // Render and notify
4813 application.SendNotification();
4814 application.Render();
4816 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4817 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4819 // Move the cursor to the third line
4820 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4821 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4823 // Render and notify
4824 application.SendNotification();
4825 application.Render();
4827 // Paste the selected text at the current cursor position
4828 DevelTextEditor::PasteText(editor);
4830 // Render and notify
4831 application.SendNotification();
4832 application.Render();
4834 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4839 int UtcDaliTextEditorLineSpacing(void)
4841 ToolkitTestApplication application;
4842 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4844 TextEditor textEditor = TextEditor::New();
4845 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4846 application.GetScene().Add(textEditor);
4847 application.SendNotification();
4848 application.Render();
4850 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4851 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4853 Vector3 sizeBefore = textEditor.GetNaturalSize();
4855 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4857 //add 20 for each line 20 * 3
4858 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4863 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4865 //Only for test coverage
4866 ToolkitTestApplication application;
4867 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4869 TextEditor textEditor = TextEditor::New();
4870 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4871 application.GetScene().Add(textEditor);
4872 application.SendNotification();
4873 application.Render();
4875 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4876 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4878 application.SendNotification();
4879 application.Render();
4881 DevelTextEditor::SelectWholeText(textEditor);
4883 application.SendNotification();
4884 application.Render();
4886 DevelTextEditor::SelectNone(textEditor);
4887 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4889 application.SendNotification();
4890 application.Render();
4892 DevelTextEditor::SelectWholeText(textEditor);
4894 application.SendNotification();
4895 application.Render();
4897 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4902 int UtcDaliTextEditorMinLineSize(void)
4904 ToolkitTestApplication application;
4905 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4907 TextEditor textEditor = TextEditor::New();
4908 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4909 application.GetScene().Add(textEditor);
4910 application.SendNotification();
4911 application.Render();
4913 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4914 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4916 Vector3 sizeBefore = textEditor.GetNaturalSize();
4918 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4920 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4923 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4928 int utcDaliTextEditorCursorPositionChangedSignal(void)
4930 ToolkitTestApplication application;
4931 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4933 TextEditor editor = TextEditor::New();
4934 DALI_TEST_CHECK(editor);
4936 application.GetScene().Add(editor);
4938 // connect to the selection changed signal.
4939 ConnectionTracker* testTracker = new ConnectionTracker();
4940 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4941 bool cursorPositionChangedSignal = false;
4942 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4944 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4945 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4946 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4947 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4948 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4950 // Avoid a crash when core load gl resources.
4951 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4953 // Render and notify
4954 application.SendNotification();
4955 application.Render();
4957 editor.SetKeyInputFocus();
4959 // Tap on the text editor
4960 TestGenerateTap(application, 3.0f, 25.0f);
4962 // Render and notify
4963 application.SendNotification();
4964 application.Render();
4966 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4967 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4969 gCursorPositionChangedCallbackCalled = false;
4972 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4974 // Render and notify
4975 application.SendNotification();
4976 application.Render();
4978 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4979 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4981 gCursorPositionChangedCallbackCalled = false;
4984 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4986 // Render and notify
4987 application.SendNotification();
4988 application.Render();
4990 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4991 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4993 gCursorPositionChangedCallbackCalled = false;
4995 //delete one character
4996 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4998 // Render and notify
4999 application.SendNotification();
5000 application.Render();
5002 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5003 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
5005 gCursorPositionChangedCallbackCalled = false;
5007 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
5009 // Render and notify
5010 application.SendNotification();
5011 application.Render();
5013 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5014 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
5016 gCursorPositionChangedCallbackCalled = false;
5018 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5020 // Render and notify
5021 application.SendNotification();
5022 application.Render();
5024 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5025 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5030 int utcDaliTextEditorGeometryEllipsisStart(void)
5032 ToolkitTestApplication application;
5033 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
5035 TextEditor editor = TextEditor::New();
5036 DALI_TEST_CHECK(editor);
5038 application.GetScene().Add(editor);
5040 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5041 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5042 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5043 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5044 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5045 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5046 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5047 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5048 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5050 // Avoid a crash when core load gl resources.
5051 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5053 // Render and notify
5054 application.SendNotification();
5055 application.Render();
5057 unsigned int expectedCount = 2;
5058 unsigned int startIndex = 0;
5059 unsigned int endIndex = 24;
5061 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5062 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5064 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5065 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5067 Vector<Vector2> expectedSizes;
5068 Vector<Vector2> expectedPositions;
5070 expectedPositions.PushBack(Vector2(38, 0));
5071 expectedSizes.PushBack(Vector2(21, 25));
5073 expectedPositions.PushBack(Vector2(-1, 25));
5074 expectedSizes.PushBack(Vector2(53, 25));
5076 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5081 int utcDaliTextEditorGeometryEllipsisMiddle(void)
5083 ToolkitTestApplication application;
5084 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
5086 TextEditor editor = TextEditor::New();
5087 DALI_TEST_CHECK(editor);
5089 application.GetScene().Add(editor);
5091 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5092 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5093 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5094 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5095 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5096 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5097 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5098 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
5099 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5101 // Avoid a crash when core load gl resources.
5102 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5104 // Render and notify
5105 application.SendNotification();
5106 application.Render();
5108 unsigned int expectedCount = 2;
5109 unsigned int startIndex = 0;
5110 unsigned int endIndex = 24;
5112 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5113 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5115 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5116 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5118 Vector<Vector2> expectedSizes;
5119 Vector<Vector2> expectedPositions;
5121 expectedPositions.PushBack(Vector2(-1, 0));
5122 expectedSizes.PushBack(Vector2(26, 25));
5124 expectedPositions.PushBack(Vector2(-1, 25));
5125 expectedSizes.PushBack(Vector2(53, 25));
5127 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5132 int utcDaliTextEditorGeometryEllipsisEnd(void)
5134 ToolkitTestApplication application;
5135 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
5137 TextEditor editor = TextEditor::New();
5138 DALI_TEST_CHECK(editor);
5140 application.GetScene().Add(editor);
5142 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5143 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5144 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5145 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5146 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5147 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
5148 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
5149 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5150 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
5152 // Avoid a crash when core load gl resources.
5153 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5155 // Render and notify
5156 application.SendNotification();
5157 application.Render();
5159 unsigned int expectedCount = 2;
5160 unsigned int startIndex = 0;
5161 unsigned int endIndex = 24;
5163 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5164 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5166 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5167 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5169 Vector<Vector2> expectedSizes;
5170 Vector<Vector2> expectedPositions;
5172 expectedPositions.PushBack(Vector2(-1, 0));
5173 expectedSizes.PushBack(Vector2(60, 25));
5175 expectedPositions.PushBack(Vector2(-1, 25));
5176 expectedSizes.PushBack(Vector2(39, 25));
5178 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5183 int utcDaliTextEditorGeometryRTL(void)
5185 ToolkitTestApplication application;
5186 tet_infoline(" utcDaliTextEditorGeometryRTL");
5188 TextEditor editor = TextEditor::New();
5189 DALI_TEST_CHECK(editor);
5191 application.GetScene().Add(editor);
5193 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5194 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5195 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5196 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5197 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5198 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5200 // Avoid a crash when core load gl resources.
5201 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5203 // Render and notify
5204 application.SendNotification();
5205 application.Render();
5207 unsigned int expectedCount = 4;
5208 unsigned int startIndex = 3;
5209 unsigned int endIndex = 24;
5211 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5212 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5214 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5215 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5217 Vector<Vector2> expectedSizes;
5218 Vector<Vector2> expectedPositions;
5220 expectedPositions.PushBack(Vector2(25, 0));
5221 expectedSizes.PushBack(Vector2(34, 25));
5223 expectedPositions.PushBack(Vector2(-1, 25));
5224 expectedSizes.PushBack(Vector2(53, 25));
5226 expectedPositions.PushBack(Vector2(-1, 50));
5227 expectedSizes.PushBack(Vector2(60, 25));
5229 expectedPositions.PushBack(Vector2(63, 75));
5230 expectedSizes.PushBack(Vector2(37, 25));
5232 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5237 int utcDaliTextEditorGeometryGlyphMiddle(void)
5239 ToolkitTestApplication application;
5240 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5242 TextEditor editor = TextEditor::New();
5243 DALI_TEST_CHECK(editor);
5245 application.GetScene().Add(editor);
5247 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5248 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5249 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5250 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5251 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5252 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5254 // Avoid a crash when core load gl resources.
5255 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5257 // Render and notify
5258 application.SendNotification();
5259 application.Render();
5261 unsigned int expectedCount = 1;
5262 unsigned int startIndex = 1;
5263 unsigned int endIndex = 13;
5265 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5266 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5268 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5269 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5271 Vector<Vector2> expectedSizes;
5272 Vector<Vector2> expectedPositions;
5274 expectedPositions.PushBack(Vector2(6, 0));
5275 expectedSizes.PushBack(Vector2(125, 25));
5277 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5282 int utcDaliTextEditorGeometryOneGlyph(void)
5284 ToolkitTestApplication application;
5285 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5287 TextEditor label = TextEditor::New();
5288 DALI_TEST_CHECK(label);
5290 application.GetScene().Add(label);
5292 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5293 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5294 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5295 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5296 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5297 label.SetProperty(TextEditor::Property::TEXT, "H");
5299 // Avoid a crash when core load gl resources.
5300 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5302 // Render and notify
5303 application.SendNotification();
5304 application.Render();
5306 unsigned int expectedCount = 1;
5307 unsigned int startIndex = 0;
5308 unsigned int endIndex = 0;
5310 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5311 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5313 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5314 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5316 Vector<Vector2> expectedSizes;
5317 Vector<Vector2> expectedPositions;
5319 expectedPositions.PushBack(Vector2(-2, 0));
5320 expectedSizes.PushBack(Vector2(16, 25));
5322 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5327 int utcDaliTextEditorGeometryNullPtr(void)
5329 ToolkitTestApplication application;
5330 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5332 TextEditor editor = TextEditor::New();
5333 DALI_TEST_CHECK(editor);
5335 application.GetScene().Add(editor);
5337 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5338 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5339 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5340 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5341 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5342 editor.SetProperty(TextEditor::Property::TEXT, "");
5344 // Avoid a crash when core load gl resources.
5345 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5347 unsigned int expectedCount = 0;
5348 unsigned int startIndex = 0;
5349 unsigned int endIndex = 0;
5351 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5352 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5354 // Render and notify
5355 application.SendNotification();
5356 application.Render();
5358 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5359 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5364 int utcDaliTextEditorSelectionClearedSignal(void)
5366 ToolkitTestApplication application;
5367 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5369 TextEditor editor = TextEditor::New();
5370 DALI_TEST_CHECK(editor);
5372 application.GetScene().Add(editor);
5374 // connect to the selection changed signal.
5375 ConnectionTracker* testTracker = new ConnectionTracker();
5376 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5377 bool selectionClearedSignal = false;
5378 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5380 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5381 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5382 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5383 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5384 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5386 // Avoid a crash when core load gl resources.
5387 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5389 // Render and notify
5390 application.SendNotification();
5391 application.Render();
5393 // Tap on the text editor
5394 TestGenerateTap(application, 3.0f, 25.0f);
5396 // Render and notify
5397 application.SendNotification();
5398 application.Render();
5400 // Move to second line of the text & Select some text in the right of the current cursor position
5401 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5402 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5405 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5407 // Render and notify
5408 application.SendNotification();
5409 application.Render();
5411 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5413 // Render and notify
5414 application.SendNotification();
5415 application.Render();
5417 // Tap on the text editor
5418 TestGenerateTap(application, 3.0f, 25.0f);
5420 // Render and notify
5421 application.SendNotification();
5422 application.Render();
5424 gSelectionClearedCallbackCalled = false;
5426 // Move to second line of the text & select.
5427 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5428 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5431 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5433 // Render and notify
5434 application.SendNotification();
5435 application.Render();
5437 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5439 gSelectionClearedCallbackCalled = false;
5441 // Render and notify
5442 application.SendNotification();
5443 application.Render();
5445 // Move to second line of the text & select.
5446 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5447 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5449 // replace C with selected text
5450 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5452 // Render and notify
5453 application.SendNotification();
5454 application.Render();
5456 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5458 gSelectionClearedCallbackCalled = false;
5460 // Render and notify
5461 application.SendNotification();
5462 application.Render();
5464 DevelTextEditor::SelectText(editor, 1, 3);
5466 // Render and notify
5467 application.SendNotification();
5468 application.Render();
5470 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5472 // Render and notify
5473 application.SendNotification();
5474 application.Render();
5476 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5478 gSelectionClearedCallbackCalled = false;
5480 DevelTextEditor::SelectText(editor, 1, 3);
5482 // Render and notify
5483 application.SendNotification();
5484 application.Render();
5487 DevelTextEditor::SelectNone(editor);
5489 // Render and notify
5490 application.SendNotification();
5491 application.Render();
5493 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5498 int utcDaliTextEditorSelectionStartedSignal(void)
5500 ToolkitTestApplication application;
5501 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5503 TextEditor editor = TextEditor::New();
5504 DALI_TEST_CHECK(editor);
5506 application.GetScene().Add(editor);
5508 // connect to the selection changed signal.
5509 ConnectionTracker* testTracker = new ConnectionTracker();
5510 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5511 bool selectionStartedSignal = false;
5512 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5514 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5515 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5516 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5517 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5518 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5520 // Avoid a crash when core load gl resources.
5521 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5523 // Render and notify
5524 application.SendNotification();
5525 application.Render();
5527 // Tap on the text editor
5528 TestGenerateTap(application, 3.0f, 25.0f);
5530 // Render and notify
5531 application.SendNotification();
5532 application.Render();
5534 // Move to second line of the text & Select some text in the right of the current cursor position
5535 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5536 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5538 // Render and notify
5539 application.SendNotification();
5540 application.Render();
5542 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5545 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5547 // Render and notify
5548 application.SendNotification();
5549 application.Render();
5551 gSelectionStartedCallbackCalled = false;
5553 DevelTextEditor::SelectText(editor, 1, 3);
5555 // Render and notify
5556 application.SendNotification();
5557 application.Render();
5559 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5564 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5566 ToolkitTestApplication application;
5567 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5569 // Checks if the actor is created.
5571 TextEditor editor = TextEditor::New();
5572 DALI_TEST_CHECK(editor);
5574 application.GetScene().Add(editor);
5576 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5577 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5578 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5579 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5580 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5581 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5582 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5583 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
5585 // Avoid a crash when core load gl resources.
5586 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5588 // Render and notify
5589 application.SendNotification();
5590 application.Render();
5592 // Tap on the text editor
5593 TestGenerateTap(application, 3.0f, 25.0f);
5595 // Render and notify
5596 application.SendNotification();
5597 application.Render();
5599 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5600 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5602 application.SendNotification();
5603 application.Render();
5605 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5606 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5611 int utcDaliTextEditorSelectionChangedSignal(void)
5613 ToolkitTestApplication application;
5614 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5616 TextEditor editor = TextEditor::New();
5617 DALI_TEST_CHECK(editor);
5619 application.GetScene().Add(editor);
5621 // connect to the selection changed signal.
5622 ConnectionTracker* testTracker = new ConnectionTracker();
5623 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5624 bool selectionChangedSignal = false;
5625 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5627 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5628 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5629 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5630 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5631 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5633 // Avoid a crash when core load gl resources.
5634 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5636 // Render and notify
5637 application.SendNotification();
5638 application.Render();
5640 // Tap on the text editor
5641 TestGenerateTap(application, 3.0f, 25.0f);
5643 // Render and notify
5644 application.SendNotification();
5645 application.Render();
5647 // Move to second line of the text.
5648 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5650 // Render and notify
5651 application.SendNotification();
5652 application.Render();
5654 // Select some text in the right of the current cursor position
5655 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5656 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5658 // Render and notify
5659 application.SendNotification();
5660 application.Render();
5662 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5663 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5665 gSelectionChangedCallbackCalled = false;
5667 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5669 // Render and notify
5670 application.SendNotification();
5671 application.Render();
5673 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5674 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5675 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5677 gSelectionChangedCallbackCalled = false;
5679 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5681 // Render and notify
5682 application.SendNotification();
5683 application.Render();
5685 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5686 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5687 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5689 gSelectionChangedCallbackCalled = false;
5690 editor.SetKeyInputFocus();
5692 // Render and notify
5693 application.SendNotification();
5694 application.Render();
5696 DevelTextEditor::SelectText(editor, 0, 5);
5698 application.SendNotification();
5699 application.Render();
5701 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5702 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5704 gSelectionChangedCallbackCalled = false;
5706 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5708 // Render and notify
5709 application.SendNotification();
5710 application.Render();
5712 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5713 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5714 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5716 gSelectionChangedCallbackCalled = false;
5719 DevelTextEditor::SelectWholeText(editor);
5721 // Render and notify
5722 application.SendNotification();
5723 application.Render();
5725 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5726 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5728 gSelectionChangedCallbackCalled = false;
5731 DevelTextEditor::SelectNone(editor);
5733 // Render and notify
5734 application.SendNotification();
5735 application.Render();
5737 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5738 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5739 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5744 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5746 ToolkitTestApplication application;
5747 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5749 TextEditor textEditor = TextEditor::New();
5750 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5751 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5752 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5753 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5755 application.GetScene().Add(textEditor);
5756 application.SendNotification();
5757 application.Render();
5759 Property::Map strikethroughMapSet;
5760 Property::Map strikethroughMapGet;
5762 strikethroughMapSet.Insert("enable", true);
5763 strikethroughMapSet.Insert("color", Color::RED);
5764 strikethroughMapSet.Insert("height", 2.0f);
5766 // Check the strikethrough property
5767 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5768 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5769 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5770 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5771 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5773 // Render and notify
5774 application.SendNotification();
5775 application.Render();
5777 strikethroughMapSet.Clear();
5778 strikethroughMapGet.Clear();
5783 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5785 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5786 //DaliException on vector: "Iterator not inside vector"
5788 ToolkitTestApplication application;
5789 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5791 TextEditor editor = TextEditor::New();
5792 DALI_TEST_CHECK(editor);
5794 application.GetScene().Add(editor);
5796 // Avoid a crash when core load gl resources.
5797 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5799 //Set multilines text
5800 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5801 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5802 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5804 //Set ResizePolicy to NaturalSize
5805 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5807 // Render and notify
5808 application.SendNotification();
5809 application.Render();
5811 // Create a tap event to touch the text editor.
5812 TestGenerateTap(application, 5.0f, 5.0f);
5814 // Render and notify
5815 application.SendNotification();
5816 application.Render();
5818 // Set currsor and add character (in first line)
5819 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5820 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5821 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5823 // Render and notify
5824 application.SendNotification();
5825 application.Render();
5827 //Check the changed text and cursor position
5828 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5829 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5831 // Render and notify
5832 application.SendNotification();
5833 application.Render();
5838 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5840 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5841 //DaliException on vector: "Iterator not inside vector"
5843 ToolkitTestApplication application;
5844 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5846 TextEditor editor = TextEditor::New();
5847 DALI_TEST_CHECK(editor);
5849 application.GetScene().Add(editor);
5851 // Avoid a crash when core load gl resources.
5852 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5854 //Set multilines text
5855 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5856 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5857 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5859 //Set ResizePolicy to NaturalSize
5860 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5863 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5864 application.SendNotification();
5865 application.Render();
5867 // Set focus and remove character
5868 editor.SetKeyInputFocus();
5869 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5871 // Render and notify
5872 application.SendNotification();
5873 application.Render();
5875 //Check the changed text and cursor position
5876 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5877 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5879 // Render and notify
5880 application.SendNotification();
5881 application.Render();
5886 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5888 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5889 //DaliException on vector: "Iterator not inside vector"
5891 ToolkitTestApplication application;
5892 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5894 TextEditor editor = TextEditor::New();
5895 DALI_TEST_CHECK(editor);
5897 application.GetScene().Add(editor);
5899 // Avoid a crash when core load gl resources.
5900 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5902 //Set multilines text
5903 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5904 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5905 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5907 //Set ResizePolicy to NaturalSize
5908 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5910 //Select text at initialization (before the first render)
5911 DevelTextEditor::SelectText(editor, 3, 5);
5913 // Render and notify
5914 application.SendNotification();
5915 application.Render();
5918 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5919 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));
5921 // Render and notify
5922 application.SendNotification();
5923 application.Render();
5925 //Check the changed text and cursor position
5926 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5927 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5929 // Render and notify
5930 application.SendNotification();
5931 application.Render();
5936 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5938 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5939 //DaliException on vector: "Iterator not inside vector"
5941 ToolkitTestApplication application;
5942 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5944 TextEditor editor = TextEditor::New();
5945 DALI_TEST_CHECK(editor);
5947 application.GetScene().Add(editor);
5949 // Avoid a crash when core load gl resources.
5950 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5952 //Set multilines text
5953 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5954 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5955 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5957 //Set ResizePolicy to NaturalSize
5958 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5961 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5962 application.SendNotification();
5963 application.Render();
5965 // Set focus and double enter (new line)
5966 editor.SetKeyInputFocus();
5967 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5968 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5970 // Render and notify
5971 application.SendNotification();
5972 application.Render();
5974 //Check the changed text and cursor position
5975 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5976 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5978 // Render and notify
5979 application.SendNotification();
5980 application.Render();
5985 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5987 ToolkitTestApplication application;
5988 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5989 TextEditor textEditor = TextEditor::New();
5990 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5991 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5992 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5993 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5995 application.GetScene().Add(textEditor);
5996 application.SendNotification();
5997 application.Render();
5999 Property::Map underlineMapSet;
6000 Property::Map underlineMapGet;
6002 underlineMapSet.Insert("enable", true);
6003 underlineMapSet.Insert("color", Color::RED);
6004 underlineMapSet.Insert("height", 1);
6005 underlineMapSet.Insert("type", Text::Underline::SOLID);
6006 underlineMapSet.Insert("dashWidth", 2);
6007 underlineMapSet.Insert("dashGap", 1);
6009 // Check the underline property
6010 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6012 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6013 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6014 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6016 // Render and notify
6017 application.SendNotification();
6018 application.Render();
6020 underlineMapSet.Clear();
6021 underlineMapGet.Clear();
6023 underlineMapSet.Insert("enable", true);
6024 underlineMapSet.Insert("color", Color::BLUE);
6025 underlineMapSet.Insert("height", 1);
6026 underlineMapSet.Insert("type", Text::Underline::DASHED);
6027 underlineMapSet.Insert("dashWidth", 4);
6028 underlineMapSet.Insert("dashGap", 2);
6030 // Check the dashed underline property
6031 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6033 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6034 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6035 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6037 // Render and notify
6038 application.SendNotification();
6039 application.Render();
6041 underlineMapSet.Clear();
6042 underlineMapGet.Clear();
6044 underlineMapSet.Insert("enable", true);
6045 underlineMapSet.Insert("color", Color::BLUE);
6046 underlineMapSet.Insert("height", 1);
6047 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
6048 underlineMapSet.Insert("dashWidth", 4);
6049 underlineMapSet.Insert("dashGap", 2);
6051 // Check the dashed underline property
6052 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
6054 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6055 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
6056 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
6058 // Render and notify
6059 application.SendNotification();
6060 application.Render();
6062 underlineMapSet.Clear();
6063 underlineMapGet.Clear();
6068 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
6070 ToolkitTestApplication application;
6071 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
6073 TextEditor textEditor1 = TextEditor::New();
6074 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
6075 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6076 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6077 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6079 Property::Map underlineMapSet1;
6080 Property::Map underlineMapGet1;
6082 underlineMapSet1.Insert("enable", true);
6083 underlineMapSet1.Insert("color", Color::RED);
6084 underlineMapSet1.Insert("height", 1);
6085 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6086 underlineMapSet1.Insert("dashWidth", 2);
6087 underlineMapSet1.Insert("dashGap", 1);
6089 // Check the underline property
6090 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6092 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6093 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6094 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6096 application.GetScene().Add(textEditor1);
6097 application.SendNotification();
6098 application.Render();
6100 TextEditor textEditor2 = TextEditor::New();
6101 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
6102 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6103 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6104 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6106 Property::Map underlineMapSet2;
6107 Property::Map underlineMapGet2;
6109 underlineMapSet2.Insert("enable", true);
6110 underlineMapSet2.Insert("color", Color::BLUE);
6111 underlineMapSet2.Insert("height", 1);
6112 underlineMapSet2.Insert("type", Text::Underline::DASHED);
6113 underlineMapSet2.Insert("dashWidth", 4);
6114 underlineMapSet2.Insert("dashGap", 2);
6116 // Check the dashed underline property
6117 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
6119 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6120 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
6121 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
6123 application.GetScene().Add(textEditor2);
6124 application.SendNotification();
6125 application.Render();
6127 TextEditor textEditor3 = TextEditor::New();
6128 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
6129 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6130 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6131 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6133 Property::Map underlineMapSet3;
6134 Property::Map underlineMapGet3;
6136 underlineMapSet3.Insert("enable", true);
6137 underlineMapSet3.Insert("color", Color::BLUE);
6138 underlineMapSet3.Insert("height", 1);
6139 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
6140 underlineMapSet3.Insert("dashWidth", 4);
6141 underlineMapSet3.Insert("dashGap", 2);
6143 // Check the dashed underline property
6144 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
6146 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6147 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
6148 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
6150 application.GetScene().Add(textEditor3);
6151 application.SendNotification();
6152 application.Render();
6157 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
6159 ToolkitTestApplication application;
6160 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
6162 TextEditor textEditor1 = TextEditor::New();
6163 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
6164 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
6165 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6166 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
6168 Property::Map underlineMapSet1;
6169 Property::Map underlineMapGet1;
6171 underlineMapSet1.Insert("enable", true);
6172 underlineMapSet1.Insert("color", Color::RED);
6173 underlineMapSet1.Insert("height", 1);
6174 underlineMapSet1.Insert("type", Text::Underline::SOLID);
6175 underlineMapSet1.Insert("dashWidth", 2);
6176 underlineMapSet1.Insert("dashGap", 1);
6178 // Check the underline property
6179 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
6180 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
6182 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
6183 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
6184 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
6186 application.GetScene().Add(textEditor1);
6188 application.SendNotification();
6189 application.Render();
6194 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
6196 ToolkitTestApplication application;
6197 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6199 TextEditor editor = TextEditor::New();
6200 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6201 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6202 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6203 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6204 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6205 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6207 TextEditor editorSingleLineParagraph = TextEditor::New();
6208 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6209 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6210 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");
6211 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6212 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6213 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6215 TextEditor editorMultiLineParagraph = TextEditor::New();
6216 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6217 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6218 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");
6219 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6220 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6221 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6223 application.GetScene().Add(editor);
6224 application.GetScene().Add(editorSingleLineParagraph);
6225 application.GetScene().Add(editorMultiLineParagraph);
6226 application.SendNotification();
6227 application.Render();
6229 Vector3 naturalSize = editor.GetNaturalSize();
6230 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6231 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6233 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6235 //no effect of relative line size for paragraph with single line
6236 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6238 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6243 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6245 ToolkitTestApplication application;
6246 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6248 TextEditor editor = TextEditor::New();
6249 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6250 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6251 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6253 application.GetScene().Add(editor);
6254 application.SendNotification();
6255 application.Render();
6257 Vector3 naturalSize = editor.GetNaturalSize();
6259 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6261 application.SendNotification();
6262 application.Render();
6264 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6266 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6268 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6270 application.SendNotification();
6271 application.Render();
6273 relativeNaturalSize = editor.GetNaturalSize();
6275 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6279 int UtcDaliTextEditorCharacterSpacing(void)
6281 ToolkitTestApplication application;
6282 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6284 TextEditor textEditor = TextEditor::New();
6286 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6288 application.GetScene().Add(textEditor);
6289 application.SendNotification();
6290 application.Render();
6292 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6293 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6294 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6296 application.SendNotification();
6297 application.Render();
6302 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6304 ToolkitTestApplication application;
6305 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6307 TextEditor editor = TextEditor::New();
6309 float lineSpacing = -20.f;
6311 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6312 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6313 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6314 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6316 application.GetScene().Add(editor);
6317 application.SendNotification();
6318 application.Render();
6320 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6321 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6323 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6324 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6326 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6327 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6329 application.SendNotification();
6330 application.Render();
6335 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6337 ToolkitTestApplication application;
6338 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6340 TextEditor editor = TextEditor::New();
6341 DALI_TEST_CHECK(editor);
6343 application.GetScene().Add(editor);
6345 std::string cutText = "";
6346 std::string copiedText = "";
6348 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6349 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6350 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6351 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6352 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6353 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6354 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6356 // Render and notify
6357 application.SendNotification();
6358 application.Render();
6360 // Tap on the text editor
6361 TestGenerateTap(application, 1.0f, 1.0f);
6363 // Render and notify
6364 application.SendNotification();
6365 application.Render();
6367 // Move to second line of the text.
6368 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6370 // Render and notify
6371 application.SendNotification();
6372 application.Render();
6374 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6379 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6381 ToolkitTestApplication application;
6382 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6384 TextEditor editor = TextEditor::New();
6386 float lineSpacing = -20.f;
6388 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6389 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6390 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6391 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6392 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6394 application.GetScene().Add(editor);
6395 application.SendNotification();
6396 application.Render();
6398 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6400 int lineCount = sizeList.Size();
6401 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6403 application.SendNotification();
6404 application.Render();
6409 int UtcDaliToolkitTexteditorParagraphTag(void)
6411 ToolkitTestApplication application;
6412 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6413 TextEditor editorNewlineSeparator = TextEditor::New();
6414 TextEditor editorParagraphTag = TextEditor::New();
6415 DALI_TEST_CHECK(editorNewlineSeparator);
6416 DALI_TEST_CHECK(editorParagraphTag);
6418 application.GetScene().Add(editorNewlineSeparator);
6419 application.GetScene().Add(editorParagraphTag);
6421 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6422 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6423 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6424 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6425 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6426 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6428 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6429 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6430 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6431 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6432 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6434 application.SendNotification();
6435 application.Render();
6437 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6438 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6440 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6442 application.SendNotification();
6443 application.Render();
6448 //Handle Emoji clustering for cursor handling
6449 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6451 ToolkitTestApplication application;
6452 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6453 TextEditor textEditor = TextEditor::New();
6454 DALI_TEST_CHECK(textEditor);
6456 application.GetScene().Add(textEditor);
6458 // Avoid a crash when core load gl resources.
6459 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6461 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6462 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6464 // Render and notify
6465 application.SendNotification();
6466 application.Render();
6469 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6470 application.SendNotification();
6471 application.Render();
6473 // Set focus and remove Emoji
6474 textEditor.SetKeyInputFocus();
6475 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6477 //Check the changed text and cursor position
6478 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6479 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6481 // Render and notify
6482 application.SendNotification();
6483 application.Render();
6488 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6490 ToolkitTestApplication application;
6491 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6492 TextEditor textEditor = TextEditor::New();
6493 DALI_TEST_CHECK(textEditor);
6495 application.GetScene().Add(textEditor);
6497 // Avoid a crash when core load gl resources.
6498 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6500 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6501 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6503 // Render and notify
6504 application.SendNotification();
6505 application.Render();
6508 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6509 application.SendNotification();
6510 application.Render();
6512 // Set focus and remove Emoji
6513 textEditor.SetKeyInputFocus();
6514 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6516 //Check the changed text and cursor position
6517 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6518 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6520 // Render and notify
6521 application.SendNotification();
6522 application.Render();
6527 int utcDaliTextEditorPanGesturePropagation(void)
6529 ToolkitTestApplication application;
6530 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6532 Actor actor = Actor::New();
6533 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6534 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6535 application.GetScene().Add(actor);
6537 TextEditor editor = TextEditor::New();
6538 DALI_TEST_CHECK(editor);
6540 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6541 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6543 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6544 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6545 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6549 // Render and notify
6550 application.SendNotification();
6551 application.Render();
6554 GestureReceivedFunctor functor(data);
6556 PanGestureDetector detector = PanGestureDetector::New();
6557 detector.Attach(actor);
6558 detector.DetectedSignal().Connect(&application, functor);
6560 // Tap first to get the focus.
6561 TestGenerateTap(application, 3.0f, 25.0f, 100);
6563 // Render and notify
6564 application.SendNotification();
6565 application.Render();
6567 // Pan the text editor
6568 uint32_t time = 100;
6569 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6570 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6571 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6572 application.SendNotification();
6573 application.Render();
6575 // The text scrolls because there is text that is scrolling.
6576 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6579 // Set the size large enough to prevent scrolling.
6580 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6582 // Render and notify
6583 application.SendNotification();
6584 application.Render();
6587 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6588 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6589 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6591 // Because scrolling is not possible, the pan gesture is propagated.
6592 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6598 int utcDaliTextEditorGetTextBoundingRectangle(void)
6600 ToolkitTestApplication application;
6601 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6603 TextEditor editor = TextEditor::New();
6604 DALI_TEST_CHECK(editor);
6606 application.GetScene().Add(editor);
6608 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6609 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6610 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6611 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6612 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6614 // Avoid a crash when core load gl resources.
6615 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6617 // Render and notify
6618 application.SendNotification();
6619 application.Render();
6621 unsigned int startIndex = 0;
6622 unsigned int endIndex = 15;
6624 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6625 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6627 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);