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 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1793 ToolkitTestApplication application;
1794 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1795 TextField field = TextField::New();
1796 DALI_TEST_CHECK(field);
1798 Property::Map inputFilter;
1799 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1800 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1802 // Set input filter to TextField.
1803 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1805 application.GetScene().Add(field);
1807 // connect to the input filtered signal.
1808 ConnectionTracker* testTracker = new ConnectionTracker();
1809 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1810 bool inputFilteredSignal = false;
1811 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1813 // get InputMethodContext
1815 InputMethodContext::EventData imfEvent;
1816 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1818 field.SetKeyInputFocus();
1819 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1822 gInputFilteredAcceptedCallbackCalled = false;
1823 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1824 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1825 application.SendNotification();
1826 application.Render();
1827 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1828 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1830 inputFilteredSignal = false;
1831 gInputFilteredRejectedCallbackCalled = false;
1832 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1833 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1834 application.SendNotification();
1835 application.Render();
1836 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1837 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1842 // Negative test for the textChanged signal.
1843 int utcDaliTextFieldTextChangedN(void)
1845 ToolkitTestApplication application;
1846 tet_infoline(" utcDaliTextFieldTextChangedN");
1847 TextField field = TextField::New();
1848 DALI_TEST_CHECK(field);
1850 application.GetScene().Add(field);
1852 // connect to the text changed signal.
1853 ConnectionTracker* testTracker = new ConnectionTracker();
1854 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1855 bool textChangedSignal = false;
1856 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1858 gTextChangedCallBackCalled = false;
1859 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1860 application.SendNotification();
1861 application.Render();
1862 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1863 DALI_TEST_CHECK(!textChangedSignal);
1868 // Positive test for Max Characters reached signal.
1869 int utcDaliTextFieldMaxCharactersReachedP(void)
1871 ToolkitTestApplication application;
1872 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1873 TextField field = TextField::New();
1874 DALI_TEST_CHECK(field);
1876 application.GetScene().Add(field);
1878 const int maxNumberOfCharacters = 1;
1879 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1881 field.SetKeyInputFocus();
1883 // connect to the text changed signal.
1884 ConnectionTracker* testTracker = new ConnectionTracker();
1885 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1886 bool maxLengthReachedSignal = false;
1887 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1889 gMaxCharactersCallBackCalled = false;
1891 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1892 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1894 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1895 DALI_TEST_CHECK(maxLengthReachedSignal);
1900 // Negative test for Max Characters reached signal.
1901 int utcDaliTextFieldMaxCharactersReachedN(void)
1903 ToolkitTestApplication application;
1904 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1905 TextField field = TextField::New();
1906 DALI_TEST_CHECK(field);
1908 application.GetScene().Add(field);
1910 const int maxNumberOfCharacters = 3;
1911 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1913 field.SetKeyInputFocus();
1915 // connect to the text changed signal.
1916 ConnectionTracker* testTracker = new ConnectionTracker();
1917 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1918 bool maxLengthReachedSignal = false;
1919 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1921 gMaxCharactersCallBackCalled = false;
1923 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1924 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1926 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1927 DALI_TEST_CHECK(!maxLengthReachedSignal);
1929 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1931 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1932 DALI_TEST_CHECK(!maxLengthReachedSignal);
1937 // Positive test for Input Filtered signal.
1938 int utcDaliTextFieldInputFilteredP(void)
1940 ToolkitTestApplication application;
1941 tet_infoline(" utcDaliTextFieldInputFilteredP");
1942 TextField field = TextField::New();
1943 DALI_TEST_CHECK(field);
1945 application.GetScene().Add(field);
1947 Property::Map inputFilter;
1949 // Only digit is accepted.
1950 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1952 // Set input filter to TextField.
1953 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1955 field.SetKeyInputFocus();
1957 // connect to the input filtered signal.
1958 ConnectionTracker* testTracker = new ConnectionTracker();
1959 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1960 bool inputFilteredSignal = false;
1961 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1963 gInputFilteredAcceptedCallbackCalled = false;
1965 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1967 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1968 DALI_TEST_CHECK(inputFilteredSignal);
1970 // Word is rejected.
1971 inputFilter[InputFilter::Property::ACCEPTED] = "";
1972 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1974 // Set input filter to TextField.
1975 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1977 field.SetKeyInputFocus();
1979 inputFilteredSignal = false;
1980 gInputFilteredRejectedCallbackCalled = false;
1982 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1984 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1985 DALI_TEST_CHECK(inputFilteredSignal);
1990 // Negative test for Input Filtered signal.
1991 int utcDaliTextFieldInputFilteredN(void)
1993 ToolkitTestApplication application;
1994 tet_infoline(" utcDaliTextFieldInputFilteredP");
1995 TextField field = TextField::New();
1996 DALI_TEST_CHECK(field);
1998 application.GetScene().Add(field);
2000 Property::Map inputFilter;
2002 // Only word is accepted.
2003 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2005 // Set input filter to TextField.
2006 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2008 field.SetKeyInputFocus();
2010 // connect to the input filtered signal.
2011 ConnectionTracker* testTracker = new ConnectionTracker();
2012 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2013 bool inputFilteredSignal = false;
2014 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2016 gInputFilteredAcceptedCallbackCalled = false;
2018 // Key a, d should not be filtered.
2019 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2020 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2021 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2022 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2024 // Backspace, Delete should not be filtered.
2025 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2026 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));
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2033 DALI_TEST_CHECK(!inputFilteredSignal);
2035 // Digit is rejected.
2036 inputFilter[InputFilter::Property::ACCEPTED] = "";
2037 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2039 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2041 field.SetKeyInputFocus();
2043 inputFilteredSignal = false;
2044 gInputFilteredRejectedCallbackCalled = false;
2046 // Key a, d should not be filtered.
2047 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2048 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2049 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2050 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2052 // Backspace, Delete should not be filtered.
2053 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2054 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));
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2061 DALI_TEST_CHECK(!inputFilteredSignal);
2066 int utcDaliTextFieldInputStyleChanged01(void)
2068 // The text-field emits signals when the input style changes. These changes of style are
2069 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2070 // can't be emitted during the size negotiation as the callbacks may update the UI.
2071 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2072 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2073 ToolkitTestApplication application;
2074 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2078 char* pathNamePtr = get_current_dir_name();
2079 const std::string pathName(pathNamePtr);
2082 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2083 fontClient.SetDpi(93u, 93u);
2085 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2086 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2088 TextField field = TextField::New();
2089 DALI_TEST_CHECK(field);
2091 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2092 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2093 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2095 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2096 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2098 // connect to the text changed signal.
2099 ConnectionTracker* testTracker = new ConnectionTracker();
2100 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2101 bool inputStyleChangedSignal = false;
2102 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2104 application.GetScene().Add(field);
2106 // Render and notify
2107 application.SendNotification();
2108 application.Render();
2110 // Executes the idle callbacks added by the text control on the change of input style.
2111 application.RunIdles();
2113 gInputStyleChangedCallbackCalled = false;
2114 gInputStyleMask = TextField::InputStyle::NONE;
2115 inputStyleChangedSignal = false;
2117 // Create a tap event to touch the text field.
2118 TestGenerateTap(application, 18.0f, 25.0f);
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 // Executes the idle callbacks added by the text control on the change of input style.
2125 application.RunIdles();
2127 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2128 if(gInputStyleChangedCallbackCalled)
2130 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2132 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2133 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2135 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2136 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2138 DALI_TEST_CHECK(inputStyleChangedSignal);
2140 gInputStyleChangedCallbackCalled = false;
2141 gInputStyleMask = TextField::InputStyle::NONE;
2142 inputStyleChangedSignal = false;
2144 // Create a tap event to touch the text field.
2145 TestGenerateTap(application, 30.0f, 25.0f);
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 // Executes the idle callbacks added by the text control on the change of input style.
2152 application.RunIdles();
2154 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2155 DALI_TEST_CHECK(!inputStyleChangedSignal);
2157 gInputStyleChangedCallbackCalled = false;
2158 gInputStyleMask = TextField::InputStyle::NONE;
2159 inputStyleChangedSignal = false;
2161 // Create a tap event to touch the text field.
2162 TestGenerateTap(application, 43.0f, 25.0f);
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 // Executes the idle callbacks added by the text control on the change of input style.
2169 application.RunIdles();
2171 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2172 if(gInputStyleChangedCallbackCalled)
2174 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2176 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2177 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2179 DALI_TEST_CHECK(inputStyleChangedSignal);
2181 gInputStyleChangedCallbackCalled = false;
2182 gInputStyleMask = TextField::InputStyle::NONE;
2183 inputStyleChangedSignal = false;
2185 // Create a tap event to touch the text field.
2186 TestGenerateTap(application, 88.0f, 25.0f);
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 // Executes the idle callbacks added by the text control on the change of input style.
2193 application.RunIdles();
2195 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2196 if(gInputStyleChangedCallbackCalled)
2198 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2200 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2201 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2203 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2205 Property::Map fontStyleMapSet;
2206 fontStyleMapSet.Insert("weight", "bold");
2208 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2209 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2211 DALI_TEST_CHECK(inputStyleChangedSignal);
2213 gInputStyleChangedCallbackCalled = false;
2214 gInputStyleMask = TextField::InputStyle::NONE;
2215 inputStyleChangedSignal = false;
2217 // Create a tap event to touch the text field.
2218 TestGenerateTap(application, 115.0f, 25.0f);
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Executes the idle callbacks added by the text control on the change of input style.
2225 application.RunIdles();
2227 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2228 DALI_TEST_CHECK(!inputStyleChangedSignal);
2230 gInputStyleChangedCallbackCalled = false;
2231 gInputStyleMask = TextField::InputStyle::NONE;
2232 inputStyleChangedSignal = false;
2234 // Create a tap event to touch the text field.
2235 TestGenerateTap(application, 164.0f, 25.0f);
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2241 // Executes the idle callbacks added by the text control on the change of input style.
2242 application.RunIdles();
2244 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2245 if(gInputStyleChangedCallbackCalled)
2247 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2249 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2250 DALI_TEST_CHECK(style.empty());
2252 DALI_TEST_CHECK(inputStyleChangedSignal);
2254 gInputStyleChangedCallbackCalled = false;
2255 gInputStyleMask = TextField::InputStyle::NONE;
2256 inputStyleChangedSignal = false;
2258 // Create a tap event to touch the text field.
2259 TestGenerateTap(application, 191.0f, 25.0f);
2261 // Render and notify
2262 application.SendNotification();
2263 application.Render();
2265 // Executes the idle callbacks added by the text control on the change of input style.
2266 application.RunIdles();
2268 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2269 DALI_TEST_CHECK(!inputStyleChangedSignal);
2274 int utcDaliTextFieldInputStyleChanged02(void)
2276 // The text-field emits signals when the input style changes. These changes of style are
2277 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2278 // can't be emitted during the size negotiation as the callbacks may update the UI.
2279 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2280 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2281 ToolkitTestApplication application;
2282 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2286 char* pathNamePtr = get_current_dir_name();
2287 const std::string pathName(pathNamePtr);
2290 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2291 fontClient.SetDpi(93u, 93u);
2293 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2294 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2296 TextField field = TextField::New();
2297 DALI_TEST_CHECK(field);
2299 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2300 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2301 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2303 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2304 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>");
2306 // connect to the text changed signal.
2307 ConnectionTracker* testTracker = new ConnectionTracker();
2308 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2309 bool inputStyleChangedSignal = false;
2310 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2312 application.GetScene().Add(field);
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 // Executes the idle callbacks added by the text control on the change of input style.
2319 application.RunIdles();
2321 gInputStyleChangedCallbackCalled = false;
2322 gInputStyleMask = TextField::InputStyle::NONE;
2323 inputStyleChangedSignal = false;
2325 // Create a tap event to touch the text field.
2326 TestGenerateTap(application, 53.0f, 25.0f, 100);
2327 TestGenerateTap(application, 53.0f, 25.0f, 200);
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 // Executes the idle callbacks added by the text control on the change of input style.
2334 application.RunIdles();
2336 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2337 if(gInputStyleChangedCallbackCalled)
2339 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2340 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2341 TextField::InputStyle::POINT_SIZE |
2342 TextField::InputStyle::COLOR),
2345 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2346 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2348 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2349 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2351 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2352 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2354 DALI_TEST_CHECK(inputStyleChangedSignal);
2356 gInputStyleChangedCallbackCalled = false;
2357 gInputStyleMask = TextField::InputStyle::NONE;
2358 inputStyleChangedSignal = false;
2360 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 // Executes the idle callbacks added by the text control on the change of input style.
2367 application.RunIdles();
2369 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2370 if(gInputStyleChangedCallbackCalled)
2372 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2373 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2376 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2377 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2379 DALI_TEST_CHECK(inputStyleChangedSignal);
2381 gInputStyleChangedCallbackCalled = false;
2382 gInputStyleMask = TextField::InputStyle::NONE;
2383 inputStyleChangedSignal = false;
2385 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Executes the idle callbacks added by the text control on the change of input style.
2392 application.RunIdles();
2394 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2395 DALI_TEST_CHECK(!inputStyleChangedSignal);
2397 gInputStyleChangedCallbackCalled = false;
2398 gInputStyleMask = TextField::InputStyle::NONE;
2399 inputStyleChangedSignal = false;
2401 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Executes the idle callbacks added by the text control on the change of input style.
2408 application.RunIdles();
2410 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2411 if(gInputStyleChangedCallbackCalled)
2413 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2414 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2417 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2418 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2420 DALI_TEST_CHECK(inputStyleChangedSignal);
2422 gInputStyleChangedCallbackCalled = false;
2423 gInputStyleMask = TextField::InputStyle::NONE;
2424 inputStyleChangedSignal = false;
2426 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2428 Property::Map fontStyleMapSet;
2429 fontStyleMapSet.Insert("weight", "thin");
2430 fontStyleMapSet.Insert("width", "condensed");
2431 fontStyleMapSet.Insert("slant", "italic");
2433 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2434 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2436 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2437 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2438 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2439 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2440 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Executes the idle callbacks added by the text control on the change of input style.
2447 application.RunIdles();
2449 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2450 DALI_TEST_CHECK(!inputStyleChangedSignal);
2452 // Create a tap event to touch the text field.
2453 TestGenerateTap(application, 63.0f, 25.0f, 700);
2455 // Render and notify
2456 application.SendNotification();
2457 application.Render();
2459 // Executes the idle callbacks added by the text control on the change of input style.
2460 application.RunIdles();
2462 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2463 if(gInputStyleChangedCallbackCalled)
2465 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2466 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2467 TextField::InputStyle::POINT_SIZE |
2468 TextField::InputStyle::FONT_STYLE |
2469 TextField::InputStyle::UNDERLINE |
2470 TextField::InputStyle::SHADOW |
2471 TextField::InputStyle::EMBOSS |
2472 TextField::InputStyle::OUTLINE),
2475 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2476 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2478 DALI_TEST_CHECK(inputStyleChangedSignal);
2483 int utcDaliTextFieldEvent01(void)
2485 ToolkitTestApplication application;
2486 tet_infoline(" utcDaliTextFieldEvent01");
2488 // Creates a tap event. After creating a tap event the text field should
2489 // have the focus and add text with key events should be possible.
2491 TextField field = TextField::New();
2492 DALI_TEST_CHECK(field);
2494 application.GetScene().Add(field);
2496 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2497 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2498 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2500 // Render and notify
2501 application.SendNotification();
2502 application.Render();
2504 // Avoid a crash when core load gl resources.
2505 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2511 // Add a key event but as the text field has not the focus it should do nothing.
2512 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2514 // Render and notify
2515 application.SendNotification();
2516 application.Render();
2518 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2520 // Create a tap event to touch the text field.
2521 TestGenerateTap(application, 150.0f, 25.0f);
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Pressing delete key should be fine even if there is no text in TextField.
2528 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));
2529 // Render and notify
2530 application.SendNotification();
2531 application.Render();
2533 // Now the text field has the focus, so it can handle the key events.
2534 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2535 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2543 // Create a second text field and send key events to it.
2544 TextField field2 = TextField::New();
2546 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2547 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2548 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2549 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2551 application.GetScene().Add(field2);
2553 // Render and notify
2554 application.SendNotification();
2555 application.Render();
2557 // Create a tap event on the second text field.
2558 TestGenerateTap(application, 150.0f, 125.0f);
2560 // Render and notify
2561 application.SendNotification();
2562 application.Render();
2564 // The second text field has the focus. It should handle the key events.
2565 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2566 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Check the text has been added to the second text field.
2573 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2578 int utcDaliTextFieldEvent02(void)
2580 ToolkitTestApplication application;
2581 tet_infoline(" utcDaliTextFieldEvent02");
2583 // Checks if the right number of actors are created.
2585 TextField field = TextField::New();
2586 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2587 DALI_TEST_CHECK(field);
2588 LoadMarkerImages(application, field);
2590 application.GetScene().Add(field);
2592 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2593 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2594 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2596 // Avoid a crash when core load gl resources.
2597 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2599 // Render and notify
2600 application.SendNotification();
2601 application.Render();
2603 // Check there are the expected number of children ( stencil ).
2604 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2606 Actor stencil = field.GetChildAt(0u);
2607 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2609 // Create a tap event to touch the text field.
2610 TestGenerateTap(application, 150.0f, 25.0f, 300);
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2616 Actor layer = field.GetChildAt(2u);
2617 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2618 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2620 // Now the text field has the focus, so it can handle the key events.
2621 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2622 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2624 // Render and notify
2625 application.SendNotification();
2626 application.Render();
2628 // Checks the cursor and the renderer have been created.
2629 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2630 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2632 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2633 DALI_TEST_CHECK(cursor);
2635 // The offscreen root actor has a container with all the actors which contain the text renderers.
2636 Actor container = stencil.GetChildAt(0u);
2637 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2639 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2640 DALI_TEST_CHECK(renderer);
2643 // Move the cursor and check the position changes.
2644 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2645 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2652 DALI_TEST_CHECK(position2.x < position1.x);
2654 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2656 // Render and notify
2657 application.SendNotification();
2658 application.Render();
2660 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2661 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2663 // Move the cursor to the first position.
2664 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2665 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2667 // Render and notify
2668 application.SendNotification();
2669 application.Render();
2671 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2673 // Send some taps and check the cursor positions.
2675 // Try to tap at the beginning.
2676 TestGenerateTap(application, 1.0f, 25.0f, 900);
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 // Cursor position should be the same than position1.
2683 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2685 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2687 // Tap away from the start position.
2688 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2690 // Render and notify
2691 application.SendNotification();
2692 application.Render();
2694 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2696 DALI_TEST_CHECK(position6.x > position5.x);
2698 // Remove all the text.
2699 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2700 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2701 field.SetProperty(TextField::Property::TEXT, "");
2703 // Render and notify
2704 application.SendNotification();
2705 application.Render();
2707 // Cursor position should be the same than position2.
2708 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2710 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2712 // Should not be a renderer, there is only a clipped cursor.
2713 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2715 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2716 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2717 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2719 application.SendNotification();
2720 application.Render();
2722 // There are renderer and decorator layer
2723 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2728 int utcDaliTextFieldEvent03(void)
2730 ToolkitTestApplication application;
2731 tet_infoline(" utcDaliTextFieldEvent03");
2733 // Checks if the highlight actor is created.
2735 TextField field = TextField::New();
2736 DALI_TEST_CHECK(field);
2738 application.GetScene().Add(field);
2740 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2741 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2742 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2743 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2744 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2746 // Avoid a crash when core load gl resources.
2747 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2748 LoadMarkerImages(application, field);
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 // Tap first to get the focus.
2755 TestGenerateTap(application, 3.0f, 25.0f, 100);
2757 // Render and notify
2758 application.SendNotification();
2759 application.Render();
2761 // Double tap to select a word.
2762 TestGenerateTap(application, 3.0f, 25.0f, 200);
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2768 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2769 Actor stencil = field.GetChildAt(0u);
2771 // The highlight actor is drawn first, so is the first actor in the list
2772 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2773 DALI_TEST_CHECK(highlight);
2775 // The offscreen root actor has a container with all the actors which contain the text renderers.
2776 Actor container = stencil.GetChildAt(1u);
2777 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2779 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2780 DALI_TEST_CHECK(renderer);
2786 int utcDaliTextFieldEvent04(void)
2788 ToolkitTestApplication application;
2789 tet_infoline(" utcDaliTextFieldEvent04");
2791 // Checks if the highlight actor is created.
2793 TextField field = TextField::New();
2794 DALI_TEST_CHECK(field);
2795 application.GetScene().Add(field);
2796 LoadMarkerImages(application, field);
2797 // Render and notify
2798 application.SendNotification();
2799 application.Render();
2801 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2802 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2803 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2804 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2805 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2807 // Avoid a crash when core load gl resources.
2808 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2809 // Render and notify
2810 application.SendNotification();
2811 application.Render();
2813 // Create a tap event to touch the text field.
2814 TestGenerateTap(application, 150.0f, 25.0f);
2815 // Render and notify
2816 application.SendNotification();
2817 application.Render();
2819 // Tap first to get the focus.
2820 TestGenerateTap(application, 1.0f, 25.0f);
2822 // Render and notify
2823 application.SendNotification();
2824 application.Render();
2826 // Double tap to select a word.
2827 TestGenerateTap(application, 1.0f, 25.0f);
2829 // Render and notify
2830 application.SendNotification();
2831 application.Render();
2834 TestGenerateTap(application, 0.0f, 40.0f);
2838 int utcDaliTextFieldEvent05(void)
2840 ToolkitTestApplication application;
2841 tet_infoline(" utcDaliTextFieldEvent05");
2843 // Checks dragging of cursor/grab handle
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, "This is a long text for the size of the text-field.");
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();
2878 // Double tap to select a word.
2879 TestGenerateTap(application, 1.0f, 25.0f);
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2885 Actor stencil = field.GetChildAt(1u);
2889 int utcDaliTextFieldEvent06(void)
2891 ToolkitTestApplication application;
2892 tet_infoline(" utcDaliTextFieldEvent06");
2894 // Checks Longpress when in edit mode
2896 TextField field = TextField::New();
2897 DALI_TEST_CHECK(field);
2898 application.GetScene().Add(field);
2899 LoadMarkerImages(application, field);
2900 // Render and notify
2901 application.SendNotification();
2902 application.Render();
2904 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2905 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2906 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2907 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2908 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2910 // Avoid a crash when core load gl resources.
2911 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2912 // Render and notify
2913 application.SendNotification();
2914 application.Render();
2916 // Create a tap event to touch the text field.
2917 TestGenerateTap(application, 150.0f, 25.0f);
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 // Tap first to get the focus.
2923 TestGenerateTap(application, 1.0f, 25.0f);
2925 // Render and notify
2926 application.SendNotification();
2927 application.Render();
2930 TestGenerateLongPress(application, 1.0f, 25.0f);
2932 // Render and notify
2933 application.SendNotification();
2934 application.Render();
2939 int utcDaliTextFieldEvent07(void)
2941 ToolkitTestApplication application;
2942 tet_infoline(" utcDaliTextFieldEvent07");
2944 // Checks Longpress to start edit mode
2946 TextField field = TextField::New();
2947 DALI_TEST_CHECK(field);
2948 application.GetScene().Add(field);
2949 LoadMarkerImages(application, field);
2950 // Render and notify
2951 application.SendNotification();
2952 application.Render();
2954 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2955 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2956 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2957 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2958 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2959 Property::Map propertyMap;
2960 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2961 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2963 // Avoid a crash when core load gl resources.
2964 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2965 // Render and notify
2966 application.SendNotification();
2967 application.Render();
2970 TestGenerateLongPress(application, 1.0f, 25.0f);
2972 // Render and notify
2973 application.SendNotification();
2974 application.Render();
2979 int utcDaliTextFieldEvent08(void)
2981 ToolkitTestApplication application;
2982 tet_infoline(" utcDaliTextFieldEvent08");
2984 Dali::Clipboard clipboard = Clipboard::Get();
2985 clipboard.SetItem("testTextFieldEvent");
2987 // Checks Longpress when only place holder text
2989 TextField field = TextField::New();
2990 DALI_TEST_CHECK(field);
2991 application.GetScene().Add(field);
2992 LoadMarkerImages(application, field);
2993 // Render and notify
2994 application.SendNotification();
2995 application.Render();
2997 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2998 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2999 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3000 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3001 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3003 // Avoid a crash when core load gl resources.
3004 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3005 // Render and notify
3006 application.SendNotification();
3007 application.Render();
3010 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 Wait(application, 500);
3018 TestEndLongPress(application, 1.0f, 25.0f, 520);
3021 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3023 // Render and notify
3024 application.Render();
3026 Wait(application, 500);
3028 Integration::Scene stage = application.GetScene();
3029 Layer layer = stage.GetRootLayer();
3030 Actor actor = layer.FindChildByName("optionPaste");
3034 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3035 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3036 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3038 Dali::Integration::TouchEvent event;
3039 event = Dali::Integration::TouchEvent();
3040 event.AddPoint(GetPointDownInside(position));
3041 application.ProcessEvent(event);
3043 event = Dali::Integration::TouchEvent();
3044 event.AddPoint(GetPointUpInside(position));
3045 application.ProcessEvent(event);
3047 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3052 int utcDaliTextFieldEvent09(void)
3054 ToolkitTestApplication application;
3055 tet_infoline(" utcDaliTextFieldEvent09");
3057 TextField field = TextField::New();
3058 DALI_TEST_CHECK(field);
3059 application.GetScene().Add(field);
3060 LoadMarkerImages(application, field);
3061 // Render and notify
3062 application.SendNotification();
3063 application.Render();
3065 field.SetProperty(TextField::Property::TEXT, "Hello");
3066 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3067 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3068 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3069 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3070 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3072 // Avoid a crash when core load gl resources.
3073 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3075 // Create a tap event to touch the text field.
3076 TestGenerateTap(application, 150.0f, 25.0f);
3077 application.SendNotification();
3078 application.Render();
3081 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3082 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3083 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3084 application.SendNotification();
3085 application.Render();
3086 for(unsigned int index = 0u; index < 6u; ++index)
3088 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3089 application.SendNotification();
3090 application.Render();
3093 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3094 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3095 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3096 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3097 application.SendNotification();
3098 application.Render();
3100 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3101 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3102 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3103 for(unsigned int index = 0u; index < 5u; ++index)
3105 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3106 application.SendNotification();
3107 application.Render();
3110 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3111 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3112 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3113 for(unsigned int index = 0u; index < 5u; ++index)
3115 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3116 application.SendNotification();
3117 application.Render();
3120 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3121 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3122 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3123 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3124 application.SendNotification();
3125 application.Render();
3126 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3127 application.SendNotification();
3128 application.Render();
3130 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3131 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3132 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3133 application.SendNotification();
3134 application.Render();
3136 Property::Map mapGet;
3137 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3138 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3139 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3143 int utcDaliTextFieldStyleWhilstSelected(void)
3145 ToolkitTestApplication application;
3146 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3148 // Change font and styles whilst text is selected whilst word selected
3150 TextField field = TextField::New();
3151 DALI_TEST_CHECK(field);
3152 application.GetScene().Add(field);
3153 LoadMarkerImages(application, field);
3154 // Render and notify
3155 application.SendNotification();
3156 application.Render();
3158 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3159 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3160 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3161 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3162 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3164 // Avoid a crash when core load gl resources.
3165 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3166 // Render and notify
3167 application.SendNotification();
3168 application.Render();
3170 // Create a tap event to touch the text field.
3171 TestGenerateTap(application, 150.0f, 25.0f);
3172 // Render and notify
3173 application.SendNotification();
3174 application.Render();
3176 // Tap first to get the focus.
3177 TestGenerateTap(application, 1.0f, 25.0f);
3179 // Render and notify
3180 application.SendNotification();
3181 application.Render();
3183 // Double tap to select a word.
3184 TestGenerateTap(application, 1.0f, 25.0f);
3186 // Render and notify
3187 application.SendNotification();
3188 application.Render();
3190 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3191 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3193 Property::Map fontStyleMapSet;
3194 Property::Map fontStyleMapGet;
3196 fontStyleMapSet.Insert("weight", "bold");
3197 fontStyleMapSet.Insert("slant", "italic");
3198 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3200 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3201 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3202 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3204 fontStyleMapSet.Clear();
3205 fontStyleMapSet.Insert("width", "expanded");
3206 fontStyleMapSet.Insert("slant", "italic");
3207 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3209 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3210 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3211 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3213 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3214 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3216 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3217 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3219 fontStyleMapSet.Clear();
3220 fontStyleMapSet.Insert("weight", "bold");
3221 fontStyleMapSet.Insert("slant", "italic");
3223 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3225 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3226 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3227 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3229 fontStyleMapSet.Clear();
3230 fontStyleMapSet.Insert("width", "expanded");
3232 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3234 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3235 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3236 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3238 // Press Escape to increase coverage
3239 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3240 application.SendNotification();
3241 application.Render();
3243 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3248 int utcDaliTextFieldEscKeyLoseFocus(void)
3250 ToolkitTestApplication application;
3251 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3253 // Creates a tap event. After creating a tap event the text field should
3254 // have the focus and add text with key events should be possible.
3256 TextField field = TextField::New();
3257 DALI_TEST_CHECK(field);
3259 application.GetScene().Add(field);
3261 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3262 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3263 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3265 // Avoid a crash when core load gl resources.
3266 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3268 // Render and notify
3269 application.SendNotification();
3270 application.Render();
3272 // Add a key event but as the text field has not the focus it should do nothing.
3273 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3274 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3276 // Render and notify
3277 application.SendNotification();
3278 application.Render();
3280 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3282 // Create a tap event to touch the text field.
3283 TestGenerateTap(application, 150.0f, 25.0f);
3285 // Render and notify
3286 application.SendNotification();
3287 application.Render();
3289 // Now the text field has the focus, so it can handle the key events.
3290 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3291 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3292 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3293 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3295 // Render and notify
3296 application.SendNotification();
3297 application.Render();
3299 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3301 // Generate a Esc key event. The text field should lose the focus.
3302 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3303 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3305 // Render and notify
3306 application.SendNotification();
3307 application.Render();
3309 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3311 // No more text should be introduced
3312 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3313 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3315 // Render and notify
3316 application.SendNotification();
3317 application.Render();
3319 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3324 int utcDaliTextFieldSomeSpecialKeys(void)
3326 ToolkitTestApplication application;
3327 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3329 // Checks some special keys when the text is selected.
3331 TextField field = TextField::New();
3332 DALI_TEST_CHECK(field);
3333 application.GetScene().Add(field);
3334 LoadMarkerImages(application, field);
3335 // Render and notify
3336 application.SendNotification();
3337 application.Render();
3339 const std::string longText("This is a long text for the size of the text-field.");
3341 field.SetProperty(TextField::Property::TEXT, longText);
3342 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3343 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3344 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3345 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3347 // Avoid a crash when core load gl resources.
3348 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3349 // Render and notify
3350 application.SendNotification();
3351 application.Render();
3353 // Create a tap event to touch the text field.
3354 TestGenerateTap(application, 150.0f, 25.0f);
3356 // Render and notify
3357 application.SendNotification();
3358 application.Render();
3360 // Tap first to get the focus.
3361 TestGenerateTap(application, 1.0f, 25.0f);
3363 // Render and notify
3364 application.SendNotification();
3365 application.Render();
3367 // Double tap to select a word.
3368 TestGenerateTap(application, 1.0f, 25.0f);
3370 // Render and notify
3371 application.SendNotification();
3372 application.Render();
3374 // Generate a Esc key event. The text field should lose the focus.
3375 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3376 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3378 // Render and notify
3379 application.SendNotification();
3380 application.Render();
3382 // Generate a Esc key event. The text field should lose the focus.
3383 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3384 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3386 // Render and notify
3387 application.SendNotification();
3388 application.Render();
3390 // Generate a Esc key event. The text field should lose the focus.
3391 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3392 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3394 // Render and notify
3395 application.SendNotification();
3396 application.Render();
3398 // Generate a Back key event. Nothing happens to the text field.
3399 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3400 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3402 // Render and notify
3403 application.SendNotification();
3404 application.Render();
3406 // The text shouldn't be deleted.
3407 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3412 int utcDaliTextFieldSizeUpdate(void)
3414 ToolkitTestApplication application;
3415 tet_infoline("utcDaliTextFieldSizeUpdate");
3417 // Checks some special keys when the text is selected.
3418 TextField field = TextField::New();
3419 DALI_TEST_CHECK(field);
3420 application.GetScene().Add(field);
3422 float previousHeight = 0.0f;
3423 float currentHeight = 0.0f;
3424 const float fieldWidth = 1920.0f;
3426 // "ㅁ" is bigger then "ኢ"
3427 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3428 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3429 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3431 field.SetProperty(TextField::Property::TEXT, "ኢ");
3432 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3433 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3435 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3436 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3438 application.SendNotification();
3439 application.Render();
3441 previousHeight = field.GetHeightForWidth(fieldWidth);
3442 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3444 // Add another script characters ( glyph height is defferent )
3445 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3446 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3448 application.SendNotification();
3449 application.Render();
3451 currentHeight = field.GetHeightForWidth(fieldWidth);
3452 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3453 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3458 int utcDaliTextFieldExtremlyLargePointSize(void)
3460 ToolkitTestApplication application;
3461 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3463 TextField field = TextField::New();
3465 field.SetProperty(TextField::Property::TEXT, "Text");
3466 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3467 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3468 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3469 application.GetScene().Add(field);
3473 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3474 application.SendNotification();
3475 DALI_TEST_CHECK(field);
3479 tet_result(TET_FAIL);
3484 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3486 ToolkitTestApplication application;
3487 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3488 TextField field = TextField::New();
3489 DALI_TEST_CHECK(field);
3490 application.GetScene().Add(field);
3492 Property::Map fontStyleMapGet;
3494 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3496 Property::Value* weightValue = NULL;
3497 Property::Value* widthValue = NULL;
3498 Property::Value* slantValue = NULL;
3499 weightValue = fontStyleMapGet.Find("weight");
3500 widthValue = fontStyleMapGet.Find("width");
3501 slantValue = fontStyleMapGet.Find("slant");
3502 DALI_TEST_CHECK(!weightValue);
3503 DALI_TEST_CHECK(!widthValue);
3504 DALI_TEST_CHECK(!slantValue);
3509 int UtcDaliTextFieldSettingPlaceholder(void)
3511 ToolkitTestApplication application;
3512 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3514 TextField field = TextField::New();
3515 DALI_TEST_CHECK(field);
3516 application.GetScene().Add(field);
3518 // Check the placeholder property with pixel size
3519 Property::Map placeholderPixelSizeMapSet;
3520 Property::Map placeholderPixelSizeMapGet;
3521 Property::Map placeholderFontstyleMap;
3522 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3523 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3524 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3525 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3526 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3527 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3529 placeholderFontstyleMap.Insert("weight", "bold");
3530 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3531 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3533 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3534 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3535 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3537 // Check the placeholder property with point size
3538 Property::Map placeholderMapSet;
3539 Property::Map placeholderMapGet;
3540 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3541 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3542 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3543 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3544 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3545 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3547 // Check the placeholder font style property
3548 placeholderFontstyleMap.Clear();
3550 placeholderFontstyleMap.Insert("weight", "bold");
3551 placeholderFontstyleMap.Insert("width", "condensed");
3552 placeholderFontstyleMap.Insert("slant", "italic");
3553 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3554 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3556 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3557 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3558 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3560 // Reset font style.
3561 placeholderFontstyleMap.Clear();
3562 placeholderFontstyleMap.Insert("weight", "normal");
3563 placeholderFontstyleMap.Insert("slant", "oblique");
3564 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3565 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3567 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3568 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3569 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3571 placeholderFontstyleMap.Clear();
3572 placeholderFontstyleMap.Insert("slant", "roman");
3573 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3574 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3576 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3578 placeholderFontstyleMap.Clear();
3579 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3581 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3582 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3583 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3584 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3589 int UtcDaliTextFieldPlaceholderCoverage(void)
3591 ToolkitTestApplication application;
3592 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3594 // mPlaceholderFont is created only once, so create a new control for coverage.
3595 TextField fieldForCoverage = TextField::New();
3596 DALI_TEST_CHECK(fieldForCoverage);
3597 application.GetScene().Add(fieldForCoverage);
3599 // for SetPlaceholderFontFamily() coverage.
3600 Property::Map fontFamilyMap;
3601 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3602 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3604 // mPlaceholderFont is created only once, so create a new control for coverage.
3605 fieldForCoverage = TextField::New();
3606 DALI_TEST_CHECK(fieldForCoverage);
3607 application.GetScene().Add(fieldForCoverage);
3609 // for SetPlaceholderTextFontSize coverage.
3610 Property::Map fontSizeMap;
3611 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3612 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3614 // mPlaceholderFont is created only once, so create a new control for coverage.
3615 fieldForCoverage = TextField::New();
3616 DALI_TEST_CHECK(fieldForCoverage);
3617 application.GetScene().Add(fieldForCoverage);
3619 // for SetPlaceholderTextFontWeight coverage.
3620 Property::Map fontStyleWeightMap;
3621 Property::Map fontStyleWeightPropertyMap;
3622 fontStyleWeightPropertyMap.Insert("weight", "bold");
3623 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3624 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3626 // mPlaceholderFont is created only once, so create a new control for coverage.
3627 fieldForCoverage = TextField::New();
3628 DALI_TEST_CHECK(fieldForCoverage);
3629 application.GetScene().Add(fieldForCoverage);
3631 // for SetPlaceholderTextFontWidth coverage.
3632 Property::Map fontStyleWidthMap;
3633 Property::Map fontStyleWidthPropertyMap;
3634 fontStyleWidthPropertyMap.Insert("width", "expanded");
3635 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3636 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3638 // mPlaceholderFont is created only once, so create a new control for coverage.
3639 fieldForCoverage = TextField::New();
3640 DALI_TEST_CHECK(fieldForCoverage);
3641 application.GetScene().Add(fieldForCoverage);
3643 // for SetPlaceholderTextFontSlant coverage.
3644 Property::Map fontStyleSlantMap;
3645 Property::Map fontStyleSlantPropertyMap;
3646 fontStyleSlantPropertyMap.Insert("slant", "italic");
3647 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3648 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3653 int UtcDaliTextFieldSetPaddingProperty(void)
3655 ToolkitTestApplication application;
3656 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3658 TextField field = TextField::New();
3659 DALI_TEST_CHECK(field);
3660 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3661 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3662 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3663 application.GetScene().Add(field);
3665 application.SendNotification();
3666 application.Render();
3668 Vector3 originalSize = field.GetNaturalSize();
3670 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3672 application.SendNotification();
3673 application.Render();
3675 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3677 Vector3 paddingAddedSize = field.GetNaturalSize();
3679 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3681 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3686 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3688 ToolkitTestApplication application;
3689 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3691 TextField field = TextField::New();
3692 DALI_TEST_CHECK(field);
3693 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3694 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3695 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3696 application.GetScene().Add(field);
3698 application.SendNotification();
3699 application.Render();
3701 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3702 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3704 // Check the enable shift selection property
3705 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3706 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3708 application.SendNotification();
3709 application.Render();
3714 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3716 ToolkitTestApplication application;
3717 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3719 TextField field = TextField::New();
3720 DALI_TEST_CHECK(field);
3721 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3722 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3723 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3724 application.GetScene().Add(field);
3726 application.SendNotification();
3727 application.Render();
3729 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3730 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3732 // Check the enable grab handle property
3733 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3734 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3736 application.SendNotification();
3737 application.Render();
3742 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3744 ToolkitTestApplication application;
3745 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3747 TextField field = TextField::New();
3748 DALI_TEST_CHECK(field);
3749 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3750 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3751 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3752 application.GetScene().Add(field);
3754 application.SendNotification();
3755 application.Render();
3757 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3758 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3760 // Check the match system language direction property
3761 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3762 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3764 application.SendNotification();
3765 application.Render();
3770 int utcDaliTextFieldLayoutDirectionCoverage(void)
3772 ToolkitTestApplication application;
3773 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3775 // Creates a tap event. After creating a tap event the text field should
3776 // have the focus and add text with key events should be possible.
3777 TextField field = TextField::New();
3778 DALI_TEST_CHECK(field);
3780 application.GetScene().Add(field);
3782 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3783 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3784 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3786 // Avoid a crash when core load gl resources.
3787 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3789 // Render and notify
3790 application.SendNotification();
3791 application.Render();
3793 // init direction for coverage
3794 // Set horizontal alignment END
3795 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3797 // Create a tap event to touch the text field.
3798 TestGenerateTap(application, 150.0f, 25.0f);
3800 // Render and notify
3801 application.SendNotification();
3802 application.Render();
3804 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3805 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3806 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3808 // Set horizontal alignment BEGIN
3809 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3811 // Create a tap event to touch the text field.
3812 TestGenerateTap(application, 150.0f, 25.0f);
3814 // Render and notify
3815 application.SendNotification();
3816 application.Render();
3818 // Set horizontal alignment CENTER
3819 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3821 // Create a tap event to touch the text field.
3822 TestGenerateTap(application, 150.0f, 25.0f);
3824 // Render and notify
3825 application.SendNotification();
3826 application.Render();
3828 // Set horizontal alignment END
3829 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3831 // Create a tap event to touch the text field.
3832 TestGenerateTap(application, 150.0f, 25.0f);
3834 // Render and notify
3835 application.SendNotification();
3836 application.Render();
3838 // Generate a Esc key event. The text field should lose the focus.
3839 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3842 // Render and notify
3843 application.SendNotification();
3844 application.Render();
3846 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3851 int UtcDaliTextFieldGetInputMethodContext(void)
3853 ToolkitTestApplication application;
3854 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3856 TextField field = TextField::New();
3857 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3862 int UtcDaliTextFieldSelectWholeText(void)
3864 ToolkitTestApplication application;
3865 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3867 TextField textField = TextField::New();
3869 application.GetScene().Add(textField);
3871 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3872 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3873 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3875 // Avoid a crash when core load gl resources.
3876 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3878 application.SendNotification();
3879 application.Render();
3881 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3883 DevelTextField::SelectWholeText(textField);
3885 application.SendNotification();
3886 application.Render();
3888 // Nothing should have been selected. The number of children is still 1
3889 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3891 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3893 application.SendNotification();
3894 application.Render();
3896 DevelTextField::SelectWholeText(textField);
3898 application.SendNotification();
3899 application.Render();
3901 // Even if resize, selection should remain.
3902 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3904 application.SendNotification();
3905 application.Render();
3907 // Should be 2 children, the stencil and the layer
3908 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3910 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3911 Actor stencil = textField.GetChildAt(0u);
3913 // The highlight actor is drawn first, so is the first actor in the list
3914 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3915 DALI_TEST_CHECK(highlight);
3920 int UtcDaliTextFieldSelectText(void)
3922 ToolkitTestApplication application;
3923 tet_infoline(" UtcDaliTextFieldSelectText ");
3925 TextField textField = TextField::New();
3927 application.GetScene().Add(textField);
3929 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3930 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3931 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3933 // Avoid a crash when core load gl resources.
3934 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3936 application.SendNotification();
3937 application.Render();
3939 DevelTextField::SelectText(textField, 0, 5);
3941 application.SendNotification();
3942 application.Render();
3944 // Nothing is selected
3945 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3946 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3948 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3950 application.SendNotification();
3951 application.Render();
3953 // Hello is selected
3954 DevelTextField::SelectText(textField, 0, 5);
3956 application.SendNotification();
3957 application.Render();
3959 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3960 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3962 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3963 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3965 // world is selected
3966 DevelTextField::SelectText(textField, 6, 11);
3968 application.SendNotification();
3969 application.Render();
3971 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3972 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3974 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3975 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3980 int UtcDaliTextFieldSelectNone(void)
3982 ToolkitTestApplication application;
3983 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3985 TextField textField = TextField::New();
3987 application.GetScene().Add(textField);
3989 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3990 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3991 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3993 // Avoid a crash when core load gl resources.
3994 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3996 application.SendNotification();
3997 application.Render();
3999 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4001 application.SendNotification();
4002 application.Render();
4004 // Nothing is selected
4005 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4006 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4008 DevelTextField::SelectWholeText(textField);
4010 application.SendNotification();
4011 application.Render();
4013 // whole text is selected
4014 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4015 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4017 DevelTextField::SelectNone(textField);
4019 application.SendNotification();
4020 application.Render();
4022 // Nothing is selected
4023 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4024 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4029 int UtcDaliTextFieldSelectRange(void)
4031 ToolkitTestApplication application;
4032 tet_infoline(" UtcDaliTextFieldSelectRange ");
4034 TextField textField = TextField::New();
4036 application.GetScene().Add(textField);
4038 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4039 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4040 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4042 // Avoid a crash when core load gl resources.
4043 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4045 application.SendNotification();
4046 application.Render();
4048 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4050 application.SendNotification();
4051 application.Render();
4053 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4054 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4056 // Hello is selected
4057 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4058 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4060 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4061 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4063 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4064 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4066 // world is selected
4067 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4068 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4070 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4071 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4076 int UtcDaliTextFieldEnableEditing(void)
4078 ToolkitTestApplication application;
4079 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4081 TextField textField = TextField::New();
4083 application.GetScene().Add(textField);
4085 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4086 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4087 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4089 // Avoid a crash when core load gl resources.
4090 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4092 application.SendNotification();
4093 application.Render();
4095 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4096 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4098 textField.SetKeyInputFocus();
4099 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4100 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4102 // Render and notify
4103 application.SendNotification();
4104 application.Render();
4106 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4107 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4109 textField.SetKeyInputFocus();
4110 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4111 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4113 // Render and notify
4114 application.SendNotification();
4115 application.Render();
4117 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4118 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4120 // Check the user interaction enabled and for coverage
4121 DevelTextField::SelectWholeText(textField);
4123 // Render and notify
4124 application.SendNotification();
4125 application.Render();
4127 textField.SetKeyInputFocus();
4128 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4129 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4131 // Render and notify
4132 application.SendNotification();
4133 application.Render();
4135 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4136 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4141 int UtcDaliToolkitTextFieldFontSizeScale(void)
4143 ToolkitTestApplication application;
4144 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4146 TextField textField = TextField::New();
4147 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4148 textField.SetProperty(TextField::Property::TEXT, "Test");
4149 Vector3 nonScaledSize = textField.GetNaturalSize();
4151 TextField textFieldScaled = TextField::New();
4152 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4153 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4154 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4155 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4157 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4159 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4160 textField.SetProperty(TextField::Property::TEXT, "Test");
4161 nonScaledSize = textField.GetNaturalSize();
4163 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4164 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4165 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4166 scaledSize = textFieldScaled.GetNaturalSize();
4168 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4173 int UtcDaliTextFieldPrimaryCursorPosition(void)
4175 ToolkitTestApplication application;
4176 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4178 TextField textField = TextField::New();
4180 application.GetScene().Add(textField);
4182 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4183 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4184 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4185 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4187 // Avoid a crash when core load gl resources.
4188 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4190 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4191 application.SendNotification();
4192 application.Render();
4193 textField.SetKeyInputFocus();
4195 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4197 // Render and notify
4198 application.SendNotification();
4199 application.Render();
4201 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4202 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4207 // test max length when set after setting long text
4208 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4210 ToolkitTestApplication application;
4211 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4212 TextField field = TextField::New();
4213 DALI_TEST_CHECK(field);
4215 application.GetScene().Add(field);
4217 field.SetProperty(TextField::Property::TEXT, "123456789");
4219 const int maxNumberOfCharacters = 3;
4220 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4222 field.SetKeyInputFocus();
4224 // connect to the text max lengh reached signal.
4225 ConnectionTracker* testTracker = new ConnectionTracker();
4226 bool maxLengthReachedSignal = false;
4227 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4229 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4230 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4232 DALI_TEST_CHECK(maxLengthReachedSignal);
4234 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4239 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4241 ToolkitTestApplication application;
4242 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4244 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4245 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4246 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4248 // Create a text field
4249 TextField textField = TextField::New();
4251 //Set size to avoid automatic eliding
4252 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4253 //Set very large font-size using point-size
4254 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4255 //Specify font-family
4256 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4257 //Set text to check if appear or not
4258 textField.SetProperty(TextField::Property::TEXT, "A");
4260 application.GetScene().Add(textField);
4262 application.SendNotification();
4263 application.Render();
4264 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4265 Vector3 naturalSize = textField.GetNaturalSize();
4267 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4268 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4273 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4275 ToolkitTestApplication application;
4276 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4278 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4279 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4280 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4282 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4283 // Create a text editor
4284 TextField textField = TextField::New();
4286 //Set size to avoid automatic eliding
4287 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4288 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4289 textField.SetProperty(TextField::Property::TEXT, "A");
4291 const int numberOfCases = 6;
4292 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4294 for(int index = 0; index < numberOfCases; index++)
4296 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4297 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4298 application.GetScene().Add(textField);
4299 application.SendNotification();
4300 application.Render();
4301 naturalSize = textField.GetNaturalSize();
4302 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4303 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4309 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4311 ToolkitTestApplication application;
4312 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4313 TextField textField = TextField::New();
4315 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4316 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4318 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4319 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4320 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4322 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4323 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4324 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4326 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4327 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4328 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4330 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4331 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4332 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4334 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4335 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4336 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4338 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4339 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4340 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4342 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4343 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4344 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4346 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4347 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4348 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4350 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4351 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4352 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4354 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4355 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4356 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4358 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4359 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4360 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4362 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4363 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4364 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4369 int UtcDaliTextFieldCopyText(void)
4371 ToolkitTestApplication application;
4372 tet_infoline(" UtcDaliTextFieldCopyText ");
4374 TextField textField = TextField::New();
4376 std::string selectedText = "";
4377 std::string copiedText = "";
4379 application.GetScene().Add(textField);
4381 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4382 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4383 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4385 // Avoid a crash when core load gl resources.
4386 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4388 application.SendNotification();
4389 application.Render();
4391 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4393 application.SendNotification();
4394 application.Render();
4396 // Hello is selected
4397 DevelTextField::SelectText(textField, 0, 5);
4399 application.SendNotification();
4400 application.Render();
4402 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4403 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4405 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4406 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4409 copiedText = DevelTextField::CopyText(textField);
4410 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4412 // world is selected
4413 DevelTextField::SelectText(textField, 6, 11);
4415 application.SendNotification();
4416 application.Render();
4418 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4419 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4421 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4422 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4425 copiedText = DevelTextField::CopyText(textField);
4426 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4428 // "lo wo" is selected
4429 DevelTextField::SelectText(textField, 3, 8);
4431 application.SendNotification();
4432 application.Render();
4434 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4435 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4437 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4438 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4440 // "lo wo" is copied
4441 copiedText = DevelTextField::CopyText(textField);
4442 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4447 int UtcDaliTextFieldCutText(void)
4449 ToolkitTestApplication application;
4450 tet_infoline(" UtcDaliTextFieldCutText ");
4452 TextField textField = TextField::New();
4454 std::string selectedText = "";
4456 application.GetScene().Add(textField);
4458 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4459 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4460 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4462 // Avoid a crash when core load gl resources.
4463 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4465 application.SendNotification();
4466 application.Render();
4468 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4470 application.SendNotification();
4471 application.Render();
4473 // Hello is selected
4474 DevelTextField::SelectText(textField, 0, 5);
4476 application.SendNotification();
4477 application.Render();
4479 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4480 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4482 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4483 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4486 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4488 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4491 DevelTextField::SelectText(textField, 0, 2);
4493 application.SendNotification();
4494 application.Render();
4496 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4497 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4499 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4500 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4503 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4505 application.SendNotification();
4506 application.Render();
4508 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4510 // Test Cut from the middle
4513 DevelTextField::SelectText(textField, 1, 3);
4515 application.SendNotification();
4516 application.Render();
4518 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4519 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4521 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4522 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4525 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4527 application.SendNotification();
4528 application.Render();
4530 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4532 // Test Cut from the end
4535 DevelTextField::SelectText(textField, 1, 2);
4537 application.SendNotification();
4538 application.Render();
4540 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4541 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4543 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4544 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4547 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4549 application.SendNotification();
4550 application.Render();
4552 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4557 int UtcDaliTextFieldPasteText(void)
4559 ToolkitTestApplication application;
4560 tet_infoline(" UtcDaliTextFieldPasteText ");
4562 TextField textField = TextField::New();
4564 application.GetScene().Add(textField);
4566 std::string cutText = "";
4567 std::string copiedText = "";
4569 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4570 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4571 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4573 // Avoid a crash when core load gl resources.
4574 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4576 application.SendNotification();
4577 application.Render();
4579 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4581 application.SendNotification();
4582 application.Render();
4584 // Tap on the text editor
4585 TestGenerateTap(application, 3.0f, 25.0f);
4587 // Render and notify
4588 application.SendNotification();
4589 application.Render();
4591 // Select some text in the right of the current cursor position
4592 DevelTextField::SelectText(textField, 0, 3);
4594 // Render and notify
4595 application.SendNotification();
4596 application.Render();
4598 // Cut the selected text
4599 cutText = DevelTextField::CutText(textField);
4601 // Render and notify
4602 application.SendNotification();
4603 application.Render();
4605 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4606 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4608 DevelTextField::SelectText(textField, 0, 3);
4610 // Render and notify
4611 application.SendNotification();
4612 application.Render();
4614 // Copy the selected text
4615 copiedText = DevelTextField::CopyText(textField);
4617 // Render and notify
4618 application.SendNotification();
4619 application.Render();
4621 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4622 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4624 // Move the cursor to the end of the line
4625 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4626 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4627 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4628 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4629 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4630 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4631 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4632 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4634 // Render and notify
4635 application.SendNotification();
4636 application.Render();
4638 // Paste the selected text at the current cursor position
4639 DevelTextField::PasteText(textField);
4641 // Render and notify
4642 application.SendNotification();
4643 application.Render();
4645 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4650 int utcDaliTextFieldCursorPositionChangedSignal(void)
4652 ToolkitTestApplication application;
4653 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4655 TextField field = TextField::New();
4656 DALI_TEST_CHECK(field);
4658 application.GetScene().Add(field);
4660 // connect to the selection changed signal.
4661 ConnectionTracker* testTracker = new ConnectionTracker();
4662 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4663 bool cursorPositionChangedSignal = false;
4664 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4666 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4667 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4668 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4669 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4670 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4672 // Avoid a crash when core load gl resources.
4673 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4675 // Render and notify
4676 application.SendNotification();
4677 application.Render();
4679 field.SetKeyInputFocus();
4681 // Tap on the text field
4682 TestGenerateTap(application, 3.0f, 25.0f);
4684 // Render and notify
4685 application.SendNotification();
4686 application.Render();
4688 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4689 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4691 gCursorPositionChangedCallbackCalled = false;
4694 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4696 // Render and notify
4697 application.SendNotification();
4698 application.Render();
4700 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4701 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4703 gCursorPositionChangedCallbackCalled = false;
4706 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4708 // Render and notify
4709 application.SendNotification();
4710 application.Render();
4712 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4713 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4715 gCursorPositionChangedCallbackCalled = false;
4717 //delete one character
4718 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4720 // Render and notify
4721 application.SendNotification();
4722 application.Render();
4724 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4725 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4727 gCursorPositionChangedCallbackCalled = false;
4729 field.SetProperty(TextField::Property::TEXT, "Hello");
4731 // Render and notify
4732 application.SendNotification();
4733 application.Render();
4735 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4736 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4738 gCursorPositionChangedCallbackCalled = false;
4740 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4742 // Render and notify
4743 application.SendNotification();
4744 application.Render();
4746 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4747 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4752 int utcDaliTextFieldGeometryEllipsisStart(void)
4754 ToolkitTestApplication application;
4755 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4757 TextField field = TextField::New();
4758 DALI_TEST_CHECK(field);
4760 application.GetScene().Add(field);
4762 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4763 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4764 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4765 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4766 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4767 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4768 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4769 field.SetProperty(TextField::Property::TEXT, "Hello World");
4771 // Avoid a crash when core load gl resources.
4772 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4774 // Render and notify
4775 application.SendNotification();
4776 application.Render();
4778 unsigned int expectedCount = 1;
4779 unsigned int startIndex = 0;
4780 unsigned int endIndex = 10;
4782 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4783 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4785 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4786 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4788 Vector<Vector2> expectedSizes;
4789 Vector<Vector2> expectedPositions;
4791 expectedPositions.PushBack(Vector2(14, 0));
4792 expectedSizes.PushBack(Vector2(106, 25));
4794 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4799 int utcDaliTextFieldGeometryEllipsisEnd(void)
4801 ToolkitTestApplication application;
4802 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4804 TextField field = TextField::New();
4805 DALI_TEST_CHECK(field);
4807 application.GetScene().Add(field);
4809 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4810 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4811 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4812 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4813 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4814 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4815 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4816 field.SetProperty(TextField::Property::TEXT, "Hello World");
4818 // Avoid a crash when core load gl resources.
4819 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4821 // Render and notify
4822 application.SendNotification();
4823 application.Render();
4825 unsigned int expectedCount = 1;
4826 unsigned int startIndex = 0;
4827 unsigned int endIndex = 10;
4829 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4830 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4832 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4833 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4835 Vector<Vector2> expectedSizes;
4836 Vector<Vector2> expectedPositions;
4838 expectedPositions.PushBack(Vector2(-2, 0));
4839 expectedSizes.PushBack(Vector2(122, 25));
4841 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4846 int utcDaliTextFieldGeometryRTL(void)
4848 ToolkitTestApplication application;
4849 tet_infoline(" utcDaliTextFieldGeometryRTL");
4851 TextField field = TextField::New();
4852 DALI_TEST_CHECK(field);
4854 application.GetScene().Add(field);
4856 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4857 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4858 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4859 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4860 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4861 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4863 // Avoid a crash when core load gl resources.
4864 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4866 // Render and notify
4867 application.SendNotification();
4868 application.Render();
4870 unsigned int expectedCount = 1;
4871 unsigned int startIndex = 1;
4872 unsigned int endIndex = 7;
4874 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4875 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4877 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4878 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4880 Vector<Vector2> expectedSizes;
4881 Vector<Vector2> expectedPositions;
4883 expectedPositions.PushBack(Vector2(38, 0));
4884 expectedSizes.PushBack(Vector2(73, 25));
4886 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4891 int utcDaliTextFieldGeometryGlyphMiddle(void)
4893 ToolkitTestApplication application;
4894 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4896 TextField field = TextField::New();
4897 DALI_TEST_CHECK(field);
4899 application.GetScene().Add(field);
4901 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4902 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4903 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4904 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4905 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4906 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4908 // Avoid a crash when core load gl resources.
4909 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4911 // Render and notify
4912 application.SendNotification();
4913 application.Render();
4915 unsigned int expectedCount = 1;
4916 unsigned int startIndex = 1;
4917 unsigned int endIndex = 13;
4919 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4920 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4922 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4923 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4925 Vector<Vector2> expectedSizes;
4926 Vector<Vector2> expectedPositions;
4928 expectedPositions.PushBack(Vector2(6, 0));
4929 expectedSizes.PushBack(Vector2(124, 25));
4931 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4937 int utcDaliTextFieldGeometryNullPtr(void)
4939 ToolkitTestApplication application;
4940 tet_infoline("utcDaliTextFieldGeometryNullPtr");
4942 TextField field = TextField::New();
4943 DALI_TEST_CHECK(field);
4945 application.GetScene().Add(field);
4947 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4948 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
4949 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4950 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4951 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4952 field.SetProperty(TextField::Property::TEXT, "");
4954 // Avoid a crash when core load gl resources.
4955 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4957 unsigned int expectedCount = 0;
4958 unsigned int startIndex = 0;
4959 unsigned int endIndex = 0;
4961 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4962 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4964 // Render and notify
4965 application.SendNotification();
4966 application.Render();
4968 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4969 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4974 int utcDaliTextFieldSelectionClearedSignal(void)
4976 ToolkitTestApplication application;
4977 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4979 TextField field = TextField::New();
4980 DALI_TEST_CHECK(field);
4982 application.GetScene().Add(field);
4984 // connect to the selection changed signal.
4985 ConnectionTracker* testTracker = new ConnectionTracker();
4986 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4987 bool selectionClearedSignal = false;
4988 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4990 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4991 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4992 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4993 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4994 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4996 // Avoid a crash when core load gl resources.
4997 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4999 // Render and notify
5000 application.SendNotification();
5001 application.Render();
5003 // Tap on the text editor
5004 TestGenerateTap(application, 3.0f, 25.0f);
5006 // Render and notify
5007 application.SendNotification();
5008 application.Render();
5010 // Move to second line of the text & Select some text in the right of the current cursor position
5011 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5012 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5015 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5017 // Render and notify
5018 application.SendNotification();
5019 application.Render();
5021 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5023 // Render and notify
5024 application.SendNotification();
5025 application.Render();
5027 // Tap on the text editor
5028 TestGenerateTap(application, 3.0f, 25.0f);
5030 // Render and notify
5031 application.SendNotification();
5032 application.Render();
5034 gSelectionClearedCallbackCalled = false;
5036 // Move to second line of the text & select.
5037 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5038 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5041 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5043 // Render and notify
5044 application.SendNotification();
5045 application.Render();
5047 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5049 gSelectionClearedCallbackCalled = false;
5051 // Render and notify
5052 application.SendNotification();
5053 application.Render();
5055 // Move to second line of the text & select.
5056 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5057 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5059 // replace D with selected text
5060 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5062 // Render and notify
5063 application.SendNotification();
5064 application.Render();
5066 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5068 gSelectionClearedCallbackCalled = false;
5070 // Render and notify
5071 application.SendNotification();
5072 application.Render();
5074 DevelTextField::SelectText(field, 1, 3);
5076 // Render and notify
5077 application.SendNotification();
5078 application.Render();
5080 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5082 // Render and notify
5083 application.SendNotification();
5084 application.Render();
5086 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5088 gSelectionClearedCallbackCalled = false;
5090 DevelTextField::SelectText(field, 1, 3);
5092 // Render and notify
5093 application.SendNotification();
5094 application.Render();
5097 DevelTextField::SelectNone(field);
5099 // Render and notify
5100 application.SendNotification();
5101 application.Render();
5103 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5108 int utcDaliTextFieldSelectionStartedSignal(void)
5110 ToolkitTestApplication application;
5111 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5113 TextField field = TextField::New();
5114 DALI_TEST_CHECK(field);
5116 application.GetScene().Add(field);
5118 // connect to the selection changed signal.
5119 ConnectionTracker* testTracker = new ConnectionTracker();
5120 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5121 bool selectionStartedSignal = false;
5122 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5124 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5125 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5126 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5127 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5128 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5130 // Avoid a crash when core load gl resources.
5131 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5133 // Render and notify
5134 application.SendNotification();
5135 application.Render();
5137 // Tap on the text field
5138 TestGenerateTap(application, 3.0f, 25.0f);
5140 // Render and notify
5141 application.SendNotification();
5142 application.Render();
5144 // Move to second line of the text & Select some text in the right of the current cursor position
5145 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5146 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5148 // Render and notify
5149 application.SendNotification();
5150 application.Render();
5152 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5155 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5157 // Render and notify
5158 application.SendNotification();
5159 application.Render();
5161 gSelectionStartedCallbackCalled = false;
5163 DevelTextField::SelectText(field, 1, 3);
5165 // Render and notify
5166 application.SendNotification();
5167 application.Render();
5169 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5174 int utcDaliTextFieldSelectionChangedSignal(void)
5176 ToolkitTestApplication application;
5177 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5179 TextField field = TextField::New();
5180 DALI_TEST_CHECK(field);
5182 application.GetScene().Add(field);
5184 // connect to the selection changed signal.
5185 ConnectionTracker* testTracker = new ConnectionTracker();
5186 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5187 bool selectionChangedSignal = false;
5188 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5190 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5191 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5192 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5193 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5194 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5196 // Avoid a crash when core load gl resources.
5197 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5199 // Render and notify
5200 application.SendNotification();
5201 application.Render();
5203 // Tap on the text field
5204 TestGenerateTap(application, 3.0f, 25.0f);
5206 // Render and notify
5207 application.SendNotification();
5208 application.Render();
5210 // Select some text in the right of the current cursor position
5211 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5212 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5214 // Render and notify
5215 application.SendNotification();
5216 application.Render();
5218 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5219 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5221 gSelectionChangedCallbackCalled = false;
5223 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5225 // Render and notify
5226 application.SendNotification();
5227 application.Render();
5229 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5230 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5231 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5233 gSelectionChangedCallbackCalled = false;
5235 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5237 // Render and notify
5238 application.SendNotification();
5239 application.Render();
5241 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5242 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5243 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5245 gSelectionChangedCallbackCalled = false;
5246 field.SetKeyInputFocus();
5248 // Render and notify
5249 application.SendNotification();
5250 application.Render();
5252 DevelTextField::SelectText(field, 0, 5);
5254 application.SendNotification();
5255 application.Render();
5257 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5258 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5260 gSelectionChangedCallbackCalled = false;
5262 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5264 // Render and notify
5265 application.SendNotification();
5266 application.Render();
5268 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5269 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5270 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5272 gSelectionChangedCallbackCalled = false;
5275 DevelTextField::SelectWholeText(field);
5277 // Render and notify
5278 application.SendNotification();
5279 application.Render();
5281 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5282 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5284 gSelectionChangedCallbackCalled = false;
5287 DevelTextField::SelectNone(field);
5289 // Render and notify
5290 application.SendNotification();
5291 application.Render();
5293 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5294 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5295 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5300 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5302 ToolkitTestApplication application;
5303 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5305 TextField textField = TextField::New();
5306 textField.SetProperty(TextField::Property::TEXT, "Test");
5307 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5308 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5309 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5311 application.GetScene().Add(textField);
5312 application.SendNotification();
5313 application.Render();
5315 Property::Map strikethroughMapSet;
5316 Property::Map strikethroughMapGet;
5318 strikethroughMapSet.Insert("enable", true);
5319 strikethroughMapSet.Insert("color", Color::RED);
5320 strikethroughMapSet.Insert("height", 2.0f);
5322 // Check the strikethrough property
5323 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5324 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5325 textField.SetProperty(TextField::Property::TEXT, "Test1");
5326 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5327 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5329 // Render and notify
5330 application.SendNotification();
5331 application.Render();
5333 strikethroughMapSet.Clear();
5334 strikethroughMapGet.Clear();
5339 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5341 ToolkitTestApplication application;
5342 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5344 TextField textField = TextField::New();
5345 textField.SetProperty(TextField::Property::TEXT, "Test");
5346 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5347 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5348 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5350 application.GetScene().Add(textField);
5351 application.SendNotification();
5352 application.Render();
5354 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5356 // Check the strikethrough property
5357 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5358 textField.SetProperty(TextField::Property::TEXT, "Test1");
5359 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5361 // Render and notify
5362 application.SendNotification();
5363 application.Render();
5368 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5370 ToolkitTestApplication application;
5371 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5372 TextField field = TextField::New();
5373 field.SetProperty(TextField::Property::TEXT, "Test");
5374 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5375 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5376 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5378 application.GetScene().Add(field);
5379 application.SendNotification();
5380 application.Render();
5382 Property::Map underlineMapSet;
5383 Property::Map underlineMapGet;
5385 underlineMapSet.Insert("enable", true);
5386 underlineMapSet.Insert("color", Color::RED);
5387 underlineMapSet.Insert("height", 1);
5388 underlineMapSet.Insert("type", Text::Underline::SOLID);
5389 underlineMapSet.Insert("dashWidth", 2);
5390 underlineMapSet.Insert("dashGap", 1);
5392 // Check the underline property
5393 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5395 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5396 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5397 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5399 // Render and notify
5400 application.SendNotification();
5401 application.Render();
5403 underlineMapSet.Clear();
5404 underlineMapGet.Clear();
5406 underlineMapSet.Insert("enable", true);
5407 underlineMapSet.Insert("color", Color::BLUE);
5408 underlineMapSet.Insert("height", 1);
5409 underlineMapSet.Insert("type", Text::Underline::DASHED);
5410 underlineMapSet.Insert("dashWidth", 4);
5411 underlineMapSet.Insert("dashGap", 2);
5413 // Check the dashed underline property
5414 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5416 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5417 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5418 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5420 // Render and notify
5421 application.SendNotification();
5422 application.Render();
5424 underlineMapSet.Clear();
5425 underlineMapGet.Clear();
5427 underlineMapSet.Insert("enable", true);
5428 underlineMapSet.Insert("color", Color::BLUE);
5429 underlineMapSet.Insert("height", 1);
5430 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5431 underlineMapSet.Insert("dashWidth", 4);
5432 underlineMapSet.Insert("dashGap", 2);
5434 // Check the dashed underline property
5435 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5437 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5438 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5439 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5441 // Render and notify
5442 application.SendNotification();
5443 application.Render();
5445 underlineMapSet.Clear();
5446 underlineMapGet.Clear();
5451 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5453 ToolkitTestApplication application;
5454 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5456 TextField field1 = TextField::New();
5457 field1.SetProperty(TextField::Property::TEXT, "Test");
5458 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5459 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5460 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5462 Property::Map underlineMapSet1;
5463 Property::Map underlineMapGet1;
5465 underlineMapSet1.Insert("enable", true);
5466 underlineMapSet1.Insert("color", Color::RED);
5467 underlineMapSet1.Insert("height", 1);
5468 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5469 underlineMapSet1.Insert("dashWidth", 2);
5470 underlineMapSet1.Insert("dashGap", 1);
5472 // Check the underline property
5473 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5475 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5476 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5477 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5479 application.GetScene().Add(field1);
5480 application.SendNotification();
5481 application.Render();
5483 TextField field2 = TextField::New();
5484 field2.SetProperty(TextField::Property::TEXT, "Test");
5485 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5486 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5487 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5489 Property::Map underlineMapSet2;
5490 Property::Map underlineMapGet2;
5492 underlineMapSet2.Insert("enable", true);
5493 underlineMapSet2.Insert("color", Color::BLUE);
5494 underlineMapSet2.Insert("height", 1);
5495 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5496 underlineMapSet2.Insert("dashWidth", 4);
5497 underlineMapSet2.Insert("dashGap", 2);
5499 // Check the dashed underline property
5500 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5502 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5503 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5504 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5506 application.GetScene().Add(field2);
5507 application.SendNotification();
5508 application.Render();
5510 TextField field3 = TextField::New();
5511 field3.SetProperty(TextField::Property::TEXT, "Test");
5512 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5513 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5514 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5516 Property::Map underlineMapSet3;
5517 Property::Map underlineMapGet3;
5519 underlineMapSet3.Insert("enable", true);
5520 underlineMapSet3.Insert("color", Color::BLUE);
5521 underlineMapSet3.Insert("height", 1);
5522 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5523 underlineMapSet3.Insert("dashWidth", 4);
5524 underlineMapSet3.Insert("dashGap", 2);
5526 // Check the dashed underline property
5527 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5529 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5530 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5531 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5533 application.GetScene().Add(field3);
5535 application.SendNotification();
5536 application.Render();
5541 int UtcDaliTextFieldCharacterSpacing(void)
5543 ToolkitTestApplication application;
5544 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5546 TextField textField = TextField::New();
5548 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5550 application.GetScene().Add(textField);
5551 application.SendNotification();
5552 application.Render();
5554 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5555 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5556 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5558 application.SendNotification();
5559 application.Render();
5564 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5566 ToolkitTestApplication application;
5567 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5569 TextField field1 = TextField::New();
5570 field1.SetProperty(TextField::Property::TEXT, "Test1");
5571 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5572 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5573 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5575 Property::Map underlineMapSet1;
5576 Property::Map underlineMapGet1;
5578 underlineMapSet1.Insert("enable", true);
5579 underlineMapSet1.Insert("color", Color::RED);
5580 underlineMapSet1.Insert("height", 1);
5581 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5582 underlineMapSet1.Insert("dashWidth", 2);
5583 underlineMapSet1.Insert("dashGap", 1);
5585 // Check the underline property
5586 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5587 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5589 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5590 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5591 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5593 application.GetScene().Add(field1);
5594 application.SendNotification();
5595 application.Render();
5600 int UtcDaliToolkitTextfieldParagraphTag(void)
5602 ToolkitTestApplication application;
5603 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5604 TextField fieldNewlineSeparator = TextField::New();
5605 TextField fieldParagraphTag = TextField::New();
5606 DALI_TEST_CHECK(fieldNewlineSeparator);
5607 DALI_TEST_CHECK(fieldParagraphTag);
5609 application.GetScene().Add(fieldNewlineSeparator);
5610 application.GetScene().Add(fieldParagraphTag);
5612 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5613 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5614 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5615 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5616 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5617 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5619 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5620 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5621 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5622 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5623 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5625 application.SendNotification();
5626 application.Render();
5628 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5629 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5631 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5633 application.SendNotification();
5634 application.Render();
5639 //Handle Emoji clustering for cursor handling
5640 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5642 ToolkitTestApplication application;
5643 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5644 TextField textField = TextField::New();
5645 DALI_TEST_CHECK(textField);
5647 application.GetScene().Add(textField);
5649 // Avoid a crash when core load gl resources.
5650 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5652 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5653 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5655 // Render and notify
5656 application.SendNotification();
5657 application.Render();
5660 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5661 application.SendNotification();
5662 application.Render();
5664 // Set focus and remove Emoji
5665 textField.SetKeyInputFocus();
5666 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5668 //Check the changed text and cursor position
5669 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5670 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5672 // Render and notify
5673 application.SendNotification();
5674 application.Render();
5679 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5681 ToolkitTestApplication application;
5682 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5683 TextField textField = TextField::New();
5684 DALI_TEST_CHECK(textField);
5686 application.GetScene().Add(textField);
5688 // Avoid a crash when core load gl resources.
5689 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5691 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5692 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5694 // Render and notify
5695 application.SendNotification();
5696 application.Render();
5699 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5700 application.SendNotification();
5701 application.Render();
5703 // Set focus and remove Emoji
5704 textField.SetKeyInputFocus();
5705 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5707 //Check the changed text and cursor position
5708 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5709 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5711 // Render and notify
5712 application.SendNotification();
5713 application.Render();
5718 int utcDaliTextFieldPanGesturePropagation(void)
5720 ToolkitTestApplication application;
5721 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5723 Actor actor = Actor::New();
5724 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5725 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5726 application.GetScene().Add(actor);
5728 TextField field = TextField::New();
5729 DALI_TEST_CHECK(field);
5731 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5732 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5734 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5735 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5736 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5740 // Render and notify
5741 application.SendNotification();
5742 application.Render();
5745 GestureReceivedFunctor functor(data);
5747 PanGestureDetector detector = PanGestureDetector::New();
5748 detector.Attach(actor);
5749 detector.DetectedSignal().Connect(&application, functor);
5751 // Tap first to get the focus.
5752 TestGenerateTap(application, 3.0f, 25.0f, 100);
5754 // Render and notify
5755 application.SendNotification();
5756 application.Render();
5758 // Pan the text field
5759 uint32_t time = 100;
5760 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5761 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5762 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5763 application.SendNotification();
5764 application.Render();
5766 // The text scrolls because there is text that is scrolling.
5767 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5770 // Set the size large enough to prevent scrolling.
5771 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5773 // Render and notify
5774 application.SendNotification();
5775 application.Render();
5778 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5779 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5780 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5782 // Because scrolling is not possible, the pan gesture is propagated.
5783 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);