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.
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/public-api/rendering/renderer.h>
26 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
29 #include <dali-toolkit/devel-api/text/rendering-backend.h>
30 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
31 #include <dali/devel-api/adaptor-framework/key-devel.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include "test-text-geometry-utils.h"
34 #include "toolkit-clipboard.h"
37 using namespace Toolkit;
39 void dali_textfield_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_textfield_cleanup(void)
46 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
98 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
100 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
101 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
102 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
103 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
104 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
105 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
107 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
110 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
111 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
112 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
113 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
115 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
116 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
118 const float RENDER_FRAME_INTERVAL = 16.66f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR("/resources/fonts");
123 const int KEY_RETURN_CODE = 36;
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
126 const int KEY_SHIFT_MODIFIER = 257;
128 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130 static bool gSelectionChangedCallbackCalled;
131 static uint32_t oldSelectionStart;
132 static uint32_t oldSelectionEnd;
133 static bool gSelectionClearedCallbackCalled;
134 static bool gSelectionStartedCallbackCalled;
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gCursorPositionChangedCallbackCalled;
143 static uint32_t oldCursorPos;
144 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
146 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
148 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
149 Integration::ResourcePointer resource(bitmap);
150 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
153 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
157 LoadBitmapResource(app.GetPlatform(), width, height);
159 Property::Map propertyMap;
160 propertyMap["filename"] = "image.png";
161 propertyMap["width"] = width;
162 propertyMap["height"] = height;
163 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
164 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
165 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
174 * Simulate time passed by.
176 * @note this will always process at least 1 frame (1/60 sec)
178 * @param application Test application instance
179 * @param duration Time to pass in milliseconds.
180 * @return The actual time passed in milliseconds
182 static int Wait(ToolkitTestApplication& application, int duration = 0)
186 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
188 application.SendNotification();
189 application.Render(RENDER_FRAME_INTERVAL);
190 time += RENDER_FRAME_INTERVAL;
196 Dali::Integration::Point GetPointDownInside(Vector2& pos)
198 Dali::Integration::Point point;
199 point.SetState(PointState::DOWN);
200 point.SetScreenPosition(pos);
204 Dali::Integration::Point GetPointUpInside(Vector2& pos)
206 Dali::Integration::Point point;
207 point.SetState(PointState::UP);
208 point.SetScreenPosition(pos);
212 struct CallbackFunctor
214 CallbackFunctor(bool* callbackFlag)
215 : mCallbackFlag(callbackFlag)
221 *mCallbackFlag = true;
226 static void TestSelectionClearedCallback(TextField control)
228 tet_infoline(" TestSelectionClearedCallback");
230 gSelectionClearedCallbackCalled = true;
233 static void TestSelectionStartedCallback(TextField control)
235 tet_infoline(" TestSelectionStartedCallback");
237 gSelectionStartedCallbackCalled = true;
240 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
242 tet_infoline(" TestSelectionChangedCallback");
244 gSelectionChangedCallbackCalled = true;
245 oldSelectionStart = oldStart;
246 oldSelectionEnd = oldEnd;
249 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
251 tet_infoline(" TestAnchorClickedCallback");
253 gAnchorClickedCallBackNotCalled = false;
255 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
257 gAnchorClickedCallBackCalled = true;
261 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
263 tet_infoline(" TestCursorPositionChangedCallback");
265 gCursorPositionChangedCallbackCalled = true;
266 oldCursorPos = oldPos;
269 static void TestTextChangedCallback(TextField control)
271 tet_infoline(" TestTextChangedCallback");
273 gTextChangedCallBackCalled = true;
276 static void TestMaxLengthReachedCallback(TextField control)
278 tet_infoline(" TestMaxLengthReachedCallback");
280 gMaxCharactersCallBackCalled = true;
283 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
285 tet_infoline(" TestInputFilteredCallback");
287 if(type == Toolkit::InputFilter::Property::ACCEPTED)
289 gInputFilteredAcceptedCallbackCalled = true;
291 else if(type == Toolkit::InputFilter::Property::REJECTED)
293 gInputFilteredRejectedCallbackCalled = true;
297 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
299 tet_infoline(" TestInputStyleChangedCallback");
301 gInputStyleChangedCallbackCalled = true;
302 gInputStyleMask = mask;
305 // Generate a KeyEvent to send to Core.
306 Integration::KeyEvent GenerateKey(const std::string& keyName,
307 const std::string& logicalKey,
308 const std::string& keyString,
311 unsigned long timeStamp,
312 const Integration::KeyEvent::State& keyState,
313 const std::string& compose = "",
314 const std::string& deviceName = DEFAULT_DEVICE_NAME,
315 const Device::Class::Type& deviceClass = Device::Class::NONE,
316 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
318 return Integration::KeyEvent(keyName,
331 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
333 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
335 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
337 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
339 Property::Value* valueSet = NULL;
340 if(valueGet.first.type == Property::Key::INDEX)
342 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
346 // Get Key is a string so searching Set Map for a string key
347 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
352 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
354 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
357 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
359 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
362 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
364 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
367 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
369 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
372 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
374 Vector2 vector2Get = valueGet.second.Get<Vector2>();
375 Vector2 vector2Set = valueSet->Get<Vector2>();
376 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
379 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
381 Vector4 vector4Get = valueGet.second.Get<Vector4>();
382 Vector4 vector4Set = valueSet->Get<Vector4>();
383 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);
389 if(valueGet.first.type == Property::Key::INDEX)
391 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
395 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
407 int UtcDaliToolkitTextFieldConstructorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
412 DALI_TEST_CHECK(!textField);
416 int UtcDaliToolkitTextFieldNewP(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextFieldNewP");
420 TextField textField = TextField::New();
421 DALI_TEST_CHECK(textField);
425 int UtcDaliToolkitTextFieldDownCastP(void)
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
429 TextField textField1 = TextField::New();
430 BaseHandle object(textField1);
432 TextField textField2 = TextField::DownCast(object);
433 DALI_TEST_CHECK(textField2);
435 TextField textField3 = DownCast<TextField>(object);
436 DALI_TEST_CHECK(textField3);
440 int UtcDaliToolkitTextFieldDownCastN(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
444 BaseHandle uninitializedObject;
445 TextField textField1 = TextField::DownCast(uninitializedObject);
446 DALI_TEST_CHECK(!textField1);
448 TextField textField2 = DownCast<TextField>(uninitializedObject);
449 DALI_TEST_CHECK(!textField2);
453 int UtcDaliToolkitTextFieldCopyConstructorP(void)
455 ToolkitTestApplication application;
456 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
457 TextField textField = TextField::New();
458 textField.SetProperty(TextField::Property::TEXT, "Test");
460 TextField copy(textField);
461 DALI_TEST_CHECK(copy);
462 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
466 int UtcDaliTextFieldMoveConstructor(void)
468 ToolkitTestApplication application;
470 TextField textField = TextField::New();
471 textField.SetProperty(TextEditor::Property::TEXT, "Test");
472 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
474 TextField moved = std::move(textField);
475 DALI_TEST_CHECK(moved);
476 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
477 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
478 DALI_TEST_CHECK(!textField);
483 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
485 ToolkitTestApplication application;
486 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
487 TextField textField = TextField::New();
488 textField.SetProperty(TextField::Property::TEXT, "Test");
490 TextField copy = textField;
491 DALI_TEST_CHECK(copy);
492 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
496 int UtcDaliTextFieldMoveAssignment(void)
498 ToolkitTestApplication application;
500 TextField textField = TextField::New();
501 textField.SetProperty(TextEditor::Property::TEXT, "Test");
502 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
505 moved = std::move(textField);
506 DALI_TEST_CHECK(moved);
507 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
508 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
509 DALI_TEST_CHECK(!textField);
514 int UtcDaliTextFieldNewP(void)
516 ToolkitTestApplication application;
517 tet_infoline(" UtcDaliToolkitTextFieldNewP");
518 TextField textField = TextField::New();
519 DALI_TEST_CHECK(textField);
523 // Positive test case for a method
524 int UtcDaliTextFieldGetPropertyP(void)
526 ToolkitTestApplication application;
527 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
528 TextField field = TextField::New();
529 DALI_TEST_CHECK(field);
531 // Check Property Indices are correct
532 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
533 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
534 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
535 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
536 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
537 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
538 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
539 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
540 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
541 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
542 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
543 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
544 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
545 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
546 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
547 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
548 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
549 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
550 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
551 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
552 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
553 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
554 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
555 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
556 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
557 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
558 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
559 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
560 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
561 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
562 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
563 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
564 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
565 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
566 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
567 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
568 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
569 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
570 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
571 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
572 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
573 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
574 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
575 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
576 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
577 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
578 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
579 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
580 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
581 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
582 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
583 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
585 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
597 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
600 Property::Map imageMap;
601 imageMap[mapKey] = mapValue;
603 field.SetProperty(property, imageMap);
604 Property::Value propValue = field.GetProperty(property);
605 Property::Map* resultMap = propValue.GetMap();
607 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
615 // Positive test case for a method
616 int UtcDaliTextFieldSetPropertyP(void)
618 ToolkitTestApplication application;
619 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
620 TextField field = TextField::New();
621 DALI_TEST_CHECK(field);
622 application.GetScene().Add(field);
624 // Note - we can't check the defaults since the stylesheets are platform-specific
626 // Check the render backend property.
627 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
628 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
630 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
631 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
633 // Check text property.
634 field.SetProperty(TextField::Property::TEXT, "Setting Text");
635 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
637 // Check placeholder text properties.
638 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
639 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
641 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
642 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
644 // Check font properties.
645 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
646 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
648 Property::Map fontStyleMapSet;
649 Property::Map fontStyleMapGet;
650 Property::Value* slantValue = NULL;
652 fontStyleMapSet.Insert("weight", "bold");
653 fontStyleMapSet.Insert("width", "condensed");
654 fontStyleMapSet.Insert("slant", "italic");
655 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
657 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
658 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
659 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
661 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
662 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
664 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
665 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
666 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
668 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
669 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
670 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
673 fontStyleMapSet.Clear();
674 fontStyleMapSet.Insert("weight", "normal");
675 fontStyleMapSet.Insert("slant", "oblique");
676 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
678 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
679 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
680 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
682 fontStyleMapSet.Clear();
683 fontStyleMapSet.Insert("slant", "roman");
684 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
685 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
687 // Replace 'roman' for 'normal'.
688 slantValue = fontStyleMapGet.Find("slant");
689 if(NULL != slantValue)
691 if("normal" == slantValue->Get<std::string>())
693 fontStyleMapGet["slant"] = "roman";
696 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
697 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
699 fontStyleMapSet.Clear();
701 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
702 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
703 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
704 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
706 // Check that the MAX_LENGTH property can be correctly set
707 const int maxNumberOfCharacters = 20;
708 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
709 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
711 // Check exceed policy
712 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
713 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
714 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
715 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
717 // Check that the Alignment properties can be correctly set
718 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
719 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
720 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
721 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
723 // Check text's color property
724 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
725 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
727 // Check placeholder text's color property.
728 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
729 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
731 // Check cursor properties
732 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
733 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
734 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
735 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
737 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
738 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
739 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
740 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
741 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
742 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
743 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
744 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
746 // Check scroll properties.
747 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
748 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
749 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
750 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
752 // Check handle images
753 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
754 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
755 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
756 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
757 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
759 // Check handle images
760 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
761 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
762 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
763 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
764 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
765 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
767 // Check the highlight color
768 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
769 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
771 // Decoration bounding box
772 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
773 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
775 // Check the input method setting
776 Property::Map propertyMap;
777 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
778 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
779 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
780 int inputVariation = 1;
781 propertyMap["PANEL_LAYOUT"] = panelLayout;
782 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
783 propertyMap["BUTTON_ACTION"] = buttonAction;
784 propertyMap["VARIATION"] = inputVariation;
785 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
787 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
789 DALI_TEST_CHECK(value.Get(map));
792 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
793 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
796 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
797 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
800 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
801 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
804 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
805 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
807 // Check input color property.
808 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
809 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
811 // Check the enable markup property.
812 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
813 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
814 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
816 // Check input font properties.
817 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
818 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
820 fontStyleMapSet.Clear();
821 fontStyleMapSet.Insert("weight", "bold");
822 fontStyleMapSet.Insert("width", "condensed");
823 fontStyleMapSet.Insert("slant", "italic");
825 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
826 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
827 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
828 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
830 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
831 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
833 // Reset input font style.
834 fontStyleMapSet.Clear();
835 fontStyleMapSet.Insert("weight", "normal");
836 fontStyleMapSet.Insert("slant", "oblique");
838 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
839 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
840 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
841 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
843 fontStyleMapSet.Clear();
844 fontStyleMapSet.Insert("slant", "roman");
846 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
847 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
849 // Replace 'roman' for 'normal'.
850 slantValue = fontStyleMapGet.Find("slant");
851 if(NULL != slantValue)
853 if("normal" == slantValue->Get<std::string>())
855 fontStyleMapGet["slant"] = "roman";
858 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
859 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
861 fontStyleMapSet.Clear();
863 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
864 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
865 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
866 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
868 Property::Map strikethroughMapSet;
869 Property::Map strikethroughMapGet;
871 strikethroughMapSet.Insert("enable", true);
872 strikethroughMapSet.Insert("color", Color::RED);
873 strikethroughMapSet.Insert("height", 2.0f);
875 // Check the strikethrough property
876 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
878 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
879 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
880 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
882 // Check the input strikethrough property
883 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
884 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
886 Property::Map underlineMapSet;
887 Property::Map underlineMapGet;
889 underlineMapSet.Insert("enable", true);
890 underlineMapSet.Insert("color", Color::RED);
891 underlineMapSet.Insert("height", 1);
892 underlineMapSet.Insert("type", Text::Underline::SOLID);
893 underlineMapSet.Insert("dashWidth", 2);
894 underlineMapSet.Insert("dashGap", 1);
896 // Check the underline property
897 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
899 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
900 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
901 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
904 application.SendNotification();
905 application.Render();
907 underlineMapSet.Clear();
908 underlineMapGet.Clear();
910 underlineMapSet.Insert("enable", true);
911 underlineMapSet.Insert("color", Color::BLUE);
912 underlineMapSet.Insert("height", 1);
913 underlineMapSet.Insert("type", Text::Underline::DASHED);
914 underlineMapSet.Insert("dashWidth", 4);
915 underlineMapSet.Insert("dashGap", 2);
917 // Check the dashed underline property
918 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
920 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
921 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
922 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
925 application.SendNotification();
926 application.Render();
928 underlineMapSet.Clear();
929 underlineMapGet.Clear();
931 underlineMapSet.Insert("enable", true);
932 underlineMapSet.Insert("color", Color::BLUE);
933 underlineMapSet.Insert("height", 4);
934 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
935 underlineMapSet.Insert("dashWidth", 4);
936 underlineMapSet.Insert("dashGap", 2);
938 // Check the dashed underline property
939 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
941 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
942 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
943 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
946 application.SendNotification();
947 application.Render();
949 underlineMapSet.Clear();
950 underlineMapGet.Clear();
952 // Check the input underline property
953 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
954 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
956 // Check the shadow property
957 Property::Map shadowMapSet;
958 Property::Map shadowMapGet;
960 shadowMapSet.Insert("color", Color::GREEN);
961 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
962 shadowMapSet.Insert("blurRadius", 3.0f);
964 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
966 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
967 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
968 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
970 // Check the input shadow property
971 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
972 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
974 // Check the emboss property
975 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
976 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
978 // Check the input emboss property
979 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
980 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
982 // Check the outline property
984 // Test string type first
985 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
986 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
987 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
989 // Then test the property map type
990 Property::Map outlineMapSet;
991 Property::Map outlineMapGet;
993 outlineMapSet["color"] = Color::RED;
994 outlineMapSet["width"] = 2.0f;
996 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
998 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
999 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1000 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1002 // Check the input outline property
1003 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1004 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1006 // Check the hidden input settings property
1007 Property::Map hiddenMapSet;
1008 Property::Map hiddenMapGet;
1009 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1010 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1011 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1012 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1013 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1015 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1016 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1017 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1019 // Check the pixel size of font
1020 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1021 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1023 // Check the enable selection property
1024 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1025 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1027 // Check the placeholder property with pixel size
1028 Property::Map placeholderPixelSizeMapSet;
1029 Property::Map placeholderPixelSizeMapGet;
1030 Property::Map placeholderFontstyleMap;
1031 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1032 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1033 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1034 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1035 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1036 placeholderPixelSizeMapSet["ellipsis"] = true;
1038 placeholderFontstyleMap.Insert("weight", "bold");
1039 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1040 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1042 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1043 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1045 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1046 Property::Map placeholderConversionMap;
1047 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1048 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1049 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1050 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1051 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1052 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1054 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1056 // Check the placeholder property with point size
1057 Property::Map placeholderMapSet;
1058 Property::Map placeholderMapGet;
1059 placeholderMapSet["text"] = "Setting Placeholder Text";
1060 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1061 placeholderMapSet["color"] = Color::RED;
1062 placeholderMapSet["fontFamily"] = "Arial";
1063 placeholderMapSet["pointSize"] = 12.0f;
1064 placeholderMapSet["ellipsis"] = false;
1066 // Check the placeholder font style property
1067 placeholderFontstyleMap.Clear();
1069 placeholderFontstyleMap.Insert("weight", "bold");
1070 placeholderFontstyleMap.Insert("width", "condensed");
1071 placeholderFontstyleMap.Insert("slant", "italic");
1072 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1073 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1075 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1076 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1078 placeholderConversionMap.Clear();
1079 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1080 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1081 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1082 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1083 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1084 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1086 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1088 // Reset font style.
1089 placeholderFontstyleMap.Clear();
1090 placeholderFontstyleMap.Insert("weight", "normal");
1091 placeholderFontstyleMap.Insert("slant", "oblique");
1092 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1093 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1095 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1096 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1098 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1099 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1101 placeholderFontstyleMap.Clear();
1102 placeholderFontstyleMap.Insert("slant", "roman");
1103 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1104 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1106 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1108 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1110 placeholderFontstyleMap.Clear();
1111 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1112 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1114 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1115 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1116 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1118 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1120 // Check the ellipsis property
1121 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1122 field.SetProperty(TextField::Property::ELLIPSIS, true);
1123 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1125 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1126 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1128 // Test the ENABLE_GRAB_HANDLE_POPUP property
1129 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1130 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1131 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1133 // Check the background property
1134 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1135 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1137 //Check handle color
1138 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1139 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1141 // Check the input filter property
1142 Property::Map inputFilterMapSet;
1143 Property::Map inputFilterMapGet;
1144 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1145 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1147 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1149 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1150 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1153 inputFilterMapSet.Clear();
1154 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1156 application.SendNotification();
1157 application.Render();
1162 // Positive Atlas Text Renderer test
1163 int utcDaliTextFieldAtlasRenderP(void)
1165 ToolkitTestApplication application;
1166 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1167 StyleManager styleManager = StyleManager::Get();
1168 styleManager.ApplyDefaultTheme();
1169 TextField field = TextField::New();
1170 DALI_TEST_CHECK(field);
1172 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1174 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1176 application.GetScene().Add(field);
1180 // Render some text with the shared atlas backend
1181 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1182 application.SendNotification();
1183 application.Render();
1187 tet_result(TET_FAIL);
1192 // Positive test for the anchorClicked signal.
1193 int utcDaliTextFieldAnchorClicked01(void)
1195 ToolkitTestApplication application;
1196 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1197 TextField field = TextField::New();
1198 DALI_TEST_CHECK(field);
1200 application.GetScene().Add(field);
1202 // connect to the anchor clicked signal.
1203 ConnectionTracker* testTracker = new ConnectionTracker();
1204 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1205 bool anchorClickedSignal = false;
1206 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1208 gAnchorClickedCallBackCalled = false;
1209 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1210 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1211 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1212 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1213 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1215 application.SendNotification();
1216 application.Render();
1217 field.SetKeyInputFocus();
1219 // Create a tap event to touch the text field.
1220 TestGenerateTap(application, 5.0f, 25.0f);
1221 application.SendNotification();
1222 application.Render();
1224 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1225 DALI_TEST_CHECK(anchorClickedSignal);
1227 gAnchorClickedCallBackNotCalled = true;
1228 // Tap the outside of anchor, callback should not be called.
1229 TestGenerateTap(application, 150.f, 100.f);
1230 application.SendNotification();
1231 application.Render();
1233 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1238 // Positive test for the anchorClicked signal.
1239 int utcDaliTextFieldAnchorClicked02(void)
1241 ToolkitTestApplication application;
1242 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1243 TextField field = TextField::New();
1244 DALI_TEST_CHECK(field);
1246 application.GetScene().Add(field);
1248 // connect to the anchor clicked signal.
1249 ConnectionTracker* testTracker = new ConnectionTracker();
1250 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1251 bool anchorClickedSignal = false;
1252 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1254 gAnchorClickedCallBackCalled = false;
1255 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1256 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1257 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1258 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1259 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1261 application.SendNotification();
1262 application.Render();
1263 field.SetKeyInputFocus();
1265 // Avoid a crash when core load gl resources.
1266 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1268 // Create a tap event to touch the text field.
1269 TestGenerateTap(application, 30.0f, 25.0f, 100);
1270 application.SendNotification();
1271 application.Render();
1273 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1274 DALI_TEST_CHECK(anchorClickedSignal);
1276 // For coverage InsertTextAnchor, RemoveTextAnchor
1277 // first index insert
1278 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1279 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1280 application.SendNotification();
1281 application.Render();
1283 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1284 application.SendNotification();
1285 application.Render();
1287 gAnchorClickedCallBackCalled = false;
1288 // Create a tap event to touch the text field.
1289 TestGenerateTap(application, 30.0f, 25.0f, 700);
1290 application.SendNotification();
1291 field.SetKeyInputFocus();
1293 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1295 // last index insert
1296 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1297 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1298 application.SendNotification();
1299 application.Render();
1301 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1302 application.SendNotification();
1303 application.Render();
1305 gAnchorClickedCallBackCalled = false;
1306 // Create a tap event to touch the text field.
1307 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1308 application.SendNotification();
1309 field.SetKeyInputFocus();
1311 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1314 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1315 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1316 application.SendNotification();
1317 application.Render();
1319 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1320 application.SendNotification();
1321 application.Render();
1323 gAnchorClickedCallBackCalled = false;
1324 // Create a tap event to touch the text field.
1325 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1326 application.SendNotification();
1327 field.SetKeyInputFocus();
1329 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1331 // first index remove
1332 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1333 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1334 application.SendNotification();
1335 application.Render();
1337 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1338 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));
1339 application.SendNotification();
1340 application.Render();
1342 gAnchorClickedCallBackCalled = false;
1343 // Create a tap event to touch the text field.
1344 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1345 application.SendNotification();
1346 field.SetKeyInputFocus();
1348 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1350 // last index remove
1351 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1352 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1353 application.SendNotification();
1354 application.Render();
1356 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357 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));
1358 application.SendNotification();
1359 application.Render();
1361 gAnchorClickedCallBackCalled = false;
1362 // Create a tap event to touch the text field.
1363 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1370 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1371 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1372 application.SendNotification();
1373 application.Render();
1375 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376 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));
1377 application.SendNotification();
1378 application.Render();
1380 gAnchorClickedCallBackCalled = false;
1381 // Create a tap event to touch the text field.
1382 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1388 // 0 ~ 1 index remove
1389 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1390 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1391 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1392 application.SendNotification();
1393 application.Render();
1395 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1396 application.SendNotification();
1397 application.Render();
1399 gAnchorClickedCallBackCalled = false;
1400 // Create a tap event to touch the text field.
1401 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1402 application.SendNotification();
1403 application.Render();
1405 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1407 // 1 ~ 3 index remove
1408 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1409 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1410 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1411 application.SendNotification();
1412 application.Render();
1414 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", 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, 4900);
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1426 // 3 ~ 4 index remove
1427 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1428 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1429 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1430 application.SendNotification();
1431 application.Render();
1433 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1434 application.SendNotification();
1435 application.Render();
1437 gAnchorClickedCallBackCalled = false;
1438 // Create a tap event to touch the text field.
1439 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1445 // Remove front of anchor
1446 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1447 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1448 application.SendNotification();
1449 application.Render();
1451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1452 application.SendNotification();
1453 application.Render();
1455 // Remove whole text
1456 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1457 DevelTextField::SelectWholeText(field);
1458 application.SendNotification();
1459 application.Render();
1461 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1462 application.SendNotification();
1463 application.Render();
1465 // Remove all with backspace
1466 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1467 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1468 application.SendNotification();
1469 application.Render();
1471 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1472 application.SendNotification();
1473 application.Render();
1475 // Remove all with delete
1476 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1477 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1478 application.SendNotification();
1479 application.Render();
1481 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));
1482 application.SendNotification();
1483 application.Render();
1488 // Positive test for the textChanged signal.
1489 int utcDaliTextFieldTextChangedP(void)
1491 ToolkitTestApplication application;
1492 tet_infoline(" utcDaliTextFieldTextChangedP");
1493 TextField field = TextField::New();
1494 DALI_TEST_CHECK(field);
1496 application.GetScene().Add(field);
1498 // connect to the text changed signal.
1499 ConnectionTracker* testTracker = new ConnectionTracker();
1500 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1501 bool textChangedSignal = false;
1502 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1504 gTextChangedCallBackCalled = false;
1505 field.SetProperty(TextField::Property::TEXT, "ABC");
1506 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1507 DALI_TEST_CHECK(textChangedSignal);
1509 application.SendNotification();
1510 field.SetKeyInputFocus();
1512 gTextChangedCallBackCalled = false;
1513 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1514 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1517 field.SetProperty(TextField::Property::TEXT, "");
1519 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1520 gTextChangedCallBackCalled = false;
1521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1522 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1524 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1525 gTextChangedCallBackCalled = false;
1526 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1527 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1532 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1534 ToolkitTestApplication application;
1535 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1536 TextField field = TextField::New();
1537 DALI_TEST_CHECK(field);
1539 application.GetScene().Add(field);
1541 // connect to the text changed signal.
1542 ConnectionTracker* testTracker = new ConnectionTracker();
1543 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1544 bool textChangedSignal = false;
1545 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1547 // get InputMethodContext
1549 InputMethodContext::EventData imfEvent;
1550 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1552 field.SetKeyInputFocus();
1553 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1556 gTextChangedCallBackCalled = false;
1557 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1558 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1562 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1564 gTextChangedCallBackCalled = false;
1565 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1566 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1567 application.SendNotification();
1568 application.Render();
1569 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1570 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1572 gTextChangedCallBackCalled = false;
1573 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1574 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1578 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1580 gTextChangedCallBackCalled = false;
1581 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1582 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1583 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1585 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1586 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1587 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1589 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1590 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1591 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1593 application.SendNotification();
1594 application.Render();
1595 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1596 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1601 // Negative test for the textChanged signal.
1602 int utcDaliTextFieldTextChangedN(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" utcDaliTextFieldTextChangedN");
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::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1619 application.SendNotification();
1620 application.Render();
1621 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1622 DALI_TEST_CHECK(!textChangedSignal);
1627 // Positive test for Max Characters reached signal.
1628 int utcDaliTextFieldMaxCharactersReachedP(void)
1630 ToolkitTestApplication application;
1631 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1632 TextField field = TextField::New();
1633 DALI_TEST_CHECK(field);
1635 application.GetScene().Add(field);
1637 const int maxNumberOfCharacters = 1;
1638 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1640 field.SetKeyInputFocus();
1642 // connect to the text changed signal.
1643 ConnectionTracker* testTracker = new ConnectionTracker();
1644 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1645 bool maxLengthReachedSignal = false;
1646 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1648 gMaxCharactersCallBackCalled = false;
1650 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1651 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1653 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1654 DALI_TEST_CHECK(maxLengthReachedSignal);
1659 // Negative test for Max Characters reached signal.
1660 int utcDaliTextFieldMaxCharactersReachedN(void)
1662 ToolkitTestApplication application;
1663 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1664 TextField field = TextField::New();
1665 DALI_TEST_CHECK(field);
1667 application.GetScene().Add(field);
1669 const int maxNumberOfCharacters = 3;
1670 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1672 field.SetKeyInputFocus();
1674 // connect to the text changed signal.
1675 ConnectionTracker* testTracker = new ConnectionTracker();
1676 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1677 bool maxLengthReachedSignal = false;
1678 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1680 gMaxCharactersCallBackCalled = false;
1682 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1683 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1685 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1686 DALI_TEST_CHECK(!maxLengthReachedSignal);
1688 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1690 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1691 DALI_TEST_CHECK(!maxLengthReachedSignal);
1696 // Positive test for Input Filtered signal.
1697 int utcDaliTextFieldInputFilteredP(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextFieldInputFilteredP");
1701 TextField field = TextField::New();
1702 DALI_TEST_CHECK(field);
1704 application.GetScene().Add(field);
1706 Property::Map inputFilter;
1708 // Only digit is accepted.
1709 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1711 // Set input filter to TextField.
1712 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1714 field.SetKeyInputFocus();
1716 // connect to the input filtered signal.
1717 ConnectionTracker* testTracker = new ConnectionTracker();
1718 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1719 bool inputFilteredSignal = false;
1720 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1722 gInputFilteredAcceptedCallbackCalled = false;
1724 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1727 DALI_TEST_CHECK(inputFilteredSignal);
1729 // Word is rejected.
1730 inputFilter[InputFilter::Property::ACCEPTED] = "";
1731 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1733 // Set input filter to TextField.
1734 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1736 field.SetKeyInputFocus();
1738 inputFilteredSignal = false;
1739 gInputFilteredRejectedCallbackCalled = false;
1741 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1743 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1744 DALI_TEST_CHECK(inputFilteredSignal);
1749 // Negative test for Input Filtered signal.
1750 int utcDaliTextFieldInputFilteredN(void)
1752 ToolkitTestApplication application;
1753 tet_infoline(" utcDaliTextFieldInputFilteredP");
1754 TextField field = TextField::New();
1755 DALI_TEST_CHECK(field);
1757 application.GetScene().Add(field);
1759 Property::Map inputFilter;
1761 // Only word is accepted.
1762 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1764 // Set input filter to TextField.
1765 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1767 field.SetKeyInputFocus();
1769 // connect to the input filtered signal.
1770 ConnectionTracker* testTracker = new ConnectionTracker();
1771 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1772 bool inputFilteredSignal = false;
1773 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1775 gInputFilteredAcceptedCallbackCalled = false;
1777 // Key a, d should not be filtered.
1778 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1780 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1781 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1783 // Backspace, Delete should not be filtered.
1784 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1785 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));
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1792 DALI_TEST_CHECK(!inputFilteredSignal);
1794 // Digit is rejected.
1795 inputFilter[InputFilter::Property::ACCEPTED] = "";
1796 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1798 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1800 field.SetKeyInputFocus();
1802 inputFilteredSignal = false;
1803 gInputFilteredRejectedCallbackCalled = false;
1805 // Key a, d should not be filtered.
1806 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1807 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1808 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1809 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1811 // Backspace, Delete should not be filtered.
1812 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1813 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));
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1820 DALI_TEST_CHECK(!inputFilteredSignal);
1825 int utcDaliTextFieldInputStyleChanged01(void)
1827 // The text-field emits signals when the input style changes. These changes of style are
1828 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1829 // can't be emitted during the size negotiation as the callbacks may update the UI.
1830 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1831 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1832 ToolkitTestApplication application;
1833 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1837 char* pathNamePtr = get_current_dir_name();
1838 const std::string pathName(pathNamePtr);
1841 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1842 fontClient.SetDpi(93u, 93u);
1844 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1845 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1847 TextField field = TextField::New();
1848 DALI_TEST_CHECK(field);
1850 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1851 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1852 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1854 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1855 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1857 // connect to the text changed signal.
1858 ConnectionTracker* testTracker = new ConnectionTracker();
1859 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1860 bool inputStyleChangedSignal = false;
1861 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1863 application.GetScene().Add(field);
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Executes the idle callbacks added by the text control on the change of input style.
1870 application.RunIdles();
1872 gInputStyleChangedCallbackCalled = false;
1873 gInputStyleMask = TextField::InputStyle::NONE;
1874 inputStyleChangedSignal = false;
1876 // Create a tap event to touch the text field.
1877 TestGenerateTap(application, 18.0f, 25.0f);
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 // Executes the idle callbacks added by the text control on the change of input style.
1884 application.RunIdles();
1886 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1887 if(gInputStyleChangedCallbackCalled)
1889 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1891 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1892 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1894 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1895 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1897 DALI_TEST_CHECK(inputStyleChangedSignal);
1899 gInputStyleChangedCallbackCalled = false;
1900 gInputStyleMask = TextField::InputStyle::NONE;
1901 inputStyleChangedSignal = false;
1903 // Create a tap event to touch the text field.
1904 TestGenerateTap(application, 30.0f, 25.0f);
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Executes the idle callbacks added by the text control on the change of input style.
1911 application.RunIdles();
1913 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1914 DALI_TEST_CHECK(!inputStyleChangedSignal);
1916 gInputStyleChangedCallbackCalled = false;
1917 gInputStyleMask = TextField::InputStyle::NONE;
1918 inputStyleChangedSignal = false;
1920 // Create a tap event to touch the text field.
1921 TestGenerateTap(application, 43.0f, 25.0f);
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Executes the idle callbacks added by the text control on the change of input style.
1928 application.RunIdles();
1930 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1931 if(gInputStyleChangedCallbackCalled)
1933 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
1935 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1936 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1938 DALI_TEST_CHECK(inputStyleChangedSignal);
1940 gInputStyleChangedCallbackCalled = false;
1941 gInputStyleMask = TextField::InputStyle::NONE;
1942 inputStyleChangedSignal = false;
1944 // Create a tap event to touch the text field.
1945 TestGenerateTap(application, 88.0f, 25.0f);
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 // Executes the idle callbacks added by the text control on the change of input style.
1952 application.RunIdles();
1954 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1955 if(gInputStyleChangedCallbackCalled)
1957 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
1959 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1960 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1962 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
1964 Property::Map fontStyleMapSet;
1965 fontStyleMapSet.Insert("weight", "bold");
1967 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1968 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1970 DALI_TEST_CHECK(inputStyleChangedSignal);
1972 gInputStyleChangedCallbackCalled = false;
1973 gInputStyleMask = TextField::InputStyle::NONE;
1974 inputStyleChangedSignal = false;
1976 // Create a tap event to touch the text field.
1977 TestGenerateTap(application, 115.0f, 25.0f);
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Executes the idle callbacks added by the text control on the change of input style.
1984 application.RunIdles();
1986 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1987 DALI_TEST_CHECK(!inputStyleChangedSignal);
1989 gInputStyleChangedCallbackCalled = false;
1990 gInputStyleMask = TextField::InputStyle::NONE;
1991 inputStyleChangedSignal = false;
1993 // Create a tap event to touch the text field.
1994 TestGenerateTap(application, 164.0f, 25.0f);
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Executes the idle callbacks added by the text control on the change of input style.
2001 application.RunIdles();
2003 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2004 if(gInputStyleChangedCallbackCalled)
2006 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2008 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2009 DALI_TEST_CHECK(style.empty());
2011 DALI_TEST_CHECK(inputStyleChangedSignal);
2013 gInputStyleChangedCallbackCalled = false;
2014 gInputStyleMask = TextField::InputStyle::NONE;
2015 inputStyleChangedSignal = false;
2017 // Create a tap event to touch the text field.
2018 TestGenerateTap(application, 191.0f, 25.0f);
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 // Executes the idle callbacks added by the text control on the change of input style.
2025 application.RunIdles();
2027 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2028 DALI_TEST_CHECK(!inputStyleChangedSignal);
2033 int utcDaliTextFieldInputStyleChanged02(void)
2035 // The text-field emits signals when the input style changes. These changes of style are
2036 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2037 // can't be emitted during the size negotiation as the callbacks may update the UI.
2038 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2039 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2040 ToolkitTestApplication application;
2041 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2045 char* pathNamePtr = get_current_dir_name();
2046 const std::string pathName(pathNamePtr);
2049 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2050 fontClient.SetDpi(93u, 93u);
2052 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2053 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2055 TextField field = TextField::New();
2056 DALI_TEST_CHECK(field);
2058 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2059 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2060 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2062 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2063 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>");
2065 // connect to the text changed signal.
2066 ConnectionTracker* testTracker = new ConnectionTracker();
2067 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2068 bool inputStyleChangedSignal = false;
2069 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2071 application.GetScene().Add(field);
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 // Executes the idle callbacks added by the text control on the change of input style.
2078 application.RunIdles();
2080 gInputStyleChangedCallbackCalled = false;
2081 gInputStyleMask = TextField::InputStyle::NONE;
2082 inputStyleChangedSignal = false;
2084 // Create a tap event to touch the text field.
2085 TestGenerateTap(application, 53.0f, 25.0f, 100);
2086 TestGenerateTap(application, 53.0f, 25.0f, 200);
2088 // Render and notify
2089 application.SendNotification();
2090 application.Render();
2092 // Executes the idle callbacks added by the text control on the change of input style.
2093 application.RunIdles();
2095 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2096 if(gInputStyleChangedCallbackCalled)
2098 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2099 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2100 TextField::InputStyle::POINT_SIZE |
2101 TextField::InputStyle::COLOR),
2104 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2105 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2107 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2108 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2110 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2111 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2113 DALI_TEST_CHECK(inputStyleChangedSignal);
2115 gInputStyleChangedCallbackCalled = false;
2116 gInputStyleMask = TextField::InputStyle::NONE;
2117 inputStyleChangedSignal = false;
2119 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2125 // Executes the idle callbacks added by the text control on the change of input style.
2126 application.RunIdles();
2128 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2129 if(gInputStyleChangedCallbackCalled)
2131 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2132 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2135 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2136 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2138 DALI_TEST_CHECK(inputStyleChangedSignal);
2140 gInputStyleChangedCallbackCalled = false;
2141 gInputStyleMask = TextField::InputStyle::NONE;
2142 inputStyleChangedSignal = false;
2144 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2146 // Render and notify
2147 application.SendNotification();
2148 application.Render();
2150 // Executes the idle callbacks added by the text control on the change of input style.
2151 application.RunIdles();
2153 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2154 DALI_TEST_CHECK(!inputStyleChangedSignal);
2156 gInputStyleChangedCallbackCalled = false;
2157 gInputStyleMask = TextField::InputStyle::NONE;
2158 inputStyleChangedSignal = false;
2160 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Executes the idle callbacks added by the text control on the change of input style.
2167 application.RunIdles();
2169 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2170 if(gInputStyleChangedCallbackCalled)
2172 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2173 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2176 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2177 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2179 DALI_TEST_CHECK(inputStyleChangedSignal);
2181 gInputStyleChangedCallbackCalled = false;
2182 gInputStyleMask = TextField::InputStyle::NONE;
2183 inputStyleChangedSignal = false;
2185 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2187 Property::Map fontStyleMapSet;
2188 fontStyleMapSet.Insert("weight", "thin");
2189 fontStyleMapSet.Insert("width", "condensed");
2190 fontStyleMapSet.Insert("slant", "italic");
2192 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2193 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2195 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2196 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2197 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2198 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2199 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2201 // Render and notify
2202 application.SendNotification();
2203 application.Render();
2205 // Executes the idle callbacks added by the text control on the change of input style.
2206 application.RunIdles();
2208 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2209 DALI_TEST_CHECK(!inputStyleChangedSignal);
2211 // Create a tap event to touch the text field.
2212 TestGenerateTap(application, 63.0f, 25.0f, 700);
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // Executes the idle callbacks added by the text control on the change of input style.
2219 application.RunIdles();
2221 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2222 if(gInputStyleChangedCallbackCalled)
2224 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2225 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2226 TextField::InputStyle::POINT_SIZE |
2227 TextField::InputStyle::FONT_STYLE |
2228 TextField::InputStyle::UNDERLINE |
2229 TextField::InputStyle::SHADOW |
2230 TextField::InputStyle::EMBOSS |
2231 TextField::InputStyle::OUTLINE),
2234 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2235 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2237 DALI_TEST_CHECK(inputStyleChangedSignal);
2242 int utcDaliTextFieldEvent01(void)
2244 ToolkitTestApplication application;
2245 tet_infoline(" utcDaliTextFieldEvent01");
2247 // Creates a tap event. After creating a tap event the text field should
2248 // have the focus and add text with key events should be possible.
2250 TextField field = TextField::New();
2251 DALI_TEST_CHECK(field);
2253 application.GetScene().Add(field);
2255 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2256 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2257 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // Avoid a crash when core load gl resources.
2264 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 // Add a key event but as the text field has not the focus it should do nothing.
2271 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2277 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2279 // Create a tap event to touch the text field.
2280 TestGenerateTap(application, 150.0f, 25.0f);
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // Pressing delete key should be fine even if there is no text in TextField.
2287 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));
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 // Now the text field has the focus, so it can handle the key events.
2293 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2294 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2302 // Create a second text field and send key events to it.
2303 TextField field2 = TextField::New();
2305 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2306 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2307 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2308 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2310 application.GetScene().Add(field2);
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 // Create a tap event on the second text field.
2317 TestGenerateTap(application, 150.0f, 125.0f);
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // The second text field has the focus. It should handle the key events.
2324 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2325 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Check the text has been added to the second text field.
2332 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2337 int utcDaliTextFieldEvent02(void)
2339 ToolkitTestApplication application;
2340 tet_infoline(" utcDaliTextFieldEvent02");
2342 // Checks if the right number of actors are created.
2344 TextField field = TextField::New();
2345 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2346 DALI_TEST_CHECK(field);
2347 LoadMarkerImages(application, field);
2349 application.GetScene().Add(field);
2351 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2352 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2353 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2355 // Avoid a crash when core load gl resources.
2356 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Check there are the expected number of children ( stencil ).
2363 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2365 Actor stencil = field.GetChildAt(0u);
2366 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2368 // Create a tap event to touch the text field.
2369 TestGenerateTap(application, 150.0f, 25.0f, 300);
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 Actor layer = field.GetChildAt(2u);
2376 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2377 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2379 // Now the text field has the focus, so it can handle the key events.
2380 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2381 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 // Checks the cursor and the renderer have been created.
2388 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2389 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2391 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2392 DALI_TEST_CHECK(cursor);
2394 // The offscreen root actor has a container with all the actors which contain the text renderers.
2395 Actor container = stencil.GetChildAt(0u);
2396 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2398 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2399 DALI_TEST_CHECK(renderer);
2402 // Move the cursor and check the position changes.
2403 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2404 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2411 DALI_TEST_CHECK(position2.x < position1.x);
2413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2420 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2422 // Move the cursor to the first position.
2423 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2424 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2432 // Send some taps and check the cursor positions.
2434 // Try to tap at the beginning.
2435 TestGenerateTap(application, 1.0f, 25.0f, 900);
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Cursor position should be the same than position1.
2442 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2444 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2446 // Tap away from the start position.
2447 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2455 DALI_TEST_CHECK(position6.x > position5.x);
2457 // Remove all the text.
2458 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2460 field.SetProperty(TextField::Property::TEXT, "");
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 // Cursor position should be the same than position2.
2467 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2469 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2471 // Should not be a renderer, there is only a clipped cursor.
2472 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2474 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2475 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2476 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2478 application.SendNotification();
2479 application.Render();
2481 // There are renderer and decorator layer
2482 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2487 int utcDaliTextFieldEvent03(void)
2489 ToolkitTestApplication application;
2490 tet_infoline(" utcDaliTextFieldEvent03");
2492 // Checks if the highlight actor is created.
2494 TextField field = TextField::New();
2495 DALI_TEST_CHECK(field);
2497 application.GetScene().Add(field);
2499 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2500 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2501 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2502 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2503 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2505 // Avoid a crash when core load gl resources.
2506 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2507 LoadMarkerImages(application, field);
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Tap first to get the focus.
2514 TestGenerateTap(application, 3.0f, 25.0f);
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // Double tap to select a word.
2521 TestGenerateTap(application, 3.0f, 25.0f);
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2528 Actor stencil = field.GetChildAt(0u);
2530 // The highlight actor is drawn first, so is the first actor in the list
2531 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2532 DALI_TEST_CHECK(highlight);
2534 // The offscreen root actor has a container with all the actors which contain the text renderers.
2535 Actor container = stencil.GetChildAt(1u);
2536 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2538 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2539 DALI_TEST_CHECK(renderer);
2545 int utcDaliTextFieldEvent04(void)
2547 ToolkitTestApplication application;
2548 tet_infoline(" utcDaliTextFieldEvent04");
2550 // Checks if the highlight actor is created.
2552 TextField field = TextField::New();
2553 DALI_TEST_CHECK(field);
2554 application.GetScene().Add(field);
2555 LoadMarkerImages(application, field);
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2561 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2562 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2563 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2564 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2566 // Avoid a crash when core load gl resources.
2567 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Create a tap event to touch the text field.
2573 TestGenerateTap(application, 150.0f, 25.0f);
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Tap first to get the focus.
2579 TestGenerateTap(application, 1.0f, 25.0f);
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Double tap to select a word.
2586 TestGenerateTap(application, 1.0f, 25.0f);
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2593 TestGenerateTap(application, 0.0f, 40.0f);
2597 int utcDaliTextFieldEvent05(void)
2599 ToolkitTestApplication application;
2600 tet_infoline(" utcDaliTextFieldEvent05");
2602 // Checks dragging of cursor/grab handle
2604 TextField field = TextField::New();
2605 DALI_TEST_CHECK(field);
2606 application.GetScene().Add(field);
2607 LoadMarkerImages(application, field);
2608 // Render and notify
2609 application.SendNotification();
2610 application.Render();
2612 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2613 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2614 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2615 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2616 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2618 // Avoid a crash when core load gl resources.
2619 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Create a tap event to touch the text field.
2625 TestGenerateTap(application, 150.0f, 25.0f);
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 // Tap first to get the focus.
2631 TestGenerateTap(application, 1.0f, 25.0f);
2633 // Render and notify
2634 application.SendNotification();
2635 application.Render();
2637 // Double tap to select a word.
2638 TestGenerateTap(application, 1.0f, 25.0f);
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2644 Actor stencil = field.GetChildAt(1u);
2648 int utcDaliTextFieldEvent06(void)
2650 ToolkitTestApplication application;
2651 tet_infoline(" utcDaliTextFieldEvent06");
2653 // Checks Longpress when in edit mode
2655 TextField field = TextField::New();
2656 DALI_TEST_CHECK(field);
2657 application.GetScene().Add(field);
2658 LoadMarkerImages(application, field);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2664 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2665 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2666 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2667 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2669 // Avoid a crash when core load gl resources.
2670 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2675 // Create a tap event to touch the text field.
2676 TestGenerateTap(application, 150.0f, 25.0f);
2677 // Render and notify
2678 application.SendNotification();
2679 application.Render();
2681 // Tap first to get the focus.
2682 TestGenerateTap(application, 1.0f, 25.0f);
2684 // Render and notify
2685 application.SendNotification();
2686 application.Render();
2689 TestGenerateLongPress(application, 1.0f, 25.0f);
2691 // Render and notify
2692 application.SendNotification();
2693 application.Render();
2698 int utcDaliTextFieldEvent07(void)
2700 ToolkitTestApplication application;
2701 tet_infoline(" utcDaliTextFieldEvent07");
2703 // Checks Longpress to start edit mode
2705 TextField field = TextField::New();
2706 DALI_TEST_CHECK(field);
2707 application.GetScene().Add(field);
2708 LoadMarkerImages(application, field);
2709 // Render and notify
2710 application.SendNotification();
2711 application.Render();
2713 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2714 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2715 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2716 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2717 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2718 Property::Map propertyMap;
2719 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2720 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2722 // Avoid a crash when core load gl resources.
2723 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2729 TestGenerateLongPress(application, 1.0f, 25.0f);
2731 // Render and notify
2732 application.SendNotification();
2733 application.Render();
2738 int utcDaliTextFieldEvent08(void)
2740 ToolkitTestApplication application;
2741 tet_infoline(" utcDaliTextFieldEvent08");
2743 Dali::Clipboard clipboard = Clipboard::Get();
2744 clipboard.SetItem("testTextFieldEvent");
2746 // Checks Longpress when only place holder text
2748 TextField field = TextField::New();
2749 DALI_TEST_CHECK(field);
2750 application.GetScene().Add(field);
2751 LoadMarkerImages(application, field);
2752 // Render and notify
2753 application.SendNotification();
2754 application.Render();
2756 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2757 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2758 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2759 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2760 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2762 // Avoid a crash when core load gl resources.
2763 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2769 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2775 Wait(application, 500);
2777 TestEndLongPress(application, 1.0f, 25.0f, 520);
2780 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2782 // Render and notify
2783 application.Render();
2785 Wait(application, 500);
2787 Integration::Scene stage = application.GetScene();
2788 Layer layer = stage.GetRootLayer();
2789 Actor actor = layer.FindChildByName("optionPaste");
2793 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2794 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2795 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2797 Dali::Integration::TouchEvent event;
2798 event = Dali::Integration::TouchEvent();
2799 event.AddPoint(GetPointDownInside(position));
2800 application.ProcessEvent(event);
2802 event = Dali::Integration::TouchEvent();
2803 event.AddPoint(GetPointUpInside(position));
2804 application.ProcessEvent(event);
2806 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2811 int utcDaliTextFieldEvent09(void)
2813 ToolkitTestApplication application;
2814 tet_infoline(" utcDaliTextFieldEvent09");
2816 TextField field = TextField::New();
2817 DALI_TEST_CHECK(field);
2818 application.GetScene().Add(field);
2819 LoadMarkerImages(application, field);
2820 // Render and notify
2821 application.SendNotification();
2822 application.Render();
2824 field.SetProperty(TextField::Property::TEXT, "Hello");
2825 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2826 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2827 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2828 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2830 // Avoid a crash when core load gl resources.
2831 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2833 // Create a tap event to touch the text field.
2834 TestGenerateTap(application, 150.0f, 25.0f);
2835 application.SendNotification();
2836 application.Render();
2839 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2840 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2841 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2842 application.SendNotification();
2843 application.Render();
2845 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2846 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2847 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2848 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2849 application.SendNotification();
2850 application.Render();
2852 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2853 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2854 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2855 for(unsigned int index = 0u; index < 5u; ++index)
2857 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2858 application.SendNotification();
2859 application.Render();
2862 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
2863 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2864 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2865 for(unsigned int index = 0u; index < 5u; ++index)
2867 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2868 application.SendNotification();
2869 application.Render();
2872 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2873 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2874 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2875 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2876 application.SendNotification();
2877 application.Render();
2878 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2879 application.SendNotification();
2880 application.Render();
2882 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2883 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2884 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2885 application.SendNotification();
2886 application.Render();
2888 Property::Map mapGet;
2889 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2890 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2891 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2895 int utcDaliTextFieldStyleWhilstSelected(void)
2897 ToolkitTestApplication application;
2898 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2900 // Change font and styles whilst text is selected whilst word selected
2902 TextField field = TextField::New();
2903 DALI_TEST_CHECK(field);
2904 application.GetScene().Add(field);
2905 LoadMarkerImages(application, field);
2906 // Render and notify
2907 application.SendNotification();
2908 application.Render();
2910 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2911 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2912 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2913 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2914 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2916 // Avoid a crash when core load gl resources.
2917 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 // Create a tap event to touch the text field.
2923 TestGenerateTap(application, 150.0f, 25.0f);
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 // Tap first to get the focus.
2929 TestGenerateTap(application, 1.0f, 25.0f);
2931 // Render and notify
2932 application.SendNotification();
2933 application.Render();
2935 // Double tap to select a word.
2936 TestGenerateTap(application, 1.0f, 25.0f);
2938 // Render and notify
2939 application.SendNotification();
2940 application.Render();
2942 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
2943 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
2945 Property::Map fontStyleMapSet;
2946 Property::Map fontStyleMapGet;
2948 fontStyleMapSet.Insert("weight", "bold");
2949 fontStyleMapSet.Insert("slant", "italic");
2950 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2952 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2953 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2954 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2956 fontStyleMapSet.Clear();
2957 fontStyleMapSet.Insert("width", "expanded");
2958 fontStyleMapSet.Insert("slant", "italic");
2959 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2961 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2962 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2963 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2965 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
2966 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2968 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
2969 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
2971 fontStyleMapSet.Clear();
2972 fontStyleMapSet.Insert("weight", "bold");
2973 fontStyleMapSet.Insert("slant", "italic");
2975 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2977 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2978 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2979 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2981 fontStyleMapSet.Clear();
2982 fontStyleMapSet.Insert("width", "expanded");
2984 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2986 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2987 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2988 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2990 // Press Escape to increase coverage
2991 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2992 application.SendNotification();
2993 application.Render();
2995 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3000 int utcDaliTextFieldEscKeyLoseFocus(void)
3002 ToolkitTestApplication application;
3003 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3005 // Creates a tap event. After creating a tap event the text field should
3006 // have the focus and add text with key events should be possible.
3008 TextField field = TextField::New();
3009 DALI_TEST_CHECK(field);
3011 application.GetScene().Add(field);
3013 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3014 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3015 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3017 // Avoid a crash when core load gl resources.
3018 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3020 // Render and notify
3021 application.SendNotification();
3022 application.Render();
3024 // Add a key event but as the text field has not the focus it should do nothing.
3025 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3026 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3034 // Create a tap event to touch the text field.
3035 TestGenerateTap(application, 150.0f, 25.0f);
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 // Now the text field has the focus, so it can handle the key events.
3042 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3043 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3044 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3047 // Render and notify
3048 application.SendNotification();
3049 application.Render();
3051 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3053 // Generate a Esc key event. The text field should lose the focus.
3054 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3055 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3057 // Render and notify
3058 application.SendNotification();
3059 application.Render();
3061 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3063 // No more text should be introduced
3064 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3065 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3067 // Render and notify
3068 application.SendNotification();
3069 application.Render();
3071 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3076 int utcDaliTextFieldSomeSpecialKeys(void)
3078 ToolkitTestApplication application;
3079 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3081 // Checks some special keys when the text is selected.
3083 TextField field = TextField::New();
3084 DALI_TEST_CHECK(field);
3085 application.GetScene().Add(field);
3086 LoadMarkerImages(application, field);
3087 // Render and notify
3088 application.SendNotification();
3089 application.Render();
3091 const std::string longText("This is a long text for the size of the text-field.");
3093 field.SetProperty(TextField::Property::TEXT, longText);
3094 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3095 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3096 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3097 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3099 // Avoid a crash when core load gl resources.
3100 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3101 // Render and notify
3102 application.SendNotification();
3103 application.Render();
3105 // Create a tap event to touch the text field.
3106 TestGenerateTap(application, 150.0f, 25.0f);
3108 // Render and notify
3109 application.SendNotification();
3110 application.Render();
3112 // Tap first to get the focus.
3113 TestGenerateTap(application, 1.0f, 25.0f);
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 // Double tap to select a word.
3120 TestGenerateTap(application, 1.0f, 25.0f);
3122 // Render and notify
3123 application.SendNotification();
3124 application.Render();
3126 // Generate a Esc key event. The text field should lose the focus.
3127 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3128 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3130 // Render and notify
3131 application.SendNotification();
3132 application.Render();
3134 // Generate a Esc key event. The text field should lose the focus.
3135 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3136 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3138 // Render and notify
3139 application.SendNotification();
3140 application.Render();
3142 // Generate a Esc key event. The text field should lose the focus.
3143 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3144 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3146 // Render and notify
3147 application.SendNotification();
3148 application.Render();
3150 // The text shouldn't be deleted.
3151 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3156 int utcDaliTextFieldSizeUpdate(void)
3158 ToolkitTestApplication application;
3159 tet_infoline("utcDaliTextFieldSizeUpdate");
3161 // Checks some special keys when the text is selected.
3162 TextField field = TextField::New();
3163 DALI_TEST_CHECK(field);
3164 application.GetScene().Add(field);
3166 float previousHeight = 0.0f;
3167 float currentHeight = 0.0f;
3168 const float fieldWidth = 1920.0f;
3170 // "ㅁ" is bigger then "ኢ"
3171 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3172 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3173 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3175 field.SetProperty(TextField::Property::TEXT, "ኢ");
3176 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3177 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3179 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3180 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3182 application.SendNotification();
3183 application.Render();
3185 previousHeight = field.GetHeightForWidth(fieldWidth);
3186 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3188 // Add another script characters ( glyph height is defferent )
3189 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3190 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3192 application.SendNotification();
3193 application.Render();
3195 currentHeight = field.GetHeightForWidth(fieldWidth);
3196 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3197 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3202 int utcDaliTextFieldExtremlyLargePointSize(void)
3204 ToolkitTestApplication application;
3205 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3207 TextField field = TextField::New();
3209 field.SetProperty(TextField::Property::TEXT, "Text");
3210 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3211 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3212 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3213 application.GetScene().Add(field);
3217 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3218 application.SendNotification();
3219 DALI_TEST_CHECK(field);
3223 tet_result(TET_FAIL);
3228 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3230 ToolkitTestApplication application;
3231 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3232 TextField field = TextField::New();
3233 DALI_TEST_CHECK(field);
3234 application.GetScene().Add(field);
3236 Property::Map fontStyleMapGet;
3238 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3240 Property::Value* weightValue = NULL;
3241 Property::Value* widthValue = NULL;
3242 Property::Value* slantValue = NULL;
3243 weightValue = fontStyleMapGet.Find("weight");
3244 widthValue = fontStyleMapGet.Find("width");
3245 slantValue = fontStyleMapGet.Find("slant");
3246 DALI_TEST_CHECK(!weightValue);
3247 DALI_TEST_CHECK(!widthValue);
3248 DALI_TEST_CHECK(!slantValue);
3253 int UtcDaliTextFieldSettingPlaceholder(void)
3255 ToolkitTestApplication application;
3256 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3258 TextField field = TextField::New();
3259 DALI_TEST_CHECK(field);
3260 application.GetScene().Add(field);
3262 // Check the placeholder property with pixel size
3263 Property::Map placeholderPixelSizeMapSet;
3264 Property::Map placeholderPixelSizeMapGet;
3265 Property::Map placeholderFontstyleMap;
3266 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3267 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3268 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3269 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3270 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3271 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3273 placeholderFontstyleMap.Insert("weight", "bold");
3274 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3275 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3277 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3278 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3279 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3281 // Check the placeholder property with point size
3282 Property::Map placeholderMapSet;
3283 Property::Map placeholderMapGet;
3284 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3285 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3286 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3287 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3288 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3289 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3291 // Check the placeholder font style property
3292 placeholderFontstyleMap.Clear();
3294 placeholderFontstyleMap.Insert("weight", "bold");
3295 placeholderFontstyleMap.Insert("width", "condensed");
3296 placeholderFontstyleMap.Insert("slant", "italic");
3297 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3298 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3300 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3301 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3302 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3304 // Reset font style.
3305 placeholderFontstyleMap.Clear();
3306 placeholderFontstyleMap.Insert("weight", "normal");
3307 placeholderFontstyleMap.Insert("slant", "oblique");
3308 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3309 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3311 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3312 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3313 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3315 placeholderFontstyleMap.Clear();
3316 placeholderFontstyleMap.Insert("slant", "roman");
3317 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3318 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3320 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3322 placeholderFontstyleMap.Clear();
3323 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3325 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3326 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3327 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3328 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3333 int UtcDaliTextFieldPlaceholderCoverage(void)
3335 ToolkitTestApplication application;
3336 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3338 // mPlaceholderFont is created only once, so create a new control for coverage.
3339 TextField fieldForCoverage = TextField::New();
3340 DALI_TEST_CHECK(fieldForCoverage);
3341 application.GetScene().Add(fieldForCoverage);
3343 // for SetPlaceholderFontFamily() coverage.
3344 Property::Map fontFamilyMap;
3345 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3346 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3348 // mPlaceholderFont is created only once, so create a new control for coverage.
3349 fieldForCoverage = TextField::New();
3350 DALI_TEST_CHECK(fieldForCoverage);
3351 application.GetScene().Add(fieldForCoverage);
3353 // for SetPlaceholderTextFontSize coverage.
3354 Property::Map fontSizeMap;
3355 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3356 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3358 // mPlaceholderFont is created only once, so create a new control for coverage.
3359 fieldForCoverage = TextField::New();
3360 DALI_TEST_CHECK(fieldForCoverage);
3361 application.GetScene().Add(fieldForCoverage);
3363 // for SetPlaceholderTextFontWeight coverage.
3364 Property::Map fontStyleWeightMap;
3365 Property::Map fontStyleWeightPropertyMap;
3366 fontStyleWeightPropertyMap.Insert("weight", "bold");
3367 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3368 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3370 // mPlaceholderFont is created only once, so create a new control for coverage.
3371 fieldForCoverage = TextField::New();
3372 DALI_TEST_CHECK(fieldForCoverage);
3373 application.GetScene().Add(fieldForCoverage);
3375 // for SetPlaceholderTextFontWidth coverage.
3376 Property::Map fontStyleWidthMap;
3377 Property::Map fontStyleWidthPropertyMap;
3378 fontStyleWidthPropertyMap.Insert("width", "expanded");
3379 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3380 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3382 // mPlaceholderFont is created only once, so create a new control for coverage.
3383 fieldForCoverage = TextField::New();
3384 DALI_TEST_CHECK(fieldForCoverage);
3385 application.GetScene().Add(fieldForCoverage);
3387 // for SetPlaceholderTextFontSlant coverage.
3388 Property::Map fontStyleSlantMap;
3389 Property::Map fontStyleSlantPropertyMap;
3390 fontStyleSlantPropertyMap.Insert("slant", "italic");
3391 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3392 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3397 int UtcDaliTextFieldSetPaddingProperty(void)
3399 ToolkitTestApplication application;
3400 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3402 TextField field = TextField::New();
3403 DALI_TEST_CHECK(field);
3404 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3405 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3406 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3407 application.GetScene().Add(field);
3409 application.SendNotification();
3410 application.Render();
3412 Vector3 originalSize = field.GetNaturalSize();
3414 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3416 application.SendNotification();
3417 application.Render();
3419 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3421 Vector3 paddingAddedSize = field.GetNaturalSize();
3423 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3425 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3430 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3432 ToolkitTestApplication application;
3433 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3435 TextField field = TextField::New();
3436 DALI_TEST_CHECK(field);
3437 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3438 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3439 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3440 application.GetScene().Add(field);
3442 application.SendNotification();
3443 application.Render();
3445 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3446 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3448 // Check the enable shift selection property
3449 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3450 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3452 application.SendNotification();
3453 application.Render();
3458 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3460 ToolkitTestApplication application;
3461 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3463 TextField field = TextField::New();
3464 DALI_TEST_CHECK(field);
3465 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3466 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3467 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3468 application.GetScene().Add(field);
3470 application.SendNotification();
3471 application.Render();
3473 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3474 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3476 // Check the enable grab handle property
3477 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3478 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3480 application.SendNotification();
3481 application.Render();
3486 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3488 ToolkitTestApplication application;
3489 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3491 TextField field = TextField::New();
3492 DALI_TEST_CHECK(field);
3493 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3494 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3495 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3496 application.GetScene().Add(field);
3498 application.SendNotification();
3499 application.Render();
3501 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3502 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3504 // Check the match system language direction property
3505 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3506 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3508 application.SendNotification();
3509 application.Render();
3514 int utcDaliTextFieldLayoutDirectionCoverage(void)
3516 ToolkitTestApplication application;
3517 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3519 // Creates a tap event. After creating a tap event the text field should
3520 // have the focus and add text with key events should be possible.
3521 TextField field = TextField::New();
3522 DALI_TEST_CHECK(field);
3524 application.GetScene().Add(field);
3526 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3527 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3528 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3530 // Avoid a crash when core load gl resources.
3531 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3533 // Render and notify
3534 application.SendNotification();
3535 application.Render();
3537 // init direction for coverage
3538 // Set horizontal alignment END
3539 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3541 // Create a tap event to touch the text field.
3542 TestGenerateTap(application, 150.0f, 25.0f);
3544 // Render and notify
3545 application.SendNotification();
3546 application.Render();
3548 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3549 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3550 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3552 // Set horizontal alignment BEGIN
3553 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3555 // Create a tap event to touch the text field.
3556 TestGenerateTap(application, 150.0f, 25.0f);
3558 // Render and notify
3559 application.SendNotification();
3560 application.Render();
3562 // Set horizontal alignment CENTER
3563 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3565 // Create a tap event to touch the text field.
3566 TestGenerateTap(application, 150.0f, 25.0f);
3568 // Render and notify
3569 application.SendNotification();
3570 application.Render();
3572 // Set horizontal alignment END
3573 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3575 // Create a tap event to touch the text field.
3576 TestGenerateTap(application, 150.0f, 25.0f);
3578 // Render and notify
3579 application.SendNotification();
3580 application.Render();
3582 // Generate a Esc key event. The text field should lose the focus.
3583 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3584 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3586 // Render and notify
3587 application.SendNotification();
3588 application.Render();
3590 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3595 int UtcDaliTextFieldGetInputMethodContext(void)
3597 ToolkitTestApplication application;
3598 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3600 TextField field = TextField::New();
3601 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3606 int UtcDaliTextFieldSelectWholeText(void)
3608 ToolkitTestApplication application;
3609 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3611 TextField textField = TextField::New();
3613 application.GetScene().Add(textField);
3615 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3616 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3617 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3619 // Avoid a crash when core load gl resources.
3620 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3622 application.SendNotification();
3623 application.Render();
3625 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3627 DevelTextField::SelectWholeText(textField);
3629 application.SendNotification();
3630 application.Render();
3632 // Nothing should have been selected. The number of children is still 1
3633 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3635 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3637 application.SendNotification();
3638 application.Render();
3640 DevelTextField::SelectWholeText(textField);
3642 application.SendNotification();
3643 application.Render();
3645 // Even if resize, selection should remain.
3646 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3648 application.SendNotification();
3649 application.Render();
3651 // Should be 2 children, the stencil and the layer
3652 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3654 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3655 Actor stencil = textField.GetChildAt(0u);
3657 // The highlight actor is drawn first, so is the first actor in the list
3658 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3659 DALI_TEST_CHECK(highlight);
3664 int UtcDaliTextFieldSelectText(void)
3666 ToolkitTestApplication application;
3667 tet_infoline(" UtcDaliTextFieldSelectText ");
3669 TextField textField = TextField::New();
3671 application.GetScene().Add(textField);
3673 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3674 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3675 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3677 // Avoid a crash when core load gl resources.
3678 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3680 application.SendNotification();
3681 application.Render();
3683 DevelTextField::SelectText(textField, 0, 5);
3685 application.SendNotification();
3686 application.Render();
3688 // Nothing is selected
3689 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3690 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3692 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3694 application.SendNotification();
3695 application.Render();
3697 // Hello is selected
3698 DevelTextField::SelectText(textField, 0, 5);
3700 application.SendNotification();
3701 application.Render();
3703 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3704 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3706 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3707 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3709 // world is selected
3710 DevelTextField::SelectText(textField, 6, 11);
3712 application.SendNotification();
3713 application.Render();
3715 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3716 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3718 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3719 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3724 int UtcDaliTextFieldSelectNone(void)
3726 ToolkitTestApplication application;
3727 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3729 TextField textField = TextField::New();
3731 application.GetScene().Add(textField);
3733 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3734 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3735 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3737 // Avoid a crash when core load gl resources.
3738 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3740 application.SendNotification();
3741 application.Render();
3743 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3745 application.SendNotification();
3746 application.Render();
3748 // Nothing is selected
3749 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3750 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3752 DevelTextField::SelectWholeText(textField);
3754 application.SendNotification();
3755 application.Render();
3757 // whole text is selected
3758 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3759 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3761 DevelTextField::SelectNone(textField);
3763 application.SendNotification();
3764 application.Render();
3766 // Nothing is selected
3767 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3768 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3773 int UtcDaliTextFieldSelectRange(void)
3775 ToolkitTestApplication application;
3776 tet_infoline(" UtcDaliTextFieldSelectRange ");
3778 TextField textField = TextField::New();
3780 application.GetScene().Add(textField);
3782 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3783 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3784 textField.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 application.SendNotification();
3790 application.Render();
3792 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3794 application.SendNotification();
3795 application.Render();
3797 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3798 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3800 // Hello is selected
3801 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3802 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3804 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3805 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3807 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3808 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3810 // world is selected
3811 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3812 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3814 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3815 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3820 int UtcDaliTextFieldEnableEditing(void)
3822 ToolkitTestApplication application;
3823 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3825 TextField textField = TextField::New();
3827 application.GetScene().Add(textField);
3829 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3830 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3831 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3833 // Avoid a crash when core load gl resources.
3834 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3836 application.SendNotification();
3837 application.Render();
3839 textField.SetKeyInputFocus();
3840 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3841 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3843 // Render and notify
3844 application.SendNotification();
3845 application.Render();
3847 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3848 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3850 textField.SetKeyInputFocus();
3851 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
3852 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3854 // Render and notify
3855 application.SendNotification();
3856 application.Render();
3858 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3859 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3864 int UtcDaliToolkitTextFieldFontSizeScale(void)
3866 ToolkitTestApplication application;
3867 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3869 TextField textField = TextField::New();
3870 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
3871 textField.SetProperty(TextField::Property::TEXT, "Test");
3872 Vector3 nonScaledSize = textField.GetNaturalSize();
3874 TextField textFieldScaled = TextField::New();
3875 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
3876 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3877 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3878 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3880 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3882 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
3883 textField.SetProperty(TextField::Property::TEXT, "Test");
3884 nonScaledSize = textField.GetNaturalSize();
3886 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
3887 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3888 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3889 scaledSize = textFieldScaled.GetNaturalSize();
3891 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3896 int UtcDaliTextFieldPrimaryCursorPosition(void)
3898 ToolkitTestApplication application;
3899 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3901 TextField textField = TextField::New();
3903 application.GetScene().Add(textField);
3905 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
3906 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3907 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3908 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3910 // Avoid a crash when core load gl resources.
3911 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3913 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3914 application.SendNotification();
3915 application.Render();
3916 textField.SetKeyInputFocus();
3918 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3920 // Render and notify
3921 application.SendNotification();
3922 application.Render();
3924 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3925 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3930 // test max length when set after setting long text
3931 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3933 ToolkitTestApplication application;
3934 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3935 TextField field = TextField::New();
3936 DALI_TEST_CHECK(field);
3938 application.GetScene().Add(field);
3940 field.SetProperty(TextField::Property::TEXT, "123456789");
3942 const int maxNumberOfCharacters = 3;
3943 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
3945 field.SetKeyInputFocus();
3947 // connect to the text max lengh reached signal.
3948 ConnectionTracker* testTracker = new ConnectionTracker();
3949 bool maxLengthReachedSignal = false;
3950 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3952 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3953 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3955 DALI_TEST_CHECK(maxLengthReachedSignal);
3957 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
3962 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3964 ToolkitTestApplication application;
3965 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3967 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3968 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3969 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3971 // Create a text field
3972 TextField textField = TextField::New();
3974 //Set size to avoid automatic eliding
3975 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
3976 //Set very large font-size using point-size
3977 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
3978 //Specify font-family
3979 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
3980 //Set text to check if appear or not
3981 textField.SetProperty(TextField::Property::TEXT, "A");
3983 application.GetScene().Add(textField);
3985 application.SendNotification();
3986 application.Render();
3987 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3988 Vector3 naturalSize = textField.GetNaturalSize();
3990 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
3991 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
3996 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3998 ToolkitTestApplication application;
3999 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4001 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4002 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4003 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4005 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4006 // Create a text editor
4007 TextField textField = TextField::New();
4009 //Set size to avoid automatic eliding
4010 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4011 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4012 textField.SetProperty(TextField::Property::TEXT, "A");
4014 const int numberOfCases = 6;
4015 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4017 for(int index = 0; index < numberOfCases; index++)
4019 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4020 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4021 application.GetScene().Add(textField);
4022 application.SendNotification();
4023 application.Render();
4024 naturalSize = textField.GetNaturalSize();
4025 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4026 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4032 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4034 ToolkitTestApplication application;
4035 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4036 TextField textField = TextField::New();
4038 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4039 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4041 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4042 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4043 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4045 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4046 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4047 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4049 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4050 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4051 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4053 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4054 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4055 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4057 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4058 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4059 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4061 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4062 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4063 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4065 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4066 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4067 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4069 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4070 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4071 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4073 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4074 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4075 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4077 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4078 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4079 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4081 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4082 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4083 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4085 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4086 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4087 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4092 int UtcDaliTextFieldCopyText(void)
4094 ToolkitTestApplication application;
4095 tet_infoline(" UtcDaliTextFieldCopyText ");
4097 TextField textField = TextField::New();
4099 std::string selectedText = "";
4100 std::string copiedText = "";
4102 application.GetScene().Add(textField);
4104 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4105 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4106 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4108 // Avoid a crash when core load gl resources.
4109 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4111 application.SendNotification();
4112 application.Render();
4114 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4116 application.SendNotification();
4117 application.Render();
4119 // Hello is selected
4120 DevelTextField::SelectText(textField, 0, 5);
4122 application.SendNotification();
4123 application.Render();
4125 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4126 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4128 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4129 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4132 copiedText = DevelTextField::CopyText(textField);
4133 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4135 // world is selected
4136 DevelTextField::SelectText(textField, 6, 11);
4138 application.SendNotification();
4139 application.Render();
4141 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4142 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4144 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4145 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4148 copiedText = DevelTextField::CopyText(textField);
4149 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4151 // "lo wo" is selected
4152 DevelTextField::SelectText(textField, 3, 8);
4154 application.SendNotification();
4155 application.Render();
4157 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4158 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4160 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4161 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4163 // "lo wo" is copied
4164 copiedText = DevelTextField::CopyText(textField);
4165 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4170 int UtcDaliTextFieldCutText(void)
4172 ToolkitTestApplication application;
4173 tet_infoline(" UtcDaliTextFieldCutText ");
4175 TextField textField = TextField::New();
4177 std::string selectedText = "";
4179 application.GetScene().Add(textField);
4181 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4182 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4183 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4185 // Avoid a crash when core load gl resources.
4186 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4188 application.SendNotification();
4189 application.Render();
4191 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4193 application.SendNotification();
4194 application.Render();
4196 // Hello is selected
4197 DevelTextField::SelectText(textField, 0, 5);
4199 application.SendNotification();
4200 application.Render();
4202 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4203 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4205 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4206 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4209 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4211 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4214 DevelTextField::SelectText(textField, 0, 2);
4216 application.SendNotification();
4217 application.Render();
4219 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4220 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4222 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4223 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4226 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4228 application.SendNotification();
4229 application.Render();
4231 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4233 // Test Cut from the middle
4236 DevelTextField::SelectText(textField, 1, 3);
4238 application.SendNotification();
4239 application.Render();
4241 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4242 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4244 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4245 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4248 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4250 application.SendNotification();
4251 application.Render();
4253 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4255 // Test Cut from the end
4258 DevelTextField::SelectText(textField, 1, 2);
4260 application.SendNotification();
4261 application.Render();
4263 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4264 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4266 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4267 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4270 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4272 application.SendNotification();
4273 application.Render();
4275 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4280 int UtcDaliTextFieldPasteText(void)
4282 ToolkitTestApplication application;
4283 tet_infoline(" UtcDaliTextFieldPasteText ");
4285 TextField textField = TextField::New();
4287 application.GetScene().Add(textField);
4289 std::string cutText = "";
4290 std::string copiedText = "";
4292 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4293 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4294 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4296 // Avoid a crash when core load gl resources.
4297 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4299 application.SendNotification();
4300 application.Render();
4302 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4304 application.SendNotification();
4305 application.Render();
4307 // Tap on the text editor
4308 TestGenerateTap(application, 3.0f, 25.0f);
4310 // Render and notify
4311 application.SendNotification();
4312 application.Render();
4314 // Select some text in the right of the current cursor position
4315 DevelTextField::SelectText(textField, 0, 3);
4317 // Render and notify
4318 application.SendNotification();
4319 application.Render();
4321 // Cut the selected text
4322 cutText = DevelTextField::CutText(textField);
4324 // Render and notify
4325 application.SendNotification();
4326 application.Render();
4328 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4329 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4331 DevelTextField::SelectText(textField, 0, 3);
4333 // Render and notify
4334 application.SendNotification();
4335 application.Render();
4337 // Copy the selected text
4338 copiedText = DevelTextField::CopyText(textField);
4340 // Render and notify
4341 application.SendNotification();
4342 application.Render();
4344 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4345 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4347 // Move the cursor to the end of the line
4348 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4349 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4350 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4351 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4352 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4354 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4355 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4357 // Render and notify
4358 application.SendNotification();
4359 application.Render();
4361 // Paste the selected text at the current cursor position
4362 DevelTextField::PasteText(textField);
4364 // Render and notify
4365 application.SendNotification();
4366 application.Render();
4368 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4373 int utcDaliTextFieldCursorPositionChangedSignal(void)
4375 ToolkitTestApplication application;
4376 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4378 TextField field = TextField::New();
4379 DALI_TEST_CHECK(field);
4381 application.GetScene().Add(field);
4383 // connect to the selection changed signal.
4384 ConnectionTracker* testTracker = new ConnectionTracker();
4385 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4386 bool cursorPositionChangedSignal = false;
4387 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4389 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4390 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4391 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4392 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4393 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4395 // Avoid a crash when core load gl resources.
4396 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4398 // Render and notify
4399 application.SendNotification();
4400 application.Render();
4402 field.SetKeyInputFocus();
4404 // Tap on the text field
4405 TestGenerateTap(application, 3.0f, 25.0f);
4407 // Render and notify
4408 application.SendNotification();
4409 application.Render();
4411 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4412 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4414 gCursorPositionChangedCallbackCalled = false;
4417 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4419 // Render and notify
4420 application.SendNotification();
4421 application.Render();
4423 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4424 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4426 gCursorPositionChangedCallbackCalled = false;
4429 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4431 // Render and notify
4432 application.SendNotification();
4433 application.Render();
4435 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4436 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4438 gCursorPositionChangedCallbackCalled = false;
4440 //delete one character
4441 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4443 // Render and notify
4444 application.SendNotification();
4445 application.Render();
4447 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4448 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4450 gCursorPositionChangedCallbackCalled = false;
4452 field.SetProperty(TextField::Property::TEXT, "Hello");
4454 // Render and notify
4455 application.SendNotification();
4456 application.Render();
4458 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4459 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4461 gCursorPositionChangedCallbackCalled = false;
4463 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4465 // Render and notify
4466 application.SendNotification();
4467 application.Render();
4469 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4470 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4475 int utcDaliTextFieldGeometryEllipsisStart(void)
4477 ToolkitTestApplication application;
4478 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4480 TextField field = TextField::New();
4481 DALI_TEST_CHECK(field);
4483 application.GetScene().Add(field);
4485 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4486 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4487 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4488 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4489 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4490 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4491 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4492 field.SetProperty(TextField::Property::TEXT, "Hello World");
4494 // Avoid a crash when core load gl resources.
4495 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4497 // Render and notify
4498 application.SendNotification();
4499 application.Render();
4501 unsigned int expectedCount = 1;
4502 unsigned int startIndex = 0;
4503 unsigned int endIndex = 10;
4505 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4506 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4508 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4509 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4511 Vector<Vector2> expectedSizes;
4512 Vector<Vector2> expectedPositions;
4514 expectedPositions.PushBack(Vector2(14, 0));
4515 expectedSizes.PushBack(Vector2(106, 25));
4517 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4522 int utcDaliTextFieldGeometryEllipsisEnd(void)
4524 ToolkitTestApplication application;
4525 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4527 TextField field = TextField::New();
4528 DALI_TEST_CHECK(field);
4530 application.GetScene().Add(field);
4532 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4533 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4534 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4535 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4536 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4537 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4538 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4539 field.SetProperty(TextField::Property::TEXT, "Hello World");
4541 // Avoid a crash when core load gl resources.
4542 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4544 // Render and notify
4545 application.SendNotification();
4546 application.Render();
4548 unsigned int expectedCount = 1;
4549 unsigned int startIndex = 0;
4550 unsigned int endIndex = 10;
4552 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4553 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4555 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4556 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4558 Vector<Vector2> expectedSizes;
4559 Vector<Vector2> expectedPositions;
4561 expectedPositions.PushBack(Vector2(-2, 0));
4562 expectedSizes.PushBack(Vector2(122, 25));
4564 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4569 int utcDaliTextFieldGeometryRTL(void)
4571 ToolkitTestApplication application;
4572 tet_infoline(" utcDaliTextFieldGeometryRTL");
4574 TextField field = TextField::New();
4575 DALI_TEST_CHECK(field);
4577 application.GetScene().Add(field);
4579 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4580 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4581 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4582 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4583 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4584 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4586 // Avoid a crash when core load gl resources.
4587 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4589 // Render and notify
4590 application.SendNotification();
4591 application.Render();
4593 unsigned int expectedCount = 1;
4594 unsigned int startIndex = 1;
4595 unsigned int endIndex = 7;
4597 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4598 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4600 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4601 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4603 Vector<Vector2> expectedSizes;
4604 Vector<Vector2> expectedPositions;
4606 expectedPositions.PushBack(Vector2(38, 0));
4607 expectedSizes.PushBack(Vector2(73, 25));
4609 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4614 int utcDaliTextFieldGeometryGlyphMiddle(void)
4616 ToolkitTestApplication application;
4617 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4619 TextField field = TextField::New();
4620 DALI_TEST_CHECK(field);
4622 application.GetScene().Add(field);
4624 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4625 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4626 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4627 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4628 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4629 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4631 // Avoid a crash when core load gl resources.
4632 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4634 // Render and notify
4635 application.SendNotification();
4636 application.Render();
4638 unsigned int expectedCount = 1;
4639 unsigned int startIndex = 1;
4640 unsigned int endIndex = 13;
4642 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4643 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4645 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4646 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4648 Vector<Vector2> expectedSizes;
4649 Vector<Vector2> expectedPositions;
4651 expectedPositions.PushBack(Vector2(6, 0));
4652 expectedSizes.PushBack(Vector2(124, 25));
4654 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4659 int utcDaliTextFieldSelectionClearedSignal(void)
4661 ToolkitTestApplication application;
4662 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4664 TextField field = TextField::New();
4665 DALI_TEST_CHECK(field);
4667 application.GetScene().Add(field);
4669 // connect to the selection changed signal.
4670 ConnectionTracker* testTracker = new ConnectionTracker();
4671 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4672 bool selectionClearedSignal = false;
4673 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4675 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4676 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4677 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4678 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4679 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4681 // Avoid a crash when core load gl resources.
4682 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4684 // Render and notify
4685 application.SendNotification();
4686 application.Render();
4688 // Tap on the text editor
4689 TestGenerateTap(application, 3.0f, 25.0f);
4691 // Render and notify
4692 application.SendNotification();
4693 application.Render();
4695 // Move to second line of the text & Select some text in the right of the current cursor position
4696 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4697 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4700 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4702 // Render and notify
4703 application.SendNotification();
4704 application.Render();
4706 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4708 // Render and notify
4709 application.SendNotification();
4710 application.Render();
4712 // Tap on the text editor
4713 TestGenerateTap(application, 3.0f, 25.0f);
4715 // Render and notify
4716 application.SendNotification();
4717 application.Render();
4719 gSelectionClearedCallbackCalled = false;
4721 // Move to second line of the text & select.
4722 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4723 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4726 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4728 // Render and notify
4729 application.SendNotification();
4730 application.Render();
4732 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4734 gSelectionClearedCallbackCalled = false;
4736 // Render and notify
4737 application.SendNotification();
4738 application.Render();
4740 // Move to second line of the text & select.
4741 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4742 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4744 // replace D with selected text
4745 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4747 // Render and notify
4748 application.SendNotification();
4749 application.Render();
4751 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4753 gSelectionClearedCallbackCalled = false;
4755 // Render and notify
4756 application.SendNotification();
4757 application.Render();
4759 DevelTextField::SelectText(field, 1, 3);
4761 // Render and notify
4762 application.SendNotification();
4763 application.Render();
4765 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4767 // Render and notify
4768 application.SendNotification();
4769 application.Render();
4771 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4773 gSelectionClearedCallbackCalled = false;
4775 DevelTextField::SelectText(field, 1, 3);
4777 // Render and notify
4778 application.SendNotification();
4779 application.Render();
4782 DevelTextField::SelectNone(field);
4784 // Render and notify
4785 application.SendNotification();
4786 application.Render();
4788 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4793 int utcDaliTextFieldSelectionStartedSignal(void)
4795 ToolkitTestApplication application;
4796 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4798 TextField field = TextField::New();
4799 DALI_TEST_CHECK(field);
4801 application.GetScene().Add(field);
4803 // connect to the selection changed signal.
4804 ConnectionTracker* testTracker = new ConnectionTracker();
4805 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4806 bool selectionStartedSignal = false;
4807 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4809 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4810 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4811 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4812 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4813 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4815 // Avoid a crash when core load gl resources.
4816 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4818 // Render and notify
4819 application.SendNotification();
4820 application.Render();
4822 // Tap on the text field
4823 TestGenerateTap(application, 3.0f, 25.0f);
4825 // Render and notify
4826 application.SendNotification();
4827 application.Render();
4829 // Move to second line of the text & Select some text in the right of the current cursor position
4830 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4831 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4833 // Render and notify
4834 application.SendNotification();
4835 application.Render();
4837 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4842 // Render and notify
4843 application.SendNotification();
4844 application.Render();
4846 gSelectionStartedCallbackCalled = false;
4848 DevelTextField::SelectText(field, 1, 3);
4850 // Render and notify
4851 application.SendNotification();
4852 application.Render();
4854 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4859 int utcDaliTextFieldSelectionChangedSignal(void)
4861 ToolkitTestApplication application;
4862 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4864 TextField field = TextField::New();
4865 DALI_TEST_CHECK(field);
4867 application.GetScene().Add(field);
4869 // connect to the selection changed signal.
4870 ConnectionTracker* testTracker = new ConnectionTracker();
4871 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4872 bool selectionChangedSignal = false;
4873 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
4875 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4876 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4877 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4878 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4879 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4881 // Avoid a crash when core load gl resources.
4882 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4884 // Render and notify
4885 application.SendNotification();
4886 application.Render();
4888 // Tap on the text field
4889 TestGenerateTap(application, 3.0f, 25.0f);
4891 // Render and notify
4892 application.SendNotification();
4893 application.Render();
4895 // Select some text in the right of the current cursor position
4896 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4897 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4899 // Render and notify
4900 application.SendNotification();
4901 application.Render();
4903 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4904 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4906 gSelectionChangedCallbackCalled = false;
4908 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4910 // Render and notify
4911 application.SendNotification();
4912 application.Render();
4914 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4915 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4916 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4918 gSelectionChangedCallbackCalled = false;
4920 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4922 // Render and notify
4923 application.SendNotification();
4924 application.Render();
4926 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4927 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4928 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4930 gSelectionChangedCallbackCalled = false;
4931 field.SetKeyInputFocus();
4933 // Render and notify
4934 application.SendNotification();
4935 application.Render();
4937 DevelTextField::SelectText(field, 0, 5);
4939 application.SendNotification();
4940 application.Render();
4942 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4943 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4945 gSelectionChangedCallbackCalled = false;
4947 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4949 // Render and notify
4950 application.SendNotification();
4951 application.Render();
4953 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4954 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4955 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4957 gSelectionChangedCallbackCalled = false;
4960 DevelTextField::SelectWholeText(field);
4962 // Render and notify
4963 application.SendNotification();
4964 application.Render();
4966 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4967 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4969 gSelectionChangedCallbackCalled = false;
4972 DevelTextField::SelectNone(field);
4974 // Render and notify
4975 application.SendNotification();
4976 application.Render();
4978 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4979 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4980 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4985 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
4987 ToolkitTestApplication application;
4988 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
4990 TextField textField = TextField::New();
4991 textField.SetProperty(TextField::Property::TEXT, "Test");
4992 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
4993 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
4994 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4996 application.GetScene().Add(textField);
4997 application.SendNotification();
4998 application.Render();
5000 Property::Map strikethroughMapSet;
5001 Property::Map strikethroughMapGet;
5003 strikethroughMapSet.Insert("enable", true);
5004 strikethroughMapSet.Insert("color", Color::RED);
5005 strikethroughMapSet.Insert("height", 2.0f);
5007 // Check the strikethrough property
5008 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5009 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5010 textField.SetProperty(TextField::Property::TEXT, "Test1");
5011 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5012 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5014 // Render and notify
5015 application.SendNotification();
5016 application.Render();
5018 strikethroughMapSet.Clear();
5019 strikethroughMapGet.Clear();
5024 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5026 ToolkitTestApplication application;
5027 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5029 TextField textField = TextField::New();
5030 textField.SetProperty(TextField::Property::TEXT, "Test");
5031 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5032 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5033 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5035 application.GetScene().Add(textField);
5036 application.SendNotification();
5037 application.Render();
5039 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5041 // Check the strikethrough property
5042 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5043 textField.SetProperty(TextField::Property::TEXT, "Test1");
5044 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5046 // Render and notify
5047 application.SendNotification();
5048 application.Render();
5053 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5055 ToolkitTestApplication application;
5056 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5057 TextField field = TextField::New();
5058 field.SetProperty(TextField::Property::TEXT, "Test");
5059 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5060 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5061 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5063 application.GetScene().Add(field);
5064 application.SendNotification();
5065 application.Render();
5067 Property::Map underlineMapSet;
5068 Property::Map underlineMapGet;
5070 underlineMapSet.Insert("enable", true);
5071 underlineMapSet.Insert("color", Color::RED);
5072 underlineMapSet.Insert("height", 1);
5073 underlineMapSet.Insert("type", Text::Underline::SOLID);
5074 underlineMapSet.Insert("dashWidth", 2);
5075 underlineMapSet.Insert("dashGap", 1);
5077 // Check the underline property
5078 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5080 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5081 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5082 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5084 // Render and notify
5085 application.SendNotification();
5086 application.Render();
5088 underlineMapSet.Clear();
5089 underlineMapGet.Clear();
5091 underlineMapSet.Insert("enable", true);
5092 underlineMapSet.Insert("color", Color::BLUE);
5093 underlineMapSet.Insert("height", 1);
5094 underlineMapSet.Insert("type", Text::Underline::DASHED);
5095 underlineMapSet.Insert("dashWidth", 4);
5096 underlineMapSet.Insert("dashGap", 2);
5098 // Check the dashed underline property
5099 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5101 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5102 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5103 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5105 // Render and notify
5106 application.SendNotification();
5107 application.Render();
5109 underlineMapSet.Clear();
5110 underlineMapGet.Clear();
5112 underlineMapSet.Insert("enable", true);
5113 underlineMapSet.Insert("color", Color::BLUE);
5114 underlineMapSet.Insert("height", 1);
5115 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5116 underlineMapSet.Insert("dashWidth", 4);
5117 underlineMapSet.Insert("dashGap", 2);
5119 // Check the dashed underline property
5120 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5122 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5123 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5124 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5126 // Render and notify
5127 application.SendNotification();
5128 application.Render();
5130 underlineMapSet.Clear();
5131 underlineMapGet.Clear();
5136 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5138 ToolkitTestApplication application;
5139 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5141 TextField field1 = TextField::New();
5142 field1.SetProperty(TextField::Property::TEXT, "Test");
5143 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5144 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5145 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5147 Property::Map underlineMapSet1;
5148 Property::Map underlineMapGet1;
5150 underlineMapSet1.Insert("enable", true);
5151 underlineMapSet1.Insert("color", Color::RED);
5152 underlineMapSet1.Insert("height", 1);
5153 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5154 underlineMapSet1.Insert("dashWidth", 2);
5155 underlineMapSet1.Insert("dashGap", 1);
5157 // Check the underline property
5158 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5160 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5161 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5162 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5164 application.GetScene().Add(field1);
5165 application.SendNotification();
5166 application.Render();
5168 TextField field2 = TextField::New();
5169 field2.SetProperty(TextField::Property::TEXT, "Test");
5170 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5171 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5172 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5174 Property::Map underlineMapSet2;
5175 Property::Map underlineMapGet2;
5177 underlineMapSet2.Insert("enable", true);
5178 underlineMapSet2.Insert("color", Color::BLUE);
5179 underlineMapSet2.Insert("height", 1);
5180 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5181 underlineMapSet2.Insert("dashWidth", 4);
5182 underlineMapSet2.Insert("dashGap", 2);
5184 // Check the dashed underline property
5185 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5187 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5188 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5189 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5191 application.GetScene().Add(field2);
5192 application.SendNotification();
5193 application.Render();
5195 TextField field3 = TextField::New();
5196 field3.SetProperty(TextField::Property::TEXT, "Test");
5197 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5198 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5199 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5201 Property::Map underlineMapSet3;
5202 Property::Map underlineMapGet3;
5204 underlineMapSet3.Insert("enable", true);
5205 underlineMapSet3.Insert("color", Color::BLUE);
5206 underlineMapSet3.Insert("height", 1);
5207 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5208 underlineMapSet3.Insert("dashWidth", 4);
5209 underlineMapSet3.Insert("dashGap", 2);
5211 // Check the dashed underline property
5212 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5214 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5215 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5216 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5218 application.GetScene().Add(field3);
5220 application.SendNotification();
5221 application.Render();
5226 int UtcDaliTextFieldCharacterSpacing(void)
5228 ToolkitTestApplication application;
5229 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5231 TextField textField = TextField::New();
5233 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5235 application.GetScene().Add(textField);
5236 application.SendNotification();
5237 application.Render();
5239 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5240 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5241 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5243 application.SendNotification();
5244 application.Render();
5249 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5251 ToolkitTestApplication application;
5252 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5254 TextField field1 = TextField::New();
5255 field1.SetProperty(TextField::Property::TEXT, "Test1");
5256 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5257 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5258 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5260 Property::Map underlineMapSet1;
5261 Property::Map underlineMapGet1;
5263 underlineMapSet1.Insert("enable", true);
5264 underlineMapSet1.Insert("color", Color::RED);
5265 underlineMapSet1.Insert("height", 1);
5266 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5267 underlineMapSet1.Insert("dashWidth", 2);
5268 underlineMapSet1.Insert("dashGap", 1);
5270 // Check the underline property
5271 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5272 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5274 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5275 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5276 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5278 application.GetScene().Add(field1);
5279 application.SendNotification();
5280 application.Render();
5285 int UtcDaliToolkitTextfieldParagraphTag(void)
5287 ToolkitTestApplication application;
5288 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5289 TextField fieldNewlineSeparator = TextField::New();
5290 TextField fieldParagraphTag = TextField::New();
5291 DALI_TEST_CHECK(fieldNewlineSeparator);
5292 DALI_TEST_CHECK(fieldParagraphTag);
5294 application.GetScene().Add(fieldNewlineSeparator);
5295 application.GetScene().Add(fieldParagraphTag);
5297 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5298 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5299 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5300 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5301 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5302 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5304 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5305 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5306 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5307 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5308 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5310 application.SendNotification();
5311 application.Render();
5313 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5314 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5316 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5318 application.SendNotification();
5319 application.Render();
5324 //Handle Emoji clustering for cursor handling
5325 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5327 ToolkitTestApplication application;
5328 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5329 TextField textField = TextField::New();
5330 DALI_TEST_CHECK(textField);
5332 application.GetScene().Add(textField);
5334 // Avoid a crash when core load gl resources.
5335 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5337 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5338 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5340 // Render and notify
5341 application.SendNotification();
5342 application.Render();
5345 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5346 application.SendNotification();
5347 application.Render();
5349 // Set focus and remove Emoji
5350 textField.SetKeyInputFocus();
5351 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5353 //Check the changed text and cursor position
5354 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5355 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5357 // Render and notify
5358 application.SendNotification();
5359 application.Render();
5364 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5366 ToolkitTestApplication application;
5367 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5368 TextField textField = TextField::New();
5369 DALI_TEST_CHECK(textField);
5371 application.GetScene().Add(textField);
5373 // Avoid a crash when core load gl resources.
5374 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5376 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5377 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5379 // Render and notify
5380 application.SendNotification();
5381 application.Render();
5384 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5385 application.SendNotification();
5386 application.Render();
5388 // Set focus and remove Emoji
5389 textField.SetKeyInputFocus();
5390 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5392 //Check the changed text and cursor position
5393 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5394 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5396 // Render and notify
5397 application.SendNotification();
5398 application.Render();