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 // Negative test for the textChanged signal.
1603 int utcDaliTextFieldTextChangedN(void)
1605 ToolkitTestApplication application;
1606 tet_infoline(" utcDaliTextFieldTextChangedN");
1607 TextField field = TextField::New();
1608 DALI_TEST_CHECK(field);
1610 application.GetScene().Add(field);
1612 // connect to the text changed signal.
1613 ConnectionTracker* testTracker = new ConnectionTracker();
1614 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1615 bool textChangedSignal = false;
1616 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1618 gTextChangedCallBackCalled = false;
1619 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1620 application.SendNotification();
1621 application.Render();
1622 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1623 DALI_TEST_CHECK(!textChangedSignal);
1628 // Positive test for Max Characters reached signal.
1629 int utcDaliTextFieldMaxCharactersReachedP(void)
1631 ToolkitTestApplication application;
1632 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1633 TextField field = TextField::New();
1634 DALI_TEST_CHECK(field);
1636 application.GetScene().Add(field);
1638 const int maxNumberOfCharacters = 1;
1639 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1641 field.SetKeyInputFocus();
1643 // connect to the text changed signal.
1644 ConnectionTracker* testTracker = new ConnectionTracker();
1645 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1646 bool maxLengthReachedSignal = false;
1647 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1649 gMaxCharactersCallBackCalled = false;
1651 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1652 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1654 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1655 DALI_TEST_CHECK(maxLengthReachedSignal);
1660 // Negative test for Max Characters reached signal.
1661 int utcDaliTextFieldMaxCharactersReachedN(void)
1663 ToolkitTestApplication application;
1664 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1665 TextField field = TextField::New();
1666 DALI_TEST_CHECK(field);
1668 application.GetScene().Add(field);
1670 const int maxNumberOfCharacters = 3;
1671 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1673 field.SetKeyInputFocus();
1675 // connect to the text changed signal.
1676 ConnectionTracker* testTracker = new ConnectionTracker();
1677 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1678 bool maxLengthReachedSignal = false;
1679 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1681 gMaxCharactersCallBackCalled = false;
1683 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1684 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1686 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1687 DALI_TEST_CHECK(!maxLengthReachedSignal);
1689 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1691 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1692 DALI_TEST_CHECK(!maxLengthReachedSignal);
1697 // Positive test for Input Filtered signal.
1698 int utcDaliTextFieldInputFilteredP(void)
1700 ToolkitTestApplication application;
1701 tet_infoline(" utcDaliTextFieldInputFilteredP");
1702 TextField field = TextField::New();
1703 DALI_TEST_CHECK(field);
1705 application.GetScene().Add(field);
1707 Property::Map inputFilter;
1709 // Only digit is accepted.
1710 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1712 // Set input filter to TextField.
1713 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1715 field.SetKeyInputFocus();
1717 // connect to the input filtered signal.
1718 ConnectionTracker* testTracker = new ConnectionTracker();
1719 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1720 bool inputFilteredSignal = false;
1721 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1723 gInputFilteredAcceptedCallbackCalled = false;
1725 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1727 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1728 DALI_TEST_CHECK(inputFilteredSignal);
1730 // Word is rejected.
1731 inputFilter[InputFilter::Property::ACCEPTED] = "";
1732 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1734 // Set input filter to TextField.
1735 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1737 field.SetKeyInputFocus();
1739 inputFilteredSignal = false;
1740 gInputFilteredRejectedCallbackCalled = false;
1742 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1744 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1745 DALI_TEST_CHECK(inputFilteredSignal);
1750 // Negative test for Input Filtered signal.
1751 int utcDaliTextFieldInputFilteredN(void)
1753 ToolkitTestApplication application;
1754 tet_infoline(" utcDaliTextFieldInputFilteredP");
1755 TextField field = TextField::New();
1756 DALI_TEST_CHECK(field);
1758 application.GetScene().Add(field);
1760 Property::Map inputFilter;
1762 // Only word is accepted.
1763 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1765 // Set input filter to TextField.
1766 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1768 field.SetKeyInputFocus();
1770 // connect to the input filtered signal.
1771 ConnectionTracker* testTracker = new ConnectionTracker();
1772 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1773 bool inputFilteredSignal = false;
1774 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1776 gInputFilteredAcceptedCallbackCalled = false;
1778 // Key a, d should not be filtered.
1779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1780 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1781 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1782 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1784 // Backspace, Delete should not be filtered.
1785 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1786 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));
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1793 DALI_TEST_CHECK(!inputFilteredSignal);
1795 // Digit is rejected.
1796 inputFilter[InputFilter::Property::ACCEPTED] = "";
1797 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1799 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1801 field.SetKeyInputFocus();
1803 inputFilteredSignal = false;
1804 gInputFilteredRejectedCallbackCalled = false;
1806 // Key a, d should not be filtered.
1807 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1808 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1809 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1810 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1812 // Backspace, Delete should not be filtered.
1813 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1814 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));
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1820 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1821 DALI_TEST_CHECK(!inputFilteredSignal);
1826 int utcDaliTextFieldInputStyleChanged01(void)
1828 // The text-field emits signals when the input style changes. These changes of style are
1829 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1830 // can't be emitted during the size negotiation as the callbacks may update the UI.
1831 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1832 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1833 ToolkitTestApplication application;
1834 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1838 char* pathNamePtr = get_current_dir_name();
1839 const std::string pathName(pathNamePtr);
1842 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1843 fontClient.SetDpi(93u, 93u);
1845 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1846 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1848 TextField field = TextField::New();
1849 DALI_TEST_CHECK(field);
1851 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1852 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1853 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1855 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1856 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1858 // connect to the text changed signal.
1859 ConnectionTracker* testTracker = new ConnectionTracker();
1860 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1861 bool inputStyleChangedSignal = false;
1862 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1864 application.GetScene().Add(field);
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 // Executes the idle callbacks added by the text control on the change of input style.
1871 application.RunIdles();
1873 gInputStyleChangedCallbackCalled = false;
1874 gInputStyleMask = TextField::InputStyle::NONE;
1875 inputStyleChangedSignal = false;
1877 // Create a tap event to touch the text field.
1878 TestGenerateTap(application, 18.0f, 25.0f);
1880 // Render and notify
1881 application.SendNotification();
1882 application.Render();
1884 // Executes the idle callbacks added by the text control on the change of input style.
1885 application.RunIdles();
1887 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1888 if(gInputStyleChangedCallbackCalled)
1890 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1892 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1893 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1895 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1896 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1898 DALI_TEST_CHECK(inputStyleChangedSignal);
1900 gInputStyleChangedCallbackCalled = false;
1901 gInputStyleMask = TextField::InputStyle::NONE;
1902 inputStyleChangedSignal = false;
1904 // Create a tap event to touch the text field.
1905 TestGenerateTap(application, 30.0f, 25.0f);
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1911 // Executes the idle callbacks added by the text control on the change of input style.
1912 application.RunIdles();
1914 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1915 DALI_TEST_CHECK(!inputStyleChangedSignal);
1917 gInputStyleChangedCallbackCalled = false;
1918 gInputStyleMask = TextField::InputStyle::NONE;
1919 inputStyleChangedSignal = false;
1921 // Create a tap event to touch the text field.
1922 TestGenerateTap(application, 43.0f, 25.0f);
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 // Executes the idle callbacks added by the text control on the change of input style.
1929 application.RunIdles();
1931 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1932 if(gInputStyleChangedCallbackCalled)
1934 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
1936 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1937 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1939 DALI_TEST_CHECK(inputStyleChangedSignal);
1941 gInputStyleChangedCallbackCalled = false;
1942 gInputStyleMask = TextField::InputStyle::NONE;
1943 inputStyleChangedSignal = false;
1945 // Create a tap event to touch the text field.
1946 TestGenerateTap(application, 88.0f, 25.0f);
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Executes the idle callbacks added by the text control on the change of input style.
1953 application.RunIdles();
1955 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1956 if(gInputStyleChangedCallbackCalled)
1958 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
1960 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1961 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1963 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
1965 Property::Map fontStyleMapSet;
1966 fontStyleMapSet.Insert("weight", "bold");
1968 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1969 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1971 DALI_TEST_CHECK(inputStyleChangedSignal);
1973 gInputStyleChangedCallbackCalled = false;
1974 gInputStyleMask = TextField::InputStyle::NONE;
1975 inputStyleChangedSignal = false;
1977 // Create a tap event to touch the text field.
1978 TestGenerateTap(application, 115.0f, 25.0f);
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 // Executes the idle callbacks added by the text control on the change of input style.
1985 application.RunIdles();
1987 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1988 DALI_TEST_CHECK(!inputStyleChangedSignal);
1990 gInputStyleChangedCallbackCalled = false;
1991 gInputStyleMask = TextField::InputStyle::NONE;
1992 inputStyleChangedSignal = false;
1994 // Create a tap event to touch the text field.
1995 TestGenerateTap(application, 164.0f, 25.0f);
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2001 // Executes the idle callbacks added by the text control on the change of input style.
2002 application.RunIdles();
2004 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2005 if(gInputStyleChangedCallbackCalled)
2007 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2009 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2010 DALI_TEST_CHECK(style.empty());
2012 DALI_TEST_CHECK(inputStyleChangedSignal);
2014 gInputStyleChangedCallbackCalled = false;
2015 gInputStyleMask = TextField::InputStyle::NONE;
2016 inputStyleChangedSignal = false;
2018 // Create a tap event to touch the text field.
2019 TestGenerateTap(application, 191.0f, 25.0f);
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 // Executes the idle callbacks added by the text control on the change of input style.
2026 application.RunIdles();
2028 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2029 DALI_TEST_CHECK(!inputStyleChangedSignal);
2034 int utcDaliTextFieldInputStyleChanged02(void)
2036 // The text-field emits signals when the input style changes. These changes of style are
2037 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2038 // can't be emitted during the size negotiation as the callbacks may update the UI.
2039 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2040 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2041 ToolkitTestApplication application;
2042 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2046 char* pathNamePtr = get_current_dir_name();
2047 const std::string pathName(pathNamePtr);
2050 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2051 fontClient.SetDpi(93u, 93u);
2053 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2054 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2056 TextField field = TextField::New();
2057 DALI_TEST_CHECK(field);
2059 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2060 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2061 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2063 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2064 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>");
2066 // connect to the text changed signal.
2067 ConnectionTracker* testTracker = new ConnectionTracker();
2068 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2069 bool inputStyleChangedSignal = false;
2070 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2072 application.GetScene().Add(field);
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 gInputStyleChangedCallbackCalled = false;
2082 gInputStyleMask = TextField::InputStyle::NONE;
2083 inputStyleChangedSignal = false;
2085 // Create a tap event to touch the text field.
2086 TestGenerateTap(application, 53.0f, 25.0f, 100);
2087 TestGenerateTap(application, 53.0f, 25.0f, 200);
2089 // Render and notify
2090 application.SendNotification();
2091 application.Render();
2093 // Executes the idle callbacks added by the text control on the change of input style.
2094 application.RunIdles();
2096 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2097 if(gInputStyleChangedCallbackCalled)
2099 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2100 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2101 TextField::InputStyle::POINT_SIZE |
2102 TextField::InputStyle::COLOR),
2105 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2106 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2108 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2109 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2111 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2112 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2114 DALI_TEST_CHECK(inputStyleChangedSignal);
2116 gInputStyleChangedCallbackCalled = false;
2117 gInputStyleMask = TextField::InputStyle::NONE;
2118 inputStyleChangedSignal = false;
2120 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Executes the idle callbacks added by the text control on the change of input style.
2127 application.RunIdles();
2129 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2130 if(gInputStyleChangedCallbackCalled)
2132 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2133 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2136 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2137 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2139 DALI_TEST_CHECK(inputStyleChangedSignal);
2141 gInputStyleChangedCallbackCalled = false;
2142 gInputStyleMask = TextField::InputStyle::NONE;
2143 inputStyleChangedSignal = false;
2145 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 // Executes the idle callbacks added by the text control on the change of input style.
2152 application.RunIdles();
2154 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2155 DALI_TEST_CHECK(!inputStyleChangedSignal);
2157 gInputStyleChangedCallbackCalled = false;
2158 gInputStyleMask = TextField::InputStyle::NONE;
2159 inputStyleChangedSignal = false;
2161 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Executes the idle callbacks added by the text control on the change of input style.
2168 application.RunIdles();
2170 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2171 if(gInputStyleChangedCallbackCalled)
2173 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2174 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2177 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2178 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2180 DALI_TEST_CHECK(inputStyleChangedSignal);
2182 gInputStyleChangedCallbackCalled = false;
2183 gInputStyleMask = TextField::InputStyle::NONE;
2184 inputStyleChangedSignal = false;
2186 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2188 Property::Map fontStyleMapSet;
2189 fontStyleMapSet.Insert("weight", "thin");
2190 fontStyleMapSet.Insert("width", "condensed");
2191 fontStyleMapSet.Insert("slant", "italic");
2193 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2194 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2196 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2197 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2198 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2199 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2200 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // Executes the idle callbacks added by the text control on the change of input style.
2207 application.RunIdles();
2209 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2210 DALI_TEST_CHECK(!inputStyleChangedSignal);
2212 // Create a tap event to touch the text field.
2213 TestGenerateTap(application, 63.0f, 25.0f, 700);
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 // Executes the idle callbacks added by the text control on the change of input style.
2220 application.RunIdles();
2222 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2223 if(gInputStyleChangedCallbackCalled)
2225 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2226 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2227 TextField::InputStyle::POINT_SIZE |
2228 TextField::InputStyle::FONT_STYLE |
2229 TextField::InputStyle::UNDERLINE |
2230 TextField::InputStyle::SHADOW |
2231 TextField::InputStyle::EMBOSS |
2232 TextField::InputStyle::OUTLINE),
2235 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2236 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2238 DALI_TEST_CHECK(inputStyleChangedSignal);
2243 int utcDaliTextFieldEvent01(void)
2245 ToolkitTestApplication application;
2246 tet_infoline(" utcDaliTextFieldEvent01");
2248 // Creates a tap event. After creating a tap event the text field should
2249 // have the focus and add text with key events should be possible.
2251 TextField field = TextField::New();
2252 DALI_TEST_CHECK(field);
2254 application.GetScene().Add(field);
2256 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2257 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2258 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2264 // Avoid a crash when core load gl resources.
2265 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Add a key event but as the text field has not the focus it should do nothing.
2272 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2280 // Create a tap event to touch the text field.
2281 TestGenerateTap(application, 150.0f, 25.0f);
2283 // Render and notify
2284 application.SendNotification();
2285 application.Render();
2287 // Pressing delete key should be fine even if there is no text in TextField.
2288 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));
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 // Now the text field has the focus, so it can handle the key events.
2294 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2295 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2301 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2303 // Create a second text field and send key events to it.
2304 TextField field2 = TextField::New();
2306 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2307 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2308 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2309 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2311 application.GetScene().Add(field2);
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 // Create a tap event on the second text field.
2318 TestGenerateTap(application, 150.0f, 125.0f);
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2324 // The second text field has the focus. It should handle the key events.
2325 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2326 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Check the text has been added to the second text field.
2333 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2338 int utcDaliTextFieldEvent02(void)
2340 ToolkitTestApplication application;
2341 tet_infoline(" utcDaliTextFieldEvent02");
2343 // Checks if the right number of actors are created.
2345 TextField field = TextField::New();
2346 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2347 DALI_TEST_CHECK(field);
2348 LoadMarkerImages(application, field);
2350 application.GetScene().Add(field);
2352 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2353 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2354 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2356 // Avoid a crash when core load gl resources.
2357 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2359 // Render and notify
2360 application.SendNotification();
2361 application.Render();
2363 // Check there are the expected number of children ( stencil ).
2364 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2366 Actor stencil = field.GetChildAt(0u);
2367 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2369 // Create a tap event to touch the text field.
2370 TestGenerateTap(application, 150.0f, 25.0f, 300);
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 Actor layer = field.GetChildAt(2u);
2377 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2378 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2380 // Now the text field has the focus, so it can handle the key events.
2381 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2382 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Checks the cursor and the renderer have been created.
2389 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2390 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2392 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2393 DALI_TEST_CHECK(cursor);
2395 // The offscreen root actor has a container with all the actors which contain the text renderers.
2396 Actor container = stencil.GetChildAt(0u);
2397 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2399 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2400 DALI_TEST_CHECK(renderer);
2403 // Move the cursor and check the position changes.
2404 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2405 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2412 DALI_TEST_CHECK(position2.x < position1.x);
2414 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2421 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2423 // Move the cursor to the first position.
2424 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2425 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2433 // Send some taps and check the cursor positions.
2435 // Try to tap at the beginning.
2436 TestGenerateTap(application, 1.0f, 25.0f, 900);
2438 // Render and notify
2439 application.SendNotification();
2440 application.Render();
2442 // Cursor position should be the same than position1.
2443 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2445 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2447 // Tap away from the start position.
2448 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2454 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2456 DALI_TEST_CHECK(position6.x > position5.x);
2458 // Remove all the text.
2459 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2460 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2461 field.SetProperty(TextField::Property::TEXT, "");
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // Cursor position should be the same than position2.
2468 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2470 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2472 // Should not be a renderer, there is only a clipped cursor.
2473 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2475 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2476 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2477 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2479 application.SendNotification();
2480 application.Render();
2482 // There are renderer and decorator layer
2483 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2488 int utcDaliTextFieldEvent03(void)
2490 ToolkitTestApplication application;
2491 tet_infoline(" utcDaliTextFieldEvent03");
2493 // Checks if the highlight actor is created.
2495 TextField field = TextField::New();
2496 DALI_TEST_CHECK(field);
2498 application.GetScene().Add(field);
2500 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2501 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2502 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2503 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2504 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2506 // Avoid a crash when core load gl resources.
2507 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2508 LoadMarkerImages(application, field);
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 // Tap first to get the focus.
2515 TestGenerateTap(application, 3.0f, 25.0f);
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Double tap to select a word.
2522 TestGenerateTap(application, 3.0f, 25.0f);
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2529 Actor stencil = field.GetChildAt(0u);
2531 // The highlight actor is drawn first, so is the first actor in the list
2532 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2533 DALI_TEST_CHECK(highlight);
2535 // The offscreen root actor has a container with all the actors which contain the text renderers.
2536 Actor container = stencil.GetChildAt(1u);
2537 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2539 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2540 DALI_TEST_CHECK(renderer);
2546 int utcDaliTextFieldEvent04(void)
2548 ToolkitTestApplication application;
2549 tet_infoline(" utcDaliTextFieldEvent04");
2551 // Checks if the highlight actor is created.
2553 TextField field = TextField::New();
2554 DALI_TEST_CHECK(field);
2555 application.GetScene().Add(field);
2556 LoadMarkerImages(application, field);
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2562 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2563 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2564 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2565 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2567 // Avoid a crash when core load gl resources.
2568 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2569 // Render and notify
2570 application.SendNotification();
2571 application.Render();
2573 // Create a tap event to touch the text field.
2574 TestGenerateTap(application, 150.0f, 25.0f);
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2579 // Tap first to get the focus.
2580 TestGenerateTap(application, 1.0f, 25.0f);
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 // Double tap to select a word.
2587 TestGenerateTap(application, 1.0f, 25.0f);
2589 // Render and notify
2590 application.SendNotification();
2591 application.Render();
2594 TestGenerateTap(application, 0.0f, 40.0f);
2598 int utcDaliTextFieldEvent05(void)
2600 ToolkitTestApplication application;
2601 tet_infoline(" utcDaliTextFieldEvent05");
2603 // Checks dragging of cursor/grab handle
2605 TextField field = TextField::New();
2606 DALI_TEST_CHECK(field);
2607 application.GetScene().Add(field);
2608 LoadMarkerImages(application, field);
2609 // Render and notify
2610 application.SendNotification();
2611 application.Render();
2613 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2614 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2615 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2616 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2617 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2619 // Avoid a crash when core load gl resources.
2620 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 // Create a tap event to touch the text field.
2626 TestGenerateTap(application, 150.0f, 25.0f);
2627 // Render and notify
2628 application.SendNotification();
2629 application.Render();
2631 // Tap first to get the focus.
2632 TestGenerateTap(application, 1.0f, 25.0f);
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2638 // Double tap to select a word.
2639 TestGenerateTap(application, 1.0f, 25.0f);
2641 // Render and notify
2642 application.SendNotification();
2643 application.Render();
2645 Actor stencil = field.GetChildAt(1u);
2649 int utcDaliTextFieldEvent06(void)
2651 ToolkitTestApplication application;
2652 tet_infoline(" utcDaliTextFieldEvent06");
2654 // Checks Longpress when in edit mode
2656 TextField field = TextField::New();
2657 DALI_TEST_CHECK(field);
2658 application.GetScene().Add(field);
2659 LoadMarkerImages(application, field);
2660 // Render and notify
2661 application.SendNotification();
2662 application.Render();
2664 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2665 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2666 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2667 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2668 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2670 // Avoid a crash when core load gl resources.
2671 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2672 // Render and notify
2673 application.SendNotification();
2674 application.Render();
2676 // Create a tap event to touch the text field.
2677 TestGenerateTap(application, 150.0f, 25.0f);
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 // Tap first to get the focus.
2683 TestGenerateTap(application, 1.0f, 25.0f);
2685 // Render and notify
2686 application.SendNotification();
2687 application.Render();
2690 TestGenerateLongPress(application, 1.0f, 25.0f);
2692 // Render and notify
2693 application.SendNotification();
2694 application.Render();
2699 int utcDaliTextFieldEvent07(void)
2701 ToolkitTestApplication application;
2702 tet_infoline(" utcDaliTextFieldEvent07");
2704 // Checks Longpress to start edit mode
2706 TextField field = TextField::New();
2707 DALI_TEST_CHECK(field);
2708 application.GetScene().Add(field);
2709 LoadMarkerImages(application, field);
2710 // Render and notify
2711 application.SendNotification();
2712 application.Render();
2714 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2715 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2716 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2717 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2718 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2719 Property::Map propertyMap;
2720 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2721 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2723 // Avoid a crash when core load gl resources.
2724 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2725 // Render and notify
2726 application.SendNotification();
2727 application.Render();
2730 TestGenerateLongPress(application, 1.0f, 25.0f);
2732 // Render and notify
2733 application.SendNotification();
2734 application.Render();
2739 int utcDaliTextFieldEvent08(void)
2741 ToolkitTestApplication application;
2742 tet_infoline(" utcDaliTextFieldEvent08");
2744 Dali::Clipboard clipboard = Clipboard::Get();
2745 clipboard.SetItem("testTextFieldEvent");
2747 // Checks Longpress when only place holder text
2749 TextField field = TextField::New();
2750 DALI_TEST_CHECK(field);
2751 application.GetScene().Add(field);
2752 LoadMarkerImages(application, field);
2753 // Render and notify
2754 application.SendNotification();
2755 application.Render();
2757 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2758 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2759 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2760 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2761 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2763 // Avoid a crash when core load gl resources.
2764 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2765 // Render and notify
2766 application.SendNotification();
2767 application.Render();
2770 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2772 // Render and notify
2773 application.SendNotification();
2774 application.Render();
2776 Wait(application, 500);
2778 TestEndLongPress(application, 1.0f, 25.0f, 520);
2781 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2783 // Render and notify
2784 application.Render();
2786 Wait(application, 500);
2788 Integration::Scene stage = application.GetScene();
2789 Layer layer = stage.GetRootLayer();
2790 Actor actor = layer.FindChildByName("optionPaste");
2794 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2795 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2796 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2798 Dali::Integration::TouchEvent event;
2799 event = Dali::Integration::TouchEvent();
2800 event.AddPoint(GetPointDownInside(position));
2801 application.ProcessEvent(event);
2803 event = Dali::Integration::TouchEvent();
2804 event.AddPoint(GetPointUpInside(position));
2805 application.ProcessEvent(event);
2807 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2812 int utcDaliTextFieldEvent09(void)
2814 ToolkitTestApplication application;
2815 tet_infoline(" utcDaliTextFieldEvent09");
2817 TextField field = TextField::New();
2818 DALI_TEST_CHECK(field);
2819 application.GetScene().Add(field);
2820 LoadMarkerImages(application, field);
2821 // Render and notify
2822 application.SendNotification();
2823 application.Render();
2825 field.SetProperty(TextField::Property::TEXT, "Hello");
2826 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2827 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2828 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2829 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2831 // Avoid a crash when core load gl resources.
2832 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2834 // Create a tap event to touch the text field.
2835 TestGenerateTap(application, 150.0f, 25.0f);
2836 application.SendNotification();
2837 application.Render();
2840 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2841 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2842 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2843 application.SendNotification();
2844 application.Render();
2846 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2847 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2848 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2849 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2850 application.SendNotification();
2851 application.Render();
2853 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2854 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2855 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2856 for(unsigned int index = 0u; index < 5u; ++index)
2858 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2859 application.SendNotification();
2860 application.Render();
2863 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
2864 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2865 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2866 for(unsigned int index = 0u; index < 5u; ++index)
2868 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 application.SendNotification();
2870 application.Render();
2873 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2874 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2875 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2876 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2877 application.SendNotification();
2878 application.Render();
2879 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2880 application.SendNotification();
2881 application.Render();
2883 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2884 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2885 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2886 application.SendNotification();
2887 application.Render();
2889 Property::Map mapGet;
2890 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2891 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2892 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2896 int utcDaliTextFieldStyleWhilstSelected(void)
2898 ToolkitTestApplication application;
2899 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2901 // Change font and styles whilst text is selected whilst word selected
2903 TextField field = TextField::New();
2904 DALI_TEST_CHECK(field);
2905 application.GetScene().Add(field);
2906 LoadMarkerImages(application, field);
2907 // Render and notify
2908 application.SendNotification();
2909 application.Render();
2911 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2912 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2913 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2914 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2915 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2917 // Avoid a crash when core load gl resources.
2918 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2919 // Render and notify
2920 application.SendNotification();
2921 application.Render();
2923 // Create a tap event to touch the text field.
2924 TestGenerateTap(application, 150.0f, 25.0f);
2925 // Render and notify
2926 application.SendNotification();
2927 application.Render();
2929 // Tap first to get the focus.
2930 TestGenerateTap(application, 1.0f, 25.0f);
2932 // Render and notify
2933 application.SendNotification();
2934 application.Render();
2936 // Double tap to select a word.
2937 TestGenerateTap(application, 1.0f, 25.0f);
2939 // Render and notify
2940 application.SendNotification();
2941 application.Render();
2943 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
2944 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
2946 Property::Map fontStyleMapSet;
2947 Property::Map fontStyleMapGet;
2949 fontStyleMapSet.Insert("weight", "bold");
2950 fontStyleMapSet.Insert("slant", "italic");
2951 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2953 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2954 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2955 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2957 fontStyleMapSet.Clear();
2958 fontStyleMapSet.Insert("width", "expanded");
2959 fontStyleMapSet.Insert("slant", "italic");
2960 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2962 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2963 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2964 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2966 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
2967 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2969 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
2970 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
2972 fontStyleMapSet.Clear();
2973 fontStyleMapSet.Insert("weight", "bold");
2974 fontStyleMapSet.Insert("slant", "italic");
2976 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2978 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2979 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2980 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2982 fontStyleMapSet.Clear();
2983 fontStyleMapSet.Insert("width", "expanded");
2985 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2987 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2988 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2989 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2991 // Press Escape to increase coverage
2992 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2993 application.SendNotification();
2994 application.Render();
2996 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3001 int utcDaliTextFieldEscKeyLoseFocus(void)
3003 ToolkitTestApplication application;
3004 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3006 // Creates a tap event. After creating a tap event the text field should
3007 // have the focus and add text with key events should be possible.
3009 TextField field = TextField::New();
3010 DALI_TEST_CHECK(field);
3012 application.GetScene().Add(field);
3014 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3015 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3016 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3018 // Avoid a crash when core load gl resources.
3019 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3021 // Render and notify
3022 application.SendNotification();
3023 application.Render();
3025 // Add a key event but as the text field has not the focus it should do nothing.
3026 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3027 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3035 // Create a tap event to touch the text field.
3036 TestGenerateTap(application, 150.0f, 25.0f);
3038 // Render and notify
3039 application.SendNotification();
3040 application.Render();
3042 // Now the text field has the focus, so it can handle the key events.
3043 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3044 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3046 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3048 // Render and notify
3049 application.SendNotification();
3050 application.Render();
3052 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3054 // Generate a Esc key event. The text field should lose the focus.
3055 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3056 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3058 // Render and notify
3059 application.SendNotification();
3060 application.Render();
3062 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3064 // No more text should be introduced
3065 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3066 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3068 // Render and notify
3069 application.SendNotification();
3070 application.Render();
3072 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3077 int utcDaliTextFieldSomeSpecialKeys(void)
3079 ToolkitTestApplication application;
3080 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3082 // Checks some special keys when the text is selected.
3084 TextField field = TextField::New();
3085 DALI_TEST_CHECK(field);
3086 application.GetScene().Add(field);
3087 LoadMarkerImages(application, field);
3088 // Render and notify
3089 application.SendNotification();
3090 application.Render();
3092 const std::string longText("This is a long text for the size of the text-field.");
3094 field.SetProperty(TextField::Property::TEXT, longText);
3095 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3096 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3097 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3098 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3100 // Avoid a crash when core load gl resources.
3101 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3102 // Render and notify
3103 application.SendNotification();
3104 application.Render();
3106 // Create a tap event to touch the text field.
3107 TestGenerateTap(application, 150.0f, 25.0f);
3109 // Render and notify
3110 application.SendNotification();
3111 application.Render();
3113 // Tap first to get the focus.
3114 TestGenerateTap(application, 1.0f, 25.0f);
3116 // Render and notify
3117 application.SendNotification();
3118 application.Render();
3120 // Double tap to select a word.
3121 TestGenerateTap(application, 1.0f, 25.0f);
3123 // Render and notify
3124 application.SendNotification();
3125 application.Render();
3127 // Generate a Esc key event. The text field should lose the focus.
3128 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3129 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3131 // Render and notify
3132 application.SendNotification();
3133 application.Render();
3135 // Generate a Esc key event. The text field should lose the focus.
3136 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3137 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3139 // Render and notify
3140 application.SendNotification();
3141 application.Render();
3143 // Generate a Esc key event. The text field should lose the focus.
3144 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3145 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3147 // Render and notify
3148 application.SendNotification();
3149 application.Render();
3151 // The text shouldn't be deleted.
3152 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3157 int utcDaliTextFieldSizeUpdate(void)
3159 ToolkitTestApplication application;
3160 tet_infoline("utcDaliTextFieldSizeUpdate");
3162 // Checks some special keys when the text is selected.
3163 TextField field = TextField::New();
3164 DALI_TEST_CHECK(field);
3165 application.GetScene().Add(field);
3167 float previousHeight = 0.0f;
3168 float currentHeight = 0.0f;
3169 const float fieldWidth = 1920.0f;
3171 // "ㅁ" is bigger then "ኢ"
3172 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3173 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3174 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3176 field.SetProperty(TextField::Property::TEXT, "ኢ");
3177 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3178 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3180 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3181 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3183 application.SendNotification();
3184 application.Render();
3186 previousHeight = field.GetHeightForWidth(fieldWidth);
3187 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3189 // Add another script characters ( glyph height is defferent )
3190 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3191 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3193 application.SendNotification();
3194 application.Render();
3196 currentHeight = field.GetHeightForWidth(fieldWidth);
3197 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3198 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3203 int utcDaliTextFieldExtremlyLargePointSize(void)
3205 ToolkitTestApplication application;
3206 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3208 TextField field = TextField::New();
3210 field.SetProperty(TextField::Property::TEXT, "Text");
3211 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3212 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3213 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3214 application.GetScene().Add(field);
3218 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3219 application.SendNotification();
3220 DALI_TEST_CHECK(field);
3224 tet_result(TET_FAIL);
3229 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3231 ToolkitTestApplication application;
3232 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3233 TextField field = TextField::New();
3234 DALI_TEST_CHECK(field);
3235 application.GetScene().Add(field);
3237 Property::Map fontStyleMapGet;
3239 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3241 Property::Value* weightValue = NULL;
3242 Property::Value* widthValue = NULL;
3243 Property::Value* slantValue = NULL;
3244 weightValue = fontStyleMapGet.Find("weight");
3245 widthValue = fontStyleMapGet.Find("width");
3246 slantValue = fontStyleMapGet.Find("slant");
3247 DALI_TEST_CHECK(!weightValue);
3248 DALI_TEST_CHECK(!widthValue);
3249 DALI_TEST_CHECK(!slantValue);
3254 int UtcDaliTextFieldSettingPlaceholder(void)
3256 ToolkitTestApplication application;
3257 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3259 TextField field = TextField::New();
3260 DALI_TEST_CHECK(field);
3261 application.GetScene().Add(field);
3263 // Check the placeholder property with pixel size
3264 Property::Map placeholderPixelSizeMapSet;
3265 Property::Map placeholderPixelSizeMapGet;
3266 Property::Map placeholderFontstyleMap;
3267 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3268 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3269 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3270 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3271 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3272 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3274 placeholderFontstyleMap.Insert("weight", "bold");
3275 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3276 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3278 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3279 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3280 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3282 // Check the placeholder property with point size
3283 Property::Map placeholderMapSet;
3284 Property::Map placeholderMapGet;
3285 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3286 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3287 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3288 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3289 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3290 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3292 // Check the placeholder font style property
3293 placeholderFontstyleMap.Clear();
3295 placeholderFontstyleMap.Insert("weight", "bold");
3296 placeholderFontstyleMap.Insert("width", "condensed");
3297 placeholderFontstyleMap.Insert("slant", "italic");
3298 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3299 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3301 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3302 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3303 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3305 // Reset font style.
3306 placeholderFontstyleMap.Clear();
3307 placeholderFontstyleMap.Insert("weight", "normal");
3308 placeholderFontstyleMap.Insert("slant", "oblique");
3309 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3310 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3312 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3313 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3314 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3316 placeholderFontstyleMap.Clear();
3317 placeholderFontstyleMap.Insert("slant", "roman");
3318 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3319 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3321 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3323 placeholderFontstyleMap.Clear();
3324 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3326 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3327 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3328 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3329 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3334 int UtcDaliTextFieldPlaceholderCoverage(void)
3336 ToolkitTestApplication application;
3337 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3339 // mPlaceholderFont is created only once, so create a new control for coverage.
3340 TextField fieldForCoverage = TextField::New();
3341 DALI_TEST_CHECK(fieldForCoverage);
3342 application.GetScene().Add(fieldForCoverage);
3344 // for SetPlaceholderFontFamily() coverage.
3345 Property::Map fontFamilyMap;
3346 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3347 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3349 // mPlaceholderFont is created only once, so create a new control for coverage.
3350 fieldForCoverage = TextField::New();
3351 DALI_TEST_CHECK(fieldForCoverage);
3352 application.GetScene().Add(fieldForCoverage);
3354 // for SetPlaceholderTextFontSize coverage.
3355 Property::Map fontSizeMap;
3356 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3357 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3359 // mPlaceholderFont is created only once, so create a new control for coverage.
3360 fieldForCoverage = TextField::New();
3361 DALI_TEST_CHECK(fieldForCoverage);
3362 application.GetScene().Add(fieldForCoverage);
3364 // for SetPlaceholderTextFontWeight coverage.
3365 Property::Map fontStyleWeightMap;
3366 Property::Map fontStyleWeightPropertyMap;
3367 fontStyleWeightPropertyMap.Insert("weight", "bold");
3368 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3369 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3371 // mPlaceholderFont is created only once, so create a new control for coverage.
3372 fieldForCoverage = TextField::New();
3373 DALI_TEST_CHECK(fieldForCoverage);
3374 application.GetScene().Add(fieldForCoverage);
3376 // for SetPlaceholderTextFontWidth coverage.
3377 Property::Map fontStyleWidthMap;
3378 Property::Map fontStyleWidthPropertyMap;
3379 fontStyleWidthPropertyMap.Insert("width", "expanded");
3380 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3381 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3383 // mPlaceholderFont is created only once, so create a new control for coverage.
3384 fieldForCoverage = TextField::New();
3385 DALI_TEST_CHECK(fieldForCoverage);
3386 application.GetScene().Add(fieldForCoverage);
3388 // for SetPlaceholderTextFontSlant coverage.
3389 Property::Map fontStyleSlantMap;
3390 Property::Map fontStyleSlantPropertyMap;
3391 fontStyleSlantPropertyMap.Insert("slant", "italic");
3392 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3393 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3398 int UtcDaliTextFieldSetPaddingProperty(void)
3400 ToolkitTestApplication application;
3401 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3403 TextField field = TextField::New();
3404 DALI_TEST_CHECK(field);
3405 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3406 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3407 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3408 application.GetScene().Add(field);
3410 application.SendNotification();
3411 application.Render();
3413 Vector3 originalSize = field.GetNaturalSize();
3415 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3417 application.SendNotification();
3418 application.Render();
3420 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3422 Vector3 paddingAddedSize = field.GetNaturalSize();
3424 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3426 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3431 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3433 ToolkitTestApplication application;
3434 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3436 TextField field = TextField::New();
3437 DALI_TEST_CHECK(field);
3438 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3439 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3440 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3441 application.GetScene().Add(field);
3443 application.SendNotification();
3444 application.Render();
3446 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3447 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3449 // Check the enable shift selection property
3450 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3451 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3453 application.SendNotification();
3454 application.Render();
3459 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3461 ToolkitTestApplication application;
3462 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3464 TextField field = TextField::New();
3465 DALI_TEST_CHECK(field);
3466 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3467 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3468 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3469 application.GetScene().Add(field);
3471 application.SendNotification();
3472 application.Render();
3474 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3475 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3477 // Check the enable grab handle property
3478 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3479 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3481 application.SendNotification();
3482 application.Render();
3487 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3489 ToolkitTestApplication application;
3490 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3492 TextField field = TextField::New();
3493 DALI_TEST_CHECK(field);
3494 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3495 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3496 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3497 application.GetScene().Add(field);
3499 application.SendNotification();
3500 application.Render();
3502 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3503 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3505 // Check the match system language direction property
3506 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3507 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3509 application.SendNotification();
3510 application.Render();
3515 int utcDaliTextFieldLayoutDirectionCoverage(void)
3517 ToolkitTestApplication application;
3518 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3520 // Creates a tap event. After creating a tap event the text field should
3521 // have the focus and add text with key events should be possible.
3522 TextField field = TextField::New();
3523 DALI_TEST_CHECK(field);
3525 application.GetScene().Add(field);
3527 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3528 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3529 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3531 // Avoid a crash when core load gl resources.
3532 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3534 // Render and notify
3535 application.SendNotification();
3536 application.Render();
3538 // init direction for coverage
3539 // Set horizontal alignment END
3540 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3542 // Create a tap event to touch the text field.
3543 TestGenerateTap(application, 150.0f, 25.0f);
3545 // Render and notify
3546 application.SendNotification();
3547 application.Render();
3549 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3550 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3551 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
3553 // Set horizontal alignment BEGIN
3554 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3556 // Create a tap event to touch the text field.
3557 TestGenerateTap(application, 150.0f, 25.0f);
3559 // Render and notify
3560 application.SendNotification();
3561 application.Render();
3563 // Set horizontal alignment CENTER
3564 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3566 // Create a tap event to touch the text field.
3567 TestGenerateTap(application, 150.0f, 25.0f);
3569 // Render and notify
3570 application.SendNotification();
3571 application.Render();
3573 // Set horizontal alignment END
3574 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3576 // Create a tap event to touch the text field.
3577 TestGenerateTap(application, 150.0f, 25.0f);
3579 // Render and notify
3580 application.SendNotification();
3581 application.Render();
3583 // Generate a Esc key event. The text field should lose the focus.
3584 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3585 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3587 // Render and notify
3588 application.SendNotification();
3589 application.Render();
3591 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3596 int UtcDaliTextFieldGetInputMethodContext(void)
3598 ToolkitTestApplication application;
3599 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3601 TextField field = TextField::New();
3602 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
3607 int UtcDaliTextFieldSelectWholeText(void)
3609 ToolkitTestApplication application;
3610 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3612 TextField textField = TextField::New();
3614 application.GetScene().Add(textField);
3616 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3617 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3618 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3620 // Avoid a crash when core load gl resources.
3621 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3623 application.SendNotification();
3624 application.Render();
3626 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3628 DevelTextField::SelectWholeText(textField);
3630 application.SendNotification();
3631 application.Render();
3633 // Nothing should have been selected. The number of children is still 1
3634 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
3636 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3638 application.SendNotification();
3639 application.Render();
3641 DevelTextField::SelectWholeText(textField);
3643 application.SendNotification();
3644 application.Render();
3646 // Even if resize, selection should remain.
3647 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
3649 application.SendNotification();
3650 application.Render();
3652 // Should be 2 children, the stencil and the layer
3653 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
3655 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3656 Actor stencil = textField.GetChildAt(0u);
3658 // The highlight actor is drawn first, so is the first actor in the list
3659 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
3660 DALI_TEST_CHECK(highlight);
3665 int UtcDaliTextFieldSelectText(void)
3667 ToolkitTestApplication application;
3668 tet_infoline(" UtcDaliTextFieldSelectText ");
3670 TextField textField = TextField::New();
3672 application.GetScene().Add(textField);
3674 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3675 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3676 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3678 // Avoid a crash when core load gl resources.
3679 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3681 application.SendNotification();
3682 application.Render();
3684 DevelTextField::SelectText(textField, 0, 5);
3686 application.SendNotification();
3687 application.Render();
3689 // Nothing is selected
3690 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3691 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3693 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3695 application.SendNotification();
3696 application.Render();
3698 // Hello is selected
3699 DevelTextField::SelectText(textField, 0, 5);
3701 application.SendNotification();
3702 application.Render();
3704 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3705 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3707 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3708 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3710 // world is selected
3711 DevelTextField::SelectText(textField, 6, 11);
3713 application.SendNotification();
3714 application.Render();
3716 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3717 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3719 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3720 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3725 int UtcDaliTextFieldSelectNone(void)
3727 ToolkitTestApplication application;
3728 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3730 TextField textField = TextField::New();
3732 application.GetScene().Add(textField);
3734 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3735 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3736 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3738 // Avoid a crash when core load gl resources.
3739 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3741 application.SendNotification();
3742 application.Render();
3744 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3746 application.SendNotification();
3747 application.Render();
3749 // Nothing is selected
3750 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3751 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3753 DevelTextField::SelectWholeText(textField);
3755 application.SendNotification();
3756 application.Render();
3758 // whole text is selected
3759 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3760 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
3762 DevelTextField::SelectNone(textField);
3764 application.SendNotification();
3765 application.Render();
3767 // Nothing is selected
3768 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3769 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
3774 int UtcDaliTextFieldSelectRange(void)
3776 ToolkitTestApplication application;
3777 tet_infoline(" UtcDaliTextFieldSelectRange ");
3779 TextField textField = TextField::New();
3781 application.GetScene().Add(textField);
3783 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3784 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3785 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3787 // Avoid a crash when core load gl resources.
3788 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3790 application.SendNotification();
3791 application.Render();
3793 textField.SetProperty(TextField::Property::TEXT, "Hello world");
3795 application.SendNotification();
3796 application.Render();
3798 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
3799 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
3801 // Hello is selected
3802 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3803 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
3805 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
3806 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
3808 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
3809 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
3811 // world is selected
3812 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
3813 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
3815 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
3816 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
3821 int UtcDaliTextFieldEnableEditing(void)
3823 ToolkitTestApplication application;
3824 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3826 TextField textField = TextField::New();
3828 application.GetScene().Add(textField);
3830 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3831 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3832 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3834 // Avoid a crash when core load gl resources.
3835 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3837 application.SendNotification();
3838 application.Render();
3840 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
3841 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
3843 textField.SetKeyInputFocus();
3844 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
3845 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3847 // Render and notify
3848 application.SendNotification();
3849 application.Render();
3851 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
3852 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
3854 textField.SetKeyInputFocus();
3855 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
3856 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3858 // Render and notify
3859 application.SendNotification();
3860 application.Render();
3862 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3863 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
3865 // Check the user interaction enabled and for coverage
3866 DevelTextField::SelectWholeText(textField);
3868 // Render and notify
3869 application.SendNotification();
3870 application.Render();
3872 textField.SetKeyInputFocus();
3873 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
3874 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3876 // Render and notify
3877 application.SendNotification();
3878 application.Render();
3880 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
3881 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
3886 int UtcDaliToolkitTextFieldFontSizeScale(void)
3888 ToolkitTestApplication application;
3889 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3891 TextField textField = TextField::New();
3892 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
3893 textField.SetProperty(TextField::Property::TEXT, "Test");
3894 Vector3 nonScaledSize = textField.GetNaturalSize();
3896 TextField textFieldScaled = TextField::New();
3897 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
3898 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3899 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3900 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3902 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3904 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
3905 textField.SetProperty(TextField::Property::TEXT, "Test");
3906 nonScaledSize = textField.GetNaturalSize();
3908 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
3909 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
3910 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
3911 scaledSize = textFieldScaled.GetNaturalSize();
3913 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
3918 int UtcDaliTextFieldPrimaryCursorPosition(void)
3920 ToolkitTestApplication application;
3921 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3923 TextField textField = TextField::New();
3925 application.GetScene().Add(textField);
3927 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
3928 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3929 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3930 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3932 // Avoid a crash when core load gl resources.
3933 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3935 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3936 application.SendNotification();
3937 application.Render();
3938 textField.SetKeyInputFocus();
3940 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3942 // Render and notify
3943 application.SendNotification();
3944 application.Render();
3946 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
3947 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
3952 // test max length when set after setting long text
3953 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3955 ToolkitTestApplication application;
3956 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3957 TextField field = TextField::New();
3958 DALI_TEST_CHECK(field);
3960 application.GetScene().Add(field);
3962 field.SetProperty(TextField::Property::TEXT, "123456789");
3964 const int maxNumberOfCharacters = 3;
3965 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
3967 field.SetKeyInputFocus();
3969 // connect to the text max lengh reached signal.
3970 ConnectionTracker* testTracker = new ConnectionTracker();
3971 bool maxLengthReachedSignal = false;
3972 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
3974 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3975 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3977 DALI_TEST_CHECK(maxLengthReachedSignal);
3979 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
3984 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3986 ToolkitTestApplication application;
3987 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3989 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3990 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3991 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3993 // Create a text field
3994 TextField textField = TextField::New();
3996 //Set size to avoid automatic eliding
3997 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
3998 //Set very large font-size using point-size
3999 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4000 //Specify font-family
4001 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4002 //Set text to check if appear or not
4003 textField.SetProperty(TextField::Property::TEXT, "A");
4005 application.GetScene().Add(textField);
4007 application.SendNotification();
4008 application.Render();
4009 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4010 Vector3 naturalSize = textField.GetNaturalSize();
4012 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4013 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4018 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4020 ToolkitTestApplication application;
4021 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4023 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4024 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4025 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4027 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4028 // Create a text editor
4029 TextField textField = TextField::New();
4031 //Set size to avoid automatic eliding
4032 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4033 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4034 textField.SetProperty(TextField::Property::TEXT, "A");
4036 const int numberOfCases = 6;
4037 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4039 for(int index = 0; index < numberOfCases; index++)
4041 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4042 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4043 application.GetScene().Add(textField);
4044 application.SendNotification();
4045 application.Render();
4046 naturalSize = textField.GetNaturalSize();
4047 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4048 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4054 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4056 ToolkitTestApplication application;
4057 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4058 TextField textField = TextField::New();
4060 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4061 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4063 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4064 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4065 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4067 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4068 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4069 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4071 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4072 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4073 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4075 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4076 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4077 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4079 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4080 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4081 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4083 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4084 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4085 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4087 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4088 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4089 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4091 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4092 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4093 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4095 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4096 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4097 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4099 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4100 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4101 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4103 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4104 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4105 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4107 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4108 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4109 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4114 int UtcDaliTextFieldCopyText(void)
4116 ToolkitTestApplication application;
4117 tet_infoline(" UtcDaliTextFieldCopyText ");
4119 TextField textField = TextField::New();
4121 std::string selectedText = "";
4122 std::string copiedText = "";
4124 application.GetScene().Add(textField);
4126 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4127 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4128 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4130 // Avoid a crash when core load gl resources.
4131 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4133 application.SendNotification();
4134 application.Render();
4136 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4138 application.SendNotification();
4139 application.Render();
4141 // Hello is selected
4142 DevelTextField::SelectText(textField, 0, 5);
4144 application.SendNotification();
4145 application.Render();
4147 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4148 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4150 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4151 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4154 copiedText = DevelTextField::CopyText(textField);
4155 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4157 // world is selected
4158 DevelTextField::SelectText(textField, 6, 11);
4160 application.SendNotification();
4161 application.Render();
4163 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4164 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4166 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4167 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4170 copiedText = DevelTextField::CopyText(textField);
4171 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4173 // "lo wo" is selected
4174 DevelTextField::SelectText(textField, 3, 8);
4176 application.SendNotification();
4177 application.Render();
4179 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4180 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4182 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4183 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4185 // "lo wo" is copied
4186 copiedText = DevelTextField::CopyText(textField);
4187 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4192 int UtcDaliTextFieldCutText(void)
4194 ToolkitTestApplication application;
4195 tet_infoline(" UtcDaliTextFieldCutText ");
4197 TextField textField = TextField::New();
4199 std::string selectedText = "";
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 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4233 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4236 DevelTextField::SelectText(textField, 0, 2);
4238 application.SendNotification();
4239 application.Render();
4241 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4242 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4244 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4245 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4248 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4250 application.SendNotification();
4251 application.Render();
4253 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4255 // Test Cut from the middle
4258 DevelTextField::SelectText(textField, 1, 3);
4260 application.SendNotification();
4261 application.Render();
4263 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4264 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4266 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4267 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4270 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4272 application.SendNotification();
4273 application.Render();
4275 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4277 // Test Cut from the end
4280 DevelTextField::SelectText(textField, 1, 2);
4282 application.SendNotification();
4283 application.Render();
4285 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4286 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4288 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4289 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4292 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4294 application.SendNotification();
4295 application.Render();
4297 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4302 int UtcDaliTextFieldPasteText(void)
4304 ToolkitTestApplication application;
4305 tet_infoline(" UtcDaliTextFieldPasteText ");
4307 TextField textField = TextField::New();
4309 application.GetScene().Add(textField);
4311 std::string cutText = "";
4312 std::string copiedText = "";
4314 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4315 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4316 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4318 // Avoid a crash when core load gl resources.
4319 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4321 application.SendNotification();
4322 application.Render();
4324 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4326 application.SendNotification();
4327 application.Render();
4329 // Tap on the text editor
4330 TestGenerateTap(application, 3.0f, 25.0f);
4332 // Render and notify
4333 application.SendNotification();
4334 application.Render();
4336 // Select some text in the right of the current cursor position
4337 DevelTextField::SelectText(textField, 0, 3);
4339 // Render and notify
4340 application.SendNotification();
4341 application.Render();
4343 // Cut the selected text
4344 cutText = DevelTextField::CutText(textField);
4346 // Render and notify
4347 application.SendNotification();
4348 application.Render();
4350 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4351 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4353 DevelTextField::SelectText(textField, 0, 3);
4355 // Render and notify
4356 application.SendNotification();
4357 application.Render();
4359 // Copy the selected text
4360 copiedText = DevelTextField::CopyText(textField);
4362 // Render and notify
4363 application.SendNotification();
4364 application.Render();
4366 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4367 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4369 // Move the cursor to the end of the line
4370 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4371 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4372 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4373 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4374 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4375 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4376 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4377 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4379 // Render and notify
4380 application.SendNotification();
4381 application.Render();
4383 // Paste the selected text at the current cursor position
4384 DevelTextField::PasteText(textField);
4386 // Render and notify
4387 application.SendNotification();
4388 application.Render();
4390 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4395 int utcDaliTextFieldCursorPositionChangedSignal(void)
4397 ToolkitTestApplication application;
4398 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4400 TextField field = TextField::New();
4401 DALI_TEST_CHECK(field);
4403 application.GetScene().Add(field);
4405 // connect to the selection changed signal.
4406 ConnectionTracker* testTracker = new ConnectionTracker();
4407 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4408 bool cursorPositionChangedSignal = false;
4409 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4411 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4412 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4413 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4414 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4415 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4417 // Avoid a crash when core load gl resources.
4418 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4420 // Render and notify
4421 application.SendNotification();
4422 application.Render();
4424 field.SetKeyInputFocus();
4426 // Tap on the text field
4427 TestGenerateTap(application, 3.0f, 25.0f);
4429 // Render and notify
4430 application.SendNotification();
4431 application.Render();
4433 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4434 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4436 gCursorPositionChangedCallbackCalled = false;
4439 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4441 // Render and notify
4442 application.SendNotification();
4443 application.Render();
4445 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4446 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4448 gCursorPositionChangedCallbackCalled = false;
4451 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4453 // Render and notify
4454 application.SendNotification();
4455 application.Render();
4457 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4458 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4460 gCursorPositionChangedCallbackCalled = false;
4462 //delete one character
4463 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4465 // Render and notify
4466 application.SendNotification();
4467 application.Render();
4469 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4470 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4472 gCursorPositionChangedCallbackCalled = false;
4474 field.SetProperty(TextField::Property::TEXT, "Hello");
4476 // Render and notify
4477 application.SendNotification();
4478 application.Render();
4480 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4481 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4483 gCursorPositionChangedCallbackCalled = false;
4485 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4487 // Render and notify
4488 application.SendNotification();
4489 application.Render();
4491 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4492 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4497 int utcDaliTextFieldGeometryEllipsisStart(void)
4499 ToolkitTestApplication application;
4500 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4502 TextField field = TextField::New();
4503 DALI_TEST_CHECK(field);
4505 application.GetScene().Add(field);
4507 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4508 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4509 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4510 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4511 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4512 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4513 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4514 field.SetProperty(TextField::Property::TEXT, "Hello World");
4516 // Avoid a crash when core load gl resources.
4517 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4519 // Render and notify
4520 application.SendNotification();
4521 application.Render();
4523 unsigned int expectedCount = 1;
4524 unsigned int startIndex = 0;
4525 unsigned int endIndex = 10;
4527 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4528 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4530 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4531 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4533 Vector<Vector2> expectedSizes;
4534 Vector<Vector2> expectedPositions;
4536 expectedPositions.PushBack(Vector2(14, 0));
4537 expectedSizes.PushBack(Vector2(106, 25));
4539 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4544 int utcDaliTextFieldGeometryEllipsisEnd(void)
4546 ToolkitTestApplication application;
4547 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4549 TextField field = TextField::New();
4550 DALI_TEST_CHECK(field);
4552 application.GetScene().Add(field);
4554 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4555 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4556 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4557 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4558 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4559 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4560 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4561 field.SetProperty(TextField::Property::TEXT, "Hello World");
4563 // Avoid a crash when core load gl resources.
4564 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4566 // Render and notify
4567 application.SendNotification();
4568 application.Render();
4570 unsigned int expectedCount = 1;
4571 unsigned int startIndex = 0;
4572 unsigned int endIndex = 10;
4574 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4575 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4577 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4578 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4580 Vector<Vector2> expectedSizes;
4581 Vector<Vector2> expectedPositions;
4583 expectedPositions.PushBack(Vector2(-2, 0));
4584 expectedSizes.PushBack(Vector2(122, 25));
4586 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4591 int utcDaliTextFieldGeometryRTL(void)
4593 ToolkitTestApplication application;
4594 tet_infoline(" utcDaliTextFieldGeometryRTL");
4596 TextField field = TextField::New();
4597 DALI_TEST_CHECK(field);
4599 application.GetScene().Add(field);
4601 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4602 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4603 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4604 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4605 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4606 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
4608 // Avoid a crash when core load gl resources.
4609 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4611 // Render and notify
4612 application.SendNotification();
4613 application.Render();
4615 unsigned int expectedCount = 1;
4616 unsigned int startIndex = 1;
4617 unsigned int endIndex = 7;
4619 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4620 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4622 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4623 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4625 Vector<Vector2> expectedSizes;
4626 Vector<Vector2> expectedPositions;
4628 expectedPositions.PushBack(Vector2(38, 0));
4629 expectedSizes.PushBack(Vector2(73, 25));
4631 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4636 int utcDaliTextFieldGeometryGlyphMiddle(void)
4638 ToolkitTestApplication application;
4639 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4641 TextField field = TextField::New();
4642 DALI_TEST_CHECK(field);
4644 application.GetScene().Add(field);
4646 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4647 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
4648 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4649 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4650 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4651 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
4653 // Avoid a crash when core load gl resources.
4654 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4656 // Render and notify
4657 application.SendNotification();
4658 application.Render();
4660 unsigned int expectedCount = 1;
4661 unsigned int startIndex = 1;
4662 unsigned int endIndex = 13;
4664 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4665 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4667 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4668 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4670 Vector<Vector2> expectedSizes;
4671 Vector<Vector2> expectedPositions;
4673 expectedPositions.PushBack(Vector2(6, 0));
4674 expectedSizes.PushBack(Vector2(124, 25));
4676 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4681 int utcDaliTextFieldSelectionClearedSignal(void)
4683 ToolkitTestApplication application;
4684 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4686 TextField field = TextField::New();
4687 DALI_TEST_CHECK(field);
4689 application.GetScene().Add(field);
4691 // connect to the selection changed signal.
4692 ConnectionTracker* testTracker = new ConnectionTracker();
4693 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4694 bool selectionClearedSignal = false;
4695 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
4697 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4698 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4699 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4700 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4701 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4703 // Avoid a crash when core load gl resources.
4704 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4706 // Render and notify
4707 application.SendNotification();
4708 application.Render();
4710 // Tap on the text editor
4711 TestGenerateTap(application, 3.0f, 25.0f);
4713 // Render and notify
4714 application.SendNotification();
4715 application.Render();
4717 // Move to second line of the text & Select some text in the right of the current cursor position
4718 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4719 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4722 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4724 // Render and notify
4725 application.SendNotification();
4726 application.Render();
4728 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4730 // Render and notify
4731 application.SendNotification();
4732 application.Render();
4734 // Tap on the text editor
4735 TestGenerateTap(application, 3.0f, 25.0f);
4737 // Render and notify
4738 application.SendNotification();
4739 application.Render();
4741 gSelectionClearedCallbackCalled = false;
4743 // Move to second line of the text & select.
4744 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4745 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4748 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4750 // Render and notify
4751 application.SendNotification();
4752 application.Render();
4754 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4756 gSelectionClearedCallbackCalled = false;
4758 // Render and notify
4759 application.SendNotification();
4760 application.Render();
4762 // Move to second line of the text & select.
4763 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4764 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4766 // replace D with selected text
4767 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4769 // Render and notify
4770 application.SendNotification();
4771 application.Render();
4773 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4775 gSelectionClearedCallbackCalled = false;
4777 // Render and notify
4778 application.SendNotification();
4779 application.Render();
4781 DevelTextField::SelectText(field, 1, 3);
4783 // Render and notify
4784 application.SendNotification();
4785 application.Render();
4787 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4789 // Render and notify
4790 application.SendNotification();
4791 application.Render();
4793 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4795 gSelectionClearedCallbackCalled = false;
4797 DevelTextField::SelectText(field, 1, 3);
4799 // Render and notify
4800 application.SendNotification();
4801 application.Render();
4804 DevelTextField::SelectNone(field);
4806 // Render and notify
4807 application.SendNotification();
4808 application.Render();
4810 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4815 int utcDaliTextFieldSelectionStartedSignal(void)
4817 ToolkitTestApplication application;
4818 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
4820 TextField field = TextField::New();
4821 DALI_TEST_CHECK(field);
4823 application.GetScene().Add(field);
4825 // connect to the selection changed signal.
4826 ConnectionTracker* testTracker = new ConnectionTracker();
4827 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
4828 bool selectionStartedSignal = false;
4829 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
4831 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
4832 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4833 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4834 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4835 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4837 // Avoid a crash when core load gl resources.
4838 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4840 // Render and notify
4841 application.SendNotification();
4842 application.Render();
4844 // Tap on the text field
4845 TestGenerateTap(application, 3.0f, 25.0f);
4847 // Render and notify
4848 application.SendNotification();
4849 application.Render();
4851 // Move to second line of the text & Select some text in the right of the current cursor position
4852 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4853 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4855 // Render and notify
4856 application.SendNotification();
4857 application.Render();
4859 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4862 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4864 // Render and notify
4865 application.SendNotification();
4866 application.Render();
4868 gSelectionStartedCallbackCalled = false;
4870 DevelTextField::SelectText(field, 1, 3);
4872 // Render and notify
4873 application.SendNotification();
4874 application.Render();
4876 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
4881 int utcDaliTextFieldSelectionChangedSignal(void)
4883 ToolkitTestApplication application;
4884 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4886 TextField field = TextField::New();
4887 DALI_TEST_CHECK(field);
4889 application.GetScene().Add(field);
4891 // connect to the selection changed signal.
4892 ConnectionTracker* testTracker = new ConnectionTracker();
4893 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4894 bool selectionChangedSignal = false;
4895 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
4897 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4898 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4899 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4900 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4901 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4903 // Avoid a crash when core load gl resources.
4904 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4906 // Render and notify
4907 application.SendNotification();
4908 application.Render();
4910 // Tap on the text field
4911 TestGenerateTap(application, 3.0f, 25.0f);
4913 // Render and notify
4914 application.SendNotification();
4915 application.Render();
4917 // Select some text in the right of the current cursor position
4918 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4919 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4921 // Render and notify
4922 application.SendNotification();
4923 application.Render();
4925 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4926 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4928 gSelectionChangedCallbackCalled = false;
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(gSelectionChangedCallbackCalled);
4937 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4938 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4940 gSelectionChangedCallbackCalled = false;
4942 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4944 // Render and notify
4945 application.SendNotification();
4946 application.Render();
4948 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4949 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4950 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4952 gSelectionChangedCallbackCalled = false;
4953 field.SetKeyInputFocus();
4955 // Render and notify
4956 application.SendNotification();
4957 application.Render();
4959 DevelTextField::SelectText(field, 0, 5);
4961 application.SendNotification();
4962 application.Render();
4964 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4965 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4967 gSelectionChangedCallbackCalled = false;
4969 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4971 // Render and notify
4972 application.SendNotification();
4973 application.Render();
4975 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4976 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4977 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4979 gSelectionChangedCallbackCalled = false;
4982 DevelTextField::SelectWholeText(field);
4984 // Render and notify
4985 application.SendNotification();
4986 application.Render();
4988 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4989 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4991 gSelectionChangedCallbackCalled = false;
4994 DevelTextField::SelectNone(field);
4996 // Render and notify
4997 application.SendNotification();
4998 application.Render();
5000 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5001 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5002 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5007 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5009 ToolkitTestApplication application;
5010 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5012 TextField textField = TextField::New();
5013 textField.SetProperty(TextField::Property::TEXT, "Test");
5014 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5015 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5016 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5018 application.GetScene().Add(textField);
5019 application.SendNotification();
5020 application.Render();
5022 Property::Map strikethroughMapSet;
5023 Property::Map strikethroughMapGet;
5025 strikethroughMapSet.Insert("enable", true);
5026 strikethroughMapSet.Insert("color", Color::RED);
5027 strikethroughMapSet.Insert("height", 2.0f);
5029 // Check the strikethrough property
5030 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5031 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5032 textField.SetProperty(TextField::Property::TEXT, "Test1");
5033 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5034 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5036 // Render and notify
5037 application.SendNotification();
5038 application.Render();
5040 strikethroughMapSet.Clear();
5041 strikethroughMapGet.Clear();
5046 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5048 ToolkitTestApplication application;
5049 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5051 TextField textField = TextField::New();
5052 textField.SetProperty(TextField::Property::TEXT, "Test");
5053 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5054 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5055 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5057 application.GetScene().Add(textField);
5058 application.SendNotification();
5059 application.Render();
5061 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5063 // Check the strikethrough property
5064 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5065 textField.SetProperty(TextField::Property::TEXT, "Test1");
5066 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5068 // Render and notify
5069 application.SendNotification();
5070 application.Render();
5075 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5077 ToolkitTestApplication application;
5078 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5079 TextField field = TextField::New();
5080 field.SetProperty(TextField::Property::TEXT, "Test");
5081 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5082 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5083 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5085 application.GetScene().Add(field);
5086 application.SendNotification();
5087 application.Render();
5089 Property::Map underlineMapSet;
5090 Property::Map underlineMapGet;
5092 underlineMapSet.Insert("enable", true);
5093 underlineMapSet.Insert("color", Color::RED);
5094 underlineMapSet.Insert("height", 1);
5095 underlineMapSet.Insert("type", Text::Underline::SOLID);
5096 underlineMapSet.Insert("dashWidth", 2);
5097 underlineMapSet.Insert("dashGap", 1);
5099 // Check the underline property
5100 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5102 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5103 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5104 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5106 // Render and notify
5107 application.SendNotification();
5108 application.Render();
5110 underlineMapSet.Clear();
5111 underlineMapGet.Clear();
5113 underlineMapSet.Insert("enable", true);
5114 underlineMapSet.Insert("color", Color::BLUE);
5115 underlineMapSet.Insert("height", 1);
5116 underlineMapSet.Insert("type", Text::Underline::DASHED);
5117 underlineMapSet.Insert("dashWidth", 4);
5118 underlineMapSet.Insert("dashGap", 2);
5120 // Check the dashed underline property
5121 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5123 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5124 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5125 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5127 // Render and notify
5128 application.SendNotification();
5129 application.Render();
5131 underlineMapSet.Clear();
5132 underlineMapGet.Clear();
5134 underlineMapSet.Insert("enable", true);
5135 underlineMapSet.Insert("color", Color::BLUE);
5136 underlineMapSet.Insert("height", 1);
5137 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5138 underlineMapSet.Insert("dashWidth", 4);
5139 underlineMapSet.Insert("dashGap", 2);
5141 // Check the dashed underline property
5142 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5144 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5145 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5146 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5148 // Render and notify
5149 application.SendNotification();
5150 application.Render();
5152 underlineMapSet.Clear();
5153 underlineMapGet.Clear();
5158 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5160 ToolkitTestApplication application;
5161 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5163 TextField field1 = TextField::New();
5164 field1.SetProperty(TextField::Property::TEXT, "Test");
5165 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5166 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5167 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5169 Property::Map underlineMapSet1;
5170 Property::Map underlineMapGet1;
5172 underlineMapSet1.Insert("enable", true);
5173 underlineMapSet1.Insert("color", Color::RED);
5174 underlineMapSet1.Insert("height", 1);
5175 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5176 underlineMapSet1.Insert("dashWidth", 2);
5177 underlineMapSet1.Insert("dashGap", 1);
5179 // Check the underline property
5180 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5182 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5183 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5184 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5186 application.GetScene().Add(field1);
5187 application.SendNotification();
5188 application.Render();
5190 TextField field2 = TextField::New();
5191 field2.SetProperty(TextField::Property::TEXT, "Test");
5192 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5193 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5194 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5196 Property::Map underlineMapSet2;
5197 Property::Map underlineMapGet2;
5199 underlineMapSet2.Insert("enable", true);
5200 underlineMapSet2.Insert("color", Color::BLUE);
5201 underlineMapSet2.Insert("height", 1);
5202 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5203 underlineMapSet2.Insert("dashWidth", 4);
5204 underlineMapSet2.Insert("dashGap", 2);
5206 // Check the dashed underline property
5207 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5209 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5210 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5211 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5213 application.GetScene().Add(field2);
5214 application.SendNotification();
5215 application.Render();
5217 TextField field3 = TextField::New();
5218 field3.SetProperty(TextField::Property::TEXT, "Test");
5219 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5220 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5221 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5223 Property::Map underlineMapSet3;
5224 Property::Map underlineMapGet3;
5226 underlineMapSet3.Insert("enable", true);
5227 underlineMapSet3.Insert("color", Color::BLUE);
5228 underlineMapSet3.Insert("height", 1);
5229 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5230 underlineMapSet3.Insert("dashWidth", 4);
5231 underlineMapSet3.Insert("dashGap", 2);
5233 // Check the dashed underline property
5234 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5236 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5237 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5238 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5240 application.GetScene().Add(field3);
5242 application.SendNotification();
5243 application.Render();
5248 int UtcDaliTextFieldCharacterSpacing(void)
5250 ToolkitTestApplication application;
5251 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5253 TextField textField = TextField::New();
5255 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5257 application.GetScene().Add(textField);
5258 application.SendNotification();
5259 application.Render();
5261 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5262 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5263 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5265 application.SendNotification();
5266 application.Render();
5271 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5273 ToolkitTestApplication application;
5274 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5276 TextField field1 = TextField::New();
5277 field1.SetProperty(TextField::Property::TEXT, "Test1");
5278 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5279 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5280 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5282 Property::Map underlineMapSet1;
5283 Property::Map underlineMapGet1;
5285 underlineMapSet1.Insert("enable", true);
5286 underlineMapSet1.Insert("color", Color::RED);
5287 underlineMapSet1.Insert("height", 1);
5288 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5289 underlineMapSet1.Insert("dashWidth", 2);
5290 underlineMapSet1.Insert("dashGap", 1);
5292 // Check the underline property
5293 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5294 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5296 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5297 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5298 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5300 application.GetScene().Add(field1);
5301 application.SendNotification();
5302 application.Render();
5307 int UtcDaliToolkitTextfieldParagraphTag(void)
5309 ToolkitTestApplication application;
5310 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5311 TextField fieldNewlineSeparator = TextField::New();
5312 TextField fieldParagraphTag = TextField::New();
5313 DALI_TEST_CHECK(fieldNewlineSeparator);
5314 DALI_TEST_CHECK(fieldParagraphTag);
5316 application.GetScene().Add(fieldNewlineSeparator);
5317 application.GetScene().Add(fieldParagraphTag);
5319 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5320 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5321 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5322 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5323 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5324 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5326 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5327 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5328 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5329 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5330 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5332 application.SendNotification();
5333 application.Render();
5335 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5336 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5338 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5340 application.SendNotification();
5341 application.Render();
5346 //Handle Emoji clustering for cursor handling
5347 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5349 ToolkitTestApplication application;
5350 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5351 TextField textField = TextField::New();
5352 DALI_TEST_CHECK(textField);
5354 application.GetScene().Add(textField);
5356 // Avoid a crash when core load gl resources.
5357 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5359 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5360 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5362 // Render and notify
5363 application.SendNotification();
5364 application.Render();
5367 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5368 application.SendNotification();
5369 application.Render();
5371 // Set focus and remove Emoji
5372 textField.SetKeyInputFocus();
5373 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5375 //Check the changed text and cursor position
5376 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5377 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5379 // Render and notify
5380 application.SendNotification();
5381 application.Render();
5386 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5388 ToolkitTestApplication application;
5389 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5390 TextField textField = TextField::New();
5391 DALI_TEST_CHECK(textField);
5393 application.GetScene().Add(textField);
5395 // Avoid a crash when core load gl resources.
5396 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5398 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5399 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5401 // Render and notify
5402 application.SendNotification();
5403 application.Render();
5406 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5407 application.SendNotification();
5408 application.Render();
5410 // Set focus and remove Emoji
5411 textField.SetKeyInputFocus();
5412 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5414 //Check the changed text and cursor position
5415 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5416 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5418 // Render and notify
5419 application.SendNotification();
5420 application.Render();