2 * Copyright (c) 2022 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/text/rendering-backend.h>
22 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
23 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/devel-api/adaptor-framework/text-clipboard.h>
27 #include <dali/devel-api/adaptor-framework/key-devel.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/events/pan-gesture-devel.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;
395 // Stores data that is populated in the callback and will be read by the test cases
399 : functorCalled(false),
400 voidFunctorCalled(false),
407 functorCalled = false;
408 voidFunctorCalled = false;
410 receivedGesture.Reset();
416 bool voidFunctorCalled;
417 PanGesture receivedGesture;
421 // Functor that sets the data when called
422 struct GestureReceivedFunctor
424 GestureReceivedFunctor(SignalData& data)
429 void operator()(Actor actor, const PanGesture& pan)
431 signalData.functorCalled = true;
432 signalData.receivedGesture = pan;
433 signalData.pannedActor = actor;
438 signalData.voidFunctorCalled = true;
441 SignalData& signalData;
447 int UtcDaliToolkitTextEditorConstructorP(void)
449 ToolkitTestApplication application;
450 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
451 TextEditor textEditor;
452 DALI_TEST_CHECK(!textEditor);
456 int UtcDaliToolkitTextEditorNewP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextEditorNewP");
460 TextEditor textEditor = TextEditor::New();
461 DALI_TEST_CHECK(textEditor);
465 int UtcDaliToolkitTextEditorDownCastP(void)
467 ToolkitTestApplication application;
468 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
469 TextEditor textEditor1 = TextEditor::New();
470 BaseHandle object(textEditor1);
472 TextEditor textEditor2 = TextEditor::DownCast(object);
473 DALI_TEST_CHECK(textEditor2);
475 TextEditor textEditor3 = DownCast<TextEditor>(object);
476 DALI_TEST_CHECK(textEditor3);
480 int UtcDaliToolkitTextEditorDownCastN(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
484 BaseHandle uninitializedObject;
485 TextEditor textEditor1 = TextEditor::DownCast(uninitializedObject);
486 DALI_TEST_CHECK(!textEditor1);
488 TextEditor textEditor2 = DownCast<TextEditor>(uninitializedObject);
489 DALI_TEST_CHECK(!textEditor2);
493 int UtcDaliToolkitTextEditorCopyConstructorP(void)
495 ToolkitTestApplication application;
496 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
497 TextEditor textEditor = TextEditor::New();
498 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
500 TextEditor copy(textEditor);
501 DALI_TEST_CHECK(copy);
502 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
506 int UtcDaliTextEditorMoveConstructor(void)
508 ToolkitTestApplication application;
510 TextEditor textEditor = TextEditor::New();
511 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
512 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
514 TextEditor moved = std::move(textEditor);
515 DALI_TEST_CHECK(moved);
516 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
517 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
518 DALI_TEST_CHECK(!textEditor);
523 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
525 ToolkitTestApplication application;
526 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
527 TextEditor textEditor = TextEditor::New();
528 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
530 TextEditor copy = textEditor;
531 DALI_TEST_CHECK(copy);
532 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextEditor::Property::TEXT) == textEditor.GetProperty<std::string>(TextEditor::Property::TEXT));
536 int UtcDaliTextEditorMoveAssignment(void)
538 ToolkitTestApplication application;
540 TextEditor textEditor = TextEditor::New();
541 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
542 DALI_TEST_CHECK(textEditor.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
545 moved = std::move(textEditor);
546 DALI_TEST_CHECK(moved);
547 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
548 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextEditor::Property::TEXT) == "Test");
549 DALI_TEST_CHECK(!textEditor);
554 int UtcDaliTextEditorNewP(void)
556 ToolkitTestApplication application;
557 tet_infoline(" UtcDaliToolkitTextEditorNewP");
558 TextEditor textEditor = TextEditor::New();
559 DALI_TEST_CHECK(textEditor);
563 // Positive test case for a method
564 int UtcDaliTextEditorGetPropertyP(void)
566 ToolkitTestApplication application;
567 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
568 TextEditor editor = TextEditor::New();
569 DALI_TEST_CHECK(editor);
571 // Check Property Indices are correct
572 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextEditor::Property::RENDERING_BACKEND);
573 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextEditor::Property::TEXT);
574 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextEditor::Property::TEXT_COLOR);
575 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextEditor::Property::FONT_FAMILY);
576 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextEditor::Property::FONT_STYLE);
577 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextEditor::Property::POINT_SIZE);
578 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextEditor::Property::HORIZONTAL_ALIGNMENT);
579 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextEditor::Property::SCROLL_THRESHOLD);
580 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextEditor::Property::SCROLL_SPEED);
581 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextEditor::Property::PRIMARY_CURSOR_COLOR);
582 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextEditor::Property::SECONDARY_CURSOR_COLOR);
583 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextEditor::Property::ENABLE_CURSOR_BLINK);
584 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextEditor::Property::CURSOR_BLINK_INTERVAL);
585 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextEditor::Property::CURSOR_BLINK_DURATION);
586 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextEditor::Property::CURSOR_WIDTH);
587 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextEditor::Property::GRAB_HANDLE_IMAGE);
588 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE);
589 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT);
590 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT);
591 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
592 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
593 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
594 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
595 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR);
596 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextEditor::Property::DECORATION_BOUNDING_BOX);
597 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextEditor::Property::ENABLE_MARKUP);
598 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextEditor::Property::INPUT_COLOR);
599 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextEditor::Property::INPUT_FONT_FAMILY);
600 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextEditor::Property::INPUT_FONT_STYLE);
601 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextEditor::Property::INPUT_POINT_SIZE);
603 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextEditor::Property::LINE_SPACING);
604 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_LINE_SPACING) == TextEditor::Property::INPUT_LINE_SPACING);
605 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextEditor::Property::UNDERLINE);
606 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextEditor::Property::INPUT_UNDERLINE);
607 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextEditor::Property::SHADOW);
608 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextEditor::Property::INPUT_SHADOW);
609 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextEditor::Property::EMBOSS);
610 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextEditor::Property::INPUT_EMBOSS);
611 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextEditor::Property::OUTLINE);
612 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextEditor::Property::INPUT_OUTLINE);
613 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
614 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
615 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL) == TextEditor::Property::SMOOTH_SCROLL);
616 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SMOOTH_SCROLL_DURATION) == TextEditor::Property::SMOOTH_SCROLL_DURATION);
617 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SCROLL_BAR) == TextEditor::Property::ENABLE_SCROLL_BAR);
618 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION);
619 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SCROLL_BAR_FADE_DURATION) == TextEditor::Property::SCROLL_BAR_FADE_DURATION);
620 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextEditor::Property::PIXEL_SIZE);
621 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT);
622 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextEditor::Property::ENABLE_SELECTION);
623 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextEditor::Property::PLACEHOLDER);
624 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextEditor::Property::FONT_SIZE_SCALE);
625 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE);
626 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == DevelTextEditor::Property::PLACEHOLDER_TEXT);
627 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR);
628 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION);
629 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE);
630 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
631 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == DevelTextEditor::Property::MAX_LENGTH);
632 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextEditor::Property::GRAB_HANDLE_COLOR);
633 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP);
634 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
635 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER);
636 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH);
637 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH);
638 DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
643 bool SetPropertyMapRetrieved(TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue)
646 Property::Map imageMap;
647 imageMap[mapKey] = mapValue;
649 editor.SetProperty(property, imageMap);
650 Property::Value propValue = editor.GetProperty(property);
651 Property::Map* resultMap = propValue.GetMap();
653 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
661 // Positive test case for a method
662 int UtcDaliTextEditorSetPropertyP(void)
664 ToolkitTestApplication application;
665 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
666 TextEditor editor = TextEditor::New();
667 DALI_TEST_CHECK(editor);
668 application.GetScene().Add(editor);
670 // Note - we can't check the defaults since the stylesheets are platform-specific
672 // Check the render backend property.
673 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
674 DALI_TEST_EQUALS((DevelText::RenderingType)editor.GetProperty<int>(DevelTextEditor::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
676 // Check text property.
677 editor.SetProperty(TextEditor::Property::TEXT, "Setting Text");
678 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
680 // Check text's color property
681 editor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::WHITE);
682 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
684 // Check font properties.
685 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "Setting font family");
686 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
688 Property::Map fontStyleMapSet;
689 Property::Map fontStyleMapGet;
690 Property::Value* slantValue = NULL;
692 fontStyleMapSet.Insert("weight", "bold");
693 fontStyleMapSet.Insert("width", "condensed");
694 fontStyleMapSet.Insert("slant", "italic");
696 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
697 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
698 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
699 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
701 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
702 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
704 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f);
705 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
706 editor.SetProperty(DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f);
708 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false);
709 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
710 editor.SetProperty(DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true);
713 fontStyleMapSet.Clear();
714 fontStyleMapSet.Insert("weight", "normal");
715 fontStyleMapSet.Insert("slant", "oblique");
716 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
717 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
718 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
719 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
721 fontStyleMapSet.Clear();
722 fontStyleMapSet.Insert("slant", "roman");
723 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
724 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
726 // Replace 'roman' for 'normal'.
727 slantValue = fontStyleMapGet.Find("slant");
728 if(NULL != slantValue)
730 if("normal" == slantValue->Get<std::string>())
732 fontStyleMapGet["slant"] = "roman";
735 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
736 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
738 fontStyleMapSet.Clear();
740 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
741 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::FONT_STYLE);
742 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
743 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
745 // Check that the Alignment properties can be correctly set
746 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
747 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
749 // Check that the Alignment properties can be correctly set
750 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
751 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
752 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
753 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
754 editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
755 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
757 // Check scroll properties.
758 editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
759 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
760 editor.SetProperty(TextEditor::Property::SCROLL_SPEED, 100.f);
761 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
763 // Check cursor properties
764 editor.SetProperty(TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED);
765 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
766 editor.SetProperty(TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
767 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
769 editor.SetProperty(TextEditor::Property::ENABLE_CURSOR_BLINK, false);
770 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
771 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f);
772 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
773 editor.SetProperty(TextEditor::Property::CURSOR_BLINK_DURATION, 10.f);
774 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
775 editor.SetProperty(TextEditor::Property::CURSOR_WIDTH, 1);
776 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
778 // Check handle images
779 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, "image1");
780 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
781 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
782 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
783 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
785 // Check handle images
786 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
787 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
788 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
789 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
790 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
791 DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
793 // Check the selection popup style
794 const Vector2 popupMaxSize(200.0f, 300.0f);
795 const Vector2 optionDividerSize(30.0f, 5.0f);
796 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
797 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
799 Property::Map selectionPopupStyle;
800 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
801 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
802 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
803 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
805 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
807 Property::Map selectionPopupStyleGet;
808 selectionPopupStyleGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::SELECTION_POPUP_STYLE);
810 Property::Value* popupValue;
811 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
812 DALI_TEST_CHECK(NULL != popupValue);
815 Vector2 popupMaxSizeGet;
816 popupValue->Get(popupMaxSizeGet);
817 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
820 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
821 DALI_TEST_CHECK(NULL != popupValue);
824 Vector2 optionDividerSizeGet;
825 popupValue->Get(optionDividerSizeGet);
826 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
829 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
830 DALI_TEST_CHECK(NULL != popupValue);
833 Vector4 optionDividerPaddingGet;
834 popupValue->Get(optionDividerPaddingGet);
835 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
838 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
839 DALI_TEST_CHECK(NULL != popupValue);
842 Vector4 labelPaddingGet;
843 popupValue->Get(labelPaddingGet);
844 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
847 // Reset selection popup style
848 selectionPopupStyle.Clear();
849 editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
851 // Check the highlight color
852 editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
853 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
855 // Decoration bounding box
856 editor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
857 DALI_TEST_EQUALS(editor.GetProperty<Rect<int> >(TextEditor::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
859 // Check the enable markup property.
860 DALI_TEST_CHECK(!editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
861 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
862 DALI_TEST_CHECK(editor.GetProperty<bool>(TextEditor::Property::ENABLE_MARKUP));
864 // Check input color property.
865 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
866 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(TextEditor::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
868 // Check input font properties.
869 editor.SetProperty(TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family");
870 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
872 fontStyleMapSet.Clear();
873 fontStyleMapSet.Insert("weight", "bold");
874 fontStyleMapSet.Insert("width", "condensed");
875 fontStyleMapSet.Insert("slant", "italic");
877 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
878 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
879 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
880 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
882 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 12.f);
883 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
885 // Reset input font style.
886 fontStyleMapSet.Clear();
887 fontStyleMapSet.Insert("weight", "normal");
888 fontStyleMapSet.Insert("slant", "oblique");
890 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
891 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
892 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
893 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
895 fontStyleMapSet.Clear();
896 fontStyleMapSet.Insert("slant", "roman");
898 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
899 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
901 // Replace 'roman' for 'normal'.
902 slantValue = fontStyleMapGet.Find("slant");
903 if(NULL != slantValue)
905 if("normal" == slantValue->Get<std::string>())
907 fontStyleMapGet["slant"] = "roman";
910 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
911 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
913 fontStyleMapSet.Clear();
915 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
916 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
917 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
918 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
920 // Check the line spacing property
921 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
922 editor.SetProperty(TextEditor::Property::LINE_SPACING, 10.f);
923 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
925 // Check the input line spacing property
926 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
927 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 20.f);
928 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::INPUT_LINE_SPACING), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
930 // Check the underline property
932 Property::Map underlineMapSet;
933 Property::Map underlineMapGet;
935 underlineMapSet.Insert("enable", true);
936 underlineMapSet.Insert("color", Color::RED);
937 underlineMapSet.Insert("height", 1);
938 underlineMapSet.Insert("type", Text::Underline::SOLID);
939 underlineMapSet.Insert("dashWidth", 5);
940 underlineMapSet.Insert("dashGap", 3);
942 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
944 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
945 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
946 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
948 application.SendNotification();
949 application.Render();
951 // Check the dashed underline property
953 underlineMapSet.Clear();
954 underlineMapGet.Clear();
956 underlineMapSet.Insert("enable", true);
957 underlineMapSet.Insert("color", Color::RED);
958 underlineMapSet.Insert("height", 1);
959 underlineMapSet.Insert("type", Text::Underline::DASHED);
960 underlineMapSet.Insert("dashWidth", 5);
961 underlineMapSet.Insert("dashGap", 3);
963 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
965 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
966 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
967 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
969 application.SendNotification();
970 application.Render();
972 underlineMapSet.Clear();
973 underlineMapGet.Clear();
975 // Check the double underline property
977 underlineMapSet.Clear();
978 underlineMapGet.Clear();
980 underlineMapSet.Insert("enable", true);
981 underlineMapSet.Insert("color", Color::RED);
982 underlineMapSet.Insert("height", 1);
983 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
984 underlineMapSet.Insert("dashWidth", 5);
985 underlineMapSet.Insert("dashGap", 3);
987 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
989 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
990 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
991 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
993 application.SendNotification();
994 application.Render();
996 underlineMapSet.Clear();
997 underlineMapGet.Clear();
999 // Check the input underline property
1000 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "Underline input properties");
1001 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1003 // Check the shadow property
1004 Property::Map shadowMapSet;
1005 Property::Map shadowMapGet;
1007 shadowMapSet.Insert("color", Color::GREEN);
1008 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1009 shadowMapSet.Insert("blurRadius", 3.0f);
1011 editor.SetProperty(TextEditor::Property::SHADOW, shadowMapSet);
1013 shadowMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::SHADOW);
1014 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1015 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1017 // Check the input shadow property
1018 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "Shadow input properties");
1019 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1021 // Check the emboss property
1022 editor.SetProperty(TextEditor::Property::EMBOSS, "Emboss properties");
1023 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1025 // Check the input emboss property
1026 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "Emboss input properties");
1027 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1029 // Check the outline property
1031 // Test string type first
1032 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1033 editor.SetProperty(TextEditor::Property::OUTLINE, "Outline properties");
1034 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1036 // Then test the property map type
1037 Property::Map outlineMapSet;
1038 Property::Map outlineMapGet;
1040 outlineMapSet["color"] = Color::RED;
1041 outlineMapSet["width"] = 2.0f;
1043 editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
1045 outlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::OUTLINE);
1046 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1047 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1049 // Check the input outline property
1050 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "Outline input properties");
1051 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1053 // Check the smooth scroll property
1054 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), false, TEST_LOCATION);
1055 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
1056 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
1058 // Check the smooth scroll duration property
1059 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
1060 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1062 // Check the scroll bar property
1063 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), false, TEST_LOCATION);
1064 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
1065 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
1067 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
1068 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1069 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
1070 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1072 // Check the pixel size of font
1073 editor.SetProperty(TextEditor::Property::PIXEL_SIZE, 20.f);
1074 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1076 // Check placeholder text properties.
1077 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
1078 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
1080 // Check placeholder text's color property.
1081 editor.SetProperty(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
1082 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
1084 // Check the enable selection property
1085 editor.SetProperty(TextEditor::Property::ENABLE_SELECTION, false);
1086 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1088 // Check the placeholder property with pixel size
1089 Property::Map placeholderPixelSizeMapSet;
1090 Property::Map placeholderPixelSizeMapGet;
1091 Property::Map placeholderFontstyleMap;
1092 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1093 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1094 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1095 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1096 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1098 placeholderFontstyleMap.Insert("weight", "bold");
1099 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
1100 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1102 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1103 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1105 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1106 Property::Map placeholderConversionMap;
1107 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1108 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1109 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1110 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1111 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1112 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1114 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1116 // Check the placeholder property with point size
1117 Property::Map placeholderMapSet;
1118 Property::Map placeholderMapGet;
1119 placeholderMapSet["text"] = "Setting Placeholder Text";
1120 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1121 placeholderMapSet["color"] = Color::RED;
1122 placeholderMapSet["fontFamily"] = "Arial";
1123 placeholderMapSet["pointSize"] = 12.0f;
1124 // Check the placeholder font style property
1125 placeholderFontstyleMap.Clear();
1127 placeholderFontstyleMap.Insert("weight", "bold");
1128 placeholderFontstyleMap.Insert("width", "condensed");
1129 placeholderFontstyleMap.Insert("slant", "italic");
1130 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1131 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1133 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1134 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1136 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1137 placeholderConversionMap.Clear();
1138 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderMapSet["text"];
1139 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderMapSet["textFocused"];
1140 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderMapSet["color"];
1141 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1142 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderMapSet["fontFamily"];
1143 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderMapSet["pointSize"];
1144 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1146 // Reset font style.
1147 placeholderFontstyleMap.Clear();
1148 placeholderFontstyleMap.Insert("weight", "normal");
1149 placeholderFontstyleMap.Insert("slant", "oblique");
1150 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1151 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1153 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1154 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1155 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1156 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1158 placeholderFontstyleMap.Clear();
1159 placeholderFontstyleMap.Insert("slant", "roman");
1160 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1161 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1163 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1165 placeholderFontstyleMap.Clear();
1166 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1168 editor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
1169 placeholderMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::PLACEHOLDER);
1170 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1171 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderMapSet["fontStyle"];
1172 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1174 editor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1175 DALI_TEST_EQUALS(editor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1177 // Check handle color
1178 editor.SetProperty(DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1179 DALI_TEST_EQUALS(editor.GetProperty<Vector4>(DevelTextEditor::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1181 // Test the ENABLE_GRAB_HANDLE_POPUP property
1182 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1183 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP), false, TEST_LOCATION);
1185 // Check the input method setting
1186 Property::Map propertyMap;
1187 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1188 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1189 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1190 int inputVariation = 1;
1191 propertyMap["PANEL_LAYOUT"] = panelLayout;
1192 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1193 propertyMap["BUTTON_ACTION"] = buttonAction;
1194 propertyMap["VARIATION"] = inputVariation;
1195 editor.SetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap);
1197 Property::Value value = editor.GetProperty(DevelTextEditor::Property::INPUT_METHOD_SETTINGS);
1199 DALI_TEST_CHECK(value.Get(map));
1202 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
1203 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
1206 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
1207 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
1210 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
1211 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
1214 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
1215 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
1217 // Check the input filter property
1218 Property::Map inputFilterMapSet;
1219 Property::Map inputFilterMapGet;
1220 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1221 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1223 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1225 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1226 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1229 inputFilterMapSet.Clear();
1230 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1232 // Check the strikethrough property
1234 Property::Map strikethroughMapSet;
1235 Property::Map strikethroughMapGet;
1237 application.SendNotification();
1238 application.Render();
1240 // Check the input strikethrough property
1242 strikethroughMapSet.Clear();
1243 strikethroughMapGet.Clear();
1244 strikethroughMapSet.Insert("enable", true);
1245 strikethroughMapSet.Insert("color", Color::BLUE);
1246 strikethroughMapSet.Insert("height", 2.0f);
1248 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
1250 application.SendNotification();
1251 application.Render();
1253 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
1255 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
1256 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
1258 // Check the input strikethrough property
1259 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1260 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1262 application.SendNotification();
1263 application.Render();
1265 // Check the line size property
1266 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1267 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
1268 DALI_TEST_EQUALS(editor.GetProperty<float>(DevelTextEditor::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1273 // Positive Atlas Text Renderer test
1274 int utcDaliTextEditorAtlasRenderP(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1278 StyleManager styleManager = StyleManager::Get();
1279 styleManager.ApplyDefaultTheme();
1280 TextEditor editor = TextEditor::New();
1281 DALI_TEST_CHECK(editor);
1283 editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1285 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1287 application.GetScene().Add(editor);
1291 // Render some text with the shared atlas backend
1292 editor.SetProperty(DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1293 application.SendNotification();
1294 application.Render();
1298 tet_result(TET_FAIL);
1303 // Positive test for the anchorClicked signal.
1304 int utcDaliTextEditorAnchorClickedP(void)
1306 ToolkitTestApplication application;
1307 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1308 TextEditor editor = TextEditor::New();
1309 DALI_TEST_CHECK(editor);
1311 application.GetScene().Add(editor);
1313 // connect to the anchor clicked signal.
1314 ConnectionTracker* testTracker = new ConnectionTracker();
1315 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1316 bool anchorClickedSignal = false;
1317 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1319 gAnchorClickedCallBackCalled = false;
1320 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1321 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1322 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1323 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1324 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1326 application.SendNotification();
1327 application.Render();
1328 editor.SetKeyInputFocus();
1330 // Create a tap event to touch the text editor.
1331 TestGenerateTap(application, 5.0f, 5.0f);
1332 application.SendNotification();
1333 application.Render();
1335 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1336 DALI_TEST_CHECK(anchorClickedSignal);
1338 gAnchorClickedCallBackNotCalled = true;
1339 // Tap the outside of anchor, callback should not be called.
1340 TestGenerateTap(application, 150.f, 100.f);
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1349 // Positive test for the textChanged signal.
1350 int utcDaliTextEditorTextChangedP(void)
1352 ToolkitTestApplication application;
1353 tet_infoline(" utcDaliTextEditorTextChangedP");
1354 TextEditor editor = TextEditor::New();
1355 DALI_TEST_CHECK(editor);
1357 application.GetScene().Add(editor);
1359 // connect to the text changed signal.
1360 ConnectionTracker* testTracker = new ConnectionTracker();
1361 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1362 bool textChangedSignal = false;
1363 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1365 gTextChangedCallBackCalled = false;
1366 editor.SetProperty(TextEditor::Property::TEXT, "ABC");
1367 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1368 DALI_TEST_CHECK(textChangedSignal);
1370 application.SendNotification();
1371 editor.SetKeyInputFocus();
1373 gTextChangedCallBackCalled = false;
1374 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1375 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1378 editor.SetProperty(TextField::Property::TEXT, "");
1380 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1381 gTextChangedCallBackCalled = false;
1382 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1383 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1385 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1386 gTextChangedCallBackCalled = false;
1387 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1388 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1393 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1395 ToolkitTestApplication application;
1396 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1397 TextEditor editor = TextEditor::New();
1398 DALI_TEST_CHECK(editor);
1400 application.GetScene().Add(editor);
1402 // connect to the text changed signal.
1403 ConnectionTracker* testTracker = new ConnectionTracker();
1404 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1405 bool textChangedSignal = false;
1406 editor.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1408 // get InputMethodContext
1410 InputMethodContext::EventData imfEvent;
1411 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
1413 editor.SetKeyInputFocus();
1414 editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
1417 gTextChangedCallBackCalled = false;
1418 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1419 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1420 application.SendNotification();
1421 application.Render();
1422 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1423 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1425 gTextChangedCallBackCalled = false;
1426 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1427 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1428 application.SendNotification();
1429 application.Render();
1430 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1431 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호"), TEST_LOCATION);
1433 gTextChangedCallBackCalled = false;
1434 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1435 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1436 application.SendNotification();
1437 application.Render();
1438 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1439 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("혿"), TEST_LOCATION);
1441 gTextChangedCallBackCalled = false;
1442 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1443 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1444 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1446 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1447 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1448 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1450 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1451 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1452 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1454 application.SendNotification();
1455 application.Render();
1456 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1457 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("호두"), TEST_LOCATION);
1462 int utcDaliTextEditorInputStyleChanged01(void)
1464 // The text-editor emits signals when the input style changes. These changes of style are
1465 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1466 // can't be emitted during the size negotiation as the callbacks may update the UI.
1467 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1468 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1469 ToolkitTestApplication application;
1470 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1474 char* pathNamePtr = get_current_dir_name();
1475 const std::string pathName(pathNamePtr);
1478 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1479 fontClient.SetDpi(93u, 93u);
1481 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1482 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1484 TextEditor editor = TextEditor::New();
1485 DALI_TEST_CHECK(editor);
1487 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1488 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1489 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1491 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1492 editor.SetProperty(TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1494 // connect to the text changed signal.
1495 ConnectionTracker* testTracker = new ConnectionTracker();
1496 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1497 bool inputStyleChangedSignal = false;
1498 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1500 application.GetScene().Add(editor);
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Executes the idle callbacks added by the text control on the change of input style.
1507 application.RunIdles();
1509 gInputStyleChangedCallbackCalled = false;
1510 gInputStyleMask = TextEditor::InputStyle::NONE;
1511 inputStyleChangedSignal = false;
1513 // Create a tap event to touch the text editor.
1514 TestGenerateTap(application, 18.0f, 25.0f);
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Executes the idle callbacks added by the text control on the change of input style.
1521 application.RunIdles();
1523 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1524 if(gInputStyleChangedCallbackCalled)
1526 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
1528 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1529 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1531 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1532 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1534 DALI_TEST_CHECK(inputStyleChangedSignal);
1536 gInputStyleChangedCallbackCalled = false;
1537 gInputStyleMask = TextEditor::InputStyle::NONE;
1538 inputStyleChangedSignal = false;
1540 // Create a tap event to touch the text editor.
1541 TestGenerateTap(application, 30.0f, 25.0f);
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1547 // Executes the idle callbacks added by the text control on the change of input style.
1548 application.RunIdles();
1550 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1551 DALI_TEST_CHECK(!inputStyleChangedSignal);
1553 gInputStyleChangedCallbackCalled = false;
1554 gInputStyleMask = TextEditor::InputStyle::NONE;
1555 inputStyleChangedSignal = false;
1557 // Create a tap event to touch the text editor.
1558 TestGenerateTap(application, 43.0f, 25.0f);
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Executes the idle callbacks added by the text control on the change of input style.
1565 application.RunIdles();
1567 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1568 if(gInputStyleChangedCallbackCalled)
1570 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
1572 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1573 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1575 DALI_TEST_CHECK(inputStyleChangedSignal);
1577 gInputStyleChangedCallbackCalled = false;
1578 gInputStyleMask = TextEditor::InputStyle::NONE;
1579 inputStyleChangedSignal = false;
1581 // Create a tap event to touch the text editor.
1582 TestGenerateTap(application, 88.0f, 25.0f);
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Executes the idle callbacks added by the text control on the change of input style.
1589 application.RunIdles();
1591 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1592 if(gInputStyleChangedCallbackCalled)
1594 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1596 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1597 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1599 Property::Map fontStyleMapSet;
1600 Property::Map fontStyleMapGet;
1602 fontStyleMapSet.Insert("weight", "bold");
1604 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1605 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1606 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1608 DALI_TEST_CHECK(inputStyleChangedSignal);
1610 gInputStyleChangedCallbackCalled = false;
1611 gInputStyleMask = TextEditor::InputStyle::NONE;
1612 inputStyleChangedSignal = false;
1614 // Create a tap event to touch the text editor.
1615 TestGenerateTap(application, 115.0f, 25.0f);
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // Executes the idle callbacks added by the text control on the change of input style.
1622 application.RunIdles();
1624 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1625 DALI_TEST_CHECK(!inputStyleChangedSignal);
1627 gInputStyleChangedCallbackCalled = false;
1628 gInputStyleMask = TextEditor::InputStyle::NONE;
1629 inputStyleChangedSignal = false;
1631 // Create a tap event to touch the text editor.
1632 TestGenerateTap(application, 164.0f, 25.0f);
1634 // Render and notify
1635 application.SendNotification();
1636 application.Render();
1638 // Executes the idle callbacks added by the text control on the change of input style.
1639 application.RunIdles();
1641 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1642 if(gInputStyleChangedCallbackCalled)
1644 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
1646 Property::Map fontStyleMapSet;
1647 Property::Map fontStyleMapGet;
1649 fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
1650 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1651 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1653 DALI_TEST_CHECK(inputStyleChangedSignal);
1655 gInputStyleChangedCallbackCalled = false;
1656 gInputStyleMask = TextEditor::InputStyle::NONE;
1657 inputStyleChangedSignal = false;
1659 // Create a tap event to touch the text editor.
1660 TestGenerateTap(application, 191.0f, 25.0f);
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // Executes the idle callbacks added by the text control on the change of input style.
1667 application.RunIdles();
1669 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1670 DALI_TEST_CHECK(!inputStyleChangedSignal);
1675 int utcDaliTextEditorInputStyleChanged02(void)
1677 // The text-editor emits signals when the input style changes. These changes of style are
1678 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1679 // can't be emitted during the size negotiation as the callbacks may update the UI.
1680 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1681 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1682 ToolkitTestApplication application;
1683 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1687 char* pathNamePtr = get_current_dir_name();
1688 const std::string pathName(pathNamePtr);
1691 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1692 fontClient.SetDpi(93u, 93u);
1694 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1695 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1697 TextEditor editor = TextEditor::New();
1698 DALI_TEST_CHECK(editor);
1700 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1701 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1702 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1704 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1705 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>");
1707 // connect to the text changed signal.
1708 ConnectionTracker* testTracker = new ConnectionTracker();
1709 editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1710 bool inputStyleChangedSignal = false;
1711 editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1713 application.GetScene().Add(editor);
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Executes the idle callbacks added by the text control on the change of input style.
1720 application.RunIdles();
1722 gInputStyleChangedCallbackCalled = false;
1723 gInputStyleMask = TextEditor::InputStyle::NONE;
1724 inputStyleChangedSignal = false;
1726 // Create a tap event to touch the text editor.
1727 TestGenerateTap(application, 53.0f, 25.0f, 100);
1728 TestGenerateTap(application, 53.0f, 25.0f, 200);
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Executes the idle callbacks added by the text control on the change of input style.
1735 application.RunIdles();
1737 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1738 if(gInputStyleChangedCallbackCalled)
1740 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1741 static_cast<unsigned int>(TextEditor::InputStyle::FONT_FAMILY |
1742 TextEditor::InputStyle::POINT_SIZE |
1743 TextEditor::InputStyle::COLOR),
1746 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1747 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1749 const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
1750 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1752 const float pointSize = editor.GetProperty(TextEditor::Property::INPUT_POINT_SIZE).Get<float>();
1753 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1755 DALI_TEST_CHECK(inputStyleChangedSignal);
1757 gInputStyleChangedCallbackCalled = false;
1758 gInputStyleMask = TextEditor::InputStyle::NONE;
1759 inputStyleChangedSignal = false;
1761 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 // Executes the idle callbacks added by the text control on the change of input style.
1768 application.RunIdles();
1770 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1771 if(gInputStyleChangedCallbackCalled)
1773 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1774 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1777 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1778 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
1780 DALI_TEST_CHECK(inputStyleChangedSignal);
1782 gInputStyleChangedCallbackCalled = false;
1783 gInputStyleMask = TextEditor::InputStyle::NONE;
1784 inputStyleChangedSignal = false;
1786 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Executes the idle callbacks added by the text control on the change of input style.
1793 application.RunIdles();
1795 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1796 DALI_TEST_CHECK(!inputStyleChangedSignal);
1798 gInputStyleChangedCallbackCalled = false;
1799 gInputStyleMask = TextEditor::InputStyle::NONE;
1800 inputStyleChangedSignal = false;
1802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 // Executes the idle callbacks added by the text control on the change of input style.
1809 application.RunIdles();
1811 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1812 if(gInputStyleChangedCallbackCalled)
1814 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1815 static_cast<unsigned int>(TextEditor::InputStyle::COLOR),
1818 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1819 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1821 DALI_TEST_CHECK(inputStyleChangedSignal);
1823 gInputStyleChangedCallbackCalled = false;
1824 gInputStyleMask = TextEditor::InputStyle::NONE;
1825 inputStyleChangedSignal = false;
1827 editor.SetProperty(TextEditor::Property::INPUT_COLOR, Color::YELLOW);
1829 Property::Map fontStyleMapSet;
1830 fontStyleMapSet.Insert("weight", "thin");
1831 fontStyleMapSet.Insert("width", "condensed");
1832 fontStyleMapSet.Insert("slant", "italic");
1834 editor.SetProperty(TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet);
1835 editor.SetProperty(TextEditor::Property::INPUT_POINT_SIZE, 20.f);
1836 editor.SetProperty(TextEditor::Property::INPUT_LINE_SPACING, 5.f);
1838 editor.SetProperty(TextEditor::Property::INPUT_UNDERLINE, "underline");
1839 editor.SetProperty(TextEditor::Property::INPUT_SHADOW, "shadow");
1840 editor.SetProperty(TextEditor::Property::INPUT_EMBOSS, "emboss");
1841 editor.SetProperty(TextEditor::Property::INPUT_OUTLINE, "outline");
1842 editor.SetProperty(DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough");
1844 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1850 // Executes the idle callbacks added by the text control on the change of input style.
1851 application.RunIdles();
1853 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1854 DALI_TEST_CHECK(!inputStyleChangedSignal);
1856 // Create a tap event to touch the text editor.
1857 TestGenerateTap(application, 63.0f, 25.0f, 900);
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 // Executes the idle callbacks added by the text control on the change of input style.
1864 application.RunIdles();
1866 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1867 if(gInputStyleChangedCallbackCalled)
1869 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1870 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1871 TextEditor::InputStyle::POINT_SIZE |
1872 TextEditor::InputStyle::FONT_STYLE |
1873 TextEditor::InputStyle::LINE_SPACING |
1874 TextEditor::InputStyle::UNDERLINE |
1875 TextEditor::InputStyle::SHADOW |
1876 TextEditor::InputStyle::EMBOSS |
1877 TextEditor::InputStyle::OUTLINE),
1880 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1881 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1883 DALI_TEST_CHECK(inputStyleChangedSignal);
1885 gInputStyleChangedCallbackCalled = false;
1886 gInputStyleMask = TextEditor::InputStyle::NONE;
1887 inputStyleChangedSignal = false;
1889 editor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVuSerif");
1891 fontStyleMapSet.Clear();
1892 fontStyleMapSet.Insert("weight", "black");
1893 fontStyleMapSet.Insert("width", "expanded");
1894 fontStyleMapSet.Insert("slant", "oblique");
1896 editor.SetProperty(TextEditor::Property::FONT_STYLE, fontStyleMapSet);
1898 // Create a tap event to touch the text editor.
1899 TestGenerateTap(application, 30.0f, 25.0f, 1500);
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 // Executes the idle callbacks added by the text control on the change of input style.
1906 application.RunIdles();
1908 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1909 if(gInputStyleChangedCallbackCalled)
1911 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
1912 static_cast<unsigned int>(TextEditor::InputStyle::COLOR |
1913 TextEditor::InputStyle::POINT_SIZE |
1914 TextEditor::InputStyle::FONT_STYLE),
1917 const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
1918 DALI_TEST_EQUALS(color, Color::YELLOW, TEST_LOCATION);
1920 DALI_TEST_CHECK(inputStyleChangedSignal);
1925 int utcDaliTextEditorEvent01(void)
1927 ToolkitTestApplication application;
1928 tet_infoline(" utcDaliTextEditorEvent01");
1930 // Creates a tap event. After creating a tap event the text editor should
1931 // have the focus and add text with key events should be possible.
1933 TextEditor editor = TextEditor::New();
1934 DALI_TEST_CHECK(editor);
1936 application.GetScene().Add(editor);
1938 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1939 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1940 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1942 // Avoid a crash when core load gl resources.
1943 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 // Add a key event but as the text editor has not the focus it should do nothing.
1950 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string(""), TEST_LOCATION);
1958 // Create a tap event to touch the text editor.
1959 TestGenerateTap(application, 150.0f, 25.0f);
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1965 // Now the text editor has the focus, so it can handle the key events.
1966 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1967 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
1975 // Create a second text editor and send key events to it.
1976 TextEditor editor2 = TextEditor::New();
1978 editor2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1979 editor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1980 editor2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
1981 editor2.SetProperty(Actor::Property::POSITION, Vector2(100.f, 100.f));
1983 application.GetScene().Add(editor2);
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Create a tap event on the second text editor.
1990 TestGenerateTap(application, 150.0f, 125.0f);
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // The second text editor has the focus. It should handle the key events.
1997 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1998 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 // Check the text has been added to the second text editor.
2005 DALI_TEST_EQUALS(editor2.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("aa"), TEST_LOCATION);
2010 int utcDaliTextEditorEvent02(void)
2012 ToolkitTestApplication application;
2013 tet_infoline(" utcDaliTextEditorEvent02");
2015 // Checks if the right number of actors are created.
2017 TextEditor editor = TextEditor::New();
2018 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2019 DALI_TEST_CHECK(editor);
2021 application.GetScene().Add(editor);
2023 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2024 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2025 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2027 // Avoid a crash when core load gl resources.
2028 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 // Check there are the expected number of children (the stencil).
2035 DALI_TEST_EQUALS(editor.GetChildCount(), 1u, TEST_LOCATION);
2037 Actor stencil = editor.GetChildAt(0u);
2039 // Create a tap event to touch the text editor.
2040 TestGenerateTap(application, 150.0f, 25.0f, 100);
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 Actor layer = editor.GetChildAt(2u);
2047 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2048 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2050 // Now the text editor has the focus, so it can handle the key events.
2051 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2052 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2054 // Render and notify
2055 application.SendNotification();
2056 application.Render();
2058 // Checks the cursor and the renderer have been created.
2059 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2060 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2062 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2063 DALI_TEST_CHECK(cursor);
2065 // The stencil actor has a container with all the actors which contain the text renderers.
2066 Actor container = stencil.GetChildAt(0u);
2067 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2069 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2070 DALI_TEST_CHECK(renderer);
2073 // Move the cursor and check the position changes.
2074 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2076 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2077 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2085 DALI_TEST_CHECK(position2.x < position1.x);
2087 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2088 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2094 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2096 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2098 // Send some taps and check the cursor positions.
2100 // Try to tap at the beginning.
2101 TestGenerateTap(application, 1.0f, 25.0f, 700);
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2107 // Cursor position should be the same than position1.
2108 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2110 DALI_TEST_EQUALS(position2, position4, TEST_LOCATION); // Should be in the same position2.
2112 // Tap away from the start position.
2113 TestGenerateTap(application, 16.0f, 25.0f, 1400);
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2119 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2121 DALI_TEST_CHECK(position5.x > position4.x);
2123 // Remove all the text.
2124 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2125 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2126 editor.SetProperty(TextEditor::Property::TEXT, "");
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 // Cursor position should be the same than position2.
2133 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2135 DALI_TEST_EQUALS(position2, position6, TEST_LOCATION); // Should be in the same position2.
2137 // Should not be a renderer, there is only a clipped cursor.
2138 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2143 int utcDaliTextEditorEvent03(void)
2145 ToolkitTestApplication application;
2146 tet_infoline(" utcDaliTextEditorEvent03");
2148 // Checks if the highlight actor is created.
2150 TextEditor editor = TextEditor::New();
2151 DALI_TEST_CHECK(editor);
2153 application.GetScene().Add(editor);
2155 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2156 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2157 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2158 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2159 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2161 // Avoid a crash when core load gl resources.
2162 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 // Send some taps and check text controller with clipboard window
2169 Dali::TextClipboard clipboard = TextClipboard::Get();
2170 clipboard.ShowClipboard();
2171 TestGenerateTap(application, 3.0f, 25.0f, 100);
2172 clipboard.HideClipboard();
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 // Tap first to get the focus.
2179 TestGenerateTap(application, 3.0f, 25.0f, 1000);
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 // Double tap to select a word.
2186 TestGenerateTap(application, 3.0f, 25.0f, 1100);
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 // The stencil actor should have two actors: the renderer and the highlight actor.
2193 Actor stencil = editor.GetChildAt(0u);
2195 // Highlight needs to be drawn before text, so should come first in child order
2196 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2197 DALI_TEST_CHECK(highlight);
2199 // The stencil actor has a container with all the actors which contain the text renderers.
2200 Actor container = stencil.GetChildAt(1u);
2201 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2203 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2204 DALI_TEST_CHECK(renderer);
2207 // Double tap out of bounds
2208 TestGenerateTap(application, 29.0f, 25.0f, 1700);
2209 TestGenerateTap(application, 29.0f, 25.0f, 1800);
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // The stencil actor should have one actors: the renderer actor.
2216 stencil = editor.GetChildAt(0u);
2218 // The stencil actor has a container with all the actors which contain the text renderers.
2219 container = stencil.GetChildAt(0u);
2220 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2222 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2223 DALI_TEST_CHECK(renderer);
2227 TestGenerateLongPress(application, 1.0f, 25.0f);
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2234 TestGenerateMiniPan(application);
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2243 int utcDaliTextEditorEvent04(void)
2245 ToolkitTestApplication application;
2246 tet_infoline(" utcDaliTextEditorEvent04");
2248 // Checks if the highlight actor is created.
2250 TextEditor editor = TextEditor::New();
2251 DALI_TEST_CHECK(editor);
2253 application.GetScene().Add(editor);
2255 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2256 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2257 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2258 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2259 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2261 // Avoid a crash when core load gl resources.
2262 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2268 // Tap on the text editor
2269 TestGenerateTap(application, 3.0f, 25.0f);
2271 // Render and notify
2272 application.SendNotification();
2273 application.Render();
2275 // Move at the end of the text.
2276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2277 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 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 for(unsigned int index = 0u; index < 10u; ++index)
2285 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2286 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2294 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 DALI_TEST_EQUALS("Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2302 // Add some key events
2303 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2304 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 for(unsigned int index = 0u; index < 10u; ++index)
2312 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2313 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2321 application.ProcessEvent(GenerateKey(" ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 DALI_TEST_EQUALS(" Hello\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2332 int utcDaliTextEditorEvent05(void)
2334 ToolkitTestApplication application;
2335 tet_infoline(" utcDaliTextEditorEvent05");
2337 // Checks if the highlight actor is created.
2339 TextEditor editor = TextEditor::New();
2340 DALI_TEST_CHECK(editor);
2342 application.GetScene().Add(editor);
2344 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworl");
2345 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2346 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
2347 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2348 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2349 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2350 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f);
2351 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
2352 editor.SetProperty(TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f);
2353 editor.SetProperty(TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f);
2355 // Avoid a crash when core load gl resources.
2356 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Tap on the text editor
2363 TestGenerateTap(application, 3.0f, 25.0f);
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 // Move at the end of the text.
2370 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2371 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 for(unsigned int index = 0u; index < 10u; ++index)
2380 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 // Modify duration after scroll is enabled
2387 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f);
2389 // Continuous scroll left to increase coverage
2390 for(unsigned int index = 0u; index < 10u; ++index)
2392 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SMOOTH_SCROLL_DURATION), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2399 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::SMOOTH_SCROLL), true, TEST_LOCATION);
2400 DALI_TEST_EQUALS(editor.GetProperty<bool>(TextEditor::Property::ENABLE_SCROLL_BAR), true, TEST_LOCATION);
2401 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_SHOW_DURATION), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2402 DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_BAR_FADE_DURATION), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2404 // Press Escape to increase coverage
2405 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2406 application.SendNotification();
2407 application.Render();
2409 DALI_TEST_CHECK(!editor.HasKeyInputFocus());
2414 int utcDaliTextEditorEvent06(void)
2416 ToolkitTestApplication application;
2417 tet_infoline(" utcDaliTextEditorEvent06");
2419 // Checks if the highlight actor is created.
2421 TextEditor editor = TextEditor::New();
2422 DALI_TEST_CHECK(editor);
2424 application.GetScene().Add(editor);
2426 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2427 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2428 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2429 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2430 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2432 // Avoid a crash when core load gl resources.
2433 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // Tap on the text editor
2440 TestGenerateTap(application, 3.0f, 25.0f);
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Move to seconds line of the text.
2447 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 float layoutHeight = editor.GetHeightForWidth(100.f);
2455 // Add another script characters ( glyph height is defferent )
2456 application.ProcessEvent(GenerateKey("d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2457 application.ProcessEvent(GenerateKey("d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459 // Delete characters
2460 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2461 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2463 DALI_TEST_EQUALS(layoutHeight, editor.GetHeightForWidth(100.f), TEST_LOCATION);
2465 // Render and notify
2466 application.SendNotification();
2467 application.Render();
2469 DALI_TEST_EQUALS("Hello\nworld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2472 application.ProcessEvent(GenerateKey("", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2473 application.SendNotification();
2474 application.Render();
2476 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2477 application.SendNotification();
2478 application.Render();
2480 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2481 application.SendNotification();
2482 application.Render();
2484 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2485 application.SendNotification();
2486 application.Render();
2488 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2489 application.SendNotification();
2490 application.Render();
2492 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2493 application.SendNotification();
2494 application.Render();
2496 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2497 application.SendNotification();
2498 application.Render();
2503 int utcDaliTextEditorEvent07(void)
2505 ToolkitTestApplication application;
2506 tet_infoline(" utcDaliTextEditorEvent07");
2508 // Checks if the highlight actor is created.
2510 TextEditor editor = TextEditor::New();
2511 DALI_TEST_CHECK(editor);
2513 application.GetScene().Add(editor);
2515 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
2516 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2517 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2518 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2519 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2521 // Avoid a crash when core load gl resources.
2522 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 // Tap on the text editor
2529 TestGenerateTap(application, 3.0f, 25.0f);
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Move to second line of the text.
2536 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 // Select some text in the right of the current cursor position
2543 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2544 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2545 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2546 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 // Cut the selected text
2553 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2554 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));
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2562 // Select some text in the left of the current cursor position
2563 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2564 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2565 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2566 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Copy the selected text
2573 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2574 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));
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Move the cursor to the third line
2581 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2582 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2584 // Render and notify
2585 application.SendNotification();
2586 application.Render();
2588 // Paste the selected text at the current cursor position
2589 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2590 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));
2592 // Render and notify
2593 application.SendNotification();
2594 application.Render();
2596 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2598 // Disable Shift Selection
2599 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
2601 // Test to select some text in the right of the current cursor position
2602 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2603 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2604 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2605 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 // Cut the selected text
2612 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2613 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));
2615 // Render and notify
2616 application.SendNotification();
2617 application.Render();
2619 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2620 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2622 // Test to select some text in the left of the current cursor position
2623 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2624 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2625 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2626 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2628 // Render and notify
2629 application.SendNotification();
2630 application.Render();
2632 // Copy the selected text
2633 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2634 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));
2636 // Render and notify
2637 application.SendNotification();
2638 application.Render();
2640 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2641 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2644 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));
2646 // Render and notify
2647 application.SendNotification();
2648 application.Render();
2650 // replace text with "c"
2651 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2653 // Render and notify
2654 application.SendNotification();
2655 application.Render();
2658 DALI_TEST_EQUALS("c", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2661 DevelTextEditor::SelectWholeText(editor);
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 // Copy the selected text using logical keys
2668 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2669 application.ProcessEvent(GenerateKey("ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2676 DevelTextEditor::SelectNone(editor);
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 // Paste the selected using logical keys
2683 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2684 application.ProcessEvent(GenerateKey("ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2687 DALI_TEST_EQUALS("cc", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2689 // select all using logical keys
2690 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2691 application.ProcessEvent(GenerateKey("ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2693 // Render and notify
2694 application.SendNotification();
2695 application.Render();
2697 // cut text using logical keys
2698 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2699 application.ProcessEvent(GenerateKey("ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2701 // Render and notify
2702 application.SendNotification();
2703 application.Render();
2706 DALI_TEST_EQUALS("", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2711 int utcDaliTextEditorEvent08(void)
2713 ToolkitTestApplication application;
2714 tet_infoline(" utcDaliTextEditorEvent08");
2716 // Checks if the highlight actor is released correctly.
2718 TextEditor editor = TextEditor::New();
2719 DALI_TEST_CHECK(editor);
2721 application.GetScene().Add(editor);
2723 editor.SetProperty(TextEditor::Property::TEXT, "DALi");
2724 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2725 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2726 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2727 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2729 // Avoid a crash when core load gl resources.
2730 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2732 // Render and notify
2733 application.SendNotification();
2734 application.Render();
2736 // Tap on the text editor
2737 TestGenerateTap(application, 3.0f, 25.0f);
2739 // Render and notify
2740 application.SendNotification();
2741 application.Render();
2743 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2744 // Test to select some text in the left of the current cursor position
2745 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2746 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2747 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2748 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 // Test to the left selection handle position and the right selection handle position
2755 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2756 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2757 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2758 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2760 // Render and notify
2761 application.SendNotification();
2762 application.Render();
2764 // Test to select full text in the left of the current cursor position
2765 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 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));
2767 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2768 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2769 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2770 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2772 // Render and notify
2773 application.SendNotification();
2774 application.Render();
2776 // Test to release the current full text selection
2777 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2778 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2780 // Render and notify
2781 application.SendNotification();
2782 application.Render();
2784 // Test to move the current cursor position correctly
2785 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2787 // Render and notify
2788 application.SendNotification();
2789 application.Render();
2792 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 DALI_TEST_EQUALS("DdALi", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2800 // Test to select some text in the right of the current cursor position
2801 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2802 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2803 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2805 // Render and notify
2806 application.SendNotification();
2807 application.Render();
2809 // Test the cursor position with right arrow key
2810 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2817 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 DALI_TEST_EQUALS("DdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2825 // Test to select some text in the left of the current cursor position
2826 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2827 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2828 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2829 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2830 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2832 // Render and notify
2833 application.SendNotification();
2834 application.Render();
2836 // Test the cursor position with left arrow key
2837 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2844 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 DALI_TEST_EQUALS("DcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2852 // Test to select some text in the right of the current cursor position
2853 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2854 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2855 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2856 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2858 // Render and notify
2859 application.SendNotification();
2860 application.Render();
2862 // Test the cursor position with left arrow key
2863 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2865 // Render and notify
2866 application.SendNotification();
2867 application.Render();
2870 application.ProcessEvent(GenerateKey("x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2872 // Render and notify
2873 application.SendNotification();
2874 application.Render();
2876 DALI_TEST_EQUALS("DcxdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2878 // Test to select some text in the left of the current cursor position
2879 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2880 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2881 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2882 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2884 // Render and notify
2885 application.SendNotification();
2886 application.Render();
2888 // Test the cursor position with right arrow key
2889 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2891 // Render and notify
2892 application.SendNotification();
2893 application.Render();
2896 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2898 // Render and notify
2899 application.SendNotification();
2900 application.Render();
2902 DALI_TEST_EQUALS("DcxcdALci", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
2907 int utcDaliTextEditorHandles(void)
2909 ToolkitTestApplication application;
2910 tet_infoline(" utcDaliTextEditorHandles");
2912 TextEditor editor = TextEditor::New();
2913 DALI_TEST_CHECK(editor);
2915 application.GetScene().Add(editor);
2917 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
2918 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
2919 editor.SetProperty(TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME);
2920 editor.SetProperty(TextEditor::Property::SMOOTH_SCROLL, true);
2922 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2923 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_LEFT_SELECTION_FILE_NAME}});
2924 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2925 editor.SetProperty(TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{{"filename", HANDLE_RIGHT_SELECTION_FILE_NAME}});
2927 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
2928 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2929 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2931 // Avoid a crash when core load gl resources.
2932 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2934 // Render and notify
2935 application.SendNotification();
2936 application.Render();
2938 // Tap first to get the focus.
2939 TestGenerateTap(application, 3.0f, 25.0f, 100);
2941 // Render and notify
2942 application.SendNotification();
2943 application.Render();
2945 // Tap to create the grab handle.
2946 TestGenerateTap(application, 3.0f, 25.0f, 700);
2948 // Render and notify
2949 application.SendNotification();
2950 application.Render();
2952 // Get the active layer where the text's decoration is added.
2953 Actor activeLayer = editor.GetChildAt(1u);
2955 // Get the handle's actor.
2956 Actor handle = activeLayer.GetChildAt(0u);
2957 handle.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2959 // Render and notify
2960 application.SendNotification();
2961 application.Render();
2963 // Touch the grab handle to set it as pressed.
2964 Vector2 touchPos(10.0f, 50.0f);
2965 Dali::Integration::TouchEvent event;
2966 event = Dali::Integration::TouchEvent();
2967 event.AddPoint(GetPointDownInside(touchPos));
2968 application.ProcessEvent(event);
2970 // Render and notify
2971 application.SendNotification();
2972 application.Render();
2974 // Pan the grab handle
2975 uint32_t time = 100;
2976 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
2977 TestMovePan(application, Vector2(10.0f, 30.0f), time);
2978 TestEndPan(application, Vector2(10.0f, 50.0f), time);
2979 application.SendNotification();
2980 application.Render();
2982 // Release the grab handle.
2983 event = Dali::Integration::TouchEvent();
2984 event.AddPoint(GetPointUpInside(touchPos));
2985 application.ProcessEvent(event);
2987 // Render and notify
2988 application.SendNotification();
2989 application.Render();
2991 // Tap first to get the focus.
2992 TestGenerateTap(application, 3.0f, 25.0f, 1400);
2994 // Render and notify
2995 application.SendNotification();
2996 application.Render();
2998 // Double tap to select a word and create the selection handles.
2999 TestGenerateTap(application, 3.0f, 25.0f, 1500);
3001 // Render and notify
3002 application.SendNotification();
3003 application.Render();
3005 touchPos = Vector2(10.0f, 50.0f);
3007 // Touch the left selection handle to set it as pressed.
3008 event = Dali::Integration::TouchEvent();
3009 event.AddPoint(GetPointDownInside(touchPos));
3010 application.ProcessEvent(event);
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 // Release the left selection handle.
3017 event = Dali::Integration::TouchEvent();
3018 event.AddPoint(GetPointUpInside(touchPos));
3019 application.ProcessEvent(event);
3021 // Render and notify
3022 application.SendNotification();
3023 application.Render();
3028 int utcDaliTextEditorUnderPropertyStringP(void)
3030 ToolkitTestApplication application;
3031 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
3032 TextEditor editor = TextEditor::New();
3033 DALI_TEST_CHECK(editor);
3035 std::string underlineSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\",\"type\":\"SOLID\",\"dashWidth\":\"2\",\"dashGap\":\"1\"}");
3037 application.GetScene().Add(editor);
3039 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3040 DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::UNDERLINE), underlineSettings1, TEST_LOCATION);
3042 tet_infoline("Set underline settings with a map");
3043 // Check the input underline property
3044 Property::Map underlineMapSet;
3045 Property::Map underlineMapGet;
3046 underlineMapSet.Insert("enable", true);
3047 underlineMapSet.Insert("color", Color::BLUE);
3048 underlineMapSet.Insert("height", 1);
3049 underlineMapSet.Insert("type", Text::Underline::SOLID);
3050 underlineMapSet.Insert("dashWidth", 2);
3051 underlineMapSet.Insert("dashGap", 1);
3053 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3054 editor.SetProperty(TextEditor::Property::TEXT, "text");
3055 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3056 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3057 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3059 application.SendNotification();
3060 application.Render();
3062 underlineMapSet.Clear();
3063 underlineMapGet.Clear();
3065 tet_infoline("Set dashed underline settings with a map");
3066 // Check the input underline property
3067 underlineMapSet.Clear();
3068 underlineMapGet.Clear();
3069 underlineMapSet.Insert("enable", true);
3070 underlineMapSet.Insert("color", Color::BLUE);
3071 underlineMapSet.Insert("height", 1);
3072 underlineMapSet.Insert("type", Text::Underline::DASHED);
3073 underlineMapSet.Insert("dashWidth", 5);
3074 underlineMapSet.Insert("dashGap", 3);
3076 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3077 editor.SetProperty(TextEditor::Property::TEXT, "text");
3078 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3079 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3080 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3082 // Check the input underline property
3083 underlineMapSet.Clear();
3084 underlineMapGet.Clear();
3085 underlineMapSet.Insert("enable", true);
3086 underlineMapSet.Insert("color", Color::BLUE);
3087 underlineMapSet.Insert("height", 1);
3088 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
3089 underlineMapSet.Insert("dashWidth", 5);
3090 underlineMapSet.Insert("dashGap", 3);
3092 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3093 editor.SetProperty(TextEditor::Property::TEXT, "text");
3094 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3095 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3096 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3098 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
3099 editor.SetProperty(TextEditor::Property::TEXT, "text");
3100 underlineMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
3101 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
3102 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapSet, underlineMapGet), true, TEST_LOCATION);
3104 application.SendNotification();
3105 application.Render();
3107 underlineMapSet.Clear();
3108 underlineMapGet.Clear();
3110 tet_infoline("Set underline settings with a string");
3111 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettings1);
3112 Property::Value value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3115 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3117 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
3118 std::string underlineSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}");
3119 editor.SetProperty(TextEditor::Property::UNDERLINE, underlineSettingsVoid);
3120 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3122 DALI_TEST_EQUALS(result, underlineSettings1, TEST_LOCATION);
3127 int utcDaliTextEditorStrikethroughPropertyStringP(void)
3129 ToolkitTestApplication application;
3130 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
3131 TextEditor editor = TextEditor::New();
3132 DALI_TEST_CHECK(editor);
3134 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
3136 application.GetScene().Add(editor);
3138 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3139 DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
3141 tet_infoline("Set strikethrough settings with a map");
3142 // Check the input strikethrough property
3143 Property::Map strikethroughMapSet;
3144 Property::Map strikethroughMapGet;
3145 strikethroughMapSet.Insert("enable", true);
3146 strikethroughMapSet.Insert("color", Color::BLUE);
3147 strikethroughMapSet.Insert("height", 2.0f);
3149 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
3150 strikethroughMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
3151 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3152 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapSet, strikethroughMapGet), true, TEST_LOCATION);
3154 tet_infoline("Set strikethrough settings with a string");
3155 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1);
3156 Property::Value value = editor.GetProperty(DevelTextEditor::Property::STRIKETHROUGH);
3159 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3161 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
3162 std::string strikethroughSettingsVoid("{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}");
3163 editor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid);
3164 value = editor.GetProperty(TextEditor::Property::UNDERLINE);
3166 DALI_TEST_EQUALS(result, strikethroughSettings1, TEST_LOCATION);
3171 int utcDaliTextEditorShadowPropertyStringP(void)
3173 ToolkitTestApplication application;
3174 tet_infoline(" utcDaliTextEditorShadowPropertyStringP Setting Shadow propeties by string");
3176 TextEditor editor = TextEditor::New();
3178 std::string shadowSettings("{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3180 application.GetScene().Add(editor);
3182 editor.SetProperty(TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}");
3184 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::SHADOW);
3188 DALI_TEST_EQUALS(result, shadowSettings, TEST_LOCATION);
3193 int utcDaliTextEditorFontStylePropertyStringP(void)
3195 ToolkitTestApplication application;
3196 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
3198 TextEditor editor = TextEditor::New();
3200 std::string fontStyleSettings("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3202 application.GetScene().Add(editor);
3204 editor.SetProperty(TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}");
3206 Property::Value value = editor.GetProperty<std::string>(TextEditor::Property::FONT_STYLE);
3210 DALI_TEST_EQUALS(result, fontStyleSettings, TEST_LOCATION);
3215 int utcDaliTextEditorGetPropertyLinecountP(void)
3217 ToolkitTestApplication application;
3219 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
3223 TextEditor editor = TextEditor::New();
3224 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3225 editor.SetProperty(TextEditor::Property::TEXT,
3226 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3228 application.GetScene().Add(editor);
3230 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3231 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3232 DALI_TEST_EQUALS(lineCount, 14, TEST_LOCATION);
3234 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
3235 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3236 DALI_TEST_EQUALS(lineCount, 28, TEST_LOCATION);
3241 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3243 ToolkitTestApplication application;
3244 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3246 TextEditor editor = TextEditor::New();
3247 DALI_TEST_CHECK(editor);
3249 application.GetScene().Add(editor);
3251 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
3252 editor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 50.f));
3253 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3254 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3255 editor.SetProperty(TextEditor::Property::ENABLE_SCROLL_BAR, true);
3256 editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3258 bool startedCalled = false;
3259 bool finishedCalled = false;
3261 ScrollStateChangeCallback callback(startedCalled, finishedCalled);
3262 editor.ScrollStateChangedSignal().Connect(&callback, &ScrollStateChangeCallback::Callback);
3264 KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
3266 // Render and notify
3267 application.SendNotification();
3268 application.Render();
3270 editor.SetProperty(TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3271 application.SendNotification();
3272 application.Render(6000);
3274 application.SendNotification();
3275 DALI_TEST_EQUALS(startedCalled, true, TEST_LOCATION);
3276 DALI_TEST_EQUALS(finishedCalled, true, TEST_LOCATION);
3281 int UtcDaliToolkitTextEditorTextWrapMode(void)
3283 ToolkitTestApplication application;
3284 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3288 TextEditor editor = TextEditor::New();
3289 editor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3290 editor.SetProperty(TextEditor::Property::TEXT, "Hello world Hello world");
3292 application.GetScene().Add(editor);
3294 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "WORD");
3295 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3297 application.SendNotification();
3298 application.Render();
3300 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3301 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3303 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3304 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3306 application.SendNotification();
3307 application.Render();
3309 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3310 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3312 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
3313 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
3315 application.SendNotification();
3316 application.Render();
3318 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3319 DALI_TEST_EQUALS(lineCount, 4, TEST_LOCATION);
3321 editor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
3322 DALI_TEST_EQUALS(editor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
3324 application.SendNotification();
3325 application.Render();
3327 lineCount = editor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3328 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
3333 int UtcDaliTextEditorSetPaddingProperty(void)
3335 ToolkitTestApplication application;
3336 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3338 TextEditor editor = TextEditor::New();
3339 DALI_TEST_CHECK(editor);
3340 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3341 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3342 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3343 application.GetScene().Add(editor);
3345 application.SendNotification();
3346 application.Render();
3348 Vector3 originalSize = editor.GetNaturalSize();
3350 editor.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3352 application.SendNotification();
3353 application.Render();
3355 DALI_TEST_EQUALS(editor.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3357 Vector3 paddingAddedSize = editor.GetNaturalSize();
3359 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3361 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3366 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3368 ToolkitTestApplication application;
3369 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3371 TextEditor editor = TextEditor::New();
3372 DALI_TEST_CHECK(editor);
3373 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3374 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3375 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3376 application.GetScene().Add(editor);
3378 application.SendNotification();
3379 application.Render();
3381 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3382 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3384 // Check the enable shift selection property
3385 editor.SetProperty(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false);
3386 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3388 application.SendNotification();
3389 application.Render();
3394 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3396 ToolkitTestApplication application;
3397 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3399 TextEditor editor = TextEditor::New();
3400 DALI_TEST_CHECK(editor);
3401 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3402 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3403 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3404 application.GetScene().Add(editor);
3406 application.SendNotification();
3407 application.Render();
3409 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3410 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3412 // Check the enable grab handle property
3413 editor.SetProperty(DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false);
3414 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3416 application.SendNotification();
3417 application.Render();
3422 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3424 ToolkitTestApplication application;
3425 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3427 TextEditor editor = TextEditor::New();
3428 DALI_TEST_CHECK(editor);
3429 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3430 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3431 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3432 application.GetScene().Add(editor);
3434 application.SendNotification();
3435 application.Render();
3437 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3438 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3440 // Check the disable match system language direction property
3441 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3442 DALI_TEST_EQUALS(editor.GetProperty<bool>(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3444 application.SendNotification();
3445 application.Render();
3450 int UtcDaliTextEditorGetInputMethodContext(void)
3452 ToolkitTestApplication application;
3453 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3455 TextEditor editor = TextEditor::New();
3456 DALI_TEST_CHECK(DevelTextEditor::GetInputMethodContext(editor));
3461 int utcDaliTextEditorMaxCharactersReached(void)
3463 ToolkitTestApplication application;
3464 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3466 TextEditor editor = TextEditor::New();
3467 DALI_TEST_CHECK(editor);
3469 application.GetScene().Add(editor);
3471 const int maxNumberOfCharacters = 1;
3472 editor.SetProperty(DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters);
3473 DALI_TEST_EQUALS(editor.GetProperty<int>(DevelTextEditor::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
3475 editor.SetKeyInputFocus();
3477 // connect to the text changed signal.
3478 ConnectionTracker* testTracker = new ConnectionTracker();
3479 DevelTextEditor::MaxLengthReachedSignal(editor).Connect(&TestMaxLengthReachedCallback);
3480 bool maxLengthReachedSignal = false;
3481 editor.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3483 gMaxCharactersCallBackCalled = false;
3485 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3486 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3488 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
3489 DALI_TEST_CHECK(maxLengthReachedSignal);
3494 int utcDaliTextEditorInputFiltered(void)
3496 ToolkitTestApplication application;
3497 tet_infoline(" utcDaliTextEditorInputFiltered");
3498 TextEditor editor = TextEditor::New();
3499 DALI_TEST_CHECK(editor);
3501 application.GetScene().Add(editor);
3503 Property::Map inputFilter;
3505 // Only digit is accepted.
3506 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3508 // Set input filter to TextEditor.
3509 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3511 editor.SetKeyInputFocus();
3513 // connect to the input filtered signal.
3514 ConnectionTracker* testTracker = new ConnectionTracker();
3515 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3516 bool inputFilteredSignal = false;
3517 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3519 gInputFilteredAcceptedCallbackCalled = false;
3521 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3523 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3524 DALI_TEST_CHECK(inputFilteredSignal);
3526 // Word is rejected.
3527 inputFilter[InputFilter::Property::ACCEPTED] = "";
3528 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3530 // Set input filter to TextEditor.
3531 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3533 editor.SetKeyInputFocus();
3535 inputFilteredSignal = false;
3536 gInputFilteredRejectedCallbackCalled = false;
3538 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3540 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3541 DALI_TEST_CHECK(inputFilteredSignal);
3546 int UtcDaliTextEditorSelectWholeText(void)
3548 ToolkitTestApplication application;
3549 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3551 TextEditor textEditor = TextEditor::New();
3553 application.GetScene().Add(textEditor);
3555 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3556 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3557 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3559 // Avoid a crash when core load gl resources.
3560 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3562 application.SendNotification();
3563 application.Render();
3565 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3567 DevelTextEditor::SelectWholeText(textEditor);
3569 application.SendNotification();
3570 application.Render();
3572 // Nothing should have been selected. The number of children is still 1
3573 DALI_TEST_EQUALS(1u, textEditor.GetChildCount(), TEST_LOCATION);
3575 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3577 application.SendNotification();
3578 application.Render();
3580 DevelTextEditor::SelectWholeText(textEditor);
3582 application.SendNotification();
3583 application.Render();
3585 // Should be 2 children, the stencil and the layer
3586 DALI_TEST_EQUALS(2u, textEditor.GetChildCount(), TEST_LOCATION);
3588 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3589 Actor stencil = textEditor.GetChildAt(0u);
3591 // The highlight actor is drawn first, so is the first actor in the list
3592 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3593 DALI_TEST_CHECK(highlight);
3598 int UtcDaliTextEditorSelectText(void)
3600 ToolkitTestApplication application;
3601 tet_infoline(" UtcDaliTextEditorSelectText ");
3603 TextEditor textEditor = TextEditor::New();
3605 application.GetScene().Add(textEditor);
3607 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3608 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3609 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3611 // Avoid a crash when core load gl resources.
3612 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3614 application.SendNotification();
3615 application.Render();
3617 DevelTextEditor::SelectText(textEditor, 0, 5);
3619 application.SendNotification();
3620 application.Render();
3622 // Nothing is selected
3623 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3624 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3626 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3628 application.SendNotification();
3629 application.Render();
3631 DevelTextEditor::SelectText(textEditor, 0, 5);
3633 application.SendNotification();
3634 application.Render();
3636 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3637 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3639 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3640 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3642 // world is selected
3643 DevelTextEditor::SelectText(textEditor, 6, 11);
3645 application.SendNotification();
3646 application.Render();
3648 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3649 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3651 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3652 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3657 int UtcDaliTextEditorSelectNone(void)
3659 ToolkitTestApplication application;
3660 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3662 TextEditor textEditor = TextEditor::New();
3664 application.GetScene().Add(textEditor);
3666 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3667 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3668 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3670 // Avoid a crash when core load gl resources.
3671 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3673 application.SendNotification();
3674 application.Render();
3676 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3678 application.SendNotification();
3679 application.Render();
3681 // Nothing is selected
3682 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3683 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3685 DevelTextEditor::SelectWholeText(textEditor);
3687 application.SendNotification();
3688 application.Render();
3690 // whole text is selected
3691 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3692 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3694 DevelTextEditor::SelectNone(textEditor);
3696 application.SendNotification();
3697 application.Render();
3699 // Nothing is selected
3700 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3701 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3706 int UtcDaliTextEditorSelectRange(void)
3708 ToolkitTestApplication application;
3709 tet_infoline("utcDaliTextEditorSelectRange");
3711 TextEditor textEditor = TextEditor::New();
3712 DALI_TEST_CHECK(textEditor);
3714 application.GetScene().Add(textEditor);
3716 // Avoid a crash when core load gl resources.
3717 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3719 application.SendNotification();
3720 application.Render();
3722 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
3724 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_START, 0);
3725 textEditor.SetProperty(DevelTextEditor::Property::SELECTED_TEXT_END, 5);
3727 // Hello is selected
3728 std::string selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
3729 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3731 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3732 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3737 int UtcDaliTextEditorEnableEditing(void)
3739 ToolkitTestApplication application;
3740 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3742 TextEditor textEditor = TextEditor::New();
3744 application.GetScene().Add(textEditor);
3746 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3747 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3748 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3750 // Avoid a crash when core load gl resources.
3751 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3753 application.SendNotification();
3754 application.Render();
3756 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3757 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3759 textEditor.SetKeyInputFocus();
3760 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, false);
3761 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3763 // Render and notify
3764 application.SendNotification();
3765 application.Render();
3767 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3768 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3770 textEditor.SetKeyInputFocus();
3771 textEditor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
3772 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3774 // Render and notify
3775 application.SendNotification();
3776 application.Render();
3778 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3779 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3781 // Check the user interaction enabled and for coverage
3782 DevelTextEditor::SelectWholeText(textEditor);
3784 // Render and notify
3785 application.SendNotification();
3786 application.Render();
3788 textEditor.SetKeyInputFocus();
3789 textEditor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3790 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3792 // Render and notify
3793 application.SendNotification();
3794 application.Render();
3796 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3797 DALI_TEST_EQUALS(textEditor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3802 int UtcDaliTextEditorScrolling(void)
3804 ToolkitTestApplication application;
3805 tet_infoline(" UtcDaliTextEditorScrolling ");
3807 TextEditor textEditor = TextEditor::New();
3808 DALI_TEST_CHECK(textEditor);
3810 application.GetScene().Add(textEditor);
3812 // Avoid a crash when core load gl resources.
3813 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3815 application.SendNotification();
3816 application.Render();
3818 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3819 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3820 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3821 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3823 application.SendNotification();
3824 application.Render();
3826 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3827 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3829 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3831 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, TEST_LOCATION);
3832 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3834 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3836 DALI_TEST_NOT_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 1.0f, 0.1f, TEST_LOCATION);
3837 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3839 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION, 0.0f);
3840 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION, 0.0f);
3842 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3843 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION).Get<float>(), 0.0f, TEST_LOCATION);
3848 int UtcDaliToolkitTextEditorFontSizeScale(void)
3850 ToolkitTestApplication application;
3851 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3853 TextEditor textEditor = TextEditor::New();
3854 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 30.f);
3855 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3856 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3858 TextEditor textEditorScaled = TextEditor::New();
3859 textEditorScaled.SetProperty(TextEditor::Property::POINT_SIZE, 15.f);
3860 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3861 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3862 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3864 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3866 textEditor.SetProperty(TextEditor::Property::PIXEL_SIZE, 30.f);
3867 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
3868 nonScaledSize = textEditor.GetNaturalSize();
3870 textEditorScaled.SetProperty(TextEditor::Property::PIXEL_SIZE, 15.f);
3871 textEditorScaled.SetProperty(Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f);
3872 textEditorScaled.SetProperty(TextEditor::Property::TEXT, "Test");
3873 scaledSize = textEditorScaled.GetNaturalSize();
3875 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3880 int UtcDaliTextEditorPrimaryCursorPosition(void)
3882 ToolkitTestApplication application;
3883 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3885 TextEditor textEditor = TextEditor::New();
3887 application.GetScene().Add(textEditor);
3889 textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEF");
3890 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3891 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3892 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3894 // Avoid a crash when core load gl resources.
3895 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3897 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3898 application.SendNotification();
3899 application.Render();
3900 textEditor.SetKeyInputFocus();
3902 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3904 // Render and notify
3905 application.SendNotification();
3906 application.Render();
3908 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3909 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3914 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3916 ToolkitTestApplication application;
3917 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3919 TextEditor textEditor = TextEditor::New();
3920 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3921 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3922 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3923 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3924 application.GetScene().Add(textEditor);
3926 application.SendNotification();
3927 application.Render();
3930 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3931 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3933 textEditor.GetNaturalSize();
3935 // Create a tap event to touch the text editor.
3936 TestGenerateTap(application, 18.0f, 25.0f);
3938 application.SendNotification();
3939 application.Render();
3941 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3942 DALI_TEST_EQUALS(lineCount, 7, TEST_LOCATION);
3947 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3949 ToolkitTestApplication application;
3951 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3953 int lineCountBefore = 0;
3954 int lineCountAfter = 0;
3956 // Create a text editor
3957 TextEditor textEditor = TextEditor::New();
3958 //Set very large font-size using point-size
3959 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
3960 //Specify font-family
3961 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3963 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3964 //Set text longer than width of textEditor
3965 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3967 application.GetScene().Add(textEditor);
3969 application.SendNotification();
3970 application.Render();
3972 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3973 //GetHeightForWidth is a retrieval method which should not modify object
3974 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3975 textEditor.GetHeightForWidth(200.f);
3977 //This is to simulate focus into text editor after calling GetHeightForWidth
3978 //Create a tap event to touch the text editor.
3979 TestGenerateTap(application, 18.0f, 25.0f);
3981 application.SendNotification();
3982 application.Render();
3984 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
3986 //The LineCount must not be changed when calling GetHeightForWidth.
3987 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
3992 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3994 ToolkitTestApplication application;
3996 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3998 int lineCountBefore = 0;
3999 int lineCountAfter = 0;
4001 // Create a text editor
4002 TextEditor textEditor = TextEditor::New();
4003 //Set very large font-size using point-size
4004 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4005 //Specify font-family
4006 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4008 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4009 //Set text longer than width of textEditor
4010 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4011 //Set line wrap mode Character
4012 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4014 application.GetScene().Add(textEditor);
4016 application.SendNotification();
4017 application.Render();
4019 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
4020 //GetHeightForWidth is a retrieval method which should not modify object
4021 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4022 textEditor.GetHeightForWidth(200.f);
4024 //This is to simulate focus into text editor after calling GetHeightForWidth
4025 //Create a tap event to touch the text editor.
4026 TestGenerateTap(application, 18.0f, 25.0f);
4028 application.SendNotification();
4029 application.Render();
4031 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4033 //The LineCount must not be changed when calling GetHeightForWidth.
4034 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4039 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
4041 ToolkitTestApplication application;
4043 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
4045 int lineCountBefore = 0;
4046 int lineCountAfter = 0;
4048 // Create a text editor
4049 TextEditor textEditor = TextEditor::New();
4050 //Set very large font-size using point-size
4051 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4052 //Specify font-family
4053 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4055 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
4056 //Set text longer than width of textEditor
4057 textEditor.SetProperty(TextEditor::Property::TEXT, "Short text");
4058 //Set line wrap mode Character
4059 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4061 application.GetScene().Add(textEditor);
4063 application.SendNotification();
4064 application.Render();
4066 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4068 textEditor.SetProperty(TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
4069 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4071 // When the text changed, the Line-count should be updated according to new text.
4072 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
4073 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
4074 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
4079 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
4081 ToolkitTestApplication application;
4083 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
4085 int lineCountBefore = 0;
4086 int lineCountAfter = 0;
4088 // Create a text editor
4089 TextEditor textEditor = TextEditor::New();
4090 //Set very large font-size using point-size
4091 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4092 //Specify font-family
4093 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4095 textEditor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
4096 //Set text longer than width of textEditor
4097 textEditor.SetProperty(TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
4099 application.GetScene().Add(textEditor);
4101 application.SendNotification();
4102 application.Render();
4104 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
4105 //GetNaturalSize is a retrieval method which should not modify object
4106 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4107 textEditor.GetNaturalSize();
4109 //This is to simulate focus into text editor after calling GetNaturalSize
4110 //Create a tap event to touch the text editor.
4111 TestGenerateTap(application, 18.0f, 25.0f);
4113 application.SendNotification();
4114 application.Render();
4116 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4118 //The LineCount must not be changed when calling GetNaturalSize.
4119 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4124 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
4126 ToolkitTestApplication application;
4128 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
4130 int lineCountBefore = 0;
4131 int lineCountAfter = 0;
4133 // Create a text editor
4134 TextEditor textEditor = TextEditor::New();
4135 //Set very large font-size using point-size
4136 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
4137 //Specify font-family
4138 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4140 textEditor.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
4141 //Set text longer than width of textEditor
4142 textEditor.SetProperty(TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
4143 //Set line wrap mode Character
4144 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
4146 application.GetScene().Add(textEditor);
4148 application.SendNotification();
4149 application.Render();
4151 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
4152 //GetNaturalSize is a retrieval method which should not modify object
4153 lineCountBefore = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4154 textEditor.GetNaturalSize();
4156 //This is to simulate focus into text editor after calling GetNaturalSize
4157 //Create a tap event to touch the text editor.
4158 TestGenerateTap(application, 18.0f, 25.0f);
4160 application.SendNotification();
4161 application.Render();
4163 lineCountAfter = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4165 //The LineCount must not be changed when calling GetNaturalSize.
4166 DALI_TEST_EQUALS(lineCountAfter, lineCountBefore, TEST_LOCATION);
4171 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
4173 ToolkitTestApplication application;
4174 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
4176 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4177 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4178 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4180 // Create a text editor
4181 TextEditor textEditor = TextEditor::New();
4183 //Set size to avoid automatic eliding
4184 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4185 //Set very large font-size using point-size
4186 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
4187 //Specify font-family
4188 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4189 //Set text to check if appear or not
4190 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4192 application.GetScene().Add(textEditor);
4194 application.SendNotification();
4195 application.Render();
4196 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4197 Vector3 naturalSize = textEditor.GetNaturalSize();
4199 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4200 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4205 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
4207 ToolkitTestApplication application;
4208 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
4210 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4211 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4212 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4214 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4215 // Create a text editor
4216 TextEditor textEditor = TextEditor::New();
4217 //Set size to avoid automatic eliding
4218 textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4219 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
4220 textEditor.SetProperty(TextEditor::Property::TEXT, "A");
4222 const int numberOfCases = 6;
4223 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4225 for(int index = 0; index < numberOfCases; index++)
4227 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4228 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, arrayCases[index]);
4229 application.GetScene().Add(textEditor);
4230 application.SendNotification();
4231 application.Render();
4232 naturalSize = textEditor.GetNaturalSize();
4233 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4234 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4240 int UtcDaliTextEditorHyphenWrapMode(void)
4242 ToolkitTestApplication application;
4243 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4246 TextEditor textEditor = TextEditor::New();
4248 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
4250 application.GetScene().Add(textEditor);
4251 application.SendNotification();
4252 application.Render();
4254 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4255 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4256 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
4258 application.SendNotification();
4259 application.Render();
4261 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4267 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
4269 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experimen");
4270 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4271 DALI_TEST_EQUALS(textEditor.GetProperty<int>(TextEditor::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
4273 application.SendNotification();
4274 application.Render();
4276 lineCount = textEditor.GetProperty<int>(TextEditor::Property::LINE_COUNT);
4283 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
4288 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4290 ToolkitTestApplication application;
4291 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4292 TextEditor textEditor = TextEditor::New();
4294 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4295 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4297 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4298 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4299 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4301 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4302 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4303 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4305 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4306 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4307 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4309 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4310 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4311 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4313 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4314 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4315 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4317 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4318 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4319 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4321 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4322 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4323 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4325 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4326 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4327 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4329 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4330 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4331 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4333 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4334 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4335 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4337 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4338 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4339 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4341 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4342 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4343 DALI_TEST_EQUALS(textEditor.GetProperty<int>(DevelTextEditor::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4348 int UtcDaliTextEditorCopyText(void)
4350 ToolkitTestApplication application;
4351 tet_infoline(" UtcDaliTextEditorCopyText ");
4353 TextEditor textEditor = TextEditor::New();
4355 std::string selectedText = "";
4356 std::string copiedText = "";
4358 application.GetScene().Add(textEditor);
4360 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4361 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4362 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4364 // Avoid a crash when core load gl resources.
4365 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4367 application.SendNotification();
4368 application.Render();
4370 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4372 application.SendNotification();
4373 application.Render();
4375 // Hello is selected
4376 DevelTextEditor::SelectText(textEditor, 0, 5);
4378 application.SendNotification();
4379 application.Render();
4381 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4382 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4384 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4385 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4388 copiedText = DevelTextEditor::CopyText(textEditor);
4389 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4391 // world is selected
4392 DevelTextEditor::SelectText(textEditor, 6, 11);
4394 application.SendNotification();
4395 application.Render();
4397 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4398 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4400 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4401 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4404 copiedText = DevelTextEditor::CopyText(textEditor);
4405 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4407 // "lo wo" is selected
4408 DevelTextEditor::SelectText(textEditor, 3, 8);
4410 application.SendNotification();
4411 application.Render();
4413 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4414 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4416 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4417 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4419 // "lo wo" is copied
4420 copiedText = DevelTextEditor::CopyText(textEditor);
4421 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4426 int UtcDaliTextEditorCutText(void)
4428 ToolkitTestApplication application;
4429 tet_infoline(" UtcDaliTextEditorCutText ");
4431 TextEditor textEditor = TextEditor::New();
4433 std::string selectedText = "";
4435 application.GetScene().Add(textEditor);
4437 textEditor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4438 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4439 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4441 // Avoid a crash when core load gl resources.
4442 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4444 application.SendNotification();
4445 application.Render();
4447 textEditor.SetProperty(TextEditor::Property::TEXT, "Hello world");
4449 application.SendNotification();
4450 application.Render();
4452 // Hello is selected
4453 DevelTextEditor::SelectText(textEditor, 0, 5);
4455 application.SendNotification();
4456 application.Render();
4458 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4459 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4461 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4462 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4465 DALI_TEST_EQUALS("Hello", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4467 application.SendNotification();
4468 application.Render();
4470 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4473 DevelTextEditor::SelectText(textEditor, 0, 2);
4475 application.SendNotification();
4476 application.Render();
4478 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4479 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4481 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4482 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4485 DALI_TEST_EQUALS(" w", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4487 application.SendNotification();
4488 application.Render();
4490 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4492 // Test Cut from the middle
4495 DevelTextEditor::SelectText(textEditor, 1, 3);
4497 application.SendNotification();
4498 application.Render();
4500 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4501 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4503 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4504 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4507 DALI_TEST_EQUALS("rl", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4509 application.SendNotification();
4510 application.Render();
4512 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4514 // Test Cut from the end
4517 DevelTextEditor::SelectText(textEditor, 1, 2);
4519 application.SendNotification();
4520 application.Render();
4522 selectedText = textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
4523 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4525 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4526 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4529 DALI_TEST_EQUALS("d", DevelTextEditor::CutText(textEditor), TEST_LOCATION);
4531 application.SendNotification();
4532 application.Render();
4534 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4539 int UtcDaliTextEditorPasteText(void)
4541 ToolkitTestApplication application;
4542 tet_infoline(" UtcDaliTextEditorPasteText ");
4544 TextEditor editor = TextEditor::New();
4545 DALI_TEST_CHECK(editor);
4547 application.GetScene().Add(editor);
4549 std::string cutText = "";
4550 std::string copiedText = "";
4552 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4553 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4554 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4555 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4556 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4558 // Avoid a crash when core load gl resources.
4559 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4561 // Render and notify
4562 application.SendNotification();
4563 application.Render();
4565 // Tap on the text editor
4566 TestGenerateTap(application, 3.0f, 25.0f);
4568 // Render and notify
4569 application.SendNotification();
4570 application.Render();
4572 // Move to second line of the text.
4573 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4575 // Render and notify
4576 application.SendNotification();
4577 application.Render();
4579 // Select some text in the right of the current cursor position
4580 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4581 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4582 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4583 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4585 // Render and notify
4586 application.SendNotification();
4587 application.Render();
4589 // Cut the selected text
4590 cutText = DevelTextEditor::CutText(editor);
4592 // Render and notify
4593 application.SendNotification();
4594 application.Render();
4596 DALI_TEST_EQUALS("wor", cutText, TEST_LOCATION);
4597 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4599 // Select some text in the left of the current cursor position
4600 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4601 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4602 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4603 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4605 // Render and notify
4606 application.SendNotification();
4607 application.Render();
4609 // Copy the selected text
4610 copiedText = DevelTextEditor::CopyText(editor);
4612 // Render and notify
4613 application.SendNotification();
4614 application.Render();
4616 DALI_TEST_EQUALS("lo\n", copiedText, TEST_LOCATION);
4617 DALI_TEST_EQUALS("Hello\nld\nHello world", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4619 // Move the cursor to the third line
4620 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4621 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4623 // Render and notify
4624 application.SendNotification();
4625 application.Render();
4627 // Paste the selected text at the current cursor position
4628 DevelTextEditor::PasteText(editor);
4630 // Render and notify
4631 application.SendNotification();
4632 application.Render();
4634 DALI_TEST_EQUALS("Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>(TextEditor::Property::TEXT), TEST_LOCATION);
4639 int UtcDaliTextEditorLineSpacing(void)
4641 ToolkitTestApplication application;
4642 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4644 TextEditor textEditor = TextEditor::New();
4645 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4646 application.GetScene().Add(textEditor);
4647 application.SendNotification();
4648 application.Render();
4650 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4651 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 0);
4653 Vector3 sizeBefore = textEditor.GetNaturalSize();
4655 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4657 //add 20 for each line 20 * 3
4658 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4663 int UtcDaliTextEditorSelectionWithLineSpacing(void)
4665 //Only for test coverage
4666 ToolkitTestApplication application;
4667 tet_infoline(" UtcDaliTextEditorSelectionWithLineSpacing ");
4669 TextEditor textEditor = TextEditor::New();
4670 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4671 application.GetScene().Add(textEditor);
4672 application.SendNotification();
4673 application.Render();
4675 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4676 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, -20);
4678 application.SendNotification();
4679 application.Render();
4681 DevelTextEditor::SelectWholeText(textEditor);
4683 application.SendNotification();
4684 application.Render();
4686 DevelTextEditor::SelectNone(textEditor);
4687 textEditor.SetProperty(DevelTextEditor::Property::LINE_SPACING, 20);
4689 application.SendNotification();
4690 application.Render();
4692 DevelTextEditor::SelectWholeText(textEditor);
4694 application.SendNotification();
4695 application.Render();
4697 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::LINE_SPACING), 20.0f, TEST_LOCATION);
4702 int UtcDaliTextEditorMinLineSize(void)
4704 ToolkitTestApplication application;
4705 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4707 TextEditor textEditor = TextEditor::New();
4708 textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.f));
4709 application.GetScene().Add(textEditor);
4710 application.SendNotification();
4711 application.Render();
4713 textEditor.SetProperty(TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3");
4714 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 0);
4716 Vector3 sizeBefore = textEditor.GetNaturalSize();
4718 textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 60);
4720 DALI_TEST_NOT_EQUALS(sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4723 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4728 int utcDaliTextEditorCursorPositionChangedSignal(void)
4730 ToolkitTestApplication application;
4731 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4733 TextEditor editor = TextEditor::New();
4734 DALI_TEST_CHECK(editor);
4736 application.GetScene().Add(editor);
4738 // connect to the selection changed signal.
4739 ConnectionTracker* testTracker = new ConnectionTracker();
4740 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4741 bool cursorPositionChangedSignal = false;
4742 editor.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4744 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
4745 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
4746 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4747 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4748 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4750 // Avoid a crash when core load gl resources.
4751 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4753 // Render and notify
4754 application.SendNotification();
4755 application.Render();
4757 editor.SetKeyInputFocus();
4759 // Tap on the text editor
4760 TestGenerateTap(application, 3.0f, 25.0f);
4762 // Render and notify
4763 application.SendNotification();
4764 application.Render();
4766 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4767 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4769 gCursorPositionChangedCallbackCalled = false;
4772 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4774 // Render and notify
4775 application.SendNotification();
4776 application.Render();
4778 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4779 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4781 gCursorPositionChangedCallbackCalled = false;
4784 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4786 // Render and notify
4787 application.SendNotification();
4788 application.Render();
4790 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4791 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4793 gCursorPositionChangedCallbackCalled = false;
4795 //delete one character
4796 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4798 // Render and notify
4799 application.SendNotification();
4800 application.Render();
4802 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4803 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4805 gCursorPositionChangedCallbackCalled = false;
4807 editor.SetProperty(TextEditor::Property::TEXT, "Hello");
4809 // Render and notify
4810 application.SendNotification();
4811 application.Render();
4813 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4814 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4816 gCursorPositionChangedCallbackCalled = false;
4818 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4820 // Render and notify
4821 application.SendNotification();
4822 application.Render();
4824 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4825 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4830 int utcDaliTextEditorGeometryEllipsisStart(void)
4832 ToolkitTestApplication application;
4833 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4835 TextEditor editor = TextEditor::New();
4836 DALI_TEST_CHECK(editor);
4838 application.GetScene().Add(editor);
4840 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4841 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4842 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4843 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4844 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4845 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4846 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4847 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4848 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4850 // Avoid a crash when core load gl resources.
4851 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4853 // Render and notify
4854 application.SendNotification();
4855 application.Render();
4857 unsigned int expectedCount = 2;
4858 unsigned int startIndex = 0;
4859 unsigned int endIndex = 24;
4861 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4862 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4864 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4865 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4867 Vector<Vector2> expectedSizes;
4868 Vector<Vector2> expectedPositions;
4870 expectedPositions.PushBack(Vector2(38, 0));
4871 expectedSizes.PushBack(Vector2(21, 25));
4873 expectedPositions.PushBack(Vector2(-1, 25));
4874 expectedSizes.PushBack(Vector2(53, 25));
4876 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4881 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4883 ToolkitTestApplication application;
4884 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4886 TextEditor editor = TextEditor::New();
4887 DALI_TEST_CHECK(editor);
4889 application.GetScene().Add(editor);
4891 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4892 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4893 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4894 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4895 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4896 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4897 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4898 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4899 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4901 // Avoid a crash when core load gl resources.
4902 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4904 // Render and notify
4905 application.SendNotification();
4906 application.Render();
4908 unsigned int expectedCount = 2;
4909 unsigned int startIndex = 0;
4910 unsigned int endIndex = 24;
4912 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4913 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4915 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4916 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4918 Vector<Vector2> expectedSizes;
4919 Vector<Vector2> expectedPositions;
4921 expectedPositions.PushBack(Vector2(-1, 0));
4922 expectedSizes.PushBack(Vector2(26, 25));
4924 expectedPositions.PushBack(Vector2(-1, 25));
4925 expectedSizes.PushBack(Vector2(53, 25));
4927 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4932 int utcDaliTextEditorGeometryEllipsisEnd(void)
4934 ToolkitTestApplication application;
4935 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4937 TextEditor editor = TextEditor::New();
4938 DALI_TEST_CHECK(editor);
4940 application.GetScene().Add(editor);
4942 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4943 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4944 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4945 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4946 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4947 editor.SetProperty(DevelTextEditor::Property::ENABLE_SCROLL_BAR, false);
4948 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
4949 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4950 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4");
4952 // Avoid a crash when core load gl resources.
4953 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4955 // Render and notify
4956 application.SendNotification();
4957 application.Render();
4959 unsigned int expectedCount = 2;
4960 unsigned int startIndex = 0;
4961 unsigned int endIndex = 24;
4963 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4964 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4966 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4967 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4969 Vector<Vector2> expectedSizes;
4970 Vector<Vector2> expectedPositions;
4972 expectedPositions.PushBack(Vector2(-1, 0));
4973 expectedSizes.PushBack(Vector2(60, 25));
4975 expectedPositions.PushBack(Vector2(-1, 25));
4976 expectedSizes.PushBack(Vector2(39, 25));
4978 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4983 int utcDaliTextEditorGeometryRTL(void)
4985 ToolkitTestApplication application;
4986 tet_infoline(" utcDaliTextEditorGeometryRTL");
4988 TextEditor editor = TextEditor::New();
4989 DALI_TEST_CHECK(editor);
4991 application.GetScene().Add(editor);
4993 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
4994 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4995 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4996 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4997 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
4998 editor.SetProperty(TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
5000 // Avoid a crash when core load gl resources.
5001 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5003 // Render and notify
5004 application.SendNotification();
5005 application.Render();
5007 unsigned int expectedCount = 4;
5008 unsigned int startIndex = 3;
5009 unsigned int endIndex = 24;
5011 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5012 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5014 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5015 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5017 Vector<Vector2> expectedSizes;
5018 Vector<Vector2> expectedPositions;
5020 expectedPositions.PushBack(Vector2(25, 0));
5021 expectedSizes.PushBack(Vector2(34, 25));
5023 expectedPositions.PushBack(Vector2(-1, 25));
5024 expectedSizes.PushBack(Vector2(53, 25));
5026 expectedPositions.PushBack(Vector2(-1, 50));
5027 expectedSizes.PushBack(Vector2(60, 25));
5029 expectedPositions.PushBack(Vector2(63, 75));
5030 expectedSizes.PushBack(Vector2(37, 25));
5032 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5037 int utcDaliTextEditorGeometryGlyphMiddle(void)
5039 ToolkitTestApplication application;
5040 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
5042 TextEditor editor = TextEditor::New();
5043 DALI_TEST_CHECK(editor);
5045 application.GetScene().Add(editor);
5047 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5048 editor.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5049 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5050 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5051 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5052 editor.SetProperty(TextEditor::Property::TEXT, "لا تحتوي على لا");
5054 // Avoid a crash when core load gl resources.
5055 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5057 // Render and notify
5058 application.SendNotification();
5059 application.Render();
5061 unsigned int expectedCount = 1;
5062 unsigned int startIndex = 1;
5063 unsigned int endIndex = 13;
5065 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5066 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5068 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5069 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5071 Vector<Vector2> expectedSizes;
5072 Vector<Vector2> expectedPositions;
5074 expectedPositions.PushBack(Vector2(6, 0));
5075 expectedSizes.PushBack(Vector2(125, 25));
5077 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5082 int utcDaliTextEditorGeometryOneGlyph(void)
5084 ToolkitTestApplication application;
5085 tet_infoline(" utcDaliTextEditorGeometryOneGlyph ");
5087 TextEditor label = TextEditor::New();
5088 DALI_TEST_CHECK(label);
5090 application.GetScene().Add(label);
5092 label.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5093 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5094 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5095 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5096 label.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5097 label.SetProperty(TextEditor::Property::TEXT, "H");
5099 // Avoid a crash when core load gl resources.
5100 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5102 // Render and notify
5103 application.SendNotification();
5104 application.Render();
5106 unsigned int expectedCount = 1;
5107 unsigned int startIndex = 0;
5108 unsigned int endIndex = 0;
5110 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(label, startIndex, endIndex);
5111 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(label, startIndex, endIndex);
5113 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5114 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5116 Vector<Vector2> expectedSizes;
5117 Vector<Vector2> expectedPositions;
5119 expectedPositions.PushBack(Vector2(-2, 0));
5120 expectedSizes.PushBack(Vector2(16, 25));
5122 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5127 int utcDaliTextEditorGeometryNullPtr(void)
5129 ToolkitTestApplication application;
5130 tet_infoline("utcDaliTextEditorGeometryNullPtr");
5132 TextEditor editor = TextEditor::New();
5133 DALI_TEST_CHECK(editor);
5135 application.GetScene().Add(editor);
5137 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
5138 editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5139 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5140 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5141 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5142 editor.SetProperty(TextEditor::Property::TEXT, "");
5144 // Avoid a crash when core load gl resources.
5145 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5147 unsigned int expectedCount = 0;
5148 unsigned int startIndex = 0;
5149 unsigned int endIndex = 0;
5151 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
5152 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
5154 // Render and notify
5155 application.SendNotification();
5156 application.Render();
5158 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5159 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5165 int utcDaliTextEditorSelectionClearedSignal(void)
5167 ToolkitTestApplication application;
5168 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
5170 TextEditor editor = TextEditor::New();
5171 DALI_TEST_CHECK(editor);
5173 application.GetScene().Add(editor);
5175 // connect to the selection changed signal.
5176 ConnectionTracker* testTracker = new ConnectionTracker();
5177 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
5178 bool selectionClearedSignal = false;
5179 editor.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5181 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5182 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5183 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5184 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5185 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5187 // Avoid a crash when core load gl resources.
5188 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5190 // Render and notify
5191 application.SendNotification();
5192 application.Render();
5194 // Tap on the text editor
5195 TestGenerateTap(application, 3.0f, 25.0f);
5197 // Render and notify
5198 application.SendNotification();
5199 application.Render();
5201 // Move to second line of the text & Select some text in the right of the current cursor position
5202 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5203 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5206 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5208 // Render and notify
5209 application.SendNotification();
5210 application.Render();
5212 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5214 // Render and notify
5215 application.SendNotification();
5216 application.Render();
5218 // Tap on the text editor
5219 TestGenerateTap(application, 3.0f, 25.0f);
5221 // Render and notify
5222 application.SendNotification();
5223 application.Render();
5225 gSelectionClearedCallbackCalled = false;
5227 // Move to second line of the text & select.
5228 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5229 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5232 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5234 // Render and notify
5235 application.SendNotification();
5236 application.Render();
5238 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5240 gSelectionClearedCallbackCalled = false;
5242 // Render and notify
5243 application.SendNotification();
5244 application.Render();
5246 // Move to second line of the text & select.
5247 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5248 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5250 // replace C with selected text
5251 application.ProcessEvent(GenerateKey("c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5253 // Render and notify
5254 application.SendNotification();
5255 application.Render();
5257 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5259 gSelectionClearedCallbackCalled = false;
5261 // Render and notify
5262 application.SendNotification();
5263 application.Render();
5265 DevelTextEditor::SelectText(editor, 1, 3);
5267 // Render and notify
5268 application.SendNotification();
5269 application.Render();
5271 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5273 // Render and notify
5274 application.SendNotification();
5275 application.Render();
5277 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5279 gSelectionClearedCallbackCalled = false;
5281 DevelTextEditor::SelectText(editor, 1, 3);
5283 // Render and notify
5284 application.SendNotification();
5285 application.Render();
5288 DevelTextEditor::SelectNone(editor);
5290 // Render and notify
5291 application.SendNotification();
5292 application.Render();
5294 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5299 int utcDaliTextEditorSelectionStartedSignal(void)
5301 ToolkitTestApplication application;
5302 tet_infoline(" utcDaliTextEditorSelectionStartedSignal");
5304 TextEditor editor = TextEditor::New();
5305 DALI_TEST_CHECK(editor);
5307 application.GetScene().Add(editor);
5309 // connect to the selection changed signal.
5310 ConnectionTracker* testTracker = new ConnectionTracker();
5311 DevelTextEditor::SelectionStartedSignal(editor).Connect(&TestSelectionStartedCallback);
5312 bool selectionStartedSignal = false;
5313 editor.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5315 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5316 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5317 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5318 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5319 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5321 // Avoid a crash when core load gl resources.
5322 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5324 // Render and notify
5325 application.SendNotification();
5326 application.Render();
5328 // Tap on the text editor
5329 TestGenerateTap(application, 3.0f, 25.0f);
5331 // Render and notify
5332 application.SendNotification();
5333 application.Render();
5335 // Move to second line of the text & Select some text in the right of the current cursor position
5336 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5337 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5339 // Render and notify
5340 application.SendNotification();
5341 application.Render();
5343 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5346 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5348 // Render and notify
5349 application.SendNotification();
5350 application.Render();
5352 gSelectionStartedCallbackCalled = false;
5354 DevelTextEditor::SelectText(editor, 1, 3);
5356 // Render and notify
5357 application.SendNotification();
5358 application.Render();
5360 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5365 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
5367 ToolkitTestApplication application;
5368 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
5370 // Checks if the actor is created.
5372 TextEditor editor = TextEditor::New();
5373 DALI_TEST_CHECK(editor);
5375 application.GetScene().Add(editor);
5377 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
5378 editor.SetProperty(TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>");
5379 editor.SetProperty(TextEditor::Property::POINT_SIZE, 12.f);
5380 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5381 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5382 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5383 editor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);
5384 editor.SetProperty(DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
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 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
5401 DevelTextEditor::SelectText(editor, 35, 41); // This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
5403 application.SendNotification();
5404 application.Render();
5406 std::string selectedText = editor.GetProperty(DevelTextEditor::Property::SELECTED_TEXT).Get<std::string>();
5407 DALI_TEST_EQUALS("عليكم ", selectedText, TEST_LOCATION);
5412 int utcDaliTextEditorSelectionChangedSignal(void)
5414 ToolkitTestApplication application;
5415 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
5417 TextEditor editor = TextEditor::New();
5418 DALI_TEST_CHECK(editor);
5420 application.GetScene().Add(editor);
5422 // connect to the selection changed signal.
5423 ConnectionTracker* testTracker = new ConnectionTracker();
5424 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
5425 bool selectionChangedSignal = false;
5426 editor.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5428 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nworld\nHello world");
5429 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
5430 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5431 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5432 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5434 // Avoid a crash when core load gl resources.
5435 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5437 // Render and notify
5438 application.SendNotification();
5439 application.Render();
5441 // Tap on the text editor
5442 TestGenerateTap(application, 3.0f, 25.0f);
5444 // Render and notify
5445 application.SendNotification();
5446 application.Render();
5448 // Move to second line of the text.
5449 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5451 // Render and notify
5452 application.SendNotification();
5453 application.Render();
5455 // Select some text in the right of the current cursor position
5456 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5457 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5459 // Render and notify
5460 application.SendNotification();
5461 application.Render();
5463 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5464 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5466 gSelectionChangedCallbackCalled = false;
5468 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5470 // Render and notify
5471 application.SendNotification();
5472 application.Render();
5474 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5475 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5476 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5478 gSelectionChangedCallbackCalled = false;
5480 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5482 // Render and notify
5483 application.SendNotification();
5484 application.Render();
5486 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5487 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5488 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5490 gSelectionChangedCallbackCalled = false;
5491 editor.SetKeyInputFocus();
5493 // Render and notify
5494 application.SendNotification();
5495 application.Render();
5497 DevelTextEditor::SelectText(editor, 0, 5);
5499 application.SendNotification();
5500 application.Render();
5502 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5503 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5505 gSelectionChangedCallbackCalled = false;
5507 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5509 // Render and notify
5510 application.SendNotification();
5511 application.Render();
5513 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5514 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5515 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5517 gSelectionChangedCallbackCalled = false;
5520 DevelTextEditor::SelectWholeText(editor);
5522 // Render and notify
5523 application.SendNotification();
5524 application.Render();
5526 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5527 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5529 gSelectionChangedCallbackCalled = false;
5532 DevelTextEditor::SelectNone(editor);
5534 // Render and notify
5535 application.SendNotification();
5536 application.Render();
5538 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5539 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5540 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5545 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5547 ToolkitTestApplication application;
5548 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5550 TextEditor textEditor = TextEditor::New();
5551 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5552 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5553 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5554 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5556 application.GetScene().Add(textEditor);
5557 application.SendNotification();
5558 application.Render();
5560 Property::Map strikethroughMapSet;
5561 Property::Map strikethroughMapGet;
5563 strikethroughMapSet.Insert("enable", true);
5564 strikethroughMapSet.Insert("color", Color::RED);
5565 strikethroughMapSet.Insert("height", 2.0f);
5567 // Check the strikethrough property
5568 textEditor.SetProperty(DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet);
5569 strikethroughMapGet = textEditor.GetProperty<Property::Map>(DevelTextEditor::Property::STRIKETHROUGH);
5570 textEditor.SetProperty(TextEditor::Property::TEXT, "Test1");
5571 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5572 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5574 // Render and notify
5575 application.SendNotification();
5576 application.Render();
5578 strikethroughMapSet.Clear();
5579 strikethroughMapGet.Clear();
5584 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5586 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5587 //DaliException on vector: "Iterator not inside vector"
5589 ToolkitTestApplication application;
5590 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5592 TextEditor editor = TextEditor::New();
5593 DALI_TEST_CHECK(editor);
5595 application.GetScene().Add(editor);
5597 // Avoid a crash when core load gl resources.
5598 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5600 //Set multilines text
5601 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5602 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5603 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5605 //Set ResizePolicy to NaturalSize
5606 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5608 // Render and notify
5609 application.SendNotification();
5610 application.Render();
5612 // Create a tap event to touch the text editor.
5613 TestGenerateTap(application, 5.0f, 5.0f);
5615 // Render and notify
5616 application.SendNotification();
5617 application.Render();
5619 // Set currsor and add character (in first line)
5620 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5621 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5622 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5624 // Render and notify
5625 application.SendNotification();
5626 application.Render();
5628 //Check the changed text and cursor position
5629 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hellod \n World", TEST_LOCATION);
5630 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 6, TEST_LOCATION);
5632 // Render and notify
5633 application.SendNotification();
5634 application.Render();
5639 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5641 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5642 //DaliException on vector: "Iterator not inside vector"
5644 ToolkitTestApplication application;
5645 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5647 TextEditor editor = TextEditor::New();
5648 DALI_TEST_CHECK(editor);
5650 application.GetScene().Add(editor);
5652 // Avoid a crash when core load gl resources.
5653 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5655 //Set multilines text
5656 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5657 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5658 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5660 //Set ResizePolicy to NaturalSize
5661 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5664 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5665 application.SendNotification();
5666 application.Render();
5668 // Set focus and remove character
5669 editor.SetKeyInputFocus();
5670 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5672 // Render and notify
5673 application.SendNotification();
5674 application.Render();
5676 //Check the changed text and cursor position
5677 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hell \n World", TEST_LOCATION);
5678 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
5680 // Render and notify
5681 application.SendNotification();
5682 application.Render();
5687 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5689 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5690 //DaliException on vector: "Iterator not inside vector"
5692 ToolkitTestApplication application;
5693 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5695 TextEditor editor = TextEditor::New();
5696 DALI_TEST_CHECK(editor);
5698 application.GetScene().Add(editor);
5700 // Avoid a crash when core load gl resources.
5701 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5703 //Set multilines text
5704 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5705 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5706 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5708 //Set ResizePolicy to NaturalSize
5709 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5711 //Select text at initialization (before the first render)
5712 DevelTextEditor::SelectText(editor, 3, 5);
5714 // Render and notify
5715 application.SendNotification();
5716 application.Render();
5719 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5720 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));
5722 // Render and notify
5723 application.SendNotification();
5724 application.Render();
5726 //Check the changed text and cursor position
5727 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hel \n World", TEST_LOCATION);
5728 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5730 // Render and notify
5731 application.SendNotification();
5732 application.Render();
5737 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5739 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5740 //DaliException on vector: "Iterator not inside vector"
5742 ToolkitTestApplication application;
5743 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5745 TextEditor editor = TextEditor::New();
5746 DALI_TEST_CHECK(editor);
5748 application.GetScene().Add(editor);
5750 // Avoid a crash when core load gl resources.
5751 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5753 //Set multilines text
5754 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5755 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5756 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5758 //Set ResizePolicy to NaturalSize
5759 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5762 editor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5763 application.SendNotification();
5764 application.Render();
5766 // Set focus and double enter (new line)
5767 editor.SetKeyInputFocus();
5768 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5769 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5771 // Render and notify
5772 application.SendNotification();
5773 application.Render();
5775 //Check the changed text and cursor position
5776 DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION);
5777 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 7, TEST_LOCATION);
5779 // Render and notify
5780 application.SendNotification();
5781 application.Render();
5786 int UtcDaliToolkitTextEditorUnderlineTypesGeneration1(void)
5788 ToolkitTestApplication application;
5789 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration1");
5790 TextEditor textEditor = TextEditor::New();
5791 textEditor.SetProperty(TextEditor::Property::TEXT, "Test");
5792 textEditor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5793 textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5794 textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5796 application.GetScene().Add(textEditor);
5797 application.SendNotification();
5798 application.Render();
5800 Property::Map underlineMapSet;
5801 Property::Map underlineMapGet;
5803 underlineMapSet.Insert("enable", true);
5804 underlineMapSet.Insert("color", Color::RED);
5805 underlineMapSet.Insert("height", 1);
5806 underlineMapSet.Insert("type", Text::Underline::SOLID);
5807 underlineMapSet.Insert("dashWidth", 2);
5808 underlineMapSet.Insert("dashGap", 1);
5810 // Check the underline property
5811 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5813 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5814 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5815 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5817 // Render and notify
5818 application.SendNotification();
5819 application.Render();
5821 underlineMapSet.Clear();
5822 underlineMapGet.Clear();
5824 underlineMapSet.Insert("enable", true);
5825 underlineMapSet.Insert("color", Color::BLUE);
5826 underlineMapSet.Insert("height", 1);
5827 underlineMapSet.Insert("type", Text::Underline::DASHED);
5828 underlineMapSet.Insert("dashWidth", 4);
5829 underlineMapSet.Insert("dashGap", 2);
5831 // Check the dashed underline property
5832 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5834 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5835 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5836 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5838 // Render and notify
5839 application.SendNotification();
5840 application.Render();
5842 underlineMapSet.Clear();
5843 underlineMapGet.Clear();
5845 underlineMapSet.Insert("enable", true);
5846 underlineMapSet.Insert("color", Color::BLUE);
5847 underlineMapSet.Insert("height", 1);
5848 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5849 underlineMapSet.Insert("dashWidth", 4);
5850 underlineMapSet.Insert("dashGap", 2);
5852 // Check the dashed underline property
5853 textEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);
5855 underlineMapGet = textEditor.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5856 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5857 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5859 // Render and notify
5860 application.SendNotification();
5861 application.Render();
5863 underlineMapSet.Clear();
5864 underlineMapGet.Clear();
5869 int UtcDaliToolkitTextEditorUnderlineTypesGeneration2(void)
5871 ToolkitTestApplication application;
5872 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration2");
5874 TextEditor textEditor1 = TextEditor::New();
5875 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test");
5876 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5877 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5878 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5880 Property::Map underlineMapSet1;
5881 Property::Map underlineMapGet1;
5883 underlineMapSet1.Insert("enable", true);
5884 underlineMapSet1.Insert("color", Color::RED);
5885 underlineMapSet1.Insert("height", 1);
5886 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5887 underlineMapSet1.Insert("dashWidth", 2);
5888 underlineMapSet1.Insert("dashGap", 1);
5890 // Check the underline property
5891 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5893 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5894 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5895 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5897 application.GetScene().Add(textEditor1);
5898 application.SendNotification();
5899 application.Render();
5901 TextEditor textEditor2 = TextEditor::New();
5902 textEditor2.SetProperty(TextEditor::Property::TEXT, "Test");
5903 textEditor2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5904 textEditor2.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5905 textEditor2.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5907 Property::Map underlineMapSet2;
5908 Property::Map underlineMapGet2;
5910 underlineMapSet2.Insert("enable", true);
5911 underlineMapSet2.Insert("color", Color::BLUE);
5912 underlineMapSet2.Insert("height", 1);
5913 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5914 underlineMapSet2.Insert("dashWidth", 4);
5915 underlineMapSet2.Insert("dashGap", 2);
5917 // Check the dashed underline property
5918 textEditor2.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet2);
5920 underlineMapGet2 = textEditor2.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5921 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5922 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5924 application.GetScene().Add(textEditor2);
5925 application.SendNotification();
5926 application.Render();
5928 TextEditor textEditor3 = TextEditor::New();
5929 textEditor3.SetProperty(TextEditor::Property::TEXT, "Test");
5930 textEditor3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5931 textEditor3.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5932 textEditor3.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5934 Property::Map underlineMapSet3;
5935 Property::Map underlineMapGet3;
5937 underlineMapSet3.Insert("enable", true);
5938 underlineMapSet3.Insert("color", Color::BLUE);
5939 underlineMapSet3.Insert("height", 1);
5940 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5941 underlineMapSet3.Insert("dashWidth", 4);
5942 underlineMapSet3.Insert("dashGap", 2);
5944 // Check the dashed underline property
5945 textEditor3.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet3);
5947 underlineMapGet3 = textEditor3.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5948 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5949 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5951 application.GetScene().Add(textEditor3);
5952 application.SendNotification();
5953 application.Render();
5958 int UtcDaliToolkitTextEditorUnderlineTypesGeneration3(void)
5960 ToolkitTestApplication application;
5961 tet_infoline(" UtcDaliToolkitTextEditorUnderlineTypesGeneration3");
5963 TextEditor textEditor1 = TextEditor::New();
5964 textEditor1.SetProperty(TextEditor::Property::TEXT, "Test1");
5965 textEditor1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5966 textEditor1.SetProperty(TextEditor::Property::POINT_SIZE, 10);
5967 textEditor1.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5969 Property::Map underlineMapSet1;
5970 Property::Map underlineMapGet1;
5972 underlineMapSet1.Insert("enable", true);
5973 underlineMapSet1.Insert("color", Color::RED);
5974 underlineMapSet1.Insert("height", 1);
5975 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5976 underlineMapSet1.Insert("dashWidth", 2);
5977 underlineMapSet1.Insert("dashGap", 1);
5979 // Check the underline property
5980 textEditor1.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet1);
5981 //textEditor1.SetProperty( TextEditor::Property::TEXT, "Test2" );
5983 underlineMapGet1 = textEditor1.GetProperty<Property::Map>(TextEditor::Property::UNDERLINE);
5984 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5985 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5987 application.GetScene().Add(textEditor1);
5989 application.SendNotification();
5990 application.Render();
5995 int UtcDaliToolkitTextEditorMarkupRelativeLineHeight(void)
5997 ToolkitTestApplication application;
5998 tet_infoline(" UtcDaliToolkitTextEditorMarkupRelativeLineHeight");
6000 TextEditor editor = TextEditor::New();
6001 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6002 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6003 editor.SetProperty(TextEditor::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
6004 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6005 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6006 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6008 TextEditor editorSingleLineParagraph = TextEditor::New();
6009 editorSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6010 editorSingleLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6011 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");
6012 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6013 editorSingleLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6014 editorSingleLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6016 TextEditor editorMultiLineParagraph = TextEditor::New();
6017 editorMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6018 editorMultiLineParagraph.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6019 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");
6020 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 1.0f);
6021 editorMultiLineParagraph.SetProperty(DevelTextEditor::Property::ELLIPSIS, false);
6022 editorMultiLineParagraph.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6024 application.GetScene().Add(editor);
6025 application.GetScene().Add(editorSingleLineParagraph);
6026 application.GetScene().Add(editorMultiLineParagraph);
6027 application.SendNotification();
6028 application.Render();
6030 Vector3 naturalSize = editor.GetNaturalSize();
6031 Vector3 relativeSingleNaturalSize = editorSingleLineParagraph.GetNaturalSize();
6032 Vector3 relativeMultiNaturalSize = editorMultiLineParagraph.GetNaturalSize();
6034 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
6036 //no effect of relative line size for paragraph with single line
6037 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6039 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6044 int UtcDaliToolkitTextEditorRelativeLineHeight(void)
6046 ToolkitTestApplication application;
6047 tet_infoline(" UtcDaliToolkitTextEditorRelativeLineHeight");
6049 TextEditor editor = TextEditor::New();
6050 editor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
6051 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10);
6052 editor.SetProperty(TextEditor::Property::TEXT, "Hello\nWorld");
6054 application.GetScene().Add(editor);
6055 application.SendNotification();
6056 application.Render();
6058 Vector3 naturalSize = editor.GetNaturalSize();
6060 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 0.5f);
6062 application.SendNotification();
6063 application.Render();
6065 Vector3 relativeNaturalSize = editor.GetNaturalSize();
6067 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
6069 editor.SetProperty(DevelTextEditor::Property::RELATIVE_LINE_SIZE, 2.0f);
6071 application.SendNotification();
6072 application.Render();
6074 relativeNaturalSize = editor.GetNaturalSize();
6076 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
6080 int UtcDaliTextEditorCharacterSpacing(void)
6082 ToolkitTestApplication application;
6083 tet_infoline(" UtcDaliTextEditorCharacterSpacing ");
6085 TextEditor textEditor = TextEditor::New();
6087 textEditor.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
6089 application.GetScene().Add(textEditor);
6090 application.SendNotification();
6091 application.Render();
6093 textEditor.SetProperty(TextEditor::Property::TEXT, "Hi Experiment");
6094 textEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 10.f);
6095 DALI_TEST_EQUALS(textEditor.GetProperty<float>(DevelTextEditor::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6097 application.SendNotification();
6098 application.Render();
6103 int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
6105 ToolkitTestApplication application;
6106 tet_infoline("UtcDaliTextEditorTextSizeNegativeLineSpacing");
6108 TextEditor editor = TextEditor::New();
6110 float lineSpacing = -20.f;
6112 editor.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
6113 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6114 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6115 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6117 application.GetScene().Add(editor);
6118 application.SendNotification();
6119 application.Render();
6121 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, 0, 123);
6122 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6124 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
6125 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
6127 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6128 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
6130 application.SendNotification();
6131 application.Render();
6136 int UtcDaliTextEditorLineSpacingKeyArrowDown(void)
6138 ToolkitTestApplication application;
6139 tet_infoline("UtcDaliTextEditorLineSpacingKeyArrowDown");
6141 TextEditor editor = TextEditor::New();
6142 DALI_TEST_CHECK(editor);
6144 application.GetScene().Add(editor);
6146 std::string cutText = "";
6147 std::string copiedText = "";
6149 editor.SetProperty(TextEditor::Property::TEXT, "l1\nl2\nl3\n4");
6150 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6151 editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 200.f));
6152 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6153 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6154 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6155 editor.SetProperty(TextEditor::Property::LINE_SPACING, -15);
6157 // Render and notify
6158 application.SendNotification();
6159 application.Render();
6161 // Tap on the text editor
6162 TestGenerateTap(application, 1.0f, 1.0f);
6164 // Render and notify
6165 application.SendNotification();
6166 application.Render();
6168 // Move to second line of the text.
6169 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6171 // Render and notify
6172 application.SendNotification();
6173 application.Render();
6175 DALI_TEST_EQUALS(editor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6180 int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
6182 ToolkitTestApplication application;
6183 tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
6185 TextEditor editor = TextEditor::New();
6187 float lineSpacing = -20.f;
6189 editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
6190 editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
6191 editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
6192 editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
6193 editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
6195 application.GetScene().Add(editor);
6196 application.SendNotification();
6197 application.Render();
6199 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
6201 int lineCount = sizeList.Size();
6202 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
6204 application.SendNotification();
6205 application.Render();
6210 int UtcDaliToolkitTexteditorParagraphTag(void)
6212 ToolkitTestApplication application;
6213 tet_infoline(" UtcDaliToolkitTexteditorParagraphTag");
6214 TextEditor editorNewlineSeparator = TextEditor::New();
6215 TextEditor editorParagraphTag = TextEditor::New();
6216 DALI_TEST_CHECK(editorNewlineSeparator);
6217 DALI_TEST_CHECK(editorParagraphTag);
6219 application.GetScene().Add(editorNewlineSeparator);
6220 application.GetScene().Add(editorParagraphTag);
6222 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
6223 editorNewlineSeparator.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6224 editorNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6225 editorNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6226 editorNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6227 editorNewlineSeparator.SetProperty(TextEditor::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
6229 editorParagraphTag.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
6230 editorParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6231 editorParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6232 editorParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6233 editorParagraphTag.SetProperty(TextEditor::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
6235 application.SendNotification();
6236 application.Render();
6238 Vector3 textNaturalSizeNewlineSeparator = editorNewlineSeparator.GetNaturalSize();
6239 Vector3 textNaturalSizeParagraphTag = editorParagraphTag.GetNaturalSize();
6241 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
6243 application.SendNotification();
6244 application.Render();
6249 //Handle Emoji clustering for cursor handling
6250 int utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey(void)
6252 ToolkitTestApplication application;
6253 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionBackSpaceKey ");
6254 TextEditor textEditor = TextEditor::New();
6255 DALI_TEST_CHECK(textEditor);
6257 application.GetScene().Add(textEditor);
6259 // Avoid a crash when core load gl resources.
6260 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6262 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6263 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6265 // Render and notify
6266 application.SendNotification();
6267 application.Render();
6270 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 10);
6271 application.SendNotification();
6272 application.Render();
6274 // Set focus and remove Emoji
6275 textEditor.SetKeyInputFocus();
6276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6278 //Check the changed text and cursor position
6279 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6280 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6282 // Render and notify
6283 application.SendNotification();
6284 application.Render();
6289 int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void)
6291 ToolkitTestApplication application;
6292 tet_infoline(" utcDaliTextEditorClusteredEmojiDeletionDeleteKey ");
6293 TextEditor textEditor = TextEditor::New();
6294 DALI_TEST_CHECK(textEditor);
6296 application.GetScene().Add(textEditor);
6298 // Avoid a crash when core load gl resources.
6299 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6301 textEditor.SetProperty(TextEditor::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
6302 textEditor.SetProperty(Dali::Toolkit::TextEditor::Property::ENABLE_MARKUP, true);
6304 // Render and notify
6305 application.SendNotification();
6306 application.Render();
6309 textEditor.SetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
6310 application.SendNotification();
6311 application.Render();
6313 // Set focus and remove Emoji
6314 textEditor.SetKeyInputFocus();
6315 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
6317 //Check the changed text and cursor position
6318 DALI_TEST_EQUALS(textEditor.GetProperty(TextEditor::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
6319 DALI_TEST_EQUALS(textEditor.GetProperty(DevelTextEditor::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
6321 // Render and notify
6322 application.SendNotification();
6323 application.Render();
6328 int utcDaliTextEditorPanGesturePropagation(void)
6330 ToolkitTestApplication application;
6331 tet_infoline(" utcDaliTextEditorPanGesturePropagation");
6333 Actor actor = Actor::New();
6334 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6335 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6336 application.GetScene().Add(actor);
6338 TextEditor editor = TextEditor::New();
6339 DALI_TEST_CHECK(editor);
6341 editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor.");
6342 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f);
6344 editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f));
6345 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6346 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6350 // Render and notify
6351 application.SendNotification();
6352 application.Render();
6355 GestureReceivedFunctor functor(data);
6357 PanGestureDetector detector = PanGestureDetector::New();
6358 detector.Attach(actor);
6359 detector.DetectedSignal().Connect(&application, functor);
6361 // Tap first to get the focus.
6362 TestGenerateTap(application, 3.0f, 25.0f, 100);
6364 // Render and notify
6365 application.SendNotification();
6366 application.Render();
6368 // Pan the text editor
6369 uint32_t time = 100;
6370 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6371 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6372 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6373 application.SendNotification();
6374 application.Render();
6376 // The text scrolls because there is text that is scrolling.
6377 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6380 // Set the size large enough to prevent scrolling.
6381 editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f));
6383 // Render and notify
6384 application.SendNotification();
6385 application.Render();
6388 TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time);
6389 TestMovePan(application, Vector2(10.0f, 30.0f), time);
6390 TestEndPan(application, Vector2(10.0f, 50.0f), time);
6392 // Because scrolling is not possible, the pan gesture is propagated.
6393 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6400 int utcDaliTextEditorGetTextBoundingRectangle(void)
6402 ToolkitTestApplication application;
6403 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
6405 TextEditor editor = TextEditor::New();
6406 DALI_TEST_CHECK(editor);
6408 application.GetScene().Add(editor);
6410 editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
6411 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6412 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6413 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6414 editor.SetProperty(TextEditor::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6416 // Avoid a crash when core load gl resources.
6417 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6419 // Render and notify
6420 application.SendNotification();
6421 application.Render();
6423 unsigned int startIndex = 0;
6424 unsigned int endIndex = 15;
6426 Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
6427 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
6429 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);