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>
25 #include <dali/devel-api/actors/actor-devel.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include <dali/devel-api/adaptor-framework/key-devel.h>
33 #include <dali/devel-api/text-abstraction/font-client.h>
34 #include "test-text-geometry-utils.h"
35 #include "toolkit-clipboard.h"
38 using namespace Toolkit;
40 void dali_textfield_startup(void)
42 test_return_value = TET_UNDEF;
45 void dali_textfield_cleanup(void)
47 test_return_value = TET_PASS;
52 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT = "text";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
56 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
57 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
58 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
59 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
60 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
61 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
62 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
63 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
64 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
99 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
101 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
102 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
105 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
111 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
112 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
113 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
114 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
116 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
117 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
119 const float RENDER_FRAME_INTERVAL = 16.66f;
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR("/resources/fonts");
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
127 const int KEY_SHIFT_MODIFIER = 257;
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gSelectionChangedCallbackCalled;
132 static uint32_t oldSelectionStart;
133 static uint32_t oldSelectionEnd;
134 static bool gSelectionClearedCallbackCalled;
135 static bool gSelectionStartedCallbackCalled;
136 static bool gAnchorClickedCallBackCalled;
137 static bool gAnchorClickedCallBackNotCalled;
138 static bool gTextChangedCallBackCalled;
139 static bool gMaxCharactersCallBackCalled;
140 static bool gInputFilteredAcceptedCallbackCalled;
141 static bool gInputFilteredRejectedCallbackCalled;
142 static bool gInputStyleChangedCallbackCalled;
143 static bool gCursorPositionChangedCallbackCalled;
144 static uint32_t oldCursorPos;
145 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
147 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
149 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
150 Integration::ResourcePointer resource(bitmap);
151 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
154 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
158 LoadBitmapResource(app.GetPlatform(), width, height);
160 Property::Map propertyMap;
161 propertyMap["filename"] = "image.png";
162 propertyMap["width"] = width;
163 propertyMap["height"] = height;
164 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
165 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
175 * Simulate time passed by.
177 * @note this will always process at least 1 frame (1/60 sec)
179 * @param application Test application instance
180 * @param duration Time to pass in milliseconds.
181 * @return The actual time passed in milliseconds
183 static int Wait(ToolkitTestApplication& application, int duration = 0)
187 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
189 application.SendNotification();
190 application.Render(RENDER_FRAME_INTERVAL);
191 time += RENDER_FRAME_INTERVAL;
197 Dali::Integration::Point GetPointDownInside(Vector2& pos)
199 Dali::Integration::Point point;
200 point.SetState(PointState::DOWN);
201 point.SetScreenPosition(pos);
205 Dali::Integration::Point GetPointUpInside(Vector2& pos)
207 Dali::Integration::Point point;
208 point.SetState(PointState::UP);
209 point.SetScreenPosition(pos);
213 struct CallbackFunctor
215 CallbackFunctor(bool* callbackFlag)
216 : mCallbackFlag(callbackFlag)
222 *mCallbackFlag = true;
227 static void TestSelectionClearedCallback(TextField control)
229 tet_infoline(" TestSelectionClearedCallback");
231 gSelectionClearedCallbackCalled = true;
234 static void TestSelectionStartedCallback(TextField control)
236 tet_infoline(" TestSelectionStartedCallback");
238 gSelectionStartedCallbackCalled = true;
241 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
243 tet_infoline(" TestSelectionChangedCallback");
245 gSelectionChangedCallbackCalled = true;
246 oldSelectionStart = oldStart;
247 oldSelectionEnd = oldEnd;
250 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
252 tet_infoline(" TestAnchorClickedCallback");
254 gAnchorClickedCallBackNotCalled = false;
256 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
258 gAnchorClickedCallBackCalled = true;
262 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
264 tet_infoline(" TestCursorPositionChangedCallback");
266 gCursorPositionChangedCallbackCalled = true;
267 oldCursorPos = oldPos;
270 static void TestTextChangedCallback(TextField control)
272 tet_infoline(" TestTextChangedCallback");
274 gTextChangedCallBackCalled = true;
277 static void TestMaxLengthReachedCallback(TextField control)
279 tet_infoline(" TestMaxLengthReachedCallback");
281 gMaxCharactersCallBackCalled = true;
284 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
286 tet_infoline(" TestInputFilteredCallback");
288 if(type == Toolkit::InputFilter::Property::ACCEPTED)
290 gInputFilteredAcceptedCallbackCalled = true;
292 else if(type == Toolkit::InputFilter::Property::REJECTED)
294 gInputFilteredRejectedCallbackCalled = true;
298 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
300 tet_infoline(" TestInputStyleChangedCallback");
302 gInputStyleChangedCallbackCalled = true;
303 gInputStyleMask = mask;
306 // Generate a KeyEvent to send to Core.
307 Integration::KeyEvent GenerateKey(const std::string& keyName,
308 const std::string& logicalKey,
309 const std::string& keyString,
312 unsigned long timeStamp,
313 const Integration::KeyEvent::State& keyState,
314 const std::string& compose = "",
315 const std::string& deviceName = DEFAULT_DEVICE_NAME,
316 const Device::Class::Type& deviceClass = Device::Class::NONE,
317 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
319 return Integration::KeyEvent(keyName,
332 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
334 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
336 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
338 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
340 Property::Value* valueSet = NULL;
341 if(valueGet.first.type == Property::Key::INDEX)
343 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
347 // Get Key is a string so searching Set Map for a string key
348 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
353 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
355 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
358 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
360 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
363 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
365 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
368 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
370 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
373 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
375 Vector2 vector2Get = valueGet.second.Get<Vector2>();
376 Vector2 vector2Set = valueSet->Get<Vector2>();
377 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
380 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
382 Vector4 vector4Get = valueGet.second.Get<Vector4>();
383 Vector4 vector4Set = valueSet->Get<Vector4>();
384 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);
390 if(valueGet.first.type == Property::Key::INDEX)
392 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
396 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
408 int UtcDaliToolkitTextFieldConstructorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
413 DALI_TEST_CHECK(!textField);
417 int UtcDaliToolkitTextFieldNewP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldNewP");
421 TextField textField = TextField::New();
422 DALI_TEST_CHECK(textField);
426 int UtcDaliToolkitTextFieldDownCastP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
430 TextField textField1 = TextField::New();
431 BaseHandle object(textField1);
433 TextField textField2 = TextField::DownCast(object);
434 DALI_TEST_CHECK(textField2);
436 TextField textField3 = DownCast<TextField>(object);
437 DALI_TEST_CHECK(textField3);
441 int UtcDaliToolkitTextFieldDownCastN(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
445 BaseHandle uninitializedObject;
446 TextField textField1 = TextField::DownCast(uninitializedObject);
447 DALI_TEST_CHECK(!textField1);
449 TextField textField2 = DownCast<TextField>(uninitializedObject);
450 DALI_TEST_CHECK(!textField2);
454 int UtcDaliToolkitTextFieldCopyConstructorP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
458 TextField textField = TextField::New();
459 textField.SetProperty(TextField::Property::TEXT, "Test");
461 TextField copy(textField);
462 DALI_TEST_CHECK(copy);
463 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
467 int UtcDaliTextFieldMoveConstructor(void)
469 ToolkitTestApplication application;
471 TextField textField = TextField::New();
472 textField.SetProperty(TextEditor::Property::TEXT, "Test");
473 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
475 TextField moved = std::move(textField);
476 DALI_TEST_CHECK(moved);
477 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
478 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
479 DALI_TEST_CHECK(!textField);
484 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
486 ToolkitTestApplication application;
487 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
488 TextField textField = TextField::New();
489 textField.SetProperty(TextField::Property::TEXT, "Test");
491 TextField copy = textField;
492 DALI_TEST_CHECK(copy);
493 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
497 int UtcDaliTextFieldMoveAssignment(void)
499 ToolkitTestApplication application;
501 TextField textField = TextField::New();
502 textField.SetProperty(TextEditor::Property::TEXT, "Test");
503 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
506 moved = std::move(textField);
507 DALI_TEST_CHECK(moved);
508 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
509 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
510 DALI_TEST_CHECK(!textField);
515 int UtcDaliTextFieldNewP(void)
517 ToolkitTestApplication application;
518 tet_infoline(" UtcDaliToolkitTextFieldNewP");
519 TextField textField = TextField::New();
520 DALI_TEST_CHECK(textField);
524 // Positive test case for a method
525 int UtcDaliTextFieldGetPropertyP(void)
527 ToolkitTestApplication application;
528 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
529 TextField field = TextField::New();
530 DALI_TEST_CHECK(field);
532 // Check Property Indices are correct
533 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
534 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
535 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
536 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
537 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
538 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
539 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
540 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
541 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
542 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
543 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
544 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
545 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
546 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
547 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
548 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
549 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
550 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
551 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
552 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
553 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
554 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
555 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
556 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
557 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
558 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
559 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
560 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
561 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
562 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
563 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
564 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
565 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
566 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
567 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
568 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
569 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
570 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
571 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
572 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
573 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
574 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
575 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
576 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
577 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
578 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
579 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
580 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
581 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
582 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
583 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
585 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
598 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
601 Property::Map imageMap;
602 imageMap[mapKey] = mapValue;
604 field.SetProperty(property, imageMap);
605 Property::Value propValue = field.GetProperty(property);
606 Property::Map* resultMap = propValue.GetMap();
608 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
616 // Positive test case for a method
617 int UtcDaliTextFieldSetPropertyP(void)
619 ToolkitTestApplication application;
620 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
621 TextField field = TextField::New();
622 DALI_TEST_CHECK(field);
623 application.GetScene().Add(field);
625 // Note - we can't check the defaults since the stylesheets are platform-specific
627 // Check the render backend property.
628 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
629 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
631 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
632 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
634 // Check text property.
635 field.SetProperty(TextField::Property::TEXT, "Setting Text");
636 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
638 // Check placeholder text properties.
639 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
640 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
642 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
643 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
645 // Check font properties.
646 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
647 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
649 Property::Map fontStyleMapSet;
650 Property::Map fontStyleMapGet;
651 Property::Value* slantValue = NULL;
653 fontStyleMapSet.Insert("weight", "bold");
654 fontStyleMapSet.Insert("width", "condensed");
655 fontStyleMapSet.Insert("slant", "italic");
656 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
658 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
659 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
660 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
662 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
663 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
665 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
666 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
667 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
669 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
670 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
671 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
674 fontStyleMapSet.Clear();
675 fontStyleMapSet.Insert("weight", "normal");
676 fontStyleMapSet.Insert("slant", "oblique");
677 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
679 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
680 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
681 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
683 fontStyleMapSet.Clear();
684 fontStyleMapSet.Insert("slant", "roman");
685 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
686 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
688 // Replace 'roman' for 'normal'.
689 slantValue = fontStyleMapGet.Find("slant");
690 if(NULL != slantValue)
692 if("normal" == slantValue->Get<std::string>())
694 fontStyleMapGet["slant"] = "roman";
697 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
698 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
700 fontStyleMapSet.Clear();
702 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
703 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
704 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
705 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
707 // Check that the MAX_LENGTH property can be correctly set
708 const int maxNumberOfCharacters = 20;
709 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
710 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
712 // Check exceed policy
713 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
714 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
715 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
716 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
718 // Check that the Alignment properties can be correctly set
719 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
720 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
721 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
722 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
724 // Check text's color property
725 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
726 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
728 // Check placeholder text's color property.
729 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
730 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
732 // Check cursor properties
733 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
734 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
735 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
736 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
738 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
739 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
740 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
741 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
742 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
743 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
744 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
745 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
747 // Check scroll properties.
748 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
749 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
750 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
751 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
753 // Check handle images
754 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
755 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
756 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
757 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
758 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
760 // Check handle images
761 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
762 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
763 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
764 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
765 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
766 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
768 // Check the highlight color
769 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
770 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
772 // Decoration bounding box
773 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
774 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
776 // Check the input method setting
777 Property::Map propertyMap;
778 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
779 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
780 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
781 int inputVariation = 1;
782 propertyMap["PANEL_LAYOUT"] = panelLayout;
783 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
784 propertyMap["BUTTON_ACTION"] = buttonAction;
785 propertyMap["VARIATION"] = inputVariation;
786 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
788 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
790 DALI_TEST_CHECK(value.Get(map));
793 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
794 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
797 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
798 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
801 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
802 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
805 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
806 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
808 // Check input color property.
809 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
810 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
812 // Check the enable markup property.
813 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
814 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
815 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
817 // Check input font properties.
818 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
819 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
821 fontStyleMapSet.Clear();
822 fontStyleMapSet.Insert("weight", "bold");
823 fontStyleMapSet.Insert("width", "condensed");
824 fontStyleMapSet.Insert("slant", "italic");
826 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
827 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
828 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
829 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
831 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
832 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
834 // Reset input font style.
835 fontStyleMapSet.Clear();
836 fontStyleMapSet.Insert("weight", "normal");
837 fontStyleMapSet.Insert("slant", "oblique");
839 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
840 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
841 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
842 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
844 fontStyleMapSet.Clear();
845 fontStyleMapSet.Insert("slant", "roman");
847 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
848 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
850 // Replace 'roman' for 'normal'.
851 slantValue = fontStyleMapGet.Find("slant");
852 if(NULL != slantValue)
854 if("normal" == slantValue->Get<std::string>())
856 fontStyleMapGet["slant"] = "roman";
859 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
860 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
862 fontStyleMapSet.Clear();
864 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
865 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
866 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
867 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
869 Property::Map strikethroughMapSet;
870 Property::Map strikethroughMapGet;
872 strikethroughMapSet.Insert("enable", true);
873 strikethroughMapSet.Insert("color", Color::RED);
874 strikethroughMapSet.Insert("height", 2.0f);
876 // Check the strikethrough property
877 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
879 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
880 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
881 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
883 // Check the input strikethrough property
884 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
885 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
887 Property::Map underlineMapSet;
888 Property::Map underlineMapGet;
890 underlineMapSet.Insert("enable", true);
891 underlineMapSet.Insert("color", Color::RED);
892 underlineMapSet.Insert("height", 1);
893 underlineMapSet.Insert("type", Text::Underline::SOLID);
894 underlineMapSet.Insert("dashWidth", 2);
895 underlineMapSet.Insert("dashGap", 1);
897 // Check the underline property
898 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
900 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
901 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
902 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
905 application.SendNotification();
906 application.Render();
908 underlineMapSet.Clear();
909 underlineMapGet.Clear();
911 underlineMapSet.Insert("enable", true);
912 underlineMapSet.Insert("color", Color::BLUE);
913 underlineMapSet.Insert("height", 1);
914 underlineMapSet.Insert("type", Text::Underline::DASHED);
915 underlineMapSet.Insert("dashWidth", 4);
916 underlineMapSet.Insert("dashGap", 2);
918 // Check the dashed underline property
919 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
921 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
922 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
923 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
926 application.SendNotification();
927 application.Render();
929 underlineMapSet.Clear();
930 underlineMapGet.Clear();
932 underlineMapSet.Insert("enable", true);
933 underlineMapSet.Insert("color", Color::BLUE);
934 underlineMapSet.Insert("height", 4);
935 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
936 underlineMapSet.Insert("dashWidth", 4);
937 underlineMapSet.Insert("dashGap", 2);
939 // Check the dashed underline property
940 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
942 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
943 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
944 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
947 application.SendNotification();
948 application.Render();
950 underlineMapSet.Clear();
951 underlineMapGet.Clear();
953 // Check the input underline property
954 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
955 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
957 // Check the shadow property
958 Property::Map shadowMapSet;
959 Property::Map shadowMapGet;
961 shadowMapSet.Insert("color", Color::GREEN);
962 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
963 shadowMapSet.Insert("blurRadius", 3.0f);
965 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
967 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
968 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
969 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
971 // Check the input shadow property
972 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
973 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
975 // Check the emboss property
976 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
977 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
979 // Check the input emboss property
980 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
981 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
983 // Check the outline property
985 // Test string type first
986 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
987 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
988 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
990 // Then test the property map type
991 Property::Map outlineMapSet;
992 Property::Map outlineMapGet;
994 outlineMapSet["color"] = Color::RED;
995 outlineMapSet["width"] = 2.0f;
997 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
999 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1000 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1001 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1003 // Check the input outline property
1004 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1005 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1007 // Check the hidden input settings property
1008 Property::Map hiddenMapSet;
1009 Property::Map hiddenMapGet;
1010 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1011 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1012 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1013 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1014 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1016 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1017 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1018 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1020 // Check the pixel size of font
1021 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1022 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1024 // Check the enable selection property
1025 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1026 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1028 // Check the placeholder property with pixel size
1029 Property::Map placeholderPixelSizeMapSet;
1030 Property::Map placeholderPixelSizeMapGet;
1031 Property::Map placeholderFontstyleMap;
1032 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1033 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1034 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1035 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1036 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1037 placeholderPixelSizeMapSet["ellipsis"] = true;
1039 placeholderFontstyleMap.Insert("weight", "bold");
1040 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1041 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1043 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1044 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1046 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1047 Property::Map placeholderConversionMap;
1048 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1049 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1050 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1051 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1052 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1053 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1055 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1057 // Check the placeholder property with point size
1058 Property::Map placeholderMapSet;
1059 Property::Map placeholderMapGet;
1060 placeholderMapSet["text"] = "Setting Placeholder Text";
1061 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1062 placeholderMapSet["color"] = Color::RED;
1063 placeholderMapSet["fontFamily"] = "Arial";
1064 placeholderMapSet["pointSize"] = 12.0f;
1065 placeholderMapSet["ellipsis"] = false;
1067 // Check the placeholder font style property
1068 placeholderFontstyleMap.Clear();
1070 placeholderFontstyleMap.Insert("weight", "bold");
1071 placeholderFontstyleMap.Insert("width", "condensed");
1072 placeholderFontstyleMap.Insert("slant", "italic");
1073 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1074 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1076 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1077 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1079 placeholderConversionMap.Clear();
1080 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1081 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1082 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1083 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1084 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1085 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1087 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1089 // Reset font style.
1090 placeholderFontstyleMap.Clear();
1091 placeholderFontstyleMap.Insert("weight", "normal");
1092 placeholderFontstyleMap.Insert("slant", "oblique");
1093 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1094 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1096 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1097 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1099 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1100 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1102 placeholderFontstyleMap.Clear();
1103 placeholderFontstyleMap.Insert("slant", "roman");
1104 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1105 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1107 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1109 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1111 placeholderFontstyleMap.Clear();
1112 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1113 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1115 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1116 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1117 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1119 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1121 // Check the ellipsis property
1122 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1123 field.SetProperty(TextField::Property::ELLIPSIS, true);
1124 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1126 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1127 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1129 // Test the ENABLE_GRAB_HANDLE_POPUP property
1130 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1131 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1132 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1134 // Check the background property
1135 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1136 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1138 //Check handle color
1139 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1140 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1142 // Check the input filter property
1143 Property::Map inputFilterMapSet;
1144 Property::Map inputFilterMapGet;
1145 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1146 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1148 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1150 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1151 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1154 inputFilterMapSet.Clear();
1155 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1157 application.SendNotification();
1158 application.Render();
1163 // Positive Atlas Text Renderer test
1164 int utcDaliTextFieldAtlasRenderP(void)
1166 ToolkitTestApplication application;
1167 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1168 StyleManager styleManager = StyleManager::Get();
1169 styleManager.ApplyDefaultTheme();
1170 TextField field = TextField::New();
1171 DALI_TEST_CHECK(field);
1173 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1175 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1177 application.GetScene().Add(field);
1181 // Render some text with the shared atlas backend
1182 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1183 application.SendNotification();
1184 application.Render();
1188 tet_result(TET_FAIL);
1193 // Positive test for the anchorClicked signal.
1194 int utcDaliTextFieldAnchorClicked01(void)
1196 ToolkitTestApplication application;
1197 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1198 TextField field = TextField::New();
1199 DALI_TEST_CHECK(field);
1201 application.GetScene().Add(field);
1203 // connect to the anchor clicked signal.
1204 ConnectionTracker* testTracker = new ConnectionTracker();
1205 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1206 bool anchorClickedSignal = false;
1207 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1209 gAnchorClickedCallBackCalled = false;
1210 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1211 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1212 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1213 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1214 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1216 application.SendNotification();
1217 application.Render();
1218 field.SetKeyInputFocus();
1220 // Create a tap event to touch the text field.
1221 TestGenerateTap(application, 5.0f, 25.0f);
1222 application.SendNotification();
1223 application.Render();
1225 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1226 DALI_TEST_CHECK(anchorClickedSignal);
1228 gAnchorClickedCallBackNotCalled = true;
1229 // Tap the outside of anchor, callback should not be called.
1230 TestGenerateTap(application, 150.f, 100.f);
1231 application.SendNotification();
1232 application.Render();
1234 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1239 // Positive test for the anchorClicked signal.
1240 int utcDaliTextFieldAnchorClicked02(void)
1242 ToolkitTestApplication application;
1243 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1244 TextField field = TextField::New();
1245 DALI_TEST_CHECK(field);
1247 application.GetScene().Add(field);
1249 // connect to the anchor clicked signal.
1250 ConnectionTracker* testTracker = new ConnectionTracker();
1251 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1252 bool anchorClickedSignal = false;
1253 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1255 gAnchorClickedCallBackCalled = false;
1256 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1258 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1259 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1260 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1262 application.SendNotification();
1263 application.Render();
1264 field.SetKeyInputFocus();
1266 // Avoid a crash when core load gl resources.
1267 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1269 // Create a tap event to touch the text field.
1270 TestGenerateTap(application, 30.0f, 25.0f, 100);
1271 application.SendNotification();
1272 application.Render();
1274 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1275 DALI_TEST_CHECK(anchorClickedSignal);
1277 // For coverage InsertTextAnchor, RemoveTextAnchor
1278 // first index insert
1279 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1280 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1281 application.SendNotification();
1282 application.Render();
1284 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1285 application.SendNotification();
1286 application.Render();
1288 gAnchorClickedCallBackCalled = false;
1289 // Create a tap event to touch the text field.
1290 TestGenerateTap(application, 30.0f, 25.0f, 700);
1291 application.SendNotification();
1292 field.SetKeyInputFocus();
1294 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1296 // last index insert
1297 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1298 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1299 application.SendNotification();
1300 application.Render();
1302 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1303 application.SendNotification();
1304 application.Render();
1306 gAnchorClickedCallBackCalled = false;
1307 // Create a tap event to touch the text field.
1308 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1309 application.SendNotification();
1310 field.SetKeyInputFocus();
1312 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1315 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1316 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1317 application.SendNotification();
1318 application.Render();
1320 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1321 application.SendNotification();
1322 application.Render();
1324 gAnchorClickedCallBackCalled = false;
1325 // Create a tap event to touch the text field.
1326 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1327 application.SendNotification();
1328 field.SetKeyInputFocus();
1330 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1332 // first index remove
1333 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1334 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1335 application.SendNotification();
1336 application.Render();
1338 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1339 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));
1340 application.SendNotification();
1341 application.Render();
1343 gAnchorClickedCallBackCalled = false;
1344 // Create a tap event to touch the text field.
1345 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1346 application.SendNotification();
1347 field.SetKeyInputFocus();
1349 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1351 // last index remove
1352 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1353 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1354 application.SendNotification();
1355 application.Render();
1357 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1358 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));
1359 application.SendNotification();
1360 application.Render();
1362 gAnchorClickedCallBackCalled = false;
1363 // Create a tap event to touch the text field.
1364 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1365 application.SendNotification();
1366 application.Render();
1368 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1371 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1372 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1373 application.SendNotification();
1374 application.Render();
1376 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1377 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));
1378 application.SendNotification();
1379 application.Render();
1381 gAnchorClickedCallBackCalled = false;
1382 // Create a tap event to touch the text field.
1383 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1384 application.SendNotification();
1385 application.Render();
1387 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1389 // 0 ~ 1 index remove
1390 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1391 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1392 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1393 application.SendNotification();
1394 application.Render();
1396 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1397 application.SendNotification();
1398 application.Render();
1400 gAnchorClickedCallBackCalled = false;
1401 // Create a tap event to touch the text field.
1402 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1408 // 1 ~ 3 index remove
1409 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1410 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1411 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1412 application.SendNotification();
1413 application.Render();
1415 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1416 application.SendNotification();
1417 application.Render();
1419 gAnchorClickedCallBackCalled = false;
1420 // Create a tap event to touch the text field.
1421 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1427 // 3 ~ 4 index remove
1428 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1429 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1430 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1431 application.SendNotification();
1432 application.Render();
1434 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1435 application.SendNotification();
1436 application.Render();
1438 gAnchorClickedCallBackCalled = false;
1439 // Create a tap event to touch the text field.
1440 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1441 application.SendNotification();
1442 application.Render();
1444 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1446 // Remove front of anchor
1447 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1448 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1449 application.SendNotification();
1450 application.Render();
1452 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1453 application.SendNotification();
1454 application.Render();
1456 // Remove whole text
1457 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1458 DevelTextField::SelectWholeText(field);
1459 application.SendNotification();
1460 application.Render();
1462 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1463 application.SendNotification();
1464 application.Render();
1466 // Remove all with backspace
1467 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1468 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1469 application.SendNotification();
1470 application.Render();
1472 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1473 application.SendNotification();
1474 application.Render();
1476 // Remove all with delete
1477 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1478 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1479 application.SendNotification();
1480 application.Render();
1482 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));
1483 application.SendNotification();
1484 application.Render();
1489 // Positive test for the textChanged signal.
1490 int utcDaliTextFieldTextChangedP(void)
1492 ToolkitTestApplication application;
1493 tet_infoline(" utcDaliTextFieldTextChangedP");
1494 TextField field = TextField::New();
1495 DALI_TEST_CHECK(field);
1497 application.GetScene().Add(field);
1499 // connect to the text changed signal.
1500 ConnectionTracker* testTracker = new ConnectionTracker();
1501 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1502 bool textChangedSignal = false;
1503 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1505 gTextChangedCallBackCalled = false;
1506 field.SetProperty(TextField::Property::TEXT, "ABC");
1507 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1508 DALI_TEST_CHECK(textChangedSignal);
1510 application.SendNotification();
1511 field.SetKeyInputFocus();
1513 gTextChangedCallBackCalled = false;
1514 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1515 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1518 field.SetProperty(TextField::Property::TEXT, "");
1520 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1521 gTextChangedCallBackCalled = false;
1522 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1523 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1525 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1526 gTextChangedCallBackCalled = false;
1527 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1528 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1533 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1535 ToolkitTestApplication application;
1536 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1537 TextField field = TextField::New();
1538 DALI_TEST_CHECK(field);
1540 application.GetScene().Add(field);
1542 // connect to the text changed signal.
1543 ConnectionTracker* testTracker = new ConnectionTracker();
1544 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1545 bool textChangedSignal = false;
1546 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1548 // get InputMethodContext
1550 InputMethodContext::EventData imfEvent;
1551 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1553 field.SetKeyInputFocus();
1554 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1557 gTextChangedCallBackCalled = false;
1558 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1559 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1560 application.SendNotification();
1561 application.Render();
1562 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1563 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1565 gTextChangedCallBackCalled = false;
1566 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1567 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1568 application.SendNotification();
1569 application.Render();
1570 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1571 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1573 gTextChangedCallBackCalled = false;
1574 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1575 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1576 application.SendNotification();
1577 application.Render();
1578 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1579 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1581 gTextChangedCallBackCalled = false;
1582 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1583 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1584 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1586 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1587 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1588 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1590 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1591 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1592 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1594 application.SendNotification();
1595 application.Render();
1596 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1597 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1602 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1606 TextField field = TextField::New();
1607 DALI_TEST_CHECK(field);
1609 field.SetProperty(TextField::Property::TEXT, "Hello world");
1611 application.GetScene().Add(field);
1613 // connect to the selection changed signal.
1614 ConnectionTracker* testTracker = new ConnectionTracker();
1615 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1616 bool selectionChangedSignal = false;
1617 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1619 // get InputMethodContext
1621 InputMethodContext::EventData imfEvent;
1622 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1624 field.SetKeyInputFocus();
1625 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1628 gSelectionChangedCallbackCalled = false;
1629 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1630 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1631 application.SendNotification();
1632 application.Render();
1633 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1635 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1636 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1641 int utcDaliTextFieldPositionWithInputMethodContext(void)
1643 ToolkitTestApplication application;
1644 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1645 TextField field = TextField::New();
1646 DALI_TEST_CHECK(field);
1648 field.SetProperty(TextField::Property::TEXT, "Hello world");
1650 application.GetScene().Add(field);
1652 // connect to the selection changed signal.
1653 ConnectionTracker* testTracker = new ConnectionTracker();
1654 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1655 bool cursorPositionChangedSignal = false;
1656 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1658 // get InputMethodContext
1660 InputMethodContext::EventData imfEvent;
1661 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1663 field.SetKeyInputFocus();
1664 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1667 gCursorPositionChangedCallbackCalled = false;
1668 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1669 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1670 application.SendNotification();
1671 application.Render();
1672 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1674 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1679 // Negative test for the textChanged signal.
1680 int utcDaliTextFieldTextChangedN(void)
1682 ToolkitTestApplication application;
1683 tet_infoline(" utcDaliTextFieldTextChangedN");
1684 TextField field = TextField::New();
1685 DALI_TEST_CHECK(field);
1687 application.GetScene().Add(field);
1689 // connect to the text changed signal.
1690 ConnectionTracker* testTracker = new ConnectionTracker();
1691 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1692 bool textChangedSignal = false;
1693 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1695 gTextChangedCallBackCalled = false;
1696 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1697 application.SendNotification();
1698 application.Render();
1699 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1700 DALI_TEST_CHECK(!textChangedSignal);
1705 // Positive test for Max Characters reached signal.
1706 int utcDaliTextFieldMaxCharactersReachedP(void)
1708 ToolkitTestApplication application;
1709 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1710 TextField field = TextField::New();
1711 DALI_TEST_CHECK(field);
1713 application.GetScene().Add(field);
1715 const int maxNumberOfCharacters = 1;
1716 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1718 field.SetKeyInputFocus();
1720 // connect to the text changed signal.
1721 ConnectionTracker* testTracker = new ConnectionTracker();
1722 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1723 bool maxLengthReachedSignal = false;
1724 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1726 gMaxCharactersCallBackCalled = false;
1728 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1729 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1731 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1732 DALI_TEST_CHECK(maxLengthReachedSignal);
1737 // Negative test for Max Characters reached signal.
1738 int utcDaliTextFieldMaxCharactersReachedN(void)
1740 ToolkitTestApplication application;
1741 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1742 TextField field = TextField::New();
1743 DALI_TEST_CHECK(field);
1745 application.GetScene().Add(field);
1747 const int maxNumberOfCharacters = 3;
1748 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1750 field.SetKeyInputFocus();
1752 // connect to the text changed signal.
1753 ConnectionTracker* testTracker = new ConnectionTracker();
1754 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1755 bool maxLengthReachedSignal = false;
1756 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1758 gMaxCharactersCallBackCalled = false;
1760 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1761 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1763 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1764 DALI_TEST_CHECK(!maxLengthReachedSignal);
1766 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1768 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1769 DALI_TEST_CHECK(!maxLengthReachedSignal);
1774 // Positive test for Input Filtered signal.
1775 int utcDaliTextFieldInputFilteredP(void)
1777 ToolkitTestApplication application;
1778 tet_infoline(" utcDaliTextFieldInputFilteredP");
1779 TextField field = TextField::New();
1780 DALI_TEST_CHECK(field);
1782 application.GetScene().Add(field);
1784 Property::Map inputFilter;
1786 // Only digit is accepted.
1787 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1789 // Set input filter to TextField.
1790 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1792 field.SetKeyInputFocus();
1794 // connect to the input filtered signal.
1795 ConnectionTracker* testTracker = new ConnectionTracker();
1796 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1797 bool inputFilteredSignal = false;
1798 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1800 gInputFilteredAcceptedCallbackCalled = false;
1802 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1804 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1805 DALI_TEST_CHECK(inputFilteredSignal);
1807 // Word is rejected.
1808 inputFilter[InputFilter::Property::ACCEPTED] = "";
1809 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1811 // Set input filter to TextField.
1812 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1814 field.SetKeyInputFocus();
1816 inputFilteredSignal = false;
1817 gInputFilteredRejectedCallbackCalled = false;
1819 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1821 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1822 DALI_TEST_CHECK(inputFilteredSignal);
1827 // Negative test for Input Filtered signal.
1828 int utcDaliTextFieldInputFilteredN(void)
1830 ToolkitTestApplication application;
1831 tet_infoline(" utcDaliTextFieldInputFilteredP");
1832 TextField field = TextField::New();
1833 DALI_TEST_CHECK(field);
1835 application.GetScene().Add(field);
1837 Property::Map inputFilter;
1839 // Only word is accepted.
1840 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1842 // Set input filter to TextField.
1843 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1845 field.SetKeyInputFocus();
1847 // connect to the input filtered signal.
1848 ConnectionTracker* testTracker = new ConnectionTracker();
1849 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1850 bool inputFilteredSignal = false;
1851 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1853 gInputFilteredAcceptedCallbackCalled = false;
1855 // Key a, d should not be filtered.
1856 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1857 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1858 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1859 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1861 // Backspace, Delete should not be filtered.
1862 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1863 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));
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1870 DALI_TEST_CHECK(!inputFilteredSignal);
1872 // Digit is rejected.
1873 inputFilter[InputFilter::Property::ACCEPTED] = "";
1874 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1876 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1878 field.SetKeyInputFocus();
1880 inputFilteredSignal = false;
1881 gInputFilteredRejectedCallbackCalled = false;
1883 // Key a, d should not be filtered.
1884 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1885 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1886 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1887 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1889 // Backspace, Delete should not be filtered.
1890 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1891 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));
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1898 DALI_TEST_CHECK(!inputFilteredSignal);
1903 int utcDaliTextFieldInputStyleChanged01(void)
1905 // The text-field emits signals when the input style changes. These changes of style are
1906 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1907 // can't be emitted during the size negotiation as the callbacks may update the UI.
1908 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1909 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1910 ToolkitTestApplication application;
1911 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1915 char* pathNamePtr = get_current_dir_name();
1916 const std::string pathName(pathNamePtr);
1919 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1920 fontClient.SetDpi(93u, 93u);
1922 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1923 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1925 TextField field = TextField::New();
1926 DALI_TEST_CHECK(field);
1928 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1929 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1930 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1932 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1933 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1935 // connect to the text changed signal.
1936 ConnectionTracker* testTracker = new ConnectionTracker();
1937 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1938 bool inputStyleChangedSignal = false;
1939 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1941 application.GetScene().Add(field);
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Executes the idle callbacks added by the text control on the change of input style.
1948 application.RunIdles();
1950 gInputStyleChangedCallbackCalled = false;
1951 gInputStyleMask = TextField::InputStyle::NONE;
1952 inputStyleChangedSignal = false;
1954 // Create a tap event to touch the text field.
1955 TestGenerateTap(application, 18.0f, 25.0f);
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 // Executes the idle callbacks added by the text control on the change of input style.
1962 application.RunIdles();
1964 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1965 if(gInputStyleChangedCallbackCalled)
1967 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1969 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1970 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1972 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1973 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1975 DALI_TEST_CHECK(inputStyleChangedSignal);
1977 gInputStyleChangedCallbackCalled = false;
1978 gInputStyleMask = TextField::InputStyle::NONE;
1979 inputStyleChangedSignal = false;
1981 // Create a tap event to touch the text field.
1982 TestGenerateTap(application, 30.0f, 25.0f);
1984 // Render and notify
1985 application.SendNotification();
1986 application.Render();
1988 // Executes the idle callbacks added by the text control on the change of input style.
1989 application.RunIdles();
1991 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1992 DALI_TEST_CHECK(!inputStyleChangedSignal);
1994 gInputStyleChangedCallbackCalled = false;
1995 gInputStyleMask = TextField::InputStyle::NONE;
1996 inputStyleChangedSignal = false;
1998 // Create a tap event to touch the text field.
1999 TestGenerateTap(application, 43.0f, 25.0f);
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2005 // Executes the idle callbacks added by the text control on the change of input style.
2006 application.RunIdles();
2008 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2009 if(gInputStyleChangedCallbackCalled)
2011 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2013 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2014 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2016 DALI_TEST_CHECK(inputStyleChangedSignal);
2018 gInputStyleChangedCallbackCalled = false;
2019 gInputStyleMask = TextField::InputStyle::NONE;
2020 inputStyleChangedSignal = false;
2022 // Create a tap event to touch the text field.
2023 TestGenerateTap(application, 88.0f, 25.0f);
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2029 // Executes the idle callbacks added by the text control on the change of input style.
2030 application.RunIdles();
2032 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2033 if(gInputStyleChangedCallbackCalled)
2035 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2037 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2038 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2040 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2042 Property::Map fontStyleMapSet;
2043 fontStyleMapSet.Insert("weight", "bold");
2045 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2046 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2048 DALI_TEST_CHECK(inputStyleChangedSignal);
2050 gInputStyleChangedCallbackCalled = false;
2051 gInputStyleMask = TextField::InputStyle::NONE;
2052 inputStyleChangedSignal = false;
2054 // Create a tap event to touch the text field.
2055 TestGenerateTap(application, 115.0f, 25.0f);
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 // Executes the idle callbacks added by the text control on the change of input style.
2062 application.RunIdles();
2064 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2065 DALI_TEST_CHECK(!inputStyleChangedSignal);
2067 gInputStyleChangedCallbackCalled = false;
2068 gInputStyleMask = TextField::InputStyle::NONE;
2069 inputStyleChangedSignal = false;
2071 // Create a tap event to touch the text field.
2072 TestGenerateTap(application, 164.0f, 25.0f);
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 // Executes the idle callbacks added by the text control on the change of input style.
2079 application.RunIdles();
2081 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2082 if(gInputStyleChangedCallbackCalled)
2084 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2086 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2087 DALI_TEST_CHECK(style.empty());
2089 DALI_TEST_CHECK(inputStyleChangedSignal);
2091 gInputStyleChangedCallbackCalled = false;
2092 gInputStyleMask = TextField::InputStyle::NONE;
2093 inputStyleChangedSignal = false;
2095 // Create a tap event to touch the text field.
2096 TestGenerateTap(application, 191.0f, 25.0f);
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 // Executes the idle callbacks added by the text control on the change of input style.
2103 application.RunIdles();
2105 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2106 DALI_TEST_CHECK(!inputStyleChangedSignal);
2111 int utcDaliTextFieldInputStyleChanged02(void)
2113 // The text-field emits signals when the input style changes. These changes of style are
2114 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2115 // can't be emitted during the size negotiation as the callbacks may update the UI.
2116 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2117 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2118 ToolkitTestApplication application;
2119 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2123 char* pathNamePtr = get_current_dir_name();
2124 const std::string pathName(pathNamePtr);
2127 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2128 fontClient.SetDpi(93u, 93u);
2130 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2131 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2133 TextField field = TextField::New();
2134 DALI_TEST_CHECK(field);
2136 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2137 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2138 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2140 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2141 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>");
2143 // connect to the text changed signal.
2144 ConnectionTracker* testTracker = new ConnectionTracker();
2145 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2146 bool inputStyleChangedSignal = false;
2147 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2149 application.GetScene().Add(field);
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Executes the idle callbacks added by the text control on the change of input style.
2156 application.RunIdles();
2158 gInputStyleChangedCallbackCalled = false;
2159 gInputStyleMask = TextField::InputStyle::NONE;
2160 inputStyleChangedSignal = false;
2162 // Create a tap event to touch the text field.
2163 TestGenerateTap(application, 53.0f, 25.0f, 100);
2164 TestGenerateTap(application, 53.0f, 25.0f, 200);
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 // Executes the idle callbacks added by the text control on the change of input style.
2171 application.RunIdles();
2173 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2174 if(gInputStyleChangedCallbackCalled)
2176 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2177 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2178 TextField::InputStyle::POINT_SIZE |
2179 TextField::InputStyle::COLOR),
2182 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2183 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2185 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2186 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2188 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2189 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2191 DALI_TEST_CHECK(inputStyleChangedSignal);
2193 gInputStyleChangedCallbackCalled = false;
2194 gInputStyleMask = TextField::InputStyle::NONE;
2195 inputStyleChangedSignal = false;
2197 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Executes the idle callbacks added by the text control on the change of input style.
2204 application.RunIdles();
2206 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2207 if(gInputStyleChangedCallbackCalled)
2209 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2210 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2213 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2214 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2216 DALI_TEST_CHECK(inputStyleChangedSignal);
2218 gInputStyleChangedCallbackCalled = false;
2219 gInputStyleMask = TextField::InputStyle::NONE;
2220 inputStyleChangedSignal = false;
2222 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2224 // Render and notify
2225 application.SendNotification();
2226 application.Render();
2228 // Executes the idle callbacks added by the text control on the change of input style.
2229 application.RunIdles();
2231 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2232 DALI_TEST_CHECK(!inputStyleChangedSignal);
2234 gInputStyleChangedCallbackCalled = false;
2235 gInputStyleMask = TextField::InputStyle::NONE;
2236 inputStyleChangedSignal = false;
2238 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2244 // Executes the idle callbacks added by the text control on the change of input style.
2245 application.RunIdles();
2247 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2248 if(gInputStyleChangedCallbackCalled)
2250 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2251 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2254 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2255 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2257 DALI_TEST_CHECK(inputStyleChangedSignal);
2259 gInputStyleChangedCallbackCalled = false;
2260 gInputStyleMask = TextField::InputStyle::NONE;
2261 inputStyleChangedSignal = false;
2263 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2265 Property::Map fontStyleMapSet;
2266 fontStyleMapSet.Insert("weight", "thin");
2267 fontStyleMapSet.Insert("width", "condensed");
2268 fontStyleMapSet.Insert("slant", "italic");
2270 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2271 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2273 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2274 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2275 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2276 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2277 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 // Executes the idle callbacks added by the text control on the change of input style.
2284 application.RunIdles();
2286 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2287 DALI_TEST_CHECK(!inputStyleChangedSignal);
2289 // Create a tap event to touch the text field.
2290 TestGenerateTap(application, 63.0f, 25.0f, 700);
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 // Executes the idle callbacks added by the text control on the change of input style.
2297 application.RunIdles();
2299 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2300 if(gInputStyleChangedCallbackCalled)
2302 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2303 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2304 TextField::InputStyle::POINT_SIZE |
2305 TextField::InputStyle::FONT_STYLE |
2306 TextField::InputStyle::UNDERLINE |
2307 TextField::InputStyle::SHADOW |
2308 TextField::InputStyle::EMBOSS |
2309 TextField::InputStyle::OUTLINE),
2312 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2313 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2315 DALI_TEST_CHECK(inputStyleChangedSignal);
2320 int utcDaliTextFieldEvent01(void)
2322 ToolkitTestApplication application;
2323 tet_infoline(" utcDaliTextFieldEvent01");
2325 // Creates a tap event. After creating a tap event the text field should
2326 // have the focus and add text with key events should be possible.
2328 TextField field = TextField::New();
2329 DALI_TEST_CHECK(field);
2331 application.GetScene().Add(field);
2333 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2334 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2335 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2337 // Render and notify
2338 application.SendNotification();
2339 application.Render();
2341 // Avoid a crash when core load gl resources.
2342 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Add a key event but as the text field has not the focus it should do nothing.
2349 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2351 // Render and notify
2352 application.SendNotification();
2353 application.Render();
2355 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2357 // Create a tap event to touch the text field.
2358 TestGenerateTap(application, 150.0f, 25.0f);
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // Pressing delete key should be fine even if there is no text in TextField.
2365 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));
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 // Now the text field has the focus, so it can handle the key events.
2371 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2372 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2380 // Create a second text field and send key events to it.
2381 TextField field2 = TextField::New();
2383 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2384 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2385 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2386 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2388 application.GetScene().Add(field2);
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Create a tap event on the second text field.
2395 TestGenerateTap(application, 150.0f, 125.0f);
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // The second text field has the focus. It should handle the key events.
2402 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2403 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Check the text has been added to the second text field.
2410 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2415 int utcDaliTextFieldEvent02(void)
2417 ToolkitTestApplication application;
2418 tet_infoline(" utcDaliTextFieldEvent02");
2420 // Checks if the right number of actors are created.
2422 TextField field = TextField::New();
2423 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2424 DALI_TEST_CHECK(field);
2425 LoadMarkerImages(application, field);
2427 application.GetScene().Add(field);
2429 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2430 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2431 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2433 // Avoid a crash when core load gl resources.
2434 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2436 // Render and notify
2437 application.SendNotification();
2438 application.Render();
2440 // Check there are the expected number of children ( stencil ).
2441 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2443 Actor stencil = field.GetChildAt(0u);
2444 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2446 // Create a tap event to touch the text field.
2447 TestGenerateTap(application, 150.0f, 25.0f, 300);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 Actor layer = field.GetChildAt(2u);
2454 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2455 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2457 // Now the text field has the focus, so it can handle the key events.
2458 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 // Checks the cursor and the renderer have been created.
2466 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2467 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2469 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2470 DALI_TEST_CHECK(cursor);
2472 // The offscreen root actor has a container with all the actors which contain the text renderers.
2473 Actor container = stencil.GetChildAt(0u);
2474 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2476 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2477 DALI_TEST_CHECK(renderer);
2480 // Move the cursor and check the position changes.
2481 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2482 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2488 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2489 DALI_TEST_CHECK(position2.x < position1.x);
2491 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2498 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2500 // Move the cursor to the first position.
2501 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2504 // Render and notify
2505 application.SendNotification();
2506 application.Render();
2508 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2510 // Send some taps and check the cursor positions.
2512 // Try to tap at the beginning.
2513 TestGenerateTap(application, 1.0f, 25.0f, 900);
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // Cursor position should be the same than position1.
2520 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2522 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2524 // Tap away from the start position.
2525 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2533 DALI_TEST_CHECK(position6.x > position5.x);
2535 // Remove all the text.
2536 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2537 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2538 field.SetProperty(TextField::Property::TEXT, "");
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 // Cursor position should be the same than position2.
2545 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2547 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2549 // Should not be a renderer, there is only a clipped cursor.
2550 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2552 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2553 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2554 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2556 application.SendNotification();
2557 application.Render();
2559 // There are renderer and decorator layer
2560 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2565 int utcDaliTextFieldEvent03(void)
2567 ToolkitTestApplication application;
2568 tet_infoline(" utcDaliTextFieldEvent03");
2570 // Checks if the highlight actor is created.
2572 TextField field = TextField::New();
2573 DALI_TEST_CHECK(field);
2575 application.GetScene().Add(field);
2577 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2578 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2579 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2580 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2581 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2583 // Avoid a crash when core load gl resources.
2584 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2585 LoadMarkerImages(application, field);
2587 // Render and notify
2588 application.SendNotification();
2589 application.Render();
2591 // Tap first to get the focus.
2592 TestGenerateTap(application, 3.0f, 25.0f);
2594 // Render and notify
2595 application.SendNotification();
2596 application.Render();
2598 // Double tap to select a word.
2599 TestGenerateTap(application, 3.0f, 25.0f);
2601 // Render and notify
2602 application.SendNotification();
2603 application.Render();
2605 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2606 Actor stencil = field.GetChildAt(0u);
2608 // The highlight actor is drawn first, so is the first actor in the list
2609 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2610 DALI_TEST_CHECK(highlight);
2612 // The offscreen root actor has a container with all the actors which contain the text renderers.
2613 Actor container = stencil.GetChildAt(1u);
2614 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2616 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2617 DALI_TEST_CHECK(renderer);
2623 int utcDaliTextFieldEvent04(void)
2625 ToolkitTestApplication application;
2626 tet_infoline(" utcDaliTextFieldEvent04");
2628 // Checks if the highlight actor is created.
2630 TextField field = TextField::New();
2631 DALI_TEST_CHECK(field);
2632 application.GetScene().Add(field);
2633 LoadMarkerImages(application, field);
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2638 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2639 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2640 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2641 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2642 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2644 // Avoid a crash when core load gl resources.
2645 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2646 // Render and notify
2647 application.SendNotification();
2648 application.Render();
2650 // Create a tap event to touch the text field.
2651 TestGenerateTap(application, 150.0f, 25.0f);
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 // Tap first to get the focus.
2657 TestGenerateTap(application, 1.0f, 25.0f);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Double tap to select a word.
2664 TestGenerateTap(application, 1.0f, 25.0f);
2666 // Render and notify
2667 application.SendNotification();
2668 application.Render();
2671 TestGenerateTap(application, 0.0f, 40.0f);
2675 int utcDaliTextFieldEvent05(void)
2677 ToolkitTestApplication application;
2678 tet_infoline(" utcDaliTextFieldEvent05");
2680 // Checks dragging of cursor/grab handle
2682 TextField field = TextField::New();
2683 DALI_TEST_CHECK(field);
2684 application.GetScene().Add(field);
2685 LoadMarkerImages(application, field);
2686 // Render and notify
2687 application.SendNotification();
2688 application.Render();
2690 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2691 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2692 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2693 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2694 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2696 // Avoid a crash when core load gl resources.
2697 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2698 // Render and notify
2699 application.SendNotification();
2700 application.Render();
2702 // Create a tap event to touch the text field.
2703 TestGenerateTap(application, 150.0f, 25.0f);
2704 // Render and notify
2705 application.SendNotification();
2706 application.Render();
2708 // Tap first to get the focus.
2709 TestGenerateTap(application, 1.0f, 25.0f);
2711 // Render and notify
2712 application.SendNotification();
2713 application.Render();
2715 // Double tap to select a word.
2716 TestGenerateTap(application, 1.0f, 25.0f);
2718 // Render and notify
2719 application.SendNotification();
2720 application.Render();
2722 Actor stencil = field.GetChildAt(1u);
2726 int utcDaliTextFieldEvent06(void)
2728 ToolkitTestApplication application;
2729 tet_infoline(" utcDaliTextFieldEvent06");
2731 // Checks Longpress when in edit mode
2733 TextField field = TextField::New();
2734 DALI_TEST_CHECK(field);
2735 application.GetScene().Add(field);
2736 LoadMarkerImages(application, field);
2737 // Render and notify
2738 application.SendNotification();
2739 application.Render();
2741 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2742 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2743 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2744 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2745 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2747 // Avoid a crash when core load gl resources.
2748 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2749 // Render and notify
2750 application.SendNotification();
2751 application.Render();
2753 // Create a tap event to touch the text field.
2754 TestGenerateTap(application, 150.0f, 25.0f);
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 // Tap first to get the focus.
2760 TestGenerateTap(application, 1.0f, 25.0f);
2762 // Render and notify
2763 application.SendNotification();
2764 application.Render();
2767 TestGenerateLongPress(application, 1.0f, 25.0f);
2769 // Render and notify
2770 application.SendNotification();
2771 application.Render();
2776 int utcDaliTextFieldEvent07(void)
2778 ToolkitTestApplication application;
2779 tet_infoline(" utcDaliTextFieldEvent07");
2781 // Checks Longpress to start edit mode
2783 TextField field = TextField::New();
2784 DALI_TEST_CHECK(field);
2785 application.GetScene().Add(field);
2786 LoadMarkerImages(application, field);
2787 // Render and notify
2788 application.SendNotification();
2789 application.Render();
2791 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2792 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2793 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2794 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2795 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2796 Property::Map propertyMap;
2797 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2798 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2800 // Avoid a crash when core load gl resources.
2801 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2802 // Render and notify
2803 application.SendNotification();
2804 application.Render();
2807 TestGenerateLongPress(application, 1.0f, 25.0f);
2809 // Render and notify
2810 application.SendNotification();
2811 application.Render();
2816 int utcDaliTextFieldEvent08(void)
2818 ToolkitTestApplication application;
2819 tet_infoline(" utcDaliTextFieldEvent08");
2821 Dali::Clipboard clipboard = Clipboard::Get();
2822 clipboard.SetItem("testTextFieldEvent");
2824 // Checks Longpress when only place holder text
2826 TextField field = TextField::New();
2827 DALI_TEST_CHECK(field);
2828 application.GetScene().Add(field);
2829 LoadMarkerImages(application, field);
2830 // Render and notify
2831 application.SendNotification();
2832 application.Render();
2834 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2835 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2836 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2837 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2838 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2840 // Avoid a crash when core load gl resources.
2841 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2842 // Render and notify
2843 application.SendNotification();
2844 application.Render();
2847 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2849 // Render and notify
2850 application.SendNotification();
2851 application.Render();
2853 Wait(application, 500);
2855 TestEndLongPress(application, 1.0f, 25.0f, 520);
2858 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2860 // Render and notify
2861 application.Render();
2863 Wait(application, 500);
2865 Integration::Scene stage = application.GetScene();
2866 Layer layer = stage.GetRootLayer();
2867 Actor actor = layer.FindChildByName("optionPaste");
2871 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2872 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2873 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2875 Dali::Integration::TouchEvent event;
2876 event = Dali::Integration::TouchEvent();
2877 event.AddPoint(GetPointDownInside(position));
2878 application.ProcessEvent(event);
2880 event = Dali::Integration::TouchEvent();
2881 event.AddPoint(GetPointUpInside(position));
2882 application.ProcessEvent(event);
2884 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2889 int utcDaliTextFieldEvent09(void)
2891 ToolkitTestApplication application;
2892 tet_infoline(" utcDaliTextFieldEvent09");
2894 TextField field = TextField::New();
2895 DALI_TEST_CHECK(field);
2896 application.GetScene().Add(field);
2897 LoadMarkerImages(application, field);
2898 // Render and notify
2899 application.SendNotification();
2900 application.Render();
2902 field.SetProperty(TextField::Property::TEXT, "Hello");
2903 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2904 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2905 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2906 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2908 // Avoid a crash when core load gl resources.
2909 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2911 // Create a tap event to touch the text field.
2912 TestGenerateTap(application, 150.0f, 25.0f);
2913 application.SendNotification();
2914 application.Render();
2917 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2918 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2919 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2920 application.SendNotification();
2921 application.Render();
2923 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2924 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2925 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2926 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2927 application.SendNotification();
2928 application.Render();
2930 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2931 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2932 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2933 for(unsigned int index = 0u; index < 5u; ++index)
2935 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2936 application.SendNotification();
2937 application.Render();
2940 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
2941 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2942 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2943 for(unsigned int index = 0u; index < 5u; ++index)
2945 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2946 application.SendNotification();
2947 application.Render();
2950 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2951 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2952 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2953 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2954 application.SendNotification();
2955 application.Render();
2956 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2957 application.SendNotification();
2958 application.Render();
2960 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2961 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2962 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2963 application.SendNotification();
2964 application.Render();
2966 Property::Map mapGet;
2967 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2968 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2969 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2973 int utcDaliTextFieldStyleWhilstSelected(void)
2975 ToolkitTestApplication application;
2976 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2978 // Change font and styles whilst text is selected whilst word selected
2980 TextField field = TextField::New();
2981 DALI_TEST_CHECK(field);
2982 application.GetScene().Add(field);
2983 LoadMarkerImages(application, field);
2984 // Render and notify
2985 application.SendNotification();
2986 application.Render();
2988 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2989 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2990 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2991 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2992 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2994 // Avoid a crash when core load gl resources.
2995 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2996 // Render and notify
2997 application.SendNotification();
2998 application.Render();
3000 // Create a tap event to touch the text field.
3001 TestGenerateTap(application, 150.0f, 25.0f);
3002 // Render and notify
3003 application.SendNotification();
3004 application.Render();
3006 // Tap first to get the focus.
3007 TestGenerateTap(application, 1.0f, 25.0f);
3009 // Render and notify
3010 application.SendNotification();
3011 application.Render();
3013 // Double tap to select a word.
3014 TestGenerateTap(application, 1.0f, 25.0f);
3016 // Render and notify
3017 application.SendNotification();
3018 application.Render();
3020 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3021 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3023 Property::Map fontStyleMapSet;
3024 Property::Map fontStyleMapGet;
3026 fontStyleMapSet.Insert("weight", "bold");
3027 fontStyleMapSet.Insert("slant", "italic");
3028 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3030 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3031 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3032 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3034 fontStyleMapSet.Clear();
3035 fontStyleMapSet.Insert("width", "expanded");
3036 fontStyleMapSet.Insert("slant", "italic");
3037 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3039 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3040 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3041 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3043 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3044 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3046 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3047 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3049 fontStyleMapSet.Clear();
3050 fontStyleMapSet.Insert("weight", "bold");
3051 fontStyleMapSet.Insert("slant", "italic");
3053 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3055 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3056 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3057 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3059 fontStyleMapSet.Clear();
3060 fontStyleMapSet.Insert("width", "expanded");
3062 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3064 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3065 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3066 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3068 // Press Escape to increase coverage
3069 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3070 application.SendNotification();
3071 application.Render();
3073 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3078 int utcDaliTextFieldEscKeyLoseFocus(void)
3080 ToolkitTestApplication application;
3081 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3083 // Creates a tap event. After creating a tap event the text field should
3084 // have the focus and add text with key events should be possible.
3086 TextField field = TextField::New();
3087 DALI_TEST_CHECK(field);
3089 application.GetScene().Add(field);
3091 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3092 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3093 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3095 // Avoid a crash when core load gl resources.
3096 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3098 // Render and notify
3099 application.SendNotification();
3100 application.Render();
3102 // Add a key event but as the text field has not the focus it should do nothing.
3103 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3104 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3106 // Render and notify
3107 application.SendNotification();
3108 application.Render();
3110 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3112 // Create a tap event to touch the text field.
3113 TestGenerateTap(application, 150.0f, 25.0f);
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 // Now the text field has the focus, so it can handle the key events.
3120 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3121 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3122 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3123 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3125 // Render and notify
3126 application.SendNotification();
3127 application.Render();
3129 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3131 // Generate a Esc key event. The text field should lose the focus.
3132 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3133 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3135 // Render and notify
3136 application.SendNotification();
3137 application.Render();
3139 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3141 // No more text should be introduced
3142 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3143 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3145 // Render and notify
3146 application.SendNotification();
3147 application.Render();
3149 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3154 int utcDaliTextFieldSomeSpecialKeys(void)
3156 ToolkitTestApplication application;
3157 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3159 // Checks some special keys when the text is selected.
3161 TextField field = TextField::New();
3162 DALI_TEST_CHECK(field);
3163 application.GetScene().Add(field);
3164 LoadMarkerImages(application, field);
3165 // Render and notify
3166 application.SendNotification();
3167 application.Render();
3169 const std::string longText("This is a long text for the size of the text-field.");
3171 field.SetProperty(TextField::Property::TEXT, longText);
3172 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3173 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3174 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3175 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3177 // Avoid a crash when core load gl resources.
3178 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3179 // Render and notify
3180 application.SendNotification();
3181 application.Render();
3183 // Create a tap event to touch the text field.
3184 TestGenerateTap(application, 150.0f, 25.0f);
3186 // Render and notify
3187 application.SendNotification();
3188 application.Render();
3190 // Tap first to get the focus.
3191 TestGenerateTap(application, 1.0f, 25.0f);
3193 // Render and notify
3194 application.SendNotification();
3195 application.Render();
3197 // Double tap to select a word.
3198 TestGenerateTap(application, 1.0f, 25.0f);
3200 // Render and notify
3201 application.SendNotification();
3202 application.Render();
3204 // Generate a Esc key event. The text field should lose the focus.
3205 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3206 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3208 // Render and notify
3209 application.SendNotification();
3210 application.Render();
3212 // Generate a Esc key event. The text field should lose the focus.
3213 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3214 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3216 // Render and notify
3217 application.SendNotification();
3218 application.Render();
3220 // Generate a Esc key event. The text field should lose the focus.
3221 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3222 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3224 // Render and notify
3225 application.SendNotification();
3226 application.Render();
3228 // The text shouldn't be deleted.
3229 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3234 int utcDaliTextFieldSizeUpdate(void)
3236 ToolkitTestApplication application;
3237 tet_infoline("utcDaliTextFieldSizeUpdate");
3239 // Checks some special keys when the text is selected.
3240 TextField field = TextField::New();
3241 DALI_TEST_CHECK(field);
3242 application.GetScene().Add(field);
3244 float previousHeight = 0.0f;
3245 float currentHeight = 0.0f;
3246 const float fieldWidth = 1920.0f;
3248 // "ㅁ" is bigger then "ኢ"
3249 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3250 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3251 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3253 field.SetProperty(TextField::Property::TEXT, "ኢ");
3254 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3255 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3257 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3258 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3260 application.SendNotification();
3261 application.Render();
3263 previousHeight = field.GetHeightForWidth(fieldWidth);
3264 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3266 // Add another script characters ( glyph height is defferent )
3267 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3268 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3270 application.SendNotification();
3271 application.Render();
3273 currentHeight = field.GetHeightForWidth(fieldWidth);
3274 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3275 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3280 int utcDaliTextFieldExtremlyLargePointSize(void)
3282 ToolkitTestApplication application;
3283 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3285 TextField field = TextField::New();
3287 field.SetProperty(TextField::Property::TEXT, "Text");
3288 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3289 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3290 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3291 application.GetScene().Add(field);
3295 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3296 application.SendNotification();
3297 DALI_TEST_CHECK(field);
3301 tet_result(TET_FAIL);
3306 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3308 ToolkitTestApplication application;
3309 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3310 TextField field = TextField::New();
3311 DALI_TEST_CHECK(field);
3312 application.GetScene().Add(field);
3314 Property::Map fontStyleMapGet;
3316 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3318 Property::Value* weightValue = NULL;
3319 Property::Value* widthValue = NULL;
3320 Property::Value* slantValue = NULL;
3321 weightValue = fontStyleMapGet.Find("weight");
3322 widthValue = fontStyleMapGet.Find("width");
3323 slantValue = fontStyleMapGet.Find("slant");
3324 DALI_TEST_CHECK(!weightValue);
3325 DALI_TEST_CHECK(!widthValue);
3326 DALI_TEST_CHECK(!slantValue);
3331 int UtcDaliTextFieldSettingPlaceholder(void)
3333 ToolkitTestApplication application;
3334 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3336 TextField field = TextField::New();
3337 DALI_TEST_CHECK(field);
3338 application.GetScene().Add(field);
3340 // Check the placeholder property with pixel size
3341 Property::Map placeholderPixelSizeMapSet;
3342 Property::Map placeholderPixelSizeMapGet;
3343 Property::Map placeholderFontstyleMap;
3344 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3345 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3346 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3347 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3348 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3349 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3351 placeholderFontstyleMap.Insert("weight", "bold");
3352 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3353 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3355 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3356 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3357 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3359 // Check the placeholder property with point size
3360 Property::Map placeholderMapSet;
3361 Property::Map placeholderMapGet;
3362 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3363 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3364 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3365 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3366 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3367 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3369 // Check the placeholder font style property
3370 placeholderFontstyleMap.Clear();
3372 placeholderFontstyleMap.Insert("weight", "bold");
3373 placeholderFontstyleMap.Insert("width", "condensed");
3374 placeholderFontstyleMap.Insert("slant", "italic");
3375 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3376 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3378 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3379 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3380 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3382 // Reset font style.
3383 placeholderFontstyleMap.Clear();
3384 placeholderFontstyleMap.Insert("weight", "normal");
3385 placeholderFontstyleMap.Insert("slant", "oblique");
3386 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3387 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3389 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3390 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3391 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3393 placeholderFontstyleMap.Clear();
3394 placeholderFontstyleMap.Insert("slant", "roman");
3395 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3396 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3398 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3400 placeholderFontstyleMap.Clear();
3401 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3403 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3404 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3405 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3406 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3411 int UtcDaliTextFieldPlaceholderCoverage(void)
3413 ToolkitTestApplication application;
3414 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3416 // mPlaceholderFont is created only once, so create a new control for coverage.
3417 TextField fieldForCoverage = TextField::New();
3418 DALI_TEST_CHECK(fieldForCoverage);
3419 application.GetScene().Add(fieldForCoverage);
3421 // for SetPlaceholderFontFamily() coverage.
3422 Property::Map fontFamilyMap;
3423 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3424 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3426 // mPlaceholderFont is created only once, so create a new control for coverage.
3427 fieldForCoverage = TextField::New();
3428 DALI_TEST_CHECK(fieldForCoverage);
3429 application.GetScene().Add(fieldForCoverage);
3431 // for SetPlaceholderTextFontSize coverage.
3432 Property::Map fontSizeMap;
3433 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3434 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3436 // mPlaceholderFont is created only once, so create a new control for coverage.
3437 fieldForCoverage = TextField::New();
3438 DALI_TEST_CHECK(fieldForCoverage);
3439 application.GetScene().Add(fieldForCoverage);
3441 // for SetPlaceholderTextFontWeight coverage.
3442 Property::Map fontStyleWeightMap;
3443 Property::Map fontStyleWeightPropertyMap;
3444 fontStyleWeightPropertyMap.Insert("weight", "bold");
3445 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3446 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3448 // mPlaceholderFont is created only once, so create a new control for coverage.
3449 fieldForCoverage = TextField::New();
3450 DALI_TEST_CHECK(fieldForCoverage);
3451 application.GetScene().Add(fieldForCoverage);
3453 // for SetPlaceholderTextFontWidth coverage.
3454 Property::Map fontStyleWidthMap;
3455 Property::Map fontStyleWidthPropertyMap;
3456 fontStyleWidthPropertyMap.Insert("width", "expanded");
3457 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3458 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3460 // mPlaceholderFont is created only once, so create a new control for coverage.
3461 fieldForCoverage = TextField::New();
3462 DALI_TEST_CHECK(fieldForCoverage);
3463 application.GetScene().Add(fieldForCoverage);
3465 // for SetPlaceholderTextFontSlant coverage.
3466 Property::Map fontStyleSlantMap;
3467 Property::Map fontStyleSlantPropertyMap;
3468 fontStyleSlantPropertyMap.Insert("slant", "italic");
3469 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3470 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3475 int UtcDaliTextFieldSetPaddingProperty(void)
3477 ToolkitTestApplication application;
3478 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3480 TextField field = TextField::New();
3481 DALI_TEST_CHECK(field);
3482 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3483 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3484 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3485 application.GetScene().Add(field);
3487 application.SendNotification();
3488 application.Render();
3490 Vector3 originalSize = field.GetNaturalSize();
3492 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3494 application.SendNotification();
3495 application.Render();
3497 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3499 Vector3 paddingAddedSize = field.GetNaturalSize();
3501 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3503 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3508 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3510 ToolkitTestApplication application;
3511 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3513 TextField field = TextField::New();
3514 DALI_TEST_CHECK(field);
3515 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3516 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3517 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3518 application.GetScene().Add(field);
3520 application.SendNotification();
3521 application.Render();
3523 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3524 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3526 // Check the enable shift selection property
3527 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3528 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3530 application.SendNotification();
3531 application.Render();
3536 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3538 ToolkitTestApplication application;
3539 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3541 TextField field = TextField::New();
3542 DALI_TEST_CHECK(field);
3543 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3544 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3545 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3546 application.GetScene().Add(field);
3548 application.SendNotification();
3549 application.Render();
3551 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3552 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3554 // Check the enable grab handle property
3555 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3556 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3558 application.SendNotification();
3559 application.Render();
3564 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3566 ToolkitTestApplication application;
3567 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3569 TextField field = TextField::New();
3570 DALI_TEST_CHECK(field);
3571 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3572 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3573 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3574 application.GetScene().Add(field);
3576 application.SendNotification();
3577 application.Render();
3579 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3580 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3582 // Check the match system language direction property
3583 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3584 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3586 application.SendNotification();
3587 application.Render();
3592 int utcDaliTextFieldLayoutDirectionCoverage(void)
3594 ToolkitTestApplication application;
3595 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3597 // Creates a tap event. After creating a tap event the text field should
3598 // have the focus and add text with key events should be possible.
3599 TextField field = TextField::New();
3600 DALI_TEST_CHECK(field);
3602 application.GetScene().Add(field);
3604 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3605 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3606 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3608 // Avoid a crash when core load gl resources.
3609 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3611 // Render and notify
3612 application.SendNotification();
3613 application.Render();
3615 // init direction for coverage
3616 // Set horizontal alignment END
3617 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3619 // Create a tap event to touch the text field.
3620 TestGenerateTap(application, 150.0f, 25.0f);
3622 // Render and notify
3623 application.SendNotification();
3624 application.Render();
3626 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3627 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3628 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3630 // Set horizontal alignment BEGIN
3631 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3633 // Create a tap event to touch the text field.
3634 TestGenerateTap(application, 150.0f, 25.0f);
3636 // Render and notify
3637 application.SendNotification();
3638 application.Render();
3640 // Set horizontal alignment CENTER
3641 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3643 // Create a tap event to touch the text field.
3644 TestGenerateTap(application, 150.0f, 25.0f);
3646 // Render and notify
3647 application.SendNotification();
3648 application.Render();
3650 // Set horizontal alignment END
3651 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3653 // Create a tap event to touch the text field.
3654 TestGenerateTap(application, 150.0f, 25.0f);
3656 // Render and notify
3657 application.SendNotification();
3658 application.Render();
3660 // Generate a Esc key event. The text field should lose the focus.
3661 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3662 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3664 // Render and notify
3665 application.SendNotification();
3666 application.Render();
3668 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3673 int UtcDaliTextFieldGetInputMethodContext(void)
3675 ToolkitTestApplication application;
3676 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3678 TextField field = TextField::New();
3679 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3684 int UtcDaliTextFieldSelectWholeText(void)
3686 ToolkitTestApplication application;
3687 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3689 TextField textField = TextField::New();
3691 application.GetScene().Add(textField);
3693 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3694 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3695 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3697 // Avoid a crash when core load gl resources.
3698 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3700 application.SendNotification();
3701 application.Render();
3703 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3705 DevelTextField::SelectWholeText(textField);
3707 application.SendNotification();
3708 application.Render();
3710 // Nothing should have been selected. The number of children is still 1
3711 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3713 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3715 application.SendNotification();
3716 application.Render();
3718 DevelTextField::SelectWholeText(textField);
3720 application.SendNotification();
3721 application.Render();
3723 // Even if resize, selection should remain.
3724 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3726 application.SendNotification();
3727 application.Render();
3729 // Should be 2 children, the stencil and the layer
3730 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3732 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3733 Actor stencil = textField.GetChildAt(0u);
3735 // The highlight actor is drawn first, so is the first actor in the list
3736 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3737 DALI_TEST_CHECK(highlight);
3742 int UtcDaliTextFieldSelectText(void)
3744 ToolkitTestApplication application;
3745 tet_infoline(" UtcDaliTextFieldSelectText ");
3747 TextField textField = TextField::New();
3749 application.GetScene().Add(textField);
3751 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3752 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3753 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3755 // Avoid a crash when core load gl resources.
3756 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3758 application.SendNotification();
3759 application.Render();
3761 DevelTextField::SelectText(textField, 0, 5);
3763 application.SendNotification();
3764 application.Render();
3766 // Nothing is selected
3767 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3768 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3770 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3772 application.SendNotification();
3773 application.Render();
3775 // Hello is selected
3776 DevelTextField::SelectText(textField, 0, 5);
3778 application.SendNotification();
3779 application.Render();
3781 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3782 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3784 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3785 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3787 // world is selected
3788 DevelTextField::SelectText(textField, 6, 11);
3790 application.SendNotification();
3791 application.Render();
3793 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3794 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3796 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3797 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3802 int UtcDaliTextFieldSelectNone(void)
3804 ToolkitTestApplication application;
3805 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3807 TextField textField = TextField::New();
3809 application.GetScene().Add(textField);
3811 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3812 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3813 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3815 // Avoid a crash when core load gl resources.
3816 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3818 application.SendNotification();
3819 application.Render();
3821 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3823 application.SendNotification();
3824 application.Render();
3826 // Nothing is selected
3827 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3828 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3830 DevelTextField::SelectWholeText(textField);
3832 application.SendNotification();
3833 application.Render();
3835 // whole text is selected
3836 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3837 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3839 DevelTextField::SelectNone(textField);
3841 application.SendNotification();
3842 application.Render();
3844 // Nothing is selected
3845 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3846 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3851 int UtcDaliTextFieldSelectRange(void)
3853 ToolkitTestApplication application;
3854 tet_infoline(" UtcDaliTextFieldSelectRange ");
3856 TextField textField = TextField::New();
3858 application.GetScene().Add(textField);
3860 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3861 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3862 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3864 // Avoid a crash when core load gl resources.
3865 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3867 application.SendNotification();
3868 application.Render();
3870 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3872 application.SendNotification();
3873 application.Render();
3875 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3876 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3878 // Hello is selected
3879 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3880 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3882 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3883 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3885 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3886 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3888 // world is selected
3889 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3890 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3892 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3893 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3898 int UtcDaliTextFieldEnableEditing(void)
3900 ToolkitTestApplication application;
3901 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3903 TextField textField = TextField::New();
3905 application.GetScene().Add(textField);
3907 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3908 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3909 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3911 // Avoid a crash when core load gl resources.
3912 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3914 application.SendNotification();
3915 application.Render();
3917 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3918 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3920 textField.SetKeyInputFocus();
3921 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3922 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3924 // Render and notify
3925 application.SendNotification();
3926 application.Render();
3928 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3929 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3931 textField.SetKeyInputFocus();
3932 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
3933 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3935 // Render and notify
3936 application.SendNotification();
3937 application.Render();
3939 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3940 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3942 // Check the user interaction enabled and for coverage
3943 DevelTextField::SelectWholeText(textField);
3945 // Render and notify
3946 application.SendNotification();
3947 application.Render();
3949 textField.SetKeyInputFocus();
3950 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3951 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3953 // Render and notify
3954 application.SendNotification();
3955 application.Render();
3957 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3958 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3963 int UtcDaliToolkitTextFieldFontSizeScale(void)
3965 ToolkitTestApplication application;
3966 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3968 TextField textField = TextField::New();
3969 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
3970 textField.SetProperty(TextField::Property::TEXT, "Test");
3971 Vector3 nonScaledSize = textField.GetNaturalSize();
3973 TextField textFieldScaled = TextField::New();
3974 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
3975 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3976 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3977 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3979 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3981 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
3982 textField.SetProperty(TextField::Property::TEXT, "Test");
3983 nonScaledSize = textField.GetNaturalSize();
3985 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
3986 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3987 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3988 scaledSize = textFieldScaled.GetNaturalSize();
3990 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3995 int UtcDaliTextFieldPrimaryCursorPosition(void)
3997 ToolkitTestApplication application;
3998 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4000 TextField textField = TextField::New();
4002 application.GetScene().Add(textField);
4004 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4005 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4006 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4007 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4009 // Avoid a crash when core load gl resources.
4010 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4012 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4013 application.SendNotification();
4014 application.Render();
4015 textField.SetKeyInputFocus();
4017 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4019 // Render and notify
4020 application.SendNotification();
4021 application.Render();
4023 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4024 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4029 // test max length when set after setting long text
4030 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4032 ToolkitTestApplication application;
4033 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4034 TextField field = TextField::New();
4035 DALI_TEST_CHECK(field);
4037 application.GetScene().Add(field);
4039 field.SetProperty(TextField::Property::TEXT, "123456789");
4041 const int maxNumberOfCharacters = 3;
4042 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4044 field.SetKeyInputFocus();
4046 // connect to the text max lengh reached signal.
4047 ConnectionTracker* testTracker = new ConnectionTracker();
4048 bool maxLengthReachedSignal = false;
4049 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4051 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4052 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4054 DALI_TEST_CHECK(maxLengthReachedSignal);
4056 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4061 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4063 ToolkitTestApplication application;
4064 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4066 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4067 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4068 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4070 // Create a text field
4071 TextField textField = TextField::New();
4073 //Set size to avoid automatic eliding
4074 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4075 //Set very large font-size using point-size
4076 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4077 //Specify font-family
4078 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4079 //Set text to check if appear or not
4080 textField.SetProperty(TextField::Property::TEXT, "A");
4082 application.GetScene().Add(textField);
4084 application.SendNotification();
4085 application.Render();
4086 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4087 Vector3 naturalSize = textField.GetNaturalSize();
4089 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4090 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4095 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4097 ToolkitTestApplication application;
4098 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4100 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4101 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4102 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4104 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4105 // Create a text editor
4106 TextField textField = TextField::New();
4108 //Set size to avoid automatic eliding
4109 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4110 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4111 textField.SetProperty(TextField::Property::TEXT, "A");
4113 const int numberOfCases = 6;
4114 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4116 for(int index = 0; index < numberOfCases; index++)
4118 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4119 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4120 application.GetScene().Add(textField);
4121 application.SendNotification();
4122 application.Render();
4123 naturalSize = textField.GetNaturalSize();
4124 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4125 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4131 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4133 ToolkitTestApplication application;
4134 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4135 TextField textField = TextField::New();
4137 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4138 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4140 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4141 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4142 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4144 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4145 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4146 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4148 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4149 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4150 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4152 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4153 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4154 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4156 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4157 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4158 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4160 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4161 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4162 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4164 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4165 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4166 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4168 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4169 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4170 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4172 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4173 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4174 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4176 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4177 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4178 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4180 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4181 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4182 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4184 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4185 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4186 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4191 int UtcDaliTextFieldCopyText(void)
4193 ToolkitTestApplication application;
4194 tet_infoline(" UtcDaliTextFieldCopyText ");
4196 TextField textField = TextField::New();
4198 std::string selectedText = "";
4199 std::string copiedText = "";
4201 application.GetScene().Add(textField);
4203 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4204 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4205 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4207 // Avoid a crash when core load gl resources.
4208 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4210 application.SendNotification();
4211 application.Render();
4213 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4215 application.SendNotification();
4216 application.Render();
4218 // Hello is selected
4219 DevelTextField::SelectText(textField, 0, 5);
4221 application.SendNotification();
4222 application.Render();
4224 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4225 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4227 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4228 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4231 copiedText = DevelTextField::CopyText(textField);
4232 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4234 // world is selected
4235 DevelTextField::SelectText(textField, 6, 11);
4237 application.SendNotification();
4238 application.Render();
4240 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4241 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4243 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4244 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4247 copiedText = DevelTextField::CopyText(textField);
4248 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4250 // "lo wo" is selected
4251 DevelTextField::SelectText(textField, 3, 8);
4253 application.SendNotification();
4254 application.Render();
4256 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4257 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4259 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4260 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4262 // "lo wo" is copied
4263 copiedText = DevelTextField::CopyText(textField);
4264 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4269 int UtcDaliTextFieldCutText(void)
4271 ToolkitTestApplication application;
4272 tet_infoline(" UtcDaliTextFieldCutText ");
4274 TextField textField = TextField::New();
4276 std::string selectedText = "";
4278 application.GetScene().Add(textField);
4280 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4281 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4282 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4284 // Avoid a crash when core load gl resources.
4285 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4287 application.SendNotification();
4288 application.Render();
4290 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4292 application.SendNotification();
4293 application.Render();
4295 // Hello is selected
4296 DevelTextField::SelectText(textField, 0, 5);
4298 application.SendNotification();
4299 application.Render();
4301 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4302 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4304 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4305 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4308 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4310 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4313 DevelTextField::SelectText(textField, 0, 2);
4315 application.SendNotification();
4316 application.Render();
4318 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4319 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4321 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4322 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4325 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4327 application.SendNotification();
4328 application.Render();
4330 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4332 // Test Cut from the middle
4335 DevelTextField::SelectText(textField, 1, 3);
4337 application.SendNotification();
4338 application.Render();
4340 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4341 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4343 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4344 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4347 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4349 application.SendNotification();
4350 application.Render();
4352 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4354 // Test Cut from the end
4357 DevelTextField::SelectText(textField, 1, 2);
4359 application.SendNotification();
4360 application.Render();
4362 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4363 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4365 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4366 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4369 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4371 application.SendNotification();
4372 application.Render();
4374 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4379 int UtcDaliTextFieldPasteText(void)
4381 ToolkitTestApplication application;
4382 tet_infoline(" UtcDaliTextFieldPasteText ");
4384 TextField textField = TextField::New();
4386 application.GetScene().Add(textField);
4388 std::string cutText = "";
4389 std::string copiedText = "";
4391 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4392 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4393 textField.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 application.SendNotification();
4399 application.Render();
4401 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4403 application.SendNotification();
4404 application.Render();
4406 // Tap on the text editor
4407 TestGenerateTap(application, 3.0f, 25.0f);
4409 // Render and notify
4410 application.SendNotification();
4411 application.Render();
4413 // Select some text in the right of the current cursor position
4414 DevelTextField::SelectText(textField, 0, 3);
4416 // Render and notify
4417 application.SendNotification();
4418 application.Render();
4420 // Cut the selected text
4421 cutText = DevelTextField::CutText(textField);
4423 // Render and notify
4424 application.SendNotification();
4425 application.Render();
4427 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4428 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4430 DevelTextField::SelectText(textField, 0, 3);
4432 // Render and notify
4433 application.SendNotification();
4434 application.Render();
4436 // Copy the selected text
4437 copiedText = DevelTextField::CopyText(textField);
4439 // Render and notify
4440 application.SendNotification();
4441 application.Render();
4443 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4444 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4446 // Move the cursor to the end of the line
4447 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4448 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4449 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4452 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4453 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4454 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4456 // Render and notify
4457 application.SendNotification();
4458 application.Render();
4460 // Paste the selected text at the current cursor position
4461 DevelTextField::PasteText(textField);
4463 // Render and notify
4464 application.SendNotification();
4465 application.Render();
4467 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4472 int utcDaliTextFieldCursorPositionChangedSignal(void)
4474 ToolkitTestApplication application;
4475 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4477 TextField field = TextField::New();
4478 DALI_TEST_CHECK(field);
4480 application.GetScene().Add(field);
4482 // connect to the selection changed signal.
4483 ConnectionTracker* testTracker = new ConnectionTracker();
4484 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4485 bool cursorPositionChangedSignal = false;
4486 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4488 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4489 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4490 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4491 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4492 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
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 field.SetKeyInputFocus();
4503 // Tap on the text field
4504 TestGenerateTap(application, 3.0f, 25.0f);
4506 // Render and notify
4507 application.SendNotification();
4508 application.Render();
4510 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4511 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4513 gCursorPositionChangedCallbackCalled = false;
4516 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4518 // Render and notify
4519 application.SendNotification();
4520 application.Render();
4522 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4523 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4525 gCursorPositionChangedCallbackCalled = false;
4528 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4530 // Render and notify
4531 application.SendNotification();
4532 application.Render();
4534 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4535 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4537 gCursorPositionChangedCallbackCalled = false;
4539 //delete one character
4540 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4542 // Render and notify
4543 application.SendNotification();
4544 application.Render();
4546 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4547 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4549 gCursorPositionChangedCallbackCalled = false;
4551 field.SetProperty(TextField::Property::TEXT, "Hello");
4553 // Render and notify
4554 application.SendNotification();
4555 application.Render();
4557 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4558 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4560 gCursorPositionChangedCallbackCalled = false;
4562 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4564 // Render and notify
4565 application.SendNotification();
4566 application.Render();
4568 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4569 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4574 int utcDaliTextFieldGeometryEllipsisStart(void)
4576 ToolkitTestApplication application;
4577 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4579 TextField field = TextField::New();
4580 DALI_TEST_CHECK(field);
4582 application.GetScene().Add(field);
4584 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4585 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4586 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4587 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4588 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4589 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4590 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4591 field.SetProperty(TextField::Property::TEXT, "Hello World");
4593 // Avoid a crash when core load gl resources.
4594 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4596 // Render and notify
4597 application.SendNotification();
4598 application.Render();
4600 unsigned int expectedCount = 1;
4601 unsigned int startIndex = 0;
4602 unsigned int endIndex = 10;
4604 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4605 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4607 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4608 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4610 Vector<Vector2> expectedSizes;
4611 Vector<Vector2> expectedPositions;
4613 expectedPositions.PushBack(Vector2(14, 0));
4614 expectedSizes.PushBack(Vector2(106, 25));
4616 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4621 int utcDaliTextFieldGeometryEllipsisEnd(void)
4623 ToolkitTestApplication application;
4624 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4626 TextField field = TextField::New();
4627 DALI_TEST_CHECK(field);
4629 application.GetScene().Add(field);
4631 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4632 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4633 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4634 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4635 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4636 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4637 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4638 field.SetProperty(TextField::Property::TEXT, "Hello World");
4640 // Avoid a crash when core load gl resources.
4641 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4643 // Render and notify
4644 application.SendNotification();
4645 application.Render();
4647 unsigned int expectedCount = 1;
4648 unsigned int startIndex = 0;
4649 unsigned int endIndex = 10;
4651 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4652 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4654 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4655 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4657 Vector<Vector2> expectedSizes;
4658 Vector<Vector2> expectedPositions;
4660 expectedPositions.PushBack(Vector2(-2, 0));
4661 expectedSizes.PushBack(Vector2(122, 25));
4663 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4668 int utcDaliTextFieldGeometryRTL(void)
4670 ToolkitTestApplication application;
4671 tet_infoline(" utcDaliTextFieldGeometryRTL");
4673 TextField field = TextField::New();
4674 DALI_TEST_CHECK(field);
4676 application.GetScene().Add(field);
4678 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4679 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4680 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4681 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4682 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4683 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4685 // Avoid a crash when core load gl resources.
4686 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4688 // Render and notify
4689 application.SendNotification();
4690 application.Render();
4692 unsigned int expectedCount = 1;
4693 unsigned int startIndex = 1;
4694 unsigned int endIndex = 7;
4696 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4697 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4699 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4700 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4702 Vector<Vector2> expectedSizes;
4703 Vector<Vector2> expectedPositions;
4705 expectedPositions.PushBack(Vector2(38, 0));
4706 expectedSizes.PushBack(Vector2(73, 25));
4708 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4713 int utcDaliTextFieldGeometryGlyphMiddle(void)
4715 ToolkitTestApplication application;
4716 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4718 TextField field = TextField::New();
4719 DALI_TEST_CHECK(field);
4721 application.GetScene().Add(field);
4723 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4724 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4725 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4726 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4727 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4728 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4730 // Avoid a crash when core load gl resources.
4731 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4733 // Render and notify
4734 application.SendNotification();
4735 application.Render();
4737 unsigned int expectedCount = 1;
4738 unsigned int startIndex = 1;
4739 unsigned int endIndex = 13;
4741 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4742 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4744 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4745 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4747 Vector<Vector2> expectedSizes;
4748 Vector<Vector2> expectedPositions;
4750 expectedPositions.PushBack(Vector2(6, 0));
4751 expectedSizes.PushBack(Vector2(124, 25));
4753 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4758 int utcDaliTextFieldSelectionClearedSignal(void)
4760 ToolkitTestApplication application;
4761 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4763 TextField field = TextField::New();
4764 DALI_TEST_CHECK(field);
4766 application.GetScene().Add(field);
4768 // connect to the selection changed signal.
4769 ConnectionTracker* testTracker = new ConnectionTracker();
4770 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4771 bool selectionClearedSignal = false;
4772 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4774 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4775 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4776 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4777 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4778 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4780 // Avoid a crash when core load gl resources.
4781 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4783 // Render and notify
4784 application.SendNotification();
4785 application.Render();
4787 // Tap on the text editor
4788 TestGenerateTap(application, 3.0f, 25.0f);
4790 // Render and notify
4791 application.SendNotification();
4792 application.Render();
4794 // Move to second line of the text & Select some text in the right of the current cursor position
4795 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4796 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4799 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4801 // Render and notify
4802 application.SendNotification();
4803 application.Render();
4805 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4807 // Render and notify
4808 application.SendNotification();
4809 application.Render();
4811 // Tap on the text editor
4812 TestGenerateTap(application, 3.0f, 25.0f);
4814 // Render and notify
4815 application.SendNotification();
4816 application.Render();
4818 gSelectionClearedCallbackCalled = false;
4820 // Move to second line of the text & select.
4821 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4822 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4825 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4827 // Render and notify
4828 application.SendNotification();
4829 application.Render();
4831 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4833 gSelectionClearedCallbackCalled = false;
4835 // Render and notify
4836 application.SendNotification();
4837 application.Render();
4839 // Move to second line of the text & select.
4840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4841 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4843 // replace D with selected text
4844 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4846 // Render and notify
4847 application.SendNotification();
4848 application.Render();
4850 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4852 gSelectionClearedCallbackCalled = false;
4854 // Render and notify
4855 application.SendNotification();
4856 application.Render();
4858 DevelTextField::SelectText(field, 1, 3);
4860 // Render and notify
4861 application.SendNotification();
4862 application.Render();
4864 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4866 // Render and notify
4867 application.SendNotification();
4868 application.Render();
4870 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4872 gSelectionClearedCallbackCalled = false;
4874 DevelTextField::SelectText(field, 1, 3);
4876 // Render and notify
4877 application.SendNotification();
4878 application.Render();
4881 DevelTextField::SelectNone(field);
4883 // Render and notify
4884 application.SendNotification();
4885 application.Render();
4887 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4892 int utcDaliTextFieldSelectionStartedSignal(void)
4894 ToolkitTestApplication application;
4895 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4897 TextField field = TextField::New();
4898 DALI_TEST_CHECK(field);
4900 application.GetScene().Add(field);
4902 // connect to the selection changed signal.
4903 ConnectionTracker* testTracker = new ConnectionTracker();
4904 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4905 bool selectionStartedSignal = false;
4906 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4908 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4909 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4910 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4911 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4912 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4914 // Avoid a crash when core load gl resources.
4915 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4917 // Render and notify
4918 application.SendNotification();
4919 application.Render();
4921 // Tap on the text field
4922 TestGenerateTap(application, 3.0f, 25.0f);
4924 // Render and notify
4925 application.SendNotification();
4926 application.Render();
4928 // Move to second line of the text & Select some text in the right of the current cursor position
4929 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4930 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4932 // Render and notify
4933 application.SendNotification();
4934 application.Render();
4936 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4939 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4941 // Render and notify
4942 application.SendNotification();
4943 application.Render();
4945 gSelectionStartedCallbackCalled = false;
4947 DevelTextField::SelectText(field, 1, 3);
4949 // Render and notify
4950 application.SendNotification();
4951 application.Render();
4953 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4958 int utcDaliTextFieldSelectionChangedSignal(void)
4960 ToolkitTestApplication application;
4961 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4963 TextField field = TextField::New();
4964 DALI_TEST_CHECK(field);
4966 application.GetScene().Add(field);
4968 // connect to the selection changed signal.
4969 ConnectionTracker* testTracker = new ConnectionTracker();
4970 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4971 bool selectionChangedSignal = false;
4972 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
4974 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4975 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4976 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4977 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4978 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4980 // Avoid a crash when core load gl resources.
4981 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4983 // Render and notify
4984 application.SendNotification();
4985 application.Render();
4987 // Tap on the text field
4988 TestGenerateTap(application, 3.0f, 25.0f);
4990 // Render and notify
4991 application.SendNotification();
4992 application.Render();
4994 // Select some text in the right of the current cursor position
4995 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4996 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4998 // Render and notify
4999 application.SendNotification();
5000 application.Render();
5002 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5003 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5005 gSelectionChangedCallbackCalled = false;
5007 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5009 // Render and notify
5010 application.SendNotification();
5011 application.Render();
5013 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5014 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5015 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5017 gSelectionChangedCallbackCalled = false;
5019 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5021 // Render and notify
5022 application.SendNotification();
5023 application.Render();
5025 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5026 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5027 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5029 gSelectionChangedCallbackCalled = false;
5030 field.SetKeyInputFocus();
5032 // Render and notify
5033 application.SendNotification();
5034 application.Render();
5036 DevelTextField::SelectText(field, 0, 5);
5038 application.SendNotification();
5039 application.Render();
5041 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5042 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5044 gSelectionChangedCallbackCalled = false;
5046 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5048 // Render and notify
5049 application.SendNotification();
5050 application.Render();
5052 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5053 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5054 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5056 gSelectionChangedCallbackCalled = false;
5059 DevelTextField::SelectWholeText(field);
5061 // Render and notify
5062 application.SendNotification();
5063 application.Render();
5065 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5066 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5068 gSelectionChangedCallbackCalled = false;
5071 DevelTextField::SelectNone(field);
5073 // Render and notify
5074 application.SendNotification();
5075 application.Render();
5077 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5078 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5079 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5084 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5086 ToolkitTestApplication application;
5087 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5089 TextField textField = TextField::New();
5090 textField.SetProperty(TextField::Property::TEXT, "Test");
5091 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5092 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5093 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5095 application.GetScene().Add(textField);
5096 application.SendNotification();
5097 application.Render();
5099 Property::Map strikethroughMapSet;
5100 Property::Map strikethroughMapGet;
5102 strikethroughMapSet.Insert("enable", true);
5103 strikethroughMapSet.Insert("color", Color::RED);
5104 strikethroughMapSet.Insert("height", 2.0f);
5106 // Check the strikethrough property
5107 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5108 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5109 textField.SetProperty(TextField::Property::TEXT, "Test1");
5110 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5111 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5113 // Render and notify
5114 application.SendNotification();
5115 application.Render();
5117 strikethroughMapSet.Clear();
5118 strikethroughMapGet.Clear();
5123 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5125 ToolkitTestApplication application;
5126 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5128 TextField textField = TextField::New();
5129 textField.SetProperty(TextField::Property::TEXT, "Test");
5130 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5131 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5132 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5134 application.GetScene().Add(textField);
5135 application.SendNotification();
5136 application.Render();
5138 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5140 // Check the strikethrough property
5141 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5142 textField.SetProperty(TextField::Property::TEXT, "Test1");
5143 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5145 // Render and notify
5146 application.SendNotification();
5147 application.Render();
5152 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5154 ToolkitTestApplication application;
5155 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5156 TextField field = TextField::New();
5157 field.SetProperty(TextField::Property::TEXT, "Test");
5158 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5159 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5160 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5162 application.GetScene().Add(field);
5163 application.SendNotification();
5164 application.Render();
5166 Property::Map underlineMapSet;
5167 Property::Map underlineMapGet;
5169 underlineMapSet.Insert("enable", true);
5170 underlineMapSet.Insert("color", Color::RED);
5171 underlineMapSet.Insert("height", 1);
5172 underlineMapSet.Insert("type", Text::Underline::SOLID);
5173 underlineMapSet.Insert("dashWidth", 2);
5174 underlineMapSet.Insert("dashGap", 1);
5176 // Check the underline property
5177 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5179 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5180 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5181 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5183 // Render and notify
5184 application.SendNotification();
5185 application.Render();
5187 underlineMapSet.Clear();
5188 underlineMapGet.Clear();
5190 underlineMapSet.Insert("enable", true);
5191 underlineMapSet.Insert("color", Color::BLUE);
5192 underlineMapSet.Insert("height", 1);
5193 underlineMapSet.Insert("type", Text::Underline::DASHED);
5194 underlineMapSet.Insert("dashWidth", 4);
5195 underlineMapSet.Insert("dashGap", 2);
5197 // Check the dashed underline property
5198 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5200 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5201 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5202 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5204 // Render and notify
5205 application.SendNotification();
5206 application.Render();
5208 underlineMapSet.Clear();
5209 underlineMapGet.Clear();
5211 underlineMapSet.Insert("enable", true);
5212 underlineMapSet.Insert("color", Color::BLUE);
5213 underlineMapSet.Insert("height", 1);
5214 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5215 underlineMapSet.Insert("dashWidth", 4);
5216 underlineMapSet.Insert("dashGap", 2);
5218 // Check the dashed underline property
5219 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5221 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5222 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5223 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5225 // Render and notify
5226 application.SendNotification();
5227 application.Render();
5229 underlineMapSet.Clear();
5230 underlineMapGet.Clear();
5235 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5237 ToolkitTestApplication application;
5238 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5240 TextField field1 = TextField::New();
5241 field1.SetProperty(TextField::Property::TEXT, "Test");
5242 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5243 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5244 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5246 Property::Map underlineMapSet1;
5247 Property::Map underlineMapGet1;
5249 underlineMapSet1.Insert("enable", true);
5250 underlineMapSet1.Insert("color", Color::RED);
5251 underlineMapSet1.Insert("height", 1);
5252 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5253 underlineMapSet1.Insert("dashWidth", 2);
5254 underlineMapSet1.Insert("dashGap", 1);
5256 // Check the underline property
5257 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5259 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5260 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5261 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5263 application.GetScene().Add(field1);
5264 application.SendNotification();
5265 application.Render();
5267 TextField field2 = TextField::New();
5268 field2.SetProperty(TextField::Property::TEXT, "Test");
5269 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5270 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5271 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5273 Property::Map underlineMapSet2;
5274 Property::Map underlineMapGet2;
5276 underlineMapSet2.Insert("enable", true);
5277 underlineMapSet2.Insert("color", Color::BLUE);
5278 underlineMapSet2.Insert("height", 1);
5279 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5280 underlineMapSet2.Insert("dashWidth", 4);
5281 underlineMapSet2.Insert("dashGap", 2);
5283 // Check the dashed underline property
5284 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5286 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5287 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5288 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5290 application.GetScene().Add(field2);
5291 application.SendNotification();
5292 application.Render();
5294 TextField field3 = TextField::New();
5295 field3.SetProperty(TextField::Property::TEXT, "Test");
5296 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5297 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5298 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5300 Property::Map underlineMapSet3;
5301 Property::Map underlineMapGet3;
5303 underlineMapSet3.Insert("enable", true);
5304 underlineMapSet3.Insert("color", Color::BLUE);
5305 underlineMapSet3.Insert("height", 1);
5306 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5307 underlineMapSet3.Insert("dashWidth", 4);
5308 underlineMapSet3.Insert("dashGap", 2);
5310 // Check the dashed underline property
5311 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5313 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5314 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5315 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5317 application.GetScene().Add(field3);
5319 application.SendNotification();
5320 application.Render();
5325 int UtcDaliTextFieldCharacterSpacing(void)
5327 ToolkitTestApplication application;
5328 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5330 TextField textField = TextField::New();
5332 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5334 application.GetScene().Add(textField);
5335 application.SendNotification();
5336 application.Render();
5338 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5339 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5340 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5342 application.SendNotification();
5343 application.Render();
5348 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5350 ToolkitTestApplication application;
5351 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5353 TextField field1 = TextField::New();
5354 field1.SetProperty(TextField::Property::TEXT, "Test1");
5355 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5356 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5357 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5359 Property::Map underlineMapSet1;
5360 Property::Map underlineMapGet1;
5362 underlineMapSet1.Insert("enable", true);
5363 underlineMapSet1.Insert("color", Color::RED);
5364 underlineMapSet1.Insert("height", 1);
5365 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5366 underlineMapSet1.Insert("dashWidth", 2);
5367 underlineMapSet1.Insert("dashGap", 1);
5369 // Check the underline property
5370 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5371 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5373 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5374 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5375 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5377 application.GetScene().Add(field1);
5378 application.SendNotification();
5379 application.Render();
5384 int UtcDaliToolkitTextfieldParagraphTag(void)
5386 ToolkitTestApplication application;
5387 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5388 TextField fieldNewlineSeparator = TextField::New();
5389 TextField fieldParagraphTag = TextField::New();
5390 DALI_TEST_CHECK(fieldNewlineSeparator);
5391 DALI_TEST_CHECK(fieldParagraphTag);
5393 application.GetScene().Add(fieldNewlineSeparator);
5394 application.GetScene().Add(fieldParagraphTag);
5396 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5397 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5398 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5399 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5400 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5401 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5403 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5404 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5405 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5406 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5407 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5409 application.SendNotification();
5410 application.Render();
5412 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5413 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5415 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5417 application.SendNotification();
5418 application.Render();
5423 //Handle Emoji clustering for cursor handling
5424 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5426 ToolkitTestApplication application;
5427 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5428 TextField textField = TextField::New();
5429 DALI_TEST_CHECK(textField);
5431 application.GetScene().Add(textField);
5433 // Avoid a crash when core load gl resources.
5434 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5436 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5437 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5439 // Render and notify
5440 application.SendNotification();
5441 application.Render();
5444 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5445 application.SendNotification();
5446 application.Render();
5448 // Set focus and remove Emoji
5449 textField.SetKeyInputFocus();
5450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5452 //Check the changed text and cursor position
5453 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5454 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5456 // Render and notify
5457 application.SendNotification();
5458 application.Render();
5463 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5465 ToolkitTestApplication application;
5466 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5467 TextField textField = TextField::New();
5468 DALI_TEST_CHECK(textField);
5470 application.GetScene().Add(textField);
5472 // Avoid a crash when core load gl resources.
5473 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5475 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5476 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5478 // Render and notify
5479 application.SendNotification();
5480 application.Render();
5483 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5484 application.SendNotification();
5485 application.Render();
5487 // Set focus and remove Emoji
5488 textField.SetKeyInputFocus();
5489 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5491 //Check the changed text and cursor position
5492 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5493 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5495 // Render and notify
5496 application.SendNotification();
5497 application.Render();