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.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
27 #include <dali-toolkit/devel-api/text/rendering-backend.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali/devel-api/actors/actor-devel.h>
30 #include <dali/devel-api/adaptor-framework/key-devel.h>
31 #include <dali/devel-api/events/pan-gesture-devel.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include <dali/integration-api/events/key-event-integ.h>
34 #include <dali/integration-api/events/touch-event-integ.h>
35 #include <dali/public-api/rendering/renderer.h>
36 #include "test-text-geometry-utils.h"
37 #include "toolkit-clipboard.h"
40 using namespace Toolkit;
42 void dali_textfield_startup(void)
44 test_return_value = TET_UNDEF;
47 void dali_textfield_cleanup(void)
49 test_return_value = TET_PASS;
54 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
55 const char* const PROPERTY_NAME_TEXT = "text";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
57 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
58 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
59 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
60 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
61 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
62 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
63 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
64 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
65 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
66 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
67 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
68 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
69 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
71 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
72 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
74 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
75 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
76 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
77 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
83 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
84 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
85 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
86 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
87 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
88 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
89 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
90 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
91 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
93 const char* const PROPERTY_NAME_UNDERLINE = "underline";
94 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
95 const char* const PROPERTY_NAME_SHADOW = "shadow";
96 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
97 const char* const PROPERTY_NAME_EMBOSS = "emboss";
98 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
99 const char* const PROPERTY_NAME_OUTLINE = "outline";
100 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
101 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
102 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
104 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
105 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
106 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
107 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
108 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
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_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
113 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
114 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
115 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
116 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
117 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
119 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
120 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
122 const float RENDER_FRAME_INTERVAL = 16.66f;
124 const unsigned int DEFAULT_FONT_SIZE = 1152u;
125 const std::string DEFAULT_FONT_DIR("/resources/fonts");
127 const int KEY_RETURN_CODE = 36;
128 const int KEY_A_CODE = 38;
129 const int KEY_D_CODE = 40;
130 const int KEY_SHIFT_MODIFIER = 257;
132 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
134 static bool gSelectionChangedCallbackCalled;
135 static uint32_t oldSelectionStart;
136 static uint32_t oldSelectionEnd;
137 static bool gSelectionClearedCallbackCalled;
138 static bool gSelectionStartedCallbackCalled;
139 static bool gAnchorClickedCallBackCalled;
140 static bool gAnchorClickedCallBackNotCalled;
141 static bool gTextChangedCallBackCalled;
142 static bool gMaxCharactersCallBackCalled;
143 static bool gInputFilteredAcceptedCallbackCalled;
144 static bool gInputFilteredRejectedCallbackCalled;
145 static bool gInputStyleChangedCallbackCalled;
146 static bool gCursorPositionChangedCallbackCalled;
147 static uint32_t oldCursorPos;
148 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
150 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
152 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
153 Integration::ResourcePointer resource(bitmap);
154 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
157 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
161 LoadBitmapResource(app.GetPlatform(), width, height);
163 Property::Map propertyMap;
164 propertyMap["filename"] = "image.png";
165 propertyMap["width"] = width;
166 propertyMap["height"] = height;
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
173 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
174 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
178 * Simulate time passed by.
180 * @note this will always process at least 1 frame (1/60 sec)
182 * @param application Test application instance
183 * @param duration Time to pass in milliseconds.
184 * @return The actual time passed in milliseconds
186 static int Wait(ToolkitTestApplication& application, int duration = 0)
190 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
192 application.SendNotification();
193 application.Render(RENDER_FRAME_INTERVAL);
194 time += RENDER_FRAME_INTERVAL;
200 Dali::Integration::Point GetPointDownInside(Vector2& pos)
202 Dali::Integration::Point point;
203 point.SetState(PointState::DOWN);
204 point.SetScreenPosition(pos);
208 Dali::Integration::Point GetPointUpInside(Vector2& pos)
210 Dali::Integration::Point point;
211 point.SetState(PointState::UP);
212 point.SetScreenPosition(pos);
216 struct CallbackFunctor
218 CallbackFunctor(bool* callbackFlag)
219 : mCallbackFlag(callbackFlag)
225 *mCallbackFlag = true;
230 static void TestSelectionClearedCallback(TextField control)
232 tet_infoline(" TestSelectionClearedCallback");
234 gSelectionClearedCallbackCalled = true;
237 static void TestSelectionStartedCallback(TextField control)
239 tet_infoline(" TestSelectionStartedCallback");
241 gSelectionStartedCallbackCalled = true;
244 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
246 tet_infoline(" TestSelectionChangedCallback");
248 gSelectionChangedCallbackCalled = true;
249 oldSelectionStart = oldStart;
250 oldSelectionEnd = oldEnd;
253 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
255 tet_infoline(" TestAnchorClickedCallback");
257 gAnchorClickedCallBackNotCalled = false;
259 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
261 gAnchorClickedCallBackCalled = true;
265 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
267 tet_infoline(" TestCursorPositionChangedCallback");
269 gCursorPositionChangedCallbackCalled = true;
270 oldCursorPos = oldPos;
273 static void TestTextChangedCallback(TextField control)
275 tet_infoline(" TestTextChangedCallback");
277 gTextChangedCallBackCalled = true;
280 static void TestMaxLengthReachedCallback(TextField control)
282 tet_infoline(" TestMaxLengthReachedCallback");
284 gMaxCharactersCallBackCalled = true;
287 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
289 tet_infoline(" TestInputFilteredCallback");
291 if(type == Toolkit::InputFilter::Property::ACCEPTED)
293 gInputFilteredAcceptedCallbackCalled = true;
295 else if(type == Toolkit::InputFilter::Property::REJECTED)
297 gInputFilteredRejectedCallbackCalled = true;
301 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
303 tet_infoline(" TestInputStyleChangedCallback");
305 gInputStyleChangedCallbackCalled = true;
306 gInputStyleMask = mask;
309 // Generate a KeyEvent to send to Core.
310 Integration::KeyEvent GenerateKey(const std::string& keyName,
311 const std::string& logicalKey,
312 const std::string& keyString,
315 unsigned long timeStamp,
316 const Integration::KeyEvent::State& keyState,
317 const std::string& compose = "",
318 const std::string& deviceName = DEFAULT_DEVICE_NAME,
319 const Device::Class::Type& deviceClass = Device::Class::NONE,
320 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
322 return Integration::KeyEvent(keyName,
335 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
337 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
339 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
341 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
343 Property::Value* valueSet = NULL;
344 if(valueGet.first.type == Property::Key::INDEX)
346 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
350 // Get Key is a string so searching Set Map for a string key
351 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
356 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
358 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
361 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
363 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
366 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
368 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
371 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
373 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
376 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
378 Vector2 vector2Get = valueGet.second.Get<Vector2>();
379 Vector2 vector2Set = valueSet->Get<Vector2>();
380 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
383 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
385 Vector4 vector4Get = valueGet.second.Get<Vector4>();
386 Vector4 vector4Set = valueSet->Get<Vector4>();
387 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);
393 if(valueGet.first.type == Property::Key::INDEX)
395 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
399 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
410 // Stores data that is populated in the callback and will be read by the test cases
414 : functorCalled(false),
415 voidFunctorCalled(false),
422 functorCalled = false;
423 voidFunctorCalled = false;
425 receivedGesture.Reset();
431 bool voidFunctorCalled;
432 PanGesture receivedGesture;
436 // Functor that sets the data when called
437 struct GestureReceivedFunctor
439 GestureReceivedFunctor(SignalData& data)
444 void operator()(Actor actor, const PanGesture& pan)
446 signalData.functorCalled = true;
447 signalData.receivedGesture = pan;
448 signalData.pannedActor = actor;
453 signalData.voidFunctorCalled = true;
456 SignalData& signalData;
461 int UtcDaliToolkitTextFieldConstructorP(void)
463 ToolkitTestApplication application;
464 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
466 DALI_TEST_CHECK(!textField);
470 int UtcDaliToolkitTextFieldNewP(void)
472 ToolkitTestApplication application;
473 tet_infoline(" UtcDaliToolkitTextFieldNewP");
474 TextField textField = TextField::New();
475 DALI_TEST_CHECK(textField);
479 int UtcDaliToolkitTextFieldDownCastP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
483 TextField textField1 = TextField::New();
484 BaseHandle object(textField1);
486 TextField textField2 = TextField::DownCast(object);
487 DALI_TEST_CHECK(textField2);
489 TextField textField3 = DownCast<TextField>(object);
490 DALI_TEST_CHECK(textField3);
494 int UtcDaliToolkitTextFieldDownCastN(void)
496 ToolkitTestApplication application;
497 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
498 BaseHandle uninitializedObject;
499 TextField textField1 = TextField::DownCast(uninitializedObject);
500 DALI_TEST_CHECK(!textField1);
502 TextField textField2 = DownCast<TextField>(uninitializedObject);
503 DALI_TEST_CHECK(!textField2);
507 int UtcDaliToolkitTextFieldCopyConstructorP(void)
509 ToolkitTestApplication application;
510 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
511 TextField textField = TextField::New();
512 textField.SetProperty(TextField::Property::TEXT, "Test");
514 TextField copy(textField);
515 DALI_TEST_CHECK(copy);
516 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
520 int UtcDaliTextFieldMoveConstructor(void)
522 ToolkitTestApplication application;
524 TextField textField = TextField::New();
525 textField.SetProperty(TextEditor::Property::TEXT, "Test");
526 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
528 TextField moved = std::move(textField);
529 DALI_TEST_CHECK(moved);
530 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
531 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
532 DALI_TEST_CHECK(!textField);
537 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
539 ToolkitTestApplication application;
540 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
541 TextField textField = TextField::New();
542 textField.SetProperty(TextField::Property::TEXT, "Test");
544 TextField copy = textField;
545 DALI_TEST_CHECK(copy);
546 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
550 int UtcDaliTextFieldMoveAssignment(void)
552 ToolkitTestApplication application;
554 TextField textField = TextField::New();
555 textField.SetProperty(TextEditor::Property::TEXT, "Test");
556 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
559 moved = std::move(textField);
560 DALI_TEST_CHECK(moved);
561 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
562 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
563 DALI_TEST_CHECK(!textField);
568 int UtcDaliTextFieldNewP(void)
570 ToolkitTestApplication application;
571 tet_infoline(" UtcDaliToolkitTextFieldNewP");
572 TextField textField = TextField::New();
573 DALI_TEST_CHECK(textField);
577 // Positive test case for a method
578 int UtcDaliTextFieldGetPropertyP(void)
580 ToolkitTestApplication application;
581 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
582 TextField field = TextField::New();
583 DALI_TEST_CHECK(field);
585 // Check Property Indices are correct
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
597 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
598 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
599 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
600 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
601 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
602 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
603 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
604 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
605 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
606 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
607 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
608 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
609 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
610 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
611 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
612 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
613 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
614 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
615 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
616 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
617 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
618 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
619 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
620 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
621 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
622 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
623 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
624 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
625 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
626 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
627 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
628 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
629 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
630 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
631 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
632 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
633 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
634 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
635 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
636 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
637 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
638 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
639 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
640 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
641 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
642 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
643 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
644 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
645 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
646 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
647 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
652 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
655 Property::Map imageMap;
656 imageMap[mapKey] = mapValue;
658 field.SetProperty(property, imageMap);
659 Property::Value propValue = field.GetProperty(property);
660 Property::Map* resultMap = propValue.GetMap();
662 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
670 // Positive test case for a method
671 int UtcDaliTextFieldSetPropertyP(void)
673 ToolkitTestApplication application;
674 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
675 TextField field = TextField::New();
676 DALI_TEST_CHECK(field);
677 application.GetScene().Add(field);
679 // Note - we can't check the defaults since the stylesheets are platform-specific
681 // Check the render backend property.
682 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
683 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
685 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
686 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
688 // Check text property.
689 field.SetProperty(TextField::Property::TEXT, "Setting Text");
690 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
692 // Check placeholder text properties.
693 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
694 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
696 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
697 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
699 // Check font properties.
700 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
701 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
703 Property::Map fontStyleMapSet;
704 Property::Map fontStyleMapGet;
705 Property::Value* slantValue = NULL;
707 fontStyleMapSet.Insert("weight", "bold");
708 fontStyleMapSet.Insert("width", "condensed");
709 fontStyleMapSet.Insert("slant", "italic");
710 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
712 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
713 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
714 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
716 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
717 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
719 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
720 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
721 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
723 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
724 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
725 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
728 fontStyleMapSet.Clear();
729 fontStyleMapSet.Insert("weight", "normal");
730 fontStyleMapSet.Insert("slant", "oblique");
731 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
733 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
734 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
735 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
737 fontStyleMapSet.Clear();
738 fontStyleMapSet.Insert("slant", "roman");
739 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
740 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
742 // Replace 'roman' for 'normal'.
743 slantValue = fontStyleMapGet.Find("slant");
744 if(NULL != slantValue)
746 if("normal" == slantValue->Get<std::string>())
748 fontStyleMapGet["slant"] = "roman";
751 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
752 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
754 fontStyleMapSet.Clear();
756 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
757 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
758 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
759 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
761 // Check that the MAX_LENGTH property can be correctly set
762 const int maxNumberOfCharacters = 20;
763 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
764 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
766 // Check exceed policy
767 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
768 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
769 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
770 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
772 // Check that the Alignment properties can be correctly set
773 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
774 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
775 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
776 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
778 // Check text's color property
779 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
780 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
782 // Check placeholder text's color property.
783 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
784 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
786 // Check cursor properties
787 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
788 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
789 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
790 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
792 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
793 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
794 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
795 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
796 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
797 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
798 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
799 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
801 // Check scroll properties.
802 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
803 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
804 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
805 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
807 // Check handle images
808 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
809 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
810 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
811 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
812 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
814 // Check handle images
815 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
816 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
817 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
818 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
819 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
820 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
822 // Check the selection popup style
823 const Vector2 popupMaxSize(200.0f, 300.0f);
824 const Vector2 optionDividerSize(30.0f, 5.0f);
825 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
826 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
828 Property::Map selectionPopupStyle;
829 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
830 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
831 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
832 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
834 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
836 Property::Map selectionPopupStyleGet;
837 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
839 Property::Value* popupValue;
840 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
841 DALI_TEST_CHECK(NULL != popupValue);
844 Vector2 popupMaxSizeGet;
845 popupValue->Get(popupMaxSizeGet);
846 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
849 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
850 DALI_TEST_CHECK(NULL != popupValue);
853 Vector2 optionDividerSizeGet;
854 popupValue->Get(optionDividerSizeGet);
855 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
858 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
859 DALI_TEST_CHECK(NULL != popupValue);
862 Vector4 optionDividerPaddingGet;
863 popupValue->Get(optionDividerPaddingGet);
864 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
867 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
868 DALI_TEST_CHECK(NULL != popupValue);
871 Vector4 labelPaddingGet;
872 popupValue->Get(labelPaddingGet);
873 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
876 // Reset selection popup style
877 selectionPopupStyle.Clear();
878 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
880 // Check the highlight color
881 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
882 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
884 // Decoration bounding box
885 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
886 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
888 // Check the input method setting
889 Property::Map propertyMap;
890 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
891 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
892 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
893 int inputVariation = 1;
894 propertyMap["PANEL_LAYOUT"] = panelLayout;
895 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
896 propertyMap["BUTTON_ACTION"] = buttonAction;
897 propertyMap["VARIATION"] = inputVariation;
898 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
900 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
902 DALI_TEST_CHECK(value.Get(map));
905 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
906 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
909 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
910 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
913 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
914 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
917 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
918 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
920 // Check input color property.
921 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
922 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
924 // Check the enable markup property.
925 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
926 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
927 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
929 // Check input font properties.
930 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
931 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
933 fontStyleMapSet.Clear();
934 fontStyleMapSet.Insert("weight", "bold");
935 fontStyleMapSet.Insert("width", "condensed");
936 fontStyleMapSet.Insert("slant", "italic");
938 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
939 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
940 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
941 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
943 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
944 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
946 // Reset input font style.
947 fontStyleMapSet.Clear();
948 fontStyleMapSet.Insert("weight", "normal");
949 fontStyleMapSet.Insert("slant", "oblique");
951 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
952 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
953 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
954 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
956 fontStyleMapSet.Clear();
957 fontStyleMapSet.Insert("slant", "roman");
959 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
960 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
962 // Replace 'roman' for 'normal'.
963 slantValue = fontStyleMapGet.Find("slant");
964 if(NULL != slantValue)
966 if("normal" == slantValue->Get<std::string>())
968 fontStyleMapGet["slant"] = "roman";
971 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
972 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
974 fontStyleMapSet.Clear();
976 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
977 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
978 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
979 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
981 Property::Map strikethroughMapSet;
982 Property::Map strikethroughMapGet;
984 strikethroughMapSet.Insert("enable", true);
985 strikethroughMapSet.Insert("color", Color::RED);
986 strikethroughMapSet.Insert("height", 2.0f);
988 // Check the strikethrough property
989 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
991 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
992 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
993 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
995 // Check the input strikethrough property
996 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
997 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
999 Property::Map underlineMapSet;
1000 Property::Map underlineMapGet;
1002 underlineMapSet.Insert("enable", true);
1003 underlineMapSet.Insert("color", Color::RED);
1004 underlineMapSet.Insert("height", 1);
1005 underlineMapSet.Insert("type", Text::Underline::SOLID);
1006 underlineMapSet.Insert("dashWidth", 2);
1007 underlineMapSet.Insert("dashGap", 1);
1009 // Check the underline property
1010 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1012 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1013 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1014 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1016 // Render and notify
1017 application.SendNotification();
1018 application.Render();
1020 underlineMapSet.Clear();
1021 underlineMapGet.Clear();
1023 underlineMapSet.Insert("enable", true);
1024 underlineMapSet.Insert("color", Color::BLUE);
1025 underlineMapSet.Insert("height", 1);
1026 underlineMapSet.Insert("type", Text::Underline::DASHED);
1027 underlineMapSet.Insert("dashWidth", 4);
1028 underlineMapSet.Insert("dashGap", 2);
1030 // Check the dashed underline property
1031 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1033 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1034 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1035 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1037 // Render and notify
1038 application.SendNotification();
1039 application.Render();
1041 underlineMapSet.Clear();
1042 underlineMapGet.Clear();
1044 underlineMapSet.Insert("enable", true);
1045 underlineMapSet.Insert("color", Color::BLUE);
1046 underlineMapSet.Insert("height", 4);
1047 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
1048 underlineMapSet.Insert("dashWidth", 4);
1049 underlineMapSet.Insert("dashGap", 2);
1051 // Check the dashed underline property
1052 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1054 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1055 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1056 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1058 // Render and notify
1059 application.SendNotification();
1060 application.Render();
1062 underlineMapSet.Clear();
1063 underlineMapGet.Clear();
1065 // Check the input underline property
1066 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1067 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1069 // Check the shadow property
1070 Property::Map shadowMapSet;
1071 Property::Map shadowMapGet;
1073 shadowMapSet.Insert("color", Color::GREEN);
1074 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1075 shadowMapSet.Insert("blurRadius", 3.0f);
1077 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1079 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1080 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1081 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1083 // Check the input shadow property
1084 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1085 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1087 // Check the emboss property
1088 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1089 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1091 // Check the input emboss property
1092 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1093 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1095 // Check the outline property
1097 // Test string type first
1098 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1099 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1100 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1102 // Then test the property map type
1103 Property::Map outlineMapSet;
1104 Property::Map outlineMapGet;
1106 outlineMapSet["color"] = Color::RED;
1107 outlineMapSet["width"] = 2.0f;
1109 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1111 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1112 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1113 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1115 // Check the input outline property
1116 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1117 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1119 // Check the hidden input settings property
1120 Property::Map hiddenMapSet;
1121 Property::Map hiddenMapGet;
1122 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1123 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1124 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1125 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1126 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1128 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1129 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1130 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1132 // Check the pixel size of font
1133 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1134 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1136 // Check the enable selection property
1137 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1138 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1140 // Check the placeholder property with pixel size
1141 Property::Map placeholderPixelSizeMapSet;
1142 Property::Map placeholderPixelSizeMapGet;
1143 Property::Map placeholderFontstyleMap;
1144 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1145 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1146 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1147 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1148 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1149 placeholderPixelSizeMapSet["ellipsis"] = true;
1151 placeholderFontstyleMap.Insert("weight", "bold");
1152 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1153 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1155 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1156 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1158 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1159 Property::Map placeholderConversionMap;
1160 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1161 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1162 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1163 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1164 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1165 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1167 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1169 // Check the placeholder property with point size
1170 Property::Map placeholderMapSet;
1171 Property::Map placeholderMapGet;
1172 placeholderMapSet["text"] = "Setting Placeholder Text";
1173 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1174 placeholderMapSet["color"] = Color::RED;
1175 placeholderMapSet["fontFamily"] = "Arial";
1176 placeholderMapSet["pointSize"] = 12.0f;
1177 placeholderMapSet["ellipsis"] = false;
1179 // Check the placeholder font style property
1180 placeholderFontstyleMap.Clear();
1182 placeholderFontstyleMap.Insert("weight", "bold");
1183 placeholderFontstyleMap.Insert("width", "condensed");
1184 placeholderFontstyleMap.Insert("slant", "italic");
1185 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1186 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1188 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1189 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1191 placeholderConversionMap.Clear();
1192 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1193 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1194 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1195 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1196 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1197 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1199 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1201 // Reset font style.
1202 placeholderFontstyleMap.Clear();
1203 placeholderFontstyleMap.Insert("weight", "normal");
1204 placeholderFontstyleMap.Insert("slant", "oblique");
1205 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1206 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1208 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1209 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1211 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1212 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1214 placeholderFontstyleMap.Clear();
1215 placeholderFontstyleMap.Insert("slant", "roman");
1216 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1217 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1219 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1221 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1223 placeholderFontstyleMap.Clear();
1224 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1225 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1227 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1228 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1229 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1231 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1233 // Check the ellipsis property
1234 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1235 field.SetProperty(TextField::Property::ELLIPSIS, true);
1236 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1238 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1239 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1241 // Test the ENABLE_GRAB_HANDLE_POPUP property
1242 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1243 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1244 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1246 // Check the background property
1247 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1248 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1250 //Check handle color
1251 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1252 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1254 // Check the input filter property
1255 Property::Map inputFilterMapSet;
1256 Property::Map inputFilterMapGet;
1257 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1258 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1260 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1262 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1263 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1266 inputFilterMapSet.Clear();
1267 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1269 application.SendNotification();
1270 application.Render();
1275 // Positive Atlas Text Renderer test
1276 int utcDaliTextFieldAtlasRenderP(void)
1278 ToolkitTestApplication application;
1279 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1280 StyleManager styleManager = StyleManager::Get();
1281 styleManager.ApplyDefaultTheme();
1282 TextField field = TextField::New();
1283 DALI_TEST_CHECK(field);
1285 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1287 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1289 application.GetScene().Add(field);
1293 // Render some text with the shared atlas backend
1294 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1295 application.SendNotification();
1296 application.Render();
1300 tet_result(TET_FAIL);
1305 // Positive test for the anchorClicked signal.
1306 int utcDaliTextFieldAnchorClicked01(void)
1308 ToolkitTestApplication application;
1309 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1310 TextField field = TextField::New();
1311 DALI_TEST_CHECK(field);
1313 application.GetScene().Add(field);
1315 // connect to the anchor clicked signal.
1316 ConnectionTracker* testTracker = new ConnectionTracker();
1317 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1318 bool anchorClickedSignal = false;
1319 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1321 gAnchorClickedCallBackCalled = false;
1322 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1323 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1324 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1325 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1326 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1328 application.SendNotification();
1329 application.Render();
1330 field.SetKeyInputFocus();
1332 // Create a tap event to touch the text field.
1333 TestGenerateTap(application, 5.0f, 25.0f);
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1338 DALI_TEST_CHECK(anchorClickedSignal);
1340 gAnchorClickedCallBackNotCalled = true;
1341 // Tap the outside of anchor, callback should not be called.
1342 TestGenerateTap(application, 150.f, 100.f);
1343 application.SendNotification();
1344 application.Render();
1346 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1351 // Positive test for the anchorClicked signal.
1352 int utcDaliTextFieldAnchorClicked02(void)
1354 ToolkitTestApplication application;
1355 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1356 TextField field = TextField::New();
1357 DALI_TEST_CHECK(field);
1359 application.GetScene().Add(field);
1361 // connect to the anchor clicked signal.
1362 ConnectionTracker* testTracker = new ConnectionTracker();
1363 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1364 bool anchorClickedSignal = false;
1365 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1367 gAnchorClickedCallBackCalled = false;
1368 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1369 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1370 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1371 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1372 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1374 application.SendNotification();
1375 application.Render();
1376 field.SetKeyInputFocus();
1378 // Avoid a crash when core load gl resources.
1379 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1381 // Create a tap event to touch the text field.
1382 TestGenerateTap(application, 30.0f, 25.0f, 100);
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1387 DALI_TEST_CHECK(anchorClickedSignal);
1389 // For coverage InsertTextAnchor, RemoveTextAnchor
1390 // first index insert
1391 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1392 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1393 application.SendNotification();
1394 application.Render();
1396 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1397 application.SendNotification();
1398 application.Render();
1400 gAnchorClickedCallBackCalled = false;
1401 // Create a tap event to touch the text field.
1402 TestGenerateTap(application, 30.0f, 25.0f, 700);
1403 application.SendNotification();
1404 field.SetKeyInputFocus();
1406 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1408 // last index insert
1409 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1410 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1411 application.SendNotification();
1412 application.Render();
1414 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1415 application.SendNotification();
1416 application.Render();
1418 gAnchorClickedCallBackCalled = false;
1419 // Create a tap event to touch the text field.
1420 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1421 application.SendNotification();
1422 field.SetKeyInputFocus();
1424 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1427 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1428 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1429 application.SendNotification();
1430 application.Render();
1432 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1433 application.SendNotification();
1434 application.Render();
1436 gAnchorClickedCallBackCalled = false;
1437 // Create a tap event to touch the text field.
1438 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1439 application.SendNotification();
1440 field.SetKeyInputFocus();
1442 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1444 // first index remove
1445 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1446 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1447 application.SendNotification();
1448 application.Render();
1450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1451 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1452 application.SendNotification();
1453 application.Render();
1455 gAnchorClickedCallBackCalled = false;
1456 // Create a tap event to touch the text field.
1457 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1458 application.SendNotification();
1459 field.SetKeyInputFocus();
1461 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1463 // last index remove
1464 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1465 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1466 application.SendNotification();
1467 application.Render();
1469 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1470 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1471 application.SendNotification();
1472 application.Render();
1474 gAnchorClickedCallBackCalled = false;
1475 // Create a tap event to touch the text field.
1476 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1477 application.SendNotification();
1478 application.Render();
1480 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1483 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1484 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1485 application.SendNotification();
1486 application.Render();
1488 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1489 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1490 application.SendNotification();
1491 application.Render();
1493 gAnchorClickedCallBackCalled = false;
1494 // Create a tap event to touch the text field.
1495 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1496 application.SendNotification();
1497 application.Render();
1499 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1501 // 0 ~ 1 index remove
1502 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1503 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1504 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1505 application.SendNotification();
1506 application.Render();
1508 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1509 application.SendNotification();
1510 application.Render();
1512 gAnchorClickedCallBackCalled = false;
1513 // Create a tap event to touch the text field.
1514 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1515 application.SendNotification();
1516 application.Render();
1518 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1520 // 1 ~ 3 index remove
1521 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1522 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1523 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1524 application.SendNotification();
1525 application.Render();
1527 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1528 application.SendNotification();
1529 application.Render();
1531 gAnchorClickedCallBackCalled = false;
1532 // Create a tap event to touch the text field.
1533 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1534 application.SendNotification();
1535 application.Render();
1537 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1539 // 3 ~ 4 index remove
1540 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1541 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1542 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1543 application.SendNotification();
1544 application.Render();
1546 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1547 application.SendNotification();
1548 application.Render();
1550 gAnchorClickedCallBackCalled = false;
1551 // Create a tap event to touch the text field.
1552 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1553 application.SendNotification();
1554 application.Render();
1556 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1558 // Remove front of anchor
1559 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1560 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1561 application.SendNotification();
1562 application.Render();
1564 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1565 application.SendNotification();
1566 application.Render();
1568 // Remove whole text
1569 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1570 DevelTextField::SelectWholeText(field);
1571 application.SendNotification();
1572 application.Render();
1574 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1575 application.SendNotification();
1576 application.Render();
1578 // Remove all with backspace
1579 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1580 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1581 application.SendNotification();
1582 application.Render();
1584 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1585 application.SendNotification();
1586 application.Render();
1588 // Remove all with delete
1589 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1590 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1591 application.SendNotification();
1592 application.Render();
1594 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1595 application.SendNotification();
1596 application.Render();
1601 // Positive test for the textChanged signal.
1602 int utcDaliTextFieldTextChangedP(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" utcDaliTextFieldTextChangedP");
1606 TextField field = TextField::New();
1607 DALI_TEST_CHECK(field);
1609 application.GetScene().Add(field);
1611 // connect to the text changed signal.
1612 ConnectionTracker* testTracker = new ConnectionTracker();
1613 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1614 bool textChangedSignal = false;
1615 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1617 gTextChangedCallBackCalled = false;
1618 field.SetProperty(TextField::Property::TEXT, "ABC");
1619 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1620 DALI_TEST_CHECK(textChangedSignal);
1622 application.SendNotification();
1623 field.SetKeyInputFocus();
1625 gTextChangedCallBackCalled = false;
1626 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1627 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1630 field.SetProperty(TextField::Property::TEXT, "");
1632 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1633 gTextChangedCallBackCalled = false;
1634 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1635 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1637 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1638 gTextChangedCallBackCalled = false;
1639 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1640 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1645 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1647 ToolkitTestApplication application;
1648 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1649 TextField field = TextField::New();
1650 DALI_TEST_CHECK(field);
1652 application.GetScene().Add(field);
1654 // connect to the text changed signal.
1655 ConnectionTracker* testTracker = new ConnectionTracker();
1656 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1657 bool textChangedSignal = false;
1658 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1660 // get InputMethodContext
1662 InputMethodContext::EventData imfEvent;
1663 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1665 field.SetKeyInputFocus();
1666 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1669 gTextChangedCallBackCalled = false;
1670 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1671 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1672 application.SendNotification();
1673 application.Render();
1674 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1675 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1677 gTextChangedCallBackCalled = false;
1678 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1679 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1680 application.SendNotification();
1681 application.Render();
1682 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1683 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1685 gTextChangedCallBackCalled = false;
1686 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1687 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1688 application.SendNotification();
1689 application.Render();
1690 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1691 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1693 gTextChangedCallBackCalled = false;
1694 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1695 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1696 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1698 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1699 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1700 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1702 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1703 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1704 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1706 application.SendNotification();
1707 application.Render();
1708 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1709 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1714 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1716 ToolkitTestApplication application;
1717 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1718 TextField field = TextField::New();
1719 DALI_TEST_CHECK(field);
1721 field.SetProperty(TextField::Property::TEXT, "Hello world");
1723 application.GetScene().Add(field);
1725 // connect to the selection changed signal.
1726 ConnectionTracker* testTracker = new ConnectionTracker();
1727 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1728 bool selectionChangedSignal = false;
1729 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1731 // get InputMethodContext
1733 InputMethodContext::EventData imfEvent;
1734 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1736 field.SetKeyInputFocus();
1737 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1740 gSelectionChangedCallbackCalled = false;
1741 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1742 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1743 application.SendNotification();
1744 application.Render();
1745 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1747 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1748 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1753 int utcDaliTextFieldPositionWithInputMethodContext(void)
1755 ToolkitTestApplication application;
1756 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1757 TextField field = TextField::New();
1758 DALI_TEST_CHECK(field);
1760 field.SetProperty(TextField::Property::TEXT, "Hello world");
1762 application.GetScene().Add(field);
1764 // connect to the selection changed signal.
1765 ConnectionTracker* testTracker = new ConnectionTracker();
1766 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1767 bool cursorPositionChangedSignal = false;
1768 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1770 // get InputMethodContext
1772 InputMethodContext::EventData imfEvent;
1773 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1775 field.SetKeyInputFocus();
1776 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1779 gCursorPositionChangedCallbackCalled = false;
1780 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1781 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1782 application.SendNotification();
1783 application.Render();
1784 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1786 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1791 // Negative test for the textChanged signal.
1792 int utcDaliTextFieldTextChangedN(void)
1794 ToolkitTestApplication application;
1795 tet_infoline(" utcDaliTextFieldTextChangedN");
1796 TextField field = TextField::New();
1797 DALI_TEST_CHECK(field);
1799 application.GetScene().Add(field);
1801 // connect to the text changed signal.
1802 ConnectionTracker* testTracker = new ConnectionTracker();
1803 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1804 bool textChangedSignal = false;
1805 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1807 gTextChangedCallBackCalled = false;
1808 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1809 application.SendNotification();
1810 application.Render();
1811 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1812 DALI_TEST_CHECK(!textChangedSignal);
1817 // Positive test for Max Characters reached signal.
1818 int utcDaliTextFieldMaxCharactersReachedP(void)
1820 ToolkitTestApplication application;
1821 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1822 TextField field = TextField::New();
1823 DALI_TEST_CHECK(field);
1825 application.GetScene().Add(field);
1827 const int maxNumberOfCharacters = 1;
1828 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1830 field.SetKeyInputFocus();
1832 // connect to the text changed signal.
1833 ConnectionTracker* testTracker = new ConnectionTracker();
1834 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1835 bool maxLengthReachedSignal = false;
1836 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1838 gMaxCharactersCallBackCalled = false;
1840 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1841 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1843 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1844 DALI_TEST_CHECK(maxLengthReachedSignal);
1849 // Negative test for Max Characters reached signal.
1850 int utcDaliTextFieldMaxCharactersReachedN(void)
1852 ToolkitTestApplication application;
1853 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1854 TextField field = TextField::New();
1855 DALI_TEST_CHECK(field);
1857 application.GetScene().Add(field);
1859 const int maxNumberOfCharacters = 3;
1860 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1862 field.SetKeyInputFocus();
1864 // connect to the text changed signal.
1865 ConnectionTracker* testTracker = new ConnectionTracker();
1866 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1867 bool maxLengthReachedSignal = false;
1868 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1870 gMaxCharactersCallBackCalled = false;
1872 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1873 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1875 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1876 DALI_TEST_CHECK(!maxLengthReachedSignal);
1878 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1880 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1881 DALI_TEST_CHECK(!maxLengthReachedSignal);
1886 // Positive test for Input Filtered signal.
1887 int utcDaliTextFieldInputFilteredP(void)
1889 ToolkitTestApplication application;
1890 tet_infoline(" utcDaliTextFieldInputFilteredP");
1891 TextField field = TextField::New();
1892 DALI_TEST_CHECK(field);
1894 application.GetScene().Add(field);
1896 Property::Map inputFilter;
1898 // Only digit is accepted.
1899 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1901 // Set input filter to TextField.
1902 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1904 field.SetKeyInputFocus();
1906 // connect to the input filtered signal.
1907 ConnectionTracker* testTracker = new ConnectionTracker();
1908 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1909 bool inputFilteredSignal = false;
1910 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1912 gInputFilteredAcceptedCallbackCalled = false;
1914 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1916 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1917 DALI_TEST_CHECK(inputFilteredSignal);
1919 // Word is rejected.
1920 inputFilter[InputFilter::Property::ACCEPTED] = "";
1921 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1923 // Set input filter to TextField.
1924 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1926 field.SetKeyInputFocus();
1928 inputFilteredSignal = false;
1929 gInputFilteredRejectedCallbackCalled = false;
1931 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1933 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1934 DALI_TEST_CHECK(inputFilteredSignal);
1939 // Negative test for Input Filtered signal.
1940 int utcDaliTextFieldInputFilteredN(void)
1942 ToolkitTestApplication application;
1943 tet_infoline(" utcDaliTextFieldInputFilteredP");
1944 TextField field = TextField::New();
1945 DALI_TEST_CHECK(field);
1947 application.GetScene().Add(field);
1949 Property::Map inputFilter;
1951 // Only word is accepted.
1952 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1954 // Set input filter to TextField.
1955 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1957 field.SetKeyInputFocus();
1959 // connect to the input filtered signal.
1960 ConnectionTracker* testTracker = new ConnectionTracker();
1961 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1962 bool inputFilteredSignal = false;
1963 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1965 gInputFilteredAcceptedCallbackCalled = false;
1967 // Key a, d should not be filtered.
1968 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1969 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1970 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1971 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1973 // Backspace, Delete should not be filtered.
1974 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1975 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1982 DALI_TEST_CHECK(!inputFilteredSignal);
1984 // Digit is rejected.
1985 inputFilter[InputFilter::Property::ACCEPTED] = "";
1986 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1988 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1990 field.SetKeyInputFocus();
1992 inputFilteredSignal = false;
1993 gInputFilteredRejectedCallbackCalled = false;
1995 // Key a, d should not be filtered.
1996 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1997 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1998 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1999 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2001 // Backspace, Delete should not be filtered.
2002 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2003 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2005 // Render and notify
2006 application.SendNotification();
2007 application.Render();
2009 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2010 DALI_TEST_CHECK(!inputFilteredSignal);
2015 int utcDaliTextFieldInputStyleChanged01(void)
2017 // The text-field emits signals when the input style changes. These changes of style are
2018 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2019 // can't be emitted during the size negotiation as the callbacks may update the UI.
2020 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2021 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2022 ToolkitTestApplication application;
2023 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2027 char* pathNamePtr = get_current_dir_name();
2028 const std::string pathName(pathNamePtr);
2031 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2032 fontClient.SetDpi(93u, 93u);
2034 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2035 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2037 TextField field = TextField::New();
2038 DALI_TEST_CHECK(field);
2040 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2041 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2042 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2044 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2045 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2047 // connect to the text changed signal.
2048 ConnectionTracker* testTracker = new ConnectionTracker();
2049 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2050 bool inputStyleChangedSignal = false;
2051 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2053 application.GetScene().Add(field);
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Executes the idle callbacks added by the text control on the change of input style.
2060 application.RunIdles();
2062 gInputStyleChangedCallbackCalled = false;
2063 gInputStyleMask = TextField::InputStyle::NONE;
2064 inputStyleChangedSignal = false;
2066 // Create a tap event to touch the text field.
2067 TestGenerateTap(application, 18.0f, 25.0f);
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2073 // Executes the idle callbacks added by the text control on the change of input style.
2074 application.RunIdles();
2076 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2077 if(gInputStyleChangedCallbackCalled)
2079 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2081 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2082 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2084 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2085 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2087 DALI_TEST_CHECK(inputStyleChangedSignal);
2089 gInputStyleChangedCallbackCalled = false;
2090 gInputStyleMask = TextField::InputStyle::NONE;
2091 inputStyleChangedSignal = false;
2093 // Create a tap event to touch the text field.
2094 TestGenerateTap(application, 30.0f, 25.0f);
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2100 // Executes the idle callbacks added by the text control on the change of input style.
2101 application.RunIdles();
2103 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2104 DALI_TEST_CHECK(!inputStyleChangedSignal);
2106 gInputStyleChangedCallbackCalled = false;
2107 gInputStyleMask = TextField::InputStyle::NONE;
2108 inputStyleChangedSignal = false;
2110 // Create a tap event to touch the text field.
2111 TestGenerateTap(application, 43.0f, 25.0f);
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 // Executes the idle callbacks added by the text control on the change of input style.
2118 application.RunIdles();
2120 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2121 if(gInputStyleChangedCallbackCalled)
2123 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2125 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2126 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2128 DALI_TEST_CHECK(inputStyleChangedSignal);
2130 gInputStyleChangedCallbackCalled = false;
2131 gInputStyleMask = TextField::InputStyle::NONE;
2132 inputStyleChangedSignal = false;
2134 // Create a tap event to touch the text field.
2135 TestGenerateTap(application, 88.0f, 25.0f);
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // Executes the idle callbacks added by the text control on the change of input style.
2142 application.RunIdles();
2144 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2145 if(gInputStyleChangedCallbackCalled)
2147 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2149 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2150 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2152 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2154 Property::Map fontStyleMapSet;
2155 fontStyleMapSet.Insert("weight", "bold");
2157 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2158 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2160 DALI_TEST_CHECK(inputStyleChangedSignal);
2162 gInputStyleChangedCallbackCalled = false;
2163 gInputStyleMask = TextField::InputStyle::NONE;
2164 inputStyleChangedSignal = false;
2166 // Create a tap event to touch the text field.
2167 TestGenerateTap(application, 115.0f, 25.0f);
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 // Executes the idle callbacks added by the text control on the change of input style.
2174 application.RunIdles();
2176 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2177 DALI_TEST_CHECK(!inputStyleChangedSignal);
2179 gInputStyleChangedCallbackCalled = false;
2180 gInputStyleMask = TextField::InputStyle::NONE;
2181 inputStyleChangedSignal = false;
2183 // Create a tap event to touch the text field.
2184 TestGenerateTap(application, 164.0f, 25.0f);
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 // Executes the idle callbacks added by the text control on the change of input style.
2191 application.RunIdles();
2193 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2194 if(gInputStyleChangedCallbackCalled)
2196 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2198 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2199 DALI_TEST_CHECK(style.empty());
2201 DALI_TEST_CHECK(inputStyleChangedSignal);
2203 gInputStyleChangedCallbackCalled = false;
2204 gInputStyleMask = TextField::InputStyle::NONE;
2205 inputStyleChangedSignal = false;
2207 // Create a tap event to touch the text field.
2208 TestGenerateTap(application, 191.0f, 25.0f);
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 // Executes the idle callbacks added by the text control on the change of input style.
2215 application.RunIdles();
2217 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2218 DALI_TEST_CHECK(!inputStyleChangedSignal);
2223 int utcDaliTextFieldInputStyleChanged02(void)
2225 // The text-field emits signals when the input style changes. These changes of style are
2226 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2227 // can't be emitted during the size negotiation as the callbacks may update the UI.
2228 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2229 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2230 ToolkitTestApplication application;
2231 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2235 char* pathNamePtr = get_current_dir_name();
2236 const std::string pathName(pathNamePtr);
2239 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2240 fontClient.SetDpi(93u, 93u);
2242 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2243 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2245 TextField field = TextField::New();
2246 DALI_TEST_CHECK(field);
2248 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2249 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2250 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2252 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2253 field.SetProperty(TextField::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>");
2255 // connect to the text changed signal.
2256 ConnectionTracker* testTracker = new ConnectionTracker();
2257 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2258 bool inputStyleChangedSignal = false;
2259 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2261 application.GetScene().Add(field);
2263 // Render and notify
2264 application.SendNotification();
2265 application.Render();
2267 // Executes the idle callbacks added by the text control on the change of input style.
2268 application.RunIdles();
2270 gInputStyleChangedCallbackCalled = false;
2271 gInputStyleMask = TextField::InputStyle::NONE;
2272 inputStyleChangedSignal = false;
2274 // Create a tap event to touch the text field.
2275 TestGenerateTap(application, 53.0f, 25.0f, 100);
2276 TestGenerateTap(application, 53.0f, 25.0f, 200);
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Executes the idle callbacks added by the text control on the change of input style.
2283 application.RunIdles();
2285 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2286 if(gInputStyleChangedCallbackCalled)
2288 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2289 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2290 TextField::InputStyle::POINT_SIZE |
2291 TextField::InputStyle::COLOR),
2294 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2295 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2297 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2298 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2300 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2301 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2303 DALI_TEST_CHECK(inputStyleChangedSignal);
2305 gInputStyleChangedCallbackCalled = false;
2306 gInputStyleMask = TextField::InputStyle::NONE;
2307 inputStyleChangedSignal = false;
2309 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // Executes the idle callbacks added by the text control on the change of input style.
2316 application.RunIdles();
2318 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2319 if(gInputStyleChangedCallbackCalled)
2321 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2322 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2325 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2326 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2328 DALI_TEST_CHECK(inputStyleChangedSignal);
2330 gInputStyleChangedCallbackCalled = false;
2331 gInputStyleMask = TextField::InputStyle::NONE;
2332 inputStyleChangedSignal = false;
2334 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Executes the idle callbacks added by the text control on the change of input style.
2341 application.RunIdles();
2343 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2344 DALI_TEST_CHECK(!inputStyleChangedSignal);
2346 gInputStyleChangedCallbackCalled = false;
2347 gInputStyleMask = TextField::InputStyle::NONE;
2348 inputStyleChangedSignal = false;
2350 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 // Executes the idle callbacks added by the text control on the change of input style.
2357 application.RunIdles();
2359 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2360 if(gInputStyleChangedCallbackCalled)
2362 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2363 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2366 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2367 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2369 DALI_TEST_CHECK(inputStyleChangedSignal);
2371 gInputStyleChangedCallbackCalled = false;
2372 gInputStyleMask = TextField::InputStyle::NONE;
2373 inputStyleChangedSignal = false;
2375 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2377 Property::Map fontStyleMapSet;
2378 fontStyleMapSet.Insert("weight", "thin");
2379 fontStyleMapSet.Insert("width", "condensed");
2380 fontStyleMapSet.Insert("slant", "italic");
2382 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2383 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2385 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2386 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2387 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2388 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2389 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2395 // Executes the idle callbacks added by the text control on the change of input style.
2396 application.RunIdles();
2398 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2399 DALI_TEST_CHECK(!inputStyleChangedSignal);
2401 // Create a tap event to touch the text field.
2402 TestGenerateTap(application, 63.0f, 25.0f, 700);
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Executes the idle callbacks added by the text control on the change of input style.
2409 application.RunIdles();
2411 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2412 if(gInputStyleChangedCallbackCalled)
2414 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2415 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2416 TextField::InputStyle::POINT_SIZE |
2417 TextField::InputStyle::FONT_STYLE |
2418 TextField::InputStyle::UNDERLINE |
2419 TextField::InputStyle::SHADOW |
2420 TextField::InputStyle::EMBOSS |
2421 TextField::InputStyle::OUTLINE),
2424 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2425 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2427 DALI_TEST_CHECK(inputStyleChangedSignal);
2432 int utcDaliTextFieldEvent01(void)
2434 ToolkitTestApplication application;
2435 tet_infoline(" utcDaliTextFieldEvent01");
2437 // Creates a tap event. After creating a tap event the text field should
2438 // have the focus and add text with key events should be possible.
2440 TextField field = TextField::New();
2441 DALI_TEST_CHECK(field);
2443 application.GetScene().Add(field);
2445 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2446 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2447 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 // Avoid a crash when core load gl resources.
2454 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2460 // Add a key event but as the text field has not the focus it should do nothing.
2461 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2469 // Create a tap event to touch the text field.
2470 TestGenerateTap(application, 150.0f, 25.0f);
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 // Pressing delete key should be fine even if there is no text in TextField.
2477 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 // Now the text field has the focus, so it can handle the key events.
2483 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2484 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2492 // Create a second text field and send key events to it.
2493 TextField field2 = TextField::New();
2495 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2496 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2497 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2498 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2500 application.GetScene().Add(field2);
2502 // Render and notify
2503 application.SendNotification();
2504 application.Render();
2506 // Create a tap event on the second text field.
2507 TestGenerateTap(application, 150.0f, 125.0f);
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // The second text field has the focus. It should handle the key events.
2514 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2515 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Check the text has been added to the second text field.
2522 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2527 int utcDaliTextFieldEvent02(void)
2529 ToolkitTestApplication application;
2530 tet_infoline(" utcDaliTextFieldEvent02");
2532 // Checks if the right number of actors are created.
2534 TextField field = TextField::New();
2535 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2536 DALI_TEST_CHECK(field);
2537 LoadMarkerImages(application, field);
2539 application.GetScene().Add(field);
2541 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2542 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2543 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2545 // Avoid a crash when core load gl resources.
2546 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 // Check there are the expected number of children ( stencil ).
2553 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2555 Actor stencil = field.GetChildAt(0u);
2556 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2558 // Create a tap event to touch the text field.
2559 TestGenerateTap(application, 150.0f, 25.0f, 300);
2561 // Render and notify
2562 application.SendNotification();
2563 application.Render();
2565 Actor layer = field.GetChildAt(2u);
2566 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2567 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2569 // Now the text field has the focus, so it can handle the key events.
2570 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2571 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 // Checks the cursor and the renderer have been created.
2578 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2579 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2581 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2582 DALI_TEST_CHECK(cursor);
2584 // The offscreen root actor has a container with all the actors which contain the text renderers.
2585 Actor container = stencil.GetChildAt(0u);
2586 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2588 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2589 DALI_TEST_CHECK(renderer);
2592 // Move the cursor and check the position changes.
2593 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2594 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2600 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2601 DALI_TEST_CHECK(position2.x < position1.x);
2603 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2605 // Render and notify
2606 application.SendNotification();
2607 application.Render();
2609 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2610 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2612 // Move the cursor to the first position.
2613 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2614 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2616 // Render and notify
2617 application.SendNotification();
2618 application.Render();
2620 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2622 // Send some taps and check the cursor positions.
2624 // Try to tap at the beginning.
2625 TestGenerateTap(application, 1.0f, 25.0f, 900);
2627 // Render and notify
2628 application.SendNotification();
2629 application.Render();
2631 // Cursor position should be the same than position1.
2632 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2634 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2636 // Tap away from the start position.
2637 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2639 // Render and notify
2640 application.SendNotification();
2641 application.Render();
2643 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2645 DALI_TEST_CHECK(position6.x > position5.x);
2647 // Remove all the text.
2648 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2649 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2650 field.SetProperty(TextField::Property::TEXT, "");
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 // Cursor position should be the same than position2.
2657 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2659 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2661 // Should not be a renderer, there is only a clipped cursor.
2662 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2664 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2665 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2666 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2668 application.SendNotification();
2669 application.Render();
2671 // There are renderer and decorator layer
2672 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2677 int utcDaliTextFieldEvent03(void)
2679 ToolkitTestApplication application;
2680 tet_infoline(" utcDaliTextFieldEvent03");
2682 // Checks if the highlight actor is created.
2684 TextField field = TextField::New();
2685 DALI_TEST_CHECK(field);
2687 application.GetScene().Add(field);
2689 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2690 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2691 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2692 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2693 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2695 // Avoid a crash when core load gl resources.
2696 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2697 LoadMarkerImages(application, field);
2699 // Render and notify
2700 application.SendNotification();
2701 application.Render();
2703 // Tap first to get the focus.
2704 TestGenerateTap(application, 3.0f, 25.0f, 100);
2706 // Render and notify
2707 application.SendNotification();
2708 application.Render();
2710 // Double tap to select a word.
2711 TestGenerateTap(application, 3.0f, 25.0f, 200);
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2718 Actor stencil = field.GetChildAt(0u);
2720 // The highlight actor is drawn first, so is the first actor in the list
2721 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2722 DALI_TEST_CHECK(highlight);
2724 // The offscreen root actor has a container with all the actors which contain the text renderers.
2725 Actor container = stencil.GetChildAt(1u);
2726 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2728 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2729 DALI_TEST_CHECK(renderer);
2735 int utcDaliTextFieldEvent04(void)
2737 ToolkitTestApplication application;
2738 tet_infoline(" utcDaliTextFieldEvent04");
2740 // Checks if the highlight actor is created.
2742 TextField field = TextField::New();
2743 DALI_TEST_CHECK(field);
2744 application.GetScene().Add(field);
2745 LoadMarkerImages(application, field);
2746 // Render and notify
2747 application.SendNotification();
2748 application.Render();
2750 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2751 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2752 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2753 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2754 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2756 // Avoid a crash when core load gl resources.
2757 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2758 // Render and notify
2759 application.SendNotification();
2760 application.Render();
2762 // Create a tap event to touch the text field.
2763 TestGenerateTap(application, 150.0f, 25.0f);
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2768 // Tap first to get the focus.
2769 TestGenerateTap(application, 1.0f, 25.0f);
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2775 // Double tap to select a word.
2776 TestGenerateTap(application, 1.0f, 25.0f);
2778 // Render and notify
2779 application.SendNotification();
2780 application.Render();
2783 TestGenerateTap(application, 0.0f, 40.0f);
2787 int utcDaliTextFieldEvent05(void)
2789 ToolkitTestApplication application;
2790 tet_infoline(" utcDaliTextFieldEvent05");
2792 // Checks dragging of cursor/grab handle
2794 TextField field = TextField::New();
2795 DALI_TEST_CHECK(field);
2796 application.GetScene().Add(field);
2797 LoadMarkerImages(application, field);
2798 // Render and notify
2799 application.SendNotification();
2800 application.Render();
2802 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2803 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2804 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2805 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2806 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2808 // Avoid a crash when core load gl resources.
2809 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2810 // Render and notify
2811 application.SendNotification();
2812 application.Render();
2814 // Create a tap event to touch the text field.
2815 TestGenerateTap(application, 150.0f, 25.0f);
2816 // Render and notify
2817 application.SendNotification();
2818 application.Render();
2820 // Tap first to get the focus.
2821 TestGenerateTap(application, 1.0f, 25.0f);
2823 // Render and notify
2824 application.SendNotification();
2825 application.Render();
2827 // Double tap to select a word.
2828 TestGenerateTap(application, 1.0f, 25.0f);
2830 // Render and notify
2831 application.SendNotification();
2832 application.Render();
2834 Actor stencil = field.GetChildAt(1u);
2838 int utcDaliTextFieldEvent06(void)
2840 ToolkitTestApplication application;
2841 tet_infoline(" utcDaliTextFieldEvent06");
2843 // Checks Longpress when in edit mode
2845 TextField field = TextField::New();
2846 DALI_TEST_CHECK(field);
2847 application.GetScene().Add(field);
2848 LoadMarkerImages(application, field);
2849 // Render and notify
2850 application.SendNotification();
2851 application.Render();
2853 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2854 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2855 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2856 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2857 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2859 // Avoid a crash when core load gl resources.
2860 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2861 // Render and notify
2862 application.SendNotification();
2863 application.Render();
2865 // Create a tap event to touch the text field.
2866 TestGenerateTap(application, 150.0f, 25.0f);
2867 // Render and notify
2868 application.SendNotification();
2869 application.Render();
2871 // Tap first to get the focus.
2872 TestGenerateTap(application, 1.0f, 25.0f);
2874 // Render and notify
2875 application.SendNotification();
2876 application.Render();
2879 TestGenerateLongPress(application, 1.0f, 25.0f);
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2888 int utcDaliTextFieldEvent07(void)
2890 ToolkitTestApplication application;
2891 tet_infoline(" utcDaliTextFieldEvent07");
2893 // Checks Longpress to start edit mode
2895 TextField field = TextField::New();
2896 DALI_TEST_CHECK(field);
2897 application.GetScene().Add(field);
2898 LoadMarkerImages(application, field);
2899 // Render and notify
2900 application.SendNotification();
2901 application.Render();
2903 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2904 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2905 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2906 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2907 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2908 Property::Map propertyMap;
2909 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2910 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2912 // Avoid a crash when core load gl resources.
2913 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2914 // Render and notify
2915 application.SendNotification();
2916 application.Render();
2919 TestGenerateLongPress(application, 1.0f, 25.0f);
2921 // Render and notify
2922 application.SendNotification();
2923 application.Render();
2928 int utcDaliTextFieldEvent08(void)
2930 ToolkitTestApplication application;
2931 tet_infoline(" utcDaliTextFieldEvent08");
2933 Dali::Clipboard clipboard = Clipboard::Get();
2934 clipboard.SetItem("testTextFieldEvent");
2936 // Checks Longpress when only place holder text
2938 TextField field = TextField::New();
2939 DALI_TEST_CHECK(field);
2940 application.GetScene().Add(field);
2941 LoadMarkerImages(application, field);
2942 // Render and notify
2943 application.SendNotification();
2944 application.Render();
2946 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2947 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2948 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2949 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2950 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2952 // Avoid a crash when core load gl resources.
2953 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2954 // Render and notify
2955 application.SendNotification();
2956 application.Render();
2959 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2961 // Render and notify
2962 application.SendNotification();
2963 application.Render();
2965 Wait(application, 500);
2967 TestEndLongPress(application, 1.0f, 25.0f, 520);
2970 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2972 // Render and notify
2973 application.Render();
2975 Wait(application, 500);
2977 Integration::Scene stage = application.GetScene();
2978 Layer layer = stage.GetRootLayer();
2979 Actor actor = layer.FindChildByName("optionPaste");
2983 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2984 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2985 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2987 Dali::Integration::TouchEvent event;
2988 event = Dali::Integration::TouchEvent();
2989 event.AddPoint(GetPointDownInside(position));
2990 application.ProcessEvent(event);
2992 event = Dali::Integration::TouchEvent();
2993 event.AddPoint(GetPointUpInside(position));
2994 application.ProcessEvent(event);
2996 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3001 int utcDaliTextFieldEvent09(void)
3003 ToolkitTestApplication application;
3004 tet_infoline(" utcDaliTextFieldEvent09");
3006 TextField field = TextField::New();
3007 DALI_TEST_CHECK(field);
3008 application.GetScene().Add(field);
3009 LoadMarkerImages(application, field);
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 field.SetProperty(TextField::Property::TEXT, "Hello");
3015 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3016 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3017 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3018 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3019 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3021 // Avoid a crash when core load gl resources.
3022 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3024 // Create a tap event to touch the text field.
3025 TestGenerateTap(application, 150.0f, 25.0f);
3026 application.SendNotification();
3027 application.Render();
3030 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3031 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3032 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3033 application.SendNotification();
3034 application.Render();
3035 for(unsigned int index = 0u; index < 6u; ++index)
3037 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3038 application.SendNotification();
3039 application.Render();
3042 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3043 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3044 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3045 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3046 application.SendNotification();
3047 application.Render();
3049 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3050 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3051 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3052 for(unsigned int index = 0u; index < 5u; ++index)
3054 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3055 application.SendNotification();
3056 application.Render();
3059 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3060 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3061 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3062 for(unsigned int index = 0u; index < 5u; ++index)
3064 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3065 application.SendNotification();
3066 application.Render();
3069 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3070 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3071 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3072 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3073 application.SendNotification();
3074 application.Render();
3075 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3076 application.SendNotification();
3077 application.Render();
3079 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3080 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3081 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3082 application.SendNotification();
3083 application.Render();
3085 Property::Map mapGet;
3086 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3087 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3088 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3092 int utcDaliTextFieldStyleWhilstSelected(void)
3094 ToolkitTestApplication application;
3095 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3097 // Change font and styles whilst text is selected whilst word selected
3099 TextField field = TextField::New();
3100 DALI_TEST_CHECK(field);
3101 application.GetScene().Add(field);
3102 LoadMarkerImages(application, field);
3103 // Render and notify
3104 application.SendNotification();
3105 application.Render();
3107 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3108 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3109 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3110 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3111 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3113 // Avoid a crash when core load gl resources.
3114 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 // Create a tap event to touch the text field.
3120 TestGenerateTap(application, 150.0f, 25.0f);
3121 // Render and notify
3122 application.SendNotification();
3123 application.Render();
3125 // Tap first to get the focus.
3126 TestGenerateTap(application, 1.0f, 25.0f);
3128 // Render and notify
3129 application.SendNotification();
3130 application.Render();
3132 // Double tap to select a word.
3133 TestGenerateTap(application, 1.0f, 25.0f);
3135 // Render and notify
3136 application.SendNotification();
3137 application.Render();
3139 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3140 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3142 Property::Map fontStyleMapSet;
3143 Property::Map fontStyleMapGet;
3145 fontStyleMapSet.Insert("weight", "bold");
3146 fontStyleMapSet.Insert("slant", "italic");
3147 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3149 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3150 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3151 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3153 fontStyleMapSet.Clear();
3154 fontStyleMapSet.Insert("width", "expanded");
3155 fontStyleMapSet.Insert("slant", "italic");
3156 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3158 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3159 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3160 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3162 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3163 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3165 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3166 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3168 fontStyleMapSet.Clear();
3169 fontStyleMapSet.Insert("weight", "bold");
3170 fontStyleMapSet.Insert("slant", "italic");
3172 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3174 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3175 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3176 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3178 fontStyleMapSet.Clear();
3179 fontStyleMapSet.Insert("width", "expanded");
3181 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3183 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3184 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3185 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3187 // Press Escape to increase coverage
3188 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3189 application.SendNotification();
3190 application.Render();
3192 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3197 int utcDaliTextFieldEscKeyLoseFocus(void)
3199 ToolkitTestApplication application;
3200 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3202 // Creates a tap event. After creating a tap event the text field should
3203 // have the focus and add text with key events should be possible.
3205 TextField field = TextField::New();
3206 DALI_TEST_CHECK(field);
3208 application.GetScene().Add(field);
3210 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3211 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3212 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3214 // Avoid a crash when core load gl resources.
3215 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3217 // Render and notify
3218 application.SendNotification();
3219 application.Render();
3221 // Add a key event but as the text field has not the focus it should do nothing.
3222 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3223 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3225 // Render and notify
3226 application.SendNotification();
3227 application.Render();
3229 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3231 // Create a tap event to touch the text field.
3232 TestGenerateTap(application, 150.0f, 25.0f);
3234 // Render and notify
3235 application.SendNotification();
3236 application.Render();
3238 // Now the text field has the focus, so it can handle the key events.
3239 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3240 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3241 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3242 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3244 // Render and notify
3245 application.SendNotification();
3246 application.Render();
3248 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3250 // Generate a Esc key event. The text field should lose the focus.
3251 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3252 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3254 // Render and notify
3255 application.SendNotification();
3256 application.Render();
3258 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3260 // No more text should be introduced
3261 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3262 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3264 // Render and notify
3265 application.SendNotification();
3266 application.Render();
3268 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3273 int utcDaliTextFieldSomeSpecialKeys(void)
3275 ToolkitTestApplication application;
3276 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3278 // Checks some special keys when the text is selected.
3280 TextField field = TextField::New();
3281 DALI_TEST_CHECK(field);
3282 application.GetScene().Add(field);
3283 LoadMarkerImages(application, field);
3284 // Render and notify
3285 application.SendNotification();
3286 application.Render();
3288 const std::string longText("This is a long text for the size of the text-field.");
3290 field.SetProperty(TextField::Property::TEXT, longText);
3291 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3292 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3293 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3294 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3296 // Avoid a crash when core load gl resources.
3297 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3298 // Render and notify
3299 application.SendNotification();
3300 application.Render();
3302 // Create a tap event to touch the text field.
3303 TestGenerateTap(application, 150.0f, 25.0f);
3305 // Render and notify
3306 application.SendNotification();
3307 application.Render();
3309 // Tap first to get the focus.
3310 TestGenerateTap(application, 1.0f, 25.0f);
3312 // Render and notify
3313 application.SendNotification();
3314 application.Render();
3316 // Double tap to select a word.
3317 TestGenerateTap(application, 1.0f, 25.0f);
3319 // Render and notify
3320 application.SendNotification();
3321 application.Render();
3323 // Generate a Esc key event. The text field should lose the focus.
3324 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3325 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3327 // Render and notify
3328 application.SendNotification();
3329 application.Render();
3331 // Generate a Esc key event. The text field should lose the focus.
3332 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3333 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3335 // Render and notify
3336 application.SendNotification();
3337 application.Render();
3339 // Generate a Esc key event. The text field should lose the focus.
3340 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3341 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3343 // Render and notify
3344 application.SendNotification();
3345 application.Render();
3347 // Generate a Back key event. Nothing happens to the text field.
3348 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3349 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3351 // Render and notify
3352 application.SendNotification();
3353 application.Render();
3355 // The text shouldn't be deleted.
3356 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3361 int utcDaliTextFieldSizeUpdate(void)
3363 ToolkitTestApplication application;
3364 tet_infoline("utcDaliTextFieldSizeUpdate");
3366 // Checks some special keys when the text is selected.
3367 TextField field = TextField::New();
3368 DALI_TEST_CHECK(field);
3369 application.GetScene().Add(field);
3371 float previousHeight = 0.0f;
3372 float currentHeight = 0.0f;
3373 const float fieldWidth = 1920.0f;
3375 // "ㅁ" is bigger then "ኢ"
3376 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3377 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3378 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3380 field.SetProperty(TextField::Property::TEXT, "ኢ");
3381 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3382 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3384 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3385 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3387 application.SendNotification();
3388 application.Render();
3390 previousHeight = field.GetHeightForWidth(fieldWidth);
3391 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3393 // Add another script characters ( glyph height is defferent )
3394 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3395 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3397 application.SendNotification();
3398 application.Render();
3400 currentHeight = field.GetHeightForWidth(fieldWidth);
3401 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3402 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3407 int utcDaliTextFieldExtremlyLargePointSize(void)
3409 ToolkitTestApplication application;
3410 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3412 TextField field = TextField::New();
3414 field.SetProperty(TextField::Property::TEXT, "Text");
3415 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3416 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3417 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3418 application.GetScene().Add(field);
3422 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3423 application.SendNotification();
3424 DALI_TEST_CHECK(field);
3428 tet_result(TET_FAIL);
3433 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3435 ToolkitTestApplication application;
3436 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3437 TextField field = TextField::New();
3438 DALI_TEST_CHECK(field);
3439 application.GetScene().Add(field);
3441 Property::Map fontStyleMapGet;
3443 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3445 Property::Value* weightValue = NULL;
3446 Property::Value* widthValue = NULL;
3447 Property::Value* slantValue = NULL;
3448 weightValue = fontStyleMapGet.Find("weight");
3449 widthValue = fontStyleMapGet.Find("width");
3450 slantValue = fontStyleMapGet.Find("slant");
3451 DALI_TEST_CHECK(!weightValue);
3452 DALI_TEST_CHECK(!widthValue);
3453 DALI_TEST_CHECK(!slantValue);
3458 int UtcDaliTextFieldSettingPlaceholder(void)
3460 ToolkitTestApplication application;
3461 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3463 TextField field = TextField::New();
3464 DALI_TEST_CHECK(field);
3465 application.GetScene().Add(field);
3467 // Check the placeholder property with pixel size
3468 Property::Map placeholderPixelSizeMapSet;
3469 Property::Map placeholderPixelSizeMapGet;
3470 Property::Map placeholderFontstyleMap;
3471 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3472 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3473 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3474 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3475 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3476 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3478 placeholderFontstyleMap.Insert("weight", "bold");
3479 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3480 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3482 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3483 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3484 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3486 // Check the placeholder property with point size
3487 Property::Map placeholderMapSet;
3488 Property::Map placeholderMapGet;
3489 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3490 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3491 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3492 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3493 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3494 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3496 // Check the placeholder font style property
3497 placeholderFontstyleMap.Clear();
3499 placeholderFontstyleMap.Insert("weight", "bold");
3500 placeholderFontstyleMap.Insert("width", "condensed");
3501 placeholderFontstyleMap.Insert("slant", "italic");
3502 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3503 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3505 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3506 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3507 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3509 // Reset font style.
3510 placeholderFontstyleMap.Clear();
3511 placeholderFontstyleMap.Insert("weight", "normal");
3512 placeholderFontstyleMap.Insert("slant", "oblique");
3513 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3514 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3516 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3517 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3518 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3520 placeholderFontstyleMap.Clear();
3521 placeholderFontstyleMap.Insert("slant", "roman");
3522 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3523 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3525 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3527 placeholderFontstyleMap.Clear();
3528 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3530 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3531 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3532 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3533 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3538 int UtcDaliTextFieldPlaceholderCoverage(void)
3540 ToolkitTestApplication application;
3541 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3543 // mPlaceholderFont is created only once, so create a new control for coverage.
3544 TextField fieldForCoverage = TextField::New();
3545 DALI_TEST_CHECK(fieldForCoverage);
3546 application.GetScene().Add(fieldForCoverage);
3548 // for SetPlaceholderFontFamily() coverage.
3549 Property::Map fontFamilyMap;
3550 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3551 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3553 // mPlaceholderFont is created only once, so create a new control for coverage.
3554 fieldForCoverage = TextField::New();
3555 DALI_TEST_CHECK(fieldForCoverage);
3556 application.GetScene().Add(fieldForCoverage);
3558 // for SetPlaceholderTextFontSize coverage.
3559 Property::Map fontSizeMap;
3560 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3561 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3563 // mPlaceholderFont is created only once, so create a new control for coverage.
3564 fieldForCoverage = TextField::New();
3565 DALI_TEST_CHECK(fieldForCoverage);
3566 application.GetScene().Add(fieldForCoverage);
3568 // for SetPlaceholderTextFontWeight coverage.
3569 Property::Map fontStyleWeightMap;
3570 Property::Map fontStyleWeightPropertyMap;
3571 fontStyleWeightPropertyMap.Insert("weight", "bold");
3572 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3573 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3575 // mPlaceholderFont is created only once, so create a new control for coverage.
3576 fieldForCoverage = TextField::New();
3577 DALI_TEST_CHECK(fieldForCoverage);
3578 application.GetScene().Add(fieldForCoverage);
3580 // for SetPlaceholderTextFontWidth coverage.
3581 Property::Map fontStyleWidthMap;
3582 Property::Map fontStyleWidthPropertyMap;
3583 fontStyleWidthPropertyMap.Insert("width", "expanded");
3584 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3585 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3587 // mPlaceholderFont is created only once, so create a new control for coverage.
3588 fieldForCoverage = TextField::New();
3589 DALI_TEST_CHECK(fieldForCoverage);
3590 application.GetScene().Add(fieldForCoverage);
3592 // for SetPlaceholderTextFontSlant coverage.
3593 Property::Map fontStyleSlantMap;
3594 Property::Map fontStyleSlantPropertyMap;
3595 fontStyleSlantPropertyMap.Insert("slant", "italic");
3596 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3597 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3602 int UtcDaliTextFieldSetPaddingProperty(void)
3604 ToolkitTestApplication application;
3605 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3607 TextField field = TextField::New();
3608 DALI_TEST_CHECK(field);
3609 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3610 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3611 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3612 application.GetScene().Add(field);
3614 application.SendNotification();
3615 application.Render();
3617 Vector3 originalSize = field.GetNaturalSize();
3619 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3621 application.SendNotification();
3622 application.Render();
3624 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3626 Vector3 paddingAddedSize = field.GetNaturalSize();
3628 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3630 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3635 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3637 ToolkitTestApplication application;
3638 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3640 TextField field = TextField::New();
3641 DALI_TEST_CHECK(field);
3642 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3643 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3644 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3645 application.GetScene().Add(field);
3647 application.SendNotification();
3648 application.Render();
3650 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3651 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3653 // Check the enable shift selection property
3654 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3655 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3657 application.SendNotification();
3658 application.Render();
3663 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3665 ToolkitTestApplication application;
3666 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3668 TextField field = TextField::New();
3669 DALI_TEST_CHECK(field);
3670 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3671 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3672 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3673 application.GetScene().Add(field);
3675 application.SendNotification();
3676 application.Render();
3678 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3679 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3681 // Check the enable grab handle property
3682 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3683 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3685 application.SendNotification();
3686 application.Render();
3691 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3693 ToolkitTestApplication application;
3694 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3696 TextField field = TextField::New();
3697 DALI_TEST_CHECK(field);
3698 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3699 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3700 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3701 application.GetScene().Add(field);
3703 application.SendNotification();
3704 application.Render();
3706 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3707 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3709 // Check the match system language direction property
3710 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3711 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3713 application.SendNotification();
3714 application.Render();
3719 int utcDaliTextFieldLayoutDirectionCoverage(void)
3721 ToolkitTestApplication application;
3722 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3724 // Creates a tap event. After creating a tap event the text field should
3725 // have the focus and add text with key events should be possible.
3726 TextField field = TextField::New();
3727 DALI_TEST_CHECK(field);
3729 application.GetScene().Add(field);
3731 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3732 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3733 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3735 // Avoid a crash when core load gl resources.
3736 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3738 // Render and notify
3739 application.SendNotification();
3740 application.Render();
3742 // init direction for coverage
3743 // Set horizontal alignment END
3744 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3746 // Create a tap event to touch the text field.
3747 TestGenerateTap(application, 150.0f, 25.0f);
3749 // Render and notify
3750 application.SendNotification();
3751 application.Render();
3753 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3754 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3755 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3757 // Set horizontal alignment BEGIN
3758 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3760 // Create a tap event to touch the text field.
3761 TestGenerateTap(application, 150.0f, 25.0f);
3763 // Render and notify
3764 application.SendNotification();
3765 application.Render();
3767 // Set horizontal alignment CENTER
3768 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3770 // Create a tap event to touch the text field.
3771 TestGenerateTap(application, 150.0f, 25.0f);
3773 // Render and notify
3774 application.SendNotification();
3775 application.Render();
3777 // Set horizontal alignment END
3778 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3780 // Create a tap event to touch the text field.
3781 TestGenerateTap(application, 150.0f, 25.0f);
3783 // Render and notify
3784 application.SendNotification();
3785 application.Render();
3787 // Generate a Esc key event. The text field should lose the focus.
3788 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3789 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3791 // Render and notify
3792 application.SendNotification();
3793 application.Render();
3795 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3800 int UtcDaliTextFieldGetInputMethodContext(void)
3802 ToolkitTestApplication application;
3803 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3805 TextField field = TextField::New();
3806 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3811 int UtcDaliTextFieldSelectWholeText(void)
3813 ToolkitTestApplication application;
3814 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3816 TextField textField = TextField::New();
3818 application.GetScene().Add(textField);
3820 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3821 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3822 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3824 // Avoid a crash when core load gl resources.
3825 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3827 application.SendNotification();
3828 application.Render();
3830 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3832 DevelTextField::SelectWholeText(textField);
3834 application.SendNotification();
3835 application.Render();
3837 // Nothing should have been selected. The number of children is still 1
3838 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3840 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3842 application.SendNotification();
3843 application.Render();
3845 DevelTextField::SelectWholeText(textField);
3847 application.SendNotification();
3848 application.Render();
3850 // Even if resize, selection should remain.
3851 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3853 application.SendNotification();
3854 application.Render();
3856 // Should be 2 children, the stencil and the layer
3857 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3859 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3860 Actor stencil = textField.GetChildAt(0u);
3862 // The highlight actor is drawn first, so is the first actor in the list
3863 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3864 DALI_TEST_CHECK(highlight);
3869 int UtcDaliTextFieldSelectText(void)
3871 ToolkitTestApplication application;
3872 tet_infoline(" UtcDaliTextFieldSelectText ");
3874 TextField textField = TextField::New();
3876 application.GetScene().Add(textField);
3878 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3879 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3880 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3882 // Avoid a crash when core load gl resources.
3883 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3885 application.SendNotification();
3886 application.Render();
3888 DevelTextField::SelectText(textField, 0, 5);
3890 application.SendNotification();
3891 application.Render();
3893 // Nothing is selected
3894 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3895 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3897 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3899 application.SendNotification();
3900 application.Render();
3902 // Hello is selected
3903 DevelTextField::SelectText(textField, 0, 5);
3905 application.SendNotification();
3906 application.Render();
3908 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3909 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3911 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3912 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3914 // world is selected
3915 DevelTextField::SelectText(textField, 6, 11);
3917 application.SendNotification();
3918 application.Render();
3920 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3921 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3923 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3924 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3929 int UtcDaliTextFieldSelectNone(void)
3931 ToolkitTestApplication application;
3932 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3934 TextField textField = TextField::New();
3936 application.GetScene().Add(textField);
3938 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3939 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3940 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3942 // Avoid a crash when core load gl resources.
3943 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3945 application.SendNotification();
3946 application.Render();
3948 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3950 application.SendNotification();
3951 application.Render();
3953 // Nothing is selected
3954 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3955 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3957 DevelTextField::SelectWholeText(textField);
3959 application.SendNotification();
3960 application.Render();
3962 // whole text is selected
3963 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3964 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3966 DevelTextField::SelectNone(textField);
3968 application.SendNotification();
3969 application.Render();
3971 // Nothing is selected
3972 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3973 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3978 int UtcDaliTextFieldSelectRange(void)
3980 ToolkitTestApplication application;
3981 tet_infoline(" UtcDaliTextFieldSelectRange ");
3983 TextField textField = TextField::New();
3985 application.GetScene().Add(textField);
3987 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3988 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3989 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3991 // Avoid a crash when core load gl resources.
3992 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3994 application.SendNotification();
3995 application.Render();
3997 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3999 application.SendNotification();
4000 application.Render();
4002 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4003 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4005 // Hello is selected
4006 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4007 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4009 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4010 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4012 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4013 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4015 // world is selected
4016 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4017 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4019 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4020 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4025 int UtcDaliTextFieldEnableEditing(void)
4027 ToolkitTestApplication application;
4028 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4030 TextField textField = TextField::New();
4032 application.GetScene().Add(textField);
4034 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4035 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4036 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4038 // Avoid a crash when core load gl resources.
4039 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4041 application.SendNotification();
4042 application.Render();
4044 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4045 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4047 textField.SetKeyInputFocus();
4048 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4049 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4051 // Render and notify
4052 application.SendNotification();
4053 application.Render();
4055 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4056 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4058 textField.SetKeyInputFocus();
4059 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4060 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4062 // Render and notify
4063 application.SendNotification();
4064 application.Render();
4066 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4067 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4069 // Check the user interaction enabled and for coverage
4070 DevelTextField::SelectWholeText(textField);
4072 // Render and notify
4073 application.SendNotification();
4074 application.Render();
4076 textField.SetKeyInputFocus();
4077 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4078 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4080 // Render and notify
4081 application.SendNotification();
4082 application.Render();
4084 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4085 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4090 int UtcDaliToolkitTextFieldFontSizeScale(void)
4092 ToolkitTestApplication application;
4093 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4095 TextField textField = TextField::New();
4096 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4097 textField.SetProperty(TextField::Property::TEXT, "Test");
4098 Vector3 nonScaledSize = textField.GetNaturalSize();
4100 TextField textFieldScaled = TextField::New();
4101 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4102 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4103 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4104 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4106 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4108 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4109 textField.SetProperty(TextField::Property::TEXT, "Test");
4110 nonScaledSize = textField.GetNaturalSize();
4112 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4113 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4114 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4115 scaledSize = textFieldScaled.GetNaturalSize();
4117 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4122 int UtcDaliTextFieldPrimaryCursorPosition(void)
4124 ToolkitTestApplication application;
4125 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4127 TextField textField = TextField::New();
4129 application.GetScene().Add(textField);
4131 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4132 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4133 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4134 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4136 // Avoid a crash when core load gl resources.
4137 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4139 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4140 application.SendNotification();
4141 application.Render();
4142 textField.SetKeyInputFocus();
4144 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4146 // Render and notify
4147 application.SendNotification();
4148 application.Render();
4150 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4151 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4156 // test max length when set after setting long text
4157 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4159 ToolkitTestApplication application;
4160 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4161 TextField field = TextField::New();
4162 DALI_TEST_CHECK(field);
4164 application.GetScene().Add(field);
4166 field.SetProperty(TextField::Property::TEXT, "123456789");
4168 const int maxNumberOfCharacters = 3;
4169 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4171 field.SetKeyInputFocus();
4173 // connect to the text max lengh reached signal.
4174 ConnectionTracker* testTracker = new ConnectionTracker();
4175 bool maxLengthReachedSignal = false;
4176 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4178 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4179 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4181 DALI_TEST_CHECK(maxLengthReachedSignal);
4183 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4188 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4190 ToolkitTestApplication application;
4191 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4193 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4194 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4195 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4197 // Create a text field
4198 TextField textField = TextField::New();
4200 //Set size to avoid automatic eliding
4201 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4202 //Set very large font-size using point-size
4203 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4204 //Specify font-family
4205 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4206 //Set text to check if appear or not
4207 textField.SetProperty(TextField::Property::TEXT, "A");
4209 application.GetScene().Add(textField);
4211 application.SendNotification();
4212 application.Render();
4213 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4214 Vector3 naturalSize = textField.GetNaturalSize();
4216 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4217 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4222 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4224 ToolkitTestApplication application;
4225 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4227 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4228 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4229 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4231 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4232 // Create a text editor
4233 TextField textField = TextField::New();
4235 //Set size to avoid automatic eliding
4236 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4237 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4238 textField.SetProperty(TextField::Property::TEXT, "A");
4240 const int numberOfCases = 6;
4241 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4243 for(int index = 0; index < numberOfCases; index++)
4245 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4246 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4247 application.GetScene().Add(textField);
4248 application.SendNotification();
4249 application.Render();
4250 naturalSize = textField.GetNaturalSize();
4251 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4252 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4258 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4260 ToolkitTestApplication application;
4261 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4262 TextField textField = TextField::New();
4264 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4265 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4267 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4268 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4269 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4271 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4272 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4273 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4275 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4276 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4277 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4279 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4280 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4281 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4283 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4284 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4285 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4287 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4288 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4289 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4291 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4292 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4293 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4295 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4296 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4297 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4299 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4300 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4301 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4303 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4304 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4305 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4307 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4308 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4309 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4311 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4312 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4313 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4318 int UtcDaliTextFieldCopyText(void)
4320 ToolkitTestApplication application;
4321 tet_infoline(" UtcDaliTextFieldCopyText ");
4323 TextField textField = TextField::New();
4325 std::string selectedText = "";
4326 std::string copiedText = "";
4328 application.GetScene().Add(textField);
4330 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4331 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4332 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4334 // Avoid a crash when core load gl resources.
4335 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4337 application.SendNotification();
4338 application.Render();
4340 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4342 application.SendNotification();
4343 application.Render();
4345 // Hello is selected
4346 DevelTextField::SelectText(textField, 0, 5);
4348 application.SendNotification();
4349 application.Render();
4351 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4352 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4354 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4355 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4358 copiedText = DevelTextField::CopyText(textField);
4359 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4361 // world is selected
4362 DevelTextField::SelectText(textField, 6, 11);
4364 application.SendNotification();
4365 application.Render();
4367 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4368 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4370 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4371 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4374 copiedText = DevelTextField::CopyText(textField);
4375 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4377 // "lo wo" is selected
4378 DevelTextField::SelectText(textField, 3, 8);
4380 application.SendNotification();
4381 application.Render();
4383 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4384 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4386 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4387 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4389 // "lo wo" is copied
4390 copiedText = DevelTextField::CopyText(textField);
4391 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4396 int UtcDaliTextFieldCutText(void)
4398 ToolkitTestApplication application;
4399 tet_infoline(" UtcDaliTextFieldCutText ");
4401 TextField textField = TextField::New();
4403 std::string selectedText = "";
4405 application.GetScene().Add(textField);
4407 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4408 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4409 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4411 // Avoid a crash when core load gl resources.
4412 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4414 application.SendNotification();
4415 application.Render();
4417 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4419 application.SendNotification();
4420 application.Render();
4422 // Hello is selected
4423 DevelTextField::SelectText(textField, 0, 5);
4425 application.SendNotification();
4426 application.Render();
4428 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4429 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4431 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4432 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4435 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4437 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4440 DevelTextField::SelectText(textField, 0, 2);
4442 application.SendNotification();
4443 application.Render();
4445 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4446 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4448 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4449 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4452 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4454 application.SendNotification();
4455 application.Render();
4457 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4459 // Test Cut from the middle
4462 DevelTextField::SelectText(textField, 1, 3);
4464 application.SendNotification();
4465 application.Render();
4467 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4468 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4470 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4471 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4474 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4476 application.SendNotification();
4477 application.Render();
4479 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4481 // Test Cut from the end
4484 DevelTextField::SelectText(textField, 1, 2);
4486 application.SendNotification();
4487 application.Render();
4489 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4490 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4492 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4493 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4496 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4498 application.SendNotification();
4499 application.Render();
4501 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4506 int UtcDaliTextFieldPasteText(void)
4508 ToolkitTestApplication application;
4509 tet_infoline(" UtcDaliTextFieldPasteText ");
4511 TextField textField = TextField::New();
4513 application.GetScene().Add(textField);
4515 std::string cutText = "";
4516 std::string copiedText = "";
4518 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4519 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4520 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4522 // Avoid a crash when core load gl resources.
4523 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4525 application.SendNotification();
4526 application.Render();
4528 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4530 application.SendNotification();
4531 application.Render();
4533 // Tap on the text editor
4534 TestGenerateTap(application, 3.0f, 25.0f);
4536 // Render and notify
4537 application.SendNotification();
4538 application.Render();
4540 // Select some text in the right of the current cursor position
4541 DevelTextField::SelectText(textField, 0, 3);
4543 // Render and notify
4544 application.SendNotification();
4545 application.Render();
4547 // Cut the selected text
4548 cutText = DevelTextField::CutText(textField);
4550 // Render and notify
4551 application.SendNotification();
4552 application.Render();
4554 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4555 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4557 DevelTextField::SelectText(textField, 0, 3);
4559 // Render and notify
4560 application.SendNotification();
4561 application.Render();
4563 // Copy the selected text
4564 copiedText = DevelTextField::CopyText(textField);
4566 // Render and notify
4567 application.SendNotification();
4568 application.Render();
4570 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4571 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4573 // Move the cursor to the end of the line
4574 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4575 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4576 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4577 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4578 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4579 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4580 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4581 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4583 // Render and notify
4584 application.SendNotification();
4585 application.Render();
4587 // Paste the selected text at the current cursor position
4588 DevelTextField::PasteText(textField);
4590 // Render and notify
4591 application.SendNotification();
4592 application.Render();
4594 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4599 int utcDaliTextFieldCursorPositionChangedSignal(void)
4601 ToolkitTestApplication application;
4602 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4604 TextField field = TextField::New();
4605 DALI_TEST_CHECK(field);
4607 application.GetScene().Add(field);
4609 // connect to the selection changed signal.
4610 ConnectionTracker* testTracker = new ConnectionTracker();
4611 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4612 bool cursorPositionChangedSignal = false;
4613 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4615 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4616 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4617 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4618 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4619 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4621 // Avoid a crash when core load gl resources.
4622 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4624 // Render and notify
4625 application.SendNotification();
4626 application.Render();
4628 field.SetKeyInputFocus();
4630 // Tap on the text field
4631 TestGenerateTap(application, 3.0f, 25.0f);
4633 // Render and notify
4634 application.SendNotification();
4635 application.Render();
4637 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4638 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4640 gCursorPositionChangedCallbackCalled = false;
4643 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4645 // Render and notify
4646 application.SendNotification();
4647 application.Render();
4649 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4650 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4652 gCursorPositionChangedCallbackCalled = false;
4655 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4657 // Render and notify
4658 application.SendNotification();
4659 application.Render();
4661 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4662 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4664 gCursorPositionChangedCallbackCalled = false;
4666 //delete one character
4667 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4669 // Render and notify
4670 application.SendNotification();
4671 application.Render();
4673 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4674 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4676 gCursorPositionChangedCallbackCalled = false;
4678 field.SetProperty(TextField::Property::TEXT, "Hello");
4680 // Render and notify
4681 application.SendNotification();
4682 application.Render();
4684 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4685 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4687 gCursorPositionChangedCallbackCalled = false;
4689 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4691 // Render and notify
4692 application.SendNotification();
4693 application.Render();
4695 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4696 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4701 int utcDaliTextFieldGeometryEllipsisStart(void)
4703 ToolkitTestApplication application;
4704 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4706 TextField field = TextField::New();
4707 DALI_TEST_CHECK(field);
4709 application.GetScene().Add(field);
4711 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4712 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4713 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4714 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4715 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4716 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4717 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4718 field.SetProperty(TextField::Property::TEXT, "Hello World");
4720 // Avoid a crash when core load gl resources.
4721 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4723 // Render and notify
4724 application.SendNotification();
4725 application.Render();
4727 unsigned int expectedCount = 1;
4728 unsigned int startIndex = 0;
4729 unsigned int endIndex = 10;
4731 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4732 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4734 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4735 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4737 Vector<Vector2> expectedSizes;
4738 Vector<Vector2> expectedPositions;
4740 expectedPositions.PushBack(Vector2(14, 0));
4741 expectedSizes.PushBack(Vector2(106, 25));
4743 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4748 int utcDaliTextFieldGeometryEllipsisEnd(void)
4750 ToolkitTestApplication application;
4751 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4753 TextField field = TextField::New();
4754 DALI_TEST_CHECK(field);
4756 application.GetScene().Add(field);
4758 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4759 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4760 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4761 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4762 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4763 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4764 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4765 field.SetProperty(TextField::Property::TEXT, "Hello World");
4767 // Avoid a crash when core load gl resources.
4768 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4770 // Render and notify
4771 application.SendNotification();
4772 application.Render();
4774 unsigned int expectedCount = 1;
4775 unsigned int startIndex = 0;
4776 unsigned int endIndex = 10;
4778 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4779 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4781 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4782 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4784 Vector<Vector2> expectedSizes;
4785 Vector<Vector2> expectedPositions;
4787 expectedPositions.PushBack(Vector2(-2, 0));
4788 expectedSizes.PushBack(Vector2(122, 25));
4790 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4795 int utcDaliTextFieldGeometryRTL(void)
4797 ToolkitTestApplication application;
4798 tet_infoline(" utcDaliTextFieldGeometryRTL");
4800 TextField field = TextField::New();
4801 DALI_TEST_CHECK(field);
4803 application.GetScene().Add(field);
4805 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4806 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4807 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4808 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4809 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4810 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4812 // Avoid a crash when core load gl resources.
4813 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4815 // Render and notify
4816 application.SendNotification();
4817 application.Render();
4819 unsigned int expectedCount = 1;
4820 unsigned int startIndex = 1;
4821 unsigned int endIndex = 7;
4823 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4824 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4826 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4827 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4829 Vector<Vector2> expectedSizes;
4830 Vector<Vector2> expectedPositions;
4832 expectedPositions.PushBack(Vector2(38, 0));
4833 expectedSizes.PushBack(Vector2(73, 25));
4835 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4840 int utcDaliTextFieldGeometryGlyphMiddle(void)
4842 ToolkitTestApplication application;
4843 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4845 TextField field = TextField::New();
4846 DALI_TEST_CHECK(field);
4848 application.GetScene().Add(field);
4850 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4851 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4852 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4853 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4854 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4855 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4857 // Avoid a crash when core load gl resources.
4858 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4860 // Render and notify
4861 application.SendNotification();
4862 application.Render();
4864 unsigned int expectedCount = 1;
4865 unsigned int startIndex = 1;
4866 unsigned int endIndex = 13;
4868 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4869 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4871 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4872 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4874 Vector<Vector2> expectedSizes;
4875 Vector<Vector2> expectedPositions;
4877 expectedPositions.PushBack(Vector2(6, 0));
4878 expectedSizes.PushBack(Vector2(124, 25));
4880 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4886 int utcDaliTextFieldGeometryNullPtr(void)
4888 ToolkitTestApplication application;
4889 tet_infoline("utcDaliTextFieldGeometryNullPtr");
4891 TextField field = TextField::New();
4892 DALI_TEST_CHECK(field);
4894 application.GetScene().Add(field);
4896 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4897 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
4898 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4899 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4900 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4901 field.SetProperty(TextField::Property::TEXT, "");
4903 // Avoid a crash when core load gl resources.
4904 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4906 unsigned int expectedCount = 0;
4907 unsigned int startIndex = 0;
4908 unsigned int endIndex = 0;
4910 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4911 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4913 // Render and notify
4914 application.SendNotification();
4915 application.Render();
4917 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4918 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4923 int utcDaliTextFieldSelectionClearedSignal(void)
4925 ToolkitTestApplication application;
4926 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4928 TextField field = TextField::New();
4929 DALI_TEST_CHECK(field);
4931 application.GetScene().Add(field);
4933 // connect to the selection changed signal.
4934 ConnectionTracker* testTracker = new ConnectionTracker();
4935 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4936 bool selectionClearedSignal = false;
4937 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4939 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4940 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4941 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4942 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4943 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4945 // Avoid a crash when core load gl resources.
4946 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4948 // Render and notify
4949 application.SendNotification();
4950 application.Render();
4952 // Tap on the text editor
4953 TestGenerateTap(application, 3.0f, 25.0f);
4955 // Render and notify
4956 application.SendNotification();
4957 application.Render();
4959 // Move to second line of the text & Select some text in the right of the current cursor position
4960 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4961 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4964 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4966 // Render and notify
4967 application.SendNotification();
4968 application.Render();
4970 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4972 // Render and notify
4973 application.SendNotification();
4974 application.Render();
4976 // Tap on the text editor
4977 TestGenerateTap(application, 3.0f, 25.0f);
4979 // Render and notify
4980 application.SendNotification();
4981 application.Render();
4983 gSelectionClearedCallbackCalled = false;
4985 // Move to second line of the text & select.
4986 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4987 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4990 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4992 // Render and notify
4993 application.SendNotification();
4994 application.Render();
4996 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4998 gSelectionClearedCallbackCalled = false;
5000 // Render and notify
5001 application.SendNotification();
5002 application.Render();
5004 // Move to second line of the text & select.
5005 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5006 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5008 // replace D with selected text
5009 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5011 // Render and notify
5012 application.SendNotification();
5013 application.Render();
5015 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5017 gSelectionClearedCallbackCalled = false;
5019 // Render and notify
5020 application.SendNotification();
5021 application.Render();
5023 DevelTextField::SelectText(field, 1, 3);
5025 // Render and notify
5026 application.SendNotification();
5027 application.Render();
5029 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5031 // Render and notify
5032 application.SendNotification();
5033 application.Render();
5035 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5037 gSelectionClearedCallbackCalled = false;
5039 DevelTextField::SelectText(field, 1, 3);
5041 // Render and notify
5042 application.SendNotification();
5043 application.Render();
5046 DevelTextField::SelectNone(field);
5048 // Render and notify
5049 application.SendNotification();
5050 application.Render();
5052 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5057 int utcDaliTextFieldSelectionStartedSignal(void)
5059 ToolkitTestApplication application;
5060 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5062 TextField field = TextField::New();
5063 DALI_TEST_CHECK(field);
5065 application.GetScene().Add(field);
5067 // connect to the selection changed signal.
5068 ConnectionTracker* testTracker = new ConnectionTracker();
5069 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5070 bool selectionStartedSignal = false;
5071 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5073 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5074 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5075 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5076 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5077 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5079 // Avoid a crash when core load gl resources.
5080 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5082 // Render and notify
5083 application.SendNotification();
5084 application.Render();
5086 // Tap on the text field
5087 TestGenerateTap(application, 3.0f, 25.0f);
5089 // Render and notify
5090 application.SendNotification();
5091 application.Render();
5093 // Move to second line of the text & Select some text in the right of the current cursor position
5094 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5095 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5097 // Render and notify
5098 application.SendNotification();
5099 application.Render();
5101 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5104 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5106 // Render and notify
5107 application.SendNotification();
5108 application.Render();
5110 gSelectionStartedCallbackCalled = false;
5112 DevelTextField::SelectText(field, 1, 3);
5114 // Render and notify
5115 application.SendNotification();
5116 application.Render();
5118 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5123 int utcDaliTextFieldSelectionChangedSignal(void)
5125 ToolkitTestApplication application;
5126 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5128 TextField field = TextField::New();
5129 DALI_TEST_CHECK(field);
5131 application.GetScene().Add(field);
5133 // connect to the selection changed signal.
5134 ConnectionTracker* testTracker = new ConnectionTracker();
5135 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5136 bool selectionChangedSignal = false;
5137 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5139 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5140 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5141 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5142 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5143 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5145 // Avoid a crash when core load gl resources.
5146 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5148 // Render and notify
5149 application.SendNotification();
5150 application.Render();
5152 // Tap on the text field
5153 TestGenerateTap(application, 3.0f, 25.0f);
5155 // Render and notify
5156 application.SendNotification();
5157 application.Render();
5159 // Select some text in the right of the current cursor position
5160 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5161 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5163 // Render and notify
5164 application.SendNotification();
5165 application.Render();
5167 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5168 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5170 gSelectionChangedCallbackCalled = false;
5172 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5174 // Render and notify
5175 application.SendNotification();
5176 application.Render();
5178 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5179 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5180 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5182 gSelectionChangedCallbackCalled = false;
5184 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5186 // Render and notify
5187 application.SendNotification();
5188 application.Render();
5190 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5191 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5192 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5194 gSelectionChangedCallbackCalled = false;
5195 field.SetKeyInputFocus();
5197 // Render and notify
5198 application.SendNotification();
5199 application.Render();
5201 DevelTextField::SelectText(field, 0, 5);
5203 application.SendNotification();
5204 application.Render();
5206 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5207 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5209 gSelectionChangedCallbackCalled = false;
5211 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5213 // Render and notify
5214 application.SendNotification();
5215 application.Render();
5217 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5218 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5219 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5221 gSelectionChangedCallbackCalled = false;
5224 DevelTextField::SelectWholeText(field);
5226 // Render and notify
5227 application.SendNotification();
5228 application.Render();
5230 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5231 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5233 gSelectionChangedCallbackCalled = false;
5236 DevelTextField::SelectNone(field);
5238 // Render and notify
5239 application.SendNotification();
5240 application.Render();
5242 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5243 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5244 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5249 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5251 ToolkitTestApplication application;
5252 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5254 TextField textField = TextField::New();
5255 textField.SetProperty(TextField::Property::TEXT, "Test");
5256 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5257 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5258 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5260 application.GetScene().Add(textField);
5261 application.SendNotification();
5262 application.Render();
5264 Property::Map strikethroughMapSet;
5265 Property::Map strikethroughMapGet;
5267 strikethroughMapSet.Insert("enable", true);
5268 strikethroughMapSet.Insert("color", Color::RED);
5269 strikethroughMapSet.Insert("height", 2.0f);
5271 // Check the strikethrough property
5272 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5273 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5274 textField.SetProperty(TextField::Property::TEXT, "Test1");
5275 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5276 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5278 // Render and notify
5279 application.SendNotification();
5280 application.Render();
5282 strikethroughMapSet.Clear();
5283 strikethroughMapGet.Clear();
5288 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5290 ToolkitTestApplication application;
5291 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5293 TextField textField = TextField::New();
5294 textField.SetProperty(TextField::Property::TEXT, "Test");
5295 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5296 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5297 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5299 application.GetScene().Add(textField);
5300 application.SendNotification();
5301 application.Render();
5303 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5305 // Check the strikethrough property
5306 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5307 textField.SetProperty(TextField::Property::TEXT, "Test1");
5308 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5310 // Render and notify
5311 application.SendNotification();
5312 application.Render();
5317 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5319 ToolkitTestApplication application;
5320 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5321 TextField field = TextField::New();
5322 field.SetProperty(TextField::Property::TEXT, "Test");
5323 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5324 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5325 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5327 application.GetScene().Add(field);
5328 application.SendNotification();
5329 application.Render();
5331 Property::Map underlineMapSet;
5332 Property::Map underlineMapGet;
5334 underlineMapSet.Insert("enable", true);
5335 underlineMapSet.Insert("color", Color::RED);
5336 underlineMapSet.Insert("height", 1);
5337 underlineMapSet.Insert("type", Text::Underline::SOLID);
5338 underlineMapSet.Insert("dashWidth", 2);
5339 underlineMapSet.Insert("dashGap", 1);
5341 // Check the underline property
5342 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5344 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5345 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5346 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5348 // Render and notify
5349 application.SendNotification();
5350 application.Render();
5352 underlineMapSet.Clear();
5353 underlineMapGet.Clear();
5355 underlineMapSet.Insert("enable", true);
5356 underlineMapSet.Insert("color", Color::BLUE);
5357 underlineMapSet.Insert("height", 1);
5358 underlineMapSet.Insert("type", Text::Underline::DASHED);
5359 underlineMapSet.Insert("dashWidth", 4);
5360 underlineMapSet.Insert("dashGap", 2);
5362 // Check the dashed underline property
5363 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5365 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5366 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5367 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5369 // Render and notify
5370 application.SendNotification();
5371 application.Render();
5373 underlineMapSet.Clear();
5374 underlineMapGet.Clear();
5376 underlineMapSet.Insert("enable", true);
5377 underlineMapSet.Insert("color", Color::BLUE);
5378 underlineMapSet.Insert("height", 1);
5379 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5380 underlineMapSet.Insert("dashWidth", 4);
5381 underlineMapSet.Insert("dashGap", 2);
5383 // Check the dashed underline property
5384 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5386 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5387 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5388 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5390 // Render and notify
5391 application.SendNotification();
5392 application.Render();
5394 underlineMapSet.Clear();
5395 underlineMapGet.Clear();
5400 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5402 ToolkitTestApplication application;
5403 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5405 TextField field1 = TextField::New();
5406 field1.SetProperty(TextField::Property::TEXT, "Test");
5407 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5408 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5409 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5411 Property::Map underlineMapSet1;
5412 Property::Map underlineMapGet1;
5414 underlineMapSet1.Insert("enable", true);
5415 underlineMapSet1.Insert("color", Color::RED);
5416 underlineMapSet1.Insert("height", 1);
5417 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5418 underlineMapSet1.Insert("dashWidth", 2);
5419 underlineMapSet1.Insert("dashGap", 1);
5421 // Check the underline property
5422 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5424 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5425 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5426 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5428 application.GetScene().Add(field1);
5429 application.SendNotification();
5430 application.Render();
5432 TextField field2 = TextField::New();
5433 field2.SetProperty(TextField::Property::TEXT, "Test");
5434 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5435 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5436 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5438 Property::Map underlineMapSet2;
5439 Property::Map underlineMapGet2;
5441 underlineMapSet2.Insert("enable", true);
5442 underlineMapSet2.Insert("color", Color::BLUE);
5443 underlineMapSet2.Insert("height", 1);
5444 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5445 underlineMapSet2.Insert("dashWidth", 4);
5446 underlineMapSet2.Insert("dashGap", 2);
5448 // Check the dashed underline property
5449 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5451 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5452 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5453 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5455 application.GetScene().Add(field2);
5456 application.SendNotification();
5457 application.Render();
5459 TextField field3 = TextField::New();
5460 field3.SetProperty(TextField::Property::TEXT, "Test");
5461 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5462 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5463 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5465 Property::Map underlineMapSet3;
5466 Property::Map underlineMapGet3;
5468 underlineMapSet3.Insert("enable", true);
5469 underlineMapSet3.Insert("color", Color::BLUE);
5470 underlineMapSet3.Insert("height", 1);
5471 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5472 underlineMapSet3.Insert("dashWidth", 4);
5473 underlineMapSet3.Insert("dashGap", 2);
5475 // Check the dashed underline property
5476 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5478 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5479 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5480 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5482 application.GetScene().Add(field3);
5484 application.SendNotification();
5485 application.Render();
5490 int UtcDaliTextFieldCharacterSpacing(void)
5492 ToolkitTestApplication application;
5493 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5495 TextField textField = TextField::New();
5497 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5499 application.GetScene().Add(textField);
5500 application.SendNotification();
5501 application.Render();
5503 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5504 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5505 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5507 application.SendNotification();
5508 application.Render();
5513 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5515 ToolkitTestApplication application;
5516 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5518 TextField field1 = TextField::New();
5519 field1.SetProperty(TextField::Property::TEXT, "Test1");
5520 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5521 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5522 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5524 Property::Map underlineMapSet1;
5525 Property::Map underlineMapGet1;
5527 underlineMapSet1.Insert("enable", true);
5528 underlineMapSet1.Insert("color", Color::RED);
5529 underlineMapSet1.Insert("height", 1);
5530 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5531 underlineMapSet1.Insert("dashWidth", 2);
5532 underlineMapSet1.Insert("dashGap", 1);
5534 // Check the underline property
5535 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5536 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5538 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5539 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5540 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5542 application.GetScene().Add(field1);
5543 application.SendNotification();
5544 application.Render();
5549 int UtcDaliToolkitTextfieldParagraphTag(void)
5551 ToolkitTestApplication application;
5552 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5553 TextField fieldNewlineSeparator = TextField::New();
5554 TextField fieldParagraphTag = TextField::New();
5555 DALI_TEST_CHECK(fieldNewlineSeparator);
5556 DALI_TEST_CHECK(fieldParagraphTag);
5558 application.GetScene().Add(fieldNewlineSeparator);
5559 application.GetScene().Add(fieldParagraphTag);
5561 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5562 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5563 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5564 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5565 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5566 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5568 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5569 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5570 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5571 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5572 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5574 application.SendNotification();
5575 application.Render();
5577 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5578 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5580 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5582 application.SendNotification();
5583 application.Render();
5588 //Handle Emoji clustering for cursor handling
5589 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5591 ToolkitTestApplication application;
5592 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5593 TextField textField = TextField::New();
5594 DALI_TEST_CHECK(textField);
5596 application.GetScene().Add(textField);
5598 // Avoid a crash when core load gl resources.
5599 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5601 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5602 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5604 // Render and notify
5605 application.SendNotification();
5606 application.Render();
5609 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5610 application.SendNotification();
5611 application.Render();
5613 // Set focus and remove Emoji
5614 textField.SetKeyInputFocus();
5615 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5617 //Check the changed text and cursor position
5618 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5619 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5621 // Render and notify
5622 application.SendNotification();
5623 application.Render();
5628 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5630 ToolkitTestApplication application;
5631 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5632 TextField textField = TextField::New();
5633 DALI_TEST_CHECK(textField);
5635 application.GetScene().Add(textField);
5637 // Avoid a crash when core load gl resources.
5638 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5640 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5641 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5643 // Render and notify
5644 application.SendNotification();
5645 application.Render();
5648 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5649 application.SendNotification();
5650 application.Render();
5652 // Set focus and remove Emoji
5653 textField.SetKeyInputFocus();
5654 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5656 //Check the changed text and cursor position
5657 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5658 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5660 // Render and notify
5661 application.SendNotification();
5662 application.Render();
5667 int utcDaliTextFieldPanGesturePropagation(void)
5669 ToolkitTestApplication application;
5670 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5672 Actor actor = Actor::New();
5673 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5674 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5675 application.GetScene().Add(actor);
5677 TextField field = TextField::New();
5678 DALI_TEST_CHECK(field);
5680 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5681 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5683 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5684 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5685 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5689 // Render and notify
5690 application.SendNotification();
5691 application.Render();
5694 GestureReceivedFunctor functor(data);
5696 PanGestureDetector detector = PanGestureDetector::New();
5697 detector.Attach(actor);
5698 detector.DetectedSignal().Connect(&application, functor);
5700 // Tap first to get the focus.
5701 TestGenerateTap(application, 3.0f, 25.0f, 100);
5703 // Render and notify
5704 application.SendNotification();
5705 application.Render();
5707 // Pan the text field
5708 uint32_t time = 100;
5709 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5710 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5711 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5712 application.SendNotification();
5713 application.Render();
5715 // The text scrolls because there is text that is scrolling.
5716 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5719 // Set the size large enough to prevent scrolling.
5720 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5722 // Render and notify
5723 application.SendNotification();
5724 application.Render();
5727 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5728 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5729 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5731 // Because scrolling is not possible, the pan gesture is propagated.
5732 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);