2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/public-api/rendering/renderer.h>
26 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
29 #include <dali-toolkit/devel-api/text/rendering-backend.h>
30 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
31 #include <dali/devel-api/adaptor-framework/key-devel.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include "test-text-geometry-utils.h"
34 #include "toolkit-clipboard.h"
37 using namespace Toolkit;
39 void dali_textfield_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_textfield_cleanup(void)
46 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
98 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
100 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
101 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
102 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
103 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
104 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
105 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
107 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
110 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
111 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
112 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
113 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
115 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
116 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
118 const float RENDER_FRAME_INTERVAL = 16.66f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR("/resources/fonts");
123 const int KEY_RETURN_CODE = 36;
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
126 const int KEY_SHIFT_MODIFIER = 257;
128 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130 static bool gSelectionChangedCallbackCalled;
131 static uint32_t oldSelectionStart;
132 static uint32_t oldSelectionEnd;
133 static bool gSelectionClearedCallbackCalled;
134 static bool gSelectionStartedCallbackCalled;
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gCursorPositionChangedCallbackCalled;
143 static uint32_t oldCursorPos;
144 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
146 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
148 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
149 Integration::ResourcePointer resource(bitmap);
150 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
153 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
157 LoadBitmapResource(app.GetPlatform(), width, height);
159 Property::Map propertyMap;
160 propertyMap["filename"] = "image.png";
161 propertyMap["width"] = width;
162 propertyMap["height"] = height;
163 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
164 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
165 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
174 * Simulate time passed by.
176 * @note this will always process at least 1 frame (1/60 sec)
178 * @param application Test application instance
179 * @param duration Time to pass in milliseconds.
180 * @return The actual time passed in milliseconds
182 static int Wait(ToolkitTestApplication& application, int duration = 0)
186 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
188 application.SendNotification();
189 application.Render(RENDER_FRAME_INTERVAL);
190 time += RENDER_FRAME_INTERVAL;
196 Dali::Integration::Point GetPointDownInside(Vector2& pos)
198 Dali::Integration::Point point;
199 point.SetState(PointState::DOWN);
200 point.SetScreenPosition(pos);
204 Dali::Integration::Point GetPointUpInside(Vector2& pos)
206 Dali::Integration::Point point;
207 point.SetState(PointState::UP);
208 point.SetScreenPosition(pos);
212 struct CallbackFunctor
214 CallbackFunctor(bool* callbackFlag)
215 : mCallbackFlag(callbackFlag)
221 *mCallbackFlag = true;
226 static void TestSelectionClearedCallback(TextField control)
228 tet_infoline(" TestSelectionClearedCallback");
230 gSelectionClearedCallbackCalled = true;
233 static void TestSelectionStartedCallback(TextField control)
235 tet_infoline(" TestSelectionStartedCallback");
237 gSelectionStartedCallbackCalled = true;
240 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
242 tet_infoline(" TestSelectionChangedCallback");
244 gSelectionChangedCallbackCalled = true;
245 oldSelectionStart = oldStart;
246 oldSelectionEnd = oldEnd;
249 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
251 tet_infoline(" TestAnchorClickedCallback");
253 gAnchorClickedCallBackNotCalled = false;
255 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
257 gAnchorClickedCallBackCalled = true;
261 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
263 tet_infoline(" TestCursorPositionChangedCallback");
265 gCursorPositionChangedCallbackCalled = true;
266 oldCursorPos = oldPos;
269 static void TestTextChangedCallback(TextField control)
271 tet_infoline(" TestTextChangedCallback");
273 gTextChangedCallBackCalled = true;
276 static void TestMaxLengthReachedCallback(TextField control)
278 tet_infoline(" TestMaxLengthReachedCallback");
280 gMaxCharactersCallBackCalled = true;
283 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
285 tet_infoline(" TestInputFilteredCallback");
287 if(type == Toolkit::InputFilter::Property::ACCEPTED)
289 gInputFilteredAcceptedCallbackCalled = true;
291 else if(type == Toolkit::InputFilter::Property::REJECTED)
293 gInputFilteredRejectedCallbackCalled = true;
297 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
299 tet_infoline(" TestInputStyleChangedCallback");
301 gInputStyleChangedCallbackCalled = true;
302 gInputStyleMask = mask;
305 // Generate a KeyEvent to send to Core.
306 Integration::KeyEvent GenerateKey(const std::string& keyName,
307 const std::string& logicalKey,
308 const std::string& keyString,
311 unsigned long timeStamp,
312 const Integration::KeyEvent::State& keyState,
313 const std::string& compose = "",
314 const std::string& deviceName = DEFAULT_DEVICE_NAME,
315 const Device::Class::Type& deviceClass = Device::Class::NONE,
316 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
318 return Integration::KeyEvent(keyName,
331 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
333 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
335 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
337 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
339 Property::Value* valueSet = NULL;
340 if(valueGet.first.type == Property::Key::INDEX)
342 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
346 // Get Key is a string so searching Set Map for a string key
347 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
352 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
354 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
357 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
359 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
362 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
364 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
367 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
369 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
372 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
374 Vector2 vector2Get = valueGet.second.Get<Vector2>();
375 Vector2 vector2Set = valueSet->Get<Vector2>();
376 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
379 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
381 Vector4 vector4Get = valueGet.second.Get<Vector4>();
382 Vector4 vector4Set = valueSet->Get<Vector4>();
383 tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
389 if(valueGet.first.type == Property::Key::INDEX)
391 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
395 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
407 int UtcDaliToolkitTextFieldConstructorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
412 DALI_TEST_CHECK(!textField);
416 int UtcDaliToolkitTextFieldNewP(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextFieldNewP");
420 TextField textField = TextField::New();
421 DALI_TEST_CHECK(textField);
425 int UtcDaliToolkitTextFieldDownCastP(void)
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
429 TextField textField1 = TextField::New();
430 BaseHandle object(textField1);
432 TextField textField2 = TextField::DownCast(object);
433 DALI_TEST_CHECK(textField2);
435 TextField textField3 = DownCast<TextField>(object);
436 DALI_TEST_CHECK(textField3);
440 int UtcDaliToolkitTextFieldDownCastN(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
444 BaseHandle uninitializedObject;
445 TextField textField1 = TextField::DownCast(uninitializedObject);
446 DALI_TEST_CHECK(!textField1);
448 TextField textField2 = DownCast<TextField>(uninitializedObject);
449 DALI_TEST_CHECK(!textField2);
453 int UtcDaliToolkitTextFieldCopyConstructorP(void)
455 ToolkitTestApplication application;
456 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
457 TextField textField = TextField::New();
458 textField.SetProperty(TextField::Property::TEXT, "Test");
460 TextField copy(textField);
461 DALI_TEST_CHECK(copy);
462 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
466 int UtcDaliTextFieldMoveConstructor(void)
468 ToolkitTestApplication application;
470 TextField textField = TextField::New();
471 textField.SetProperty(TextEditor::Property::TEXT, "Test");
472 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
474 TextField moved = std::move(textField);
475 DALI_TEST_CHECK(moved);
476 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
477 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
478 DALI_TEST_CHECK(!textField);
483 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
485 ToolkitTestApplication application;
486 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
487 TextField textField = TextField::New();
488 textField.SetProperty(TextField::Property::TEXT, "Test");
490 TextField copy = textField;
491 DALI_TEST_CHECK(copy);
492 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
496 int UtcDaliTextFieldMoveAssignment(void)
498 ToolkitTestApplication application;
500 TextField textField = TextField::New();
501 textField.SetProperty(TextEditor::Property::TEXT, "Test");
502 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
505 moved = std::move(textField);
506 DALI_TEST_CHECK(moved);
507 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
508 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
509 DALI_TEST_CHECK(!textField);
514 int UtcDaliTextFieldNewP(void)
516 ToolkitTestApplication application;
517 tet_infoline(" UtcDaliToolkitTextFieldNewP");
518 TextField textField = TextField::New();
519 DALI_TEST_CHECK(textField);
523 // Positive test case for a method
524 int UtcDaliTextFieldGetPropertyP(void)
526 ToolkitTestApplication application;
527 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
528 TextField field = TextField::New();
529 DALI_TEST_CHECK(field);
531 // Check Property Indices are correct
532 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
533 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
534 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
535 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
536 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
537 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
538 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
539 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
540 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
541 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
542 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
543 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
544 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
545 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
546 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
547 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
548 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
549 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
550 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
551 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
552 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
553 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
554 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
555 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
556 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
557 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
558 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
559 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
560 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
561 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
562 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
563 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
564 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
565 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
566 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
567 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
568 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
569 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
570 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
571 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
572 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
573 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
574 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
575 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
576 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
577 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
578 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
579 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
580 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
581 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
582 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
583 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
585 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
597 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
600 Property::Map imageMap;
601 imageMap[mapKey] = mapValue;
603 field.SetProperty(property, imageMap);
604 Property::Value propValue = field.GetProperty(property);
605 Property::Map* resultMap = propValue.GetMap();
607 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
615 // Positive test case for a method
616 int UtcDaliTextFieldSetPropertyP(void)
618 ToolkitTestApplication application;
619 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
620 TextField field = TextField::New();
621 DALI_TEST_CHECK(field);
622 application.GetScene().Add(field);
624 // Note - we can't check the defaults since the stylesheets are platform-specific
626 // Check the render backend property.
627 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
628 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
630 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
631 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
633 // Check text property.
634 field.SetProperty(TextField::Property::TEXT, "Setting Text");
635 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
637 // Check placeholder text properties.
638 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
639 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
641 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
642 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
644 // Check font properties.
645 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
646 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
648 Property::Map fontStyleMapSet;
649 Property::Map fontStyleMapGet;
650 Property::Value* slantValue = NULL;
652 fontStyleMapSet.Insert("weight", "bold");
653 fontStyleMapSet.Insert("width", "condensed");
654 fontStyleMapSet.Insert("slant", "italic");
655 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
657 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
658 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
659 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
661 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
662 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
664 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
665 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
666 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
668 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
669 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
670 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
673 fontStyleMapSet.Clear();
674 fontStyleMapSet.Insert("weight", "normal");
675 fontStyleMapSet.Insert("slant", "oblique");
676 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
678 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
679 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
680 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
682 fontStyleMapSet.Clear();
683 fontStyleMapSet.Insert("slant", "roman");
684 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
685 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
687 // Replace 'roman' for 'normal'.
688 slantValue = fontStyleMapGet.Find("slant");
689 if(NULL != slantValue)
691 if("normal" == slantValue->Get<std::string>())
693 fontStyleMapGet["slant"] = "roman";
696 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
697 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
699 fontStyleMapSet.Clear();
701 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
702 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
703 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
704 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
706 // Check that the MAX_LENGTH property can be correctly set
707 const int maxNumberOfCharacters = 20;
708 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
709 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
711 // Check exceed policy
712 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
713 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
714 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
715 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
717 // Check that the Alignment properties can be correctly set
718 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
719 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
720 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
721 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
723 // Check text's color property
724 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
725 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
727 // Check placeholder text's color property.
728 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
729 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
731 // Check cursor properties
732 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
733 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
734 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
735 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
737 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
738 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
739 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
740 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
741 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
742 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
743 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
744 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
746 // Check scroll properties.
747 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
748 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
749 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
750 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
752 // Check handle images
753 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
754 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
755 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
756 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
757 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
759 // Check handle images
760 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
761 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
762 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
763 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
764 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
765 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
767 // Check the highlight color
768 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
769 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
771 // Decoration bounding box
772 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
773 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
775 // Check the input method setting
776 Property::Map propertyMap;
777 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
778 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
779 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
780 int inputVariation = 1;
781 propertyMap["PANEL_LAYOUT"] = panelLayout;
782 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
783 propertyMap["BUTTON_ACTION"] = buttonAction;
784 propertyMap["VARIATION"] = inputVariation;
785 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
787 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
789 DALI_TEST_CHECK(value.Get(map));
792 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
793 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
796 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
797 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
800 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
801 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
804 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
805 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
807 // Check input color property.
808 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
809 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
811 // Check the enable markup property.
812 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
813 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
814 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
816 // Check input font properties.
817 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
818 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
820 fontStyleMapSet.Clear();
821 fontStyleMapSet.Insert("weight", "bold");
822 fontStyleMapSet.Insert("width", "condensed");
823 fontStyleMapSet.Insert("slant", "italic");
825 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
826 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
827 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
828 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
830 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
831 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
833 // Reset input font style.
834 fontStyleMapSet.Clear();
835 fontStyleMapSet.Insert("weight", "normal");
836 fontStyleMapSet.Insert("slant", "oblique");
838 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
839 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
840 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
841 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
843 fontStyleMapSet.Clear();
844 fontStyleMapSet.Insert("slant", "roman");
846 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
847 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
849 // Replace 'roman' for 'normal'.
850 slantValue = fontStyleMapGet.Find("slant");
851 if(NULL != slantValue)
853 if("normal" == slantValue->Get<std::string>())
855 fontStyleMapGet["slant"] = "roman";
858 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
859 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
861 fontStyleMapSet.Clear();
863 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
864 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
865 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
866 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
868 Property::Map strikethroughMapSet;
869 Property::Map strikethroughMapGet;
871 strikethroughMapSet.Insert("enable", true);
872 strikethroughMapSet.Insert("color", Color::RED);
873 strikethroughMapSet.Insert("height", 2.0f);
875 // Check the strikethrough property
876 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
878 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
879 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
880 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
882 // Check the input strikethrough property
883 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
884 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
886 Property::Map underlineMapSet;
887 Property::Map underlineMapGet;
889 underlineMapSet.Insert("enable", true);
890 underlineMapSet.Insert("color", Color::RED);
891 underlineMapSet.Insert("height", 1);
892 underlineMapSet.Insert("type", Text::Underline::SOLID);
893 underlineMapSet.Insert("dashWidth", 2);
894 underlineMapSet.Insert("dashGap", 1);
896 // Check the underline property
897 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
899 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
900 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
901 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
904 application.SendNotification();
905 application.Render();
907 underlineMapSet.Clear();
908 underlineMapGet.Clear();
910 underlineMapSet.Insert("enable", true);
911 underlineMapSet.Insert("color", Color::BLUE);
912 underlineMapSet.Insert("height", 1);
913 underlineMapSet.Insert("type", Text::Underline::DASHED);
914 underlineMapSet.Insert("dashWidth", 4);
915 underlineMapSet.Insert("dashGap", 2);
917 // Check the dashed underline property
918 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
920 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
921 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
922 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
925 application.SendNotification();
926 application.Render();
928 underlineMapSet.Clear();
929 underlineMapGet.Clear();
931 underlineMapSet.Insert("enable", true);
932 underlineMapSet.Insert("color", Color::BLUE);
933 underlineMapSet.Insert("height", 4);
934 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
935 underlineMapSet.Insert("dashWidth", 4);
936 underlineMapSet.Insert("dashGap", 2);
938 // Check the dashed underline property
939 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
941 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
942 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
943 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
946 application.SendNotification();
947 application.Render();
949 underlineMapSet.Clear();
950 underlineMapGet.Clear();
952 // Check the input underline property
953 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
954 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
956 // Check the shadow property
957 Property::Map shadowMapSet;
958 Property::Map shadowMapGet;
960 shadowMapSet.Insert("color", Color::GREEN);
961 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
962 shadowMapSet.Insert("blurRadius", 3.0f);
964 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
966 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
967 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
968 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
970 // Check the input shadow property
971 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
972 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
974 // Check the emboss property
975 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
976 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
978 // Check the input emboss property
979 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
980 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
982 // Check the outline property
984 // Test string type first
985 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
986 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
987 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
989 // Then test the property map type
990 Property::Map outlineMapSet;
991 Property::Map outlineMapGet;
993 outlineMapSet["color"] = Color::RED;
994 outlineMapSet["width"] = 2.0f;
996 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
998 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
999 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1000 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1002 // Check the input outline property
1003 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1004 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1006 // Check the hidden input settings property
1007 Property::Map hiddenMapSet;
1008 Property::Map hiddenMapGet;
1009 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1010 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1011 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1012 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1013 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1015 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1016 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1017 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1019 // Check the pixel size of font
1020 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1021 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1023 // Check the enable selection property
1024 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1025 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1027 // Check the placeholder property with pixel size
1028 Property::Map placeholderPixelSizeMapSet;
1029 Property::Map placeholderPixelSizeMapGet;
1030 Property::Map placeholderFontstyleMap;
1031 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1032 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1033 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1034 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1035 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1036 placeholderPixelSizeMapSet["ellipsis"] = true;
1038 placeholderFontstyleMap.Insert("weight", "bold");
1039 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1040 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1042 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1043 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1045 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1046 Property::Map placeholderConversionMap;
1047 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1048 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1049 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1050 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1051 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1052 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1054 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1056 // Check the placeholder property with point size
1057 Property::Map placeholderMapSet;
1058 Property::Map placeholderMapGet;
1059 placeholderMapSet["text"] = "Setting Placeholder Text";
1060 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1061 placeholderMapSet["color"] = Color::RED;
1062 placeholderMapSet["fontFamily"] = "Arial";
1063 placeholderMapSet["pointSize"] = 12.0f;
1064 placeholderMapSet["ellipsis"] = false;
1066 // Check the placeholder font style property
1067 placeholderFontstyleMap.Clear();
1069 placeholderFontstyleMap.Insert("weight", "bold");
1070 placeholderFontstyleMap.Insert("width", "condensed");
1071 placeholderFontstyleMap.Insert("slant", "italic");
1072 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1073 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1075 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1076 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1078 placeholderConversionMap.Clear();
1079 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1080 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1081 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1082 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1083 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1084 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1086 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1088 // Reset font style.
1089 placeholderFontstyleMap.Clear();
1090 placeholderFontstyleMap.Insert("weight", "normal");
1091 placeholderFontstyleMap.Insert("slant", "oblique");
1092 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1093 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1095 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1096 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1098 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1099 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1101 placeholderFontstyleMap.Clear();
1102 placeholderFontstyleMap.Insert("slant", "roman");
1103 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1104 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1106 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1108 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1110 placeholderFontstyleMap.Clear();
1111 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1112 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1114 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1115 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1116 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1118 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1120 // Check the ellipsis property
1121 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1122 field.SetProperty(TextField::Property::ELLIPSIS, true);
1123 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1125 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1126 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1128 // Test the ENABLE_GRAB_HANDLE_POPUP property
1129 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1130 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1131 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1133 // Check the background property
1134 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1135 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1137 //Check handle color
1138 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1139 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1141 // Check the input filter property
1142 Property::Map inputFilterMapSet;
1143 Property::Map inputFilterMapGet;
1144 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1145 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1147 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1149 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1150 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1153 inputFilterMapSet.Clear();
1154 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1156 application.SendNotification();
1157 application.Render();
1162 // Positive Atlas Text Renderer test
1163 int utcDaliTextFieldAtlasRenderP(void)
1165 ToolkitTestApplication application;
1166 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1167 StyleManager styleManager = StyleManager::Get();
1168 styleManager.ApplyDefaultTheme();
1169 TextField field = TextField::New();
1170 DALI_TEST_CHECK(field);
1172 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1174 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1176 application.GetScene().Add(field);
1180 // Render some text with the shared atlas backend
1181 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1182 application.SendNotification();
1183 application.Render();
1187 tet_result(TET_FAIL);
1192 // Positive test for the anchorClicked signal.
1193 int utcDaliTextFieldAnchorClicked01(void)
1195 ToolkitTestApplication application;
1196 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1197 TextField field = TextField::New();
1198 DALI_TEST_CHECK(field);
1200 application.GetScene().Add(field);
1202 // connect to the anchor clicked signal.
1203 ConnectionTracker* testTracker = new ConnectionTracker();
1204 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1205 bool anchorClickedSignal = false;
1206 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1208 gAnchorClickedCallBackCalled = false;
1209 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1210 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1211 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1212 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1213 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1215 application.SendNotification();
1216 application.Render();
1217 field.SetKeyInputFocus();
1219 // Create a tap event to touch the text field.
1220 TestGenerateTap(application, 5.0f, 25.0f);
1221 application.SendNotification();
1222 application.Render();
1224 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1225 DALI_TEST_CHECK(anchorClickedSignal);
1227 gAnchorClickedCallBackNotCalled = true;
1228 // Tap the outside of anchor, callback should not be called.
1229 TestGenerateTap(application, 150.f, 100.f);
1230 application.SendNotification();
1231 application.Render();
1233 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1238 // Positive test for the anchorClicked signal.
1239 int utcDaliTextFieldAnchorClicked02(void)
1241 ToolkitTestApplication application;
1242 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1243 TextField field = TextField::New();
1244 DALI_TEST_CHECK(field);
1246 application.GetScene().Add(field);
1248 // connect to the anchor clicked signal.
1249 ConnectionTracker* testTracker = new ConnectionTracker();
1250 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1251 bool anchorClickedSignal = false;
1252 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1254 gAnchorClickedCallBackCalled = false;
1255 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1256 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1257 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1258 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1259 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1261 application.SendNotification();
1262 application.Render();
1263 field.SetKeyInputFocus();
1265 // Avoid a crash when core load gl resources.
1266 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1268 // Create a tap event to touch the text field.
1269 TestGenerateTap(application, 30.0f, 25.0f, 100);
1270 application.SendNotification();
1271 application.Render();
1273 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1274 DALI_TEST_CHECK(anchorClickedSignal);
1276 // For coverage InsertTextAnchor, RemoveTextAnchor
1277 // first index insert
1278 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1279 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1280 application.SendNotification();
1281 application.Render();
1283 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1284 application.SendNotification();
1285 application.Render();
1287 gAnchorClickedCallBackCalled = false;
1288 // Create a tap event to touch the text field.
1289 TestGenerateTap(application, 30.0f, 25.0f, 700);
1290 application.SendNotification();
1291 field.SetKeyInputFocus();
1293 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1295 // last index insert
1296 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1297 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1298 application.SendNotification();
1299 application.Render();
1301 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1302 application.SendNotification();
1303 application.Render();
1305 gAnchorClickedCallBackCalled = false;
1306 // Create a tap event to touch the text field.
1307 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1308 application.SendNotification();
1309 field.SetKeyInputFocus();
1311 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1314 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1315 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1316 application.SendNotification();
1317 application.Render();
1319 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1320 application.SendNotification();
1321 application.Render();
1323 gAnchorClickedCallBackCalled = false;
1324 // Create a tap event to touch the text field.
1325 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1326 application.SendNotification();
1327 field.SetKeyInputFocus();
1329 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1331 // first index remove
1332 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1333 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1334 application.SendNotification();
1335 application.Render();
1337 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1338 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1339 application.SendNotification();
1340 application.Render();
1342 gAnchorClickedCallBackCalled = false;
1343 // Create a tap event to touch the text field.
1344 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1345 application.SendNotification();
1346 field.SetKeyInputFocus();
1348 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1350 // last index remove
1351 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1352 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1353 application.SendNotification();
1354 application.Render();
1356 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1358 application.SendNotification();
1359 application.Render();
1361 gAnchorClickedCallBackCalled = false;
1362 // Create a tap event to touch the text field.
1363 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1370 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1371 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1372 application.SendNotification();
1373 application.Render();
1375 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1377 application.SendNotification();
1378 application.Render();
1380 gAnchorClickedCallBackCalled = false;
1381 // Create a tap event to touch the text field.
1382 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1388 // 0 ~ 1 index remove
1389 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1390 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1391 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1392 application.SendNotification();
1393 application.Render();
1395 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1396 application.SendNotification();
1397 application.Render();
1399 gAnchorClickedCallBackCalled = false;
1400 // Create a tap event to touch the text field.
1401 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1402 application.SendNotification();
1403 application.Render();
1405 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1407 // 1 ~ 3 index remove
1408 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1409 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1410 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1411 application.SendNotification();
1412 application.Render();
1414 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1415 application.SendNotification();
1416 application.Render();
1418 gAnchorClickedCallBackCalled = false;
1419 // Create a tap event to touch the text field.
1420 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1426 // 3 ~ 4 index remove
1427 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1428 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1429 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1430 application.SendNotification();
1431 application.Render();
1433 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1434 application.SendNotification();
1435 application.Render();
1437 gAnchorClickedCallBackCalled = false;
1438 // Create a tap event to touch the text field.
1439 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1445 // Remove front of anchor
1446 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1447 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1448 application.SendNotification();
1449 application.Render();
1451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1452 application.SendNotification();
1453 application.Render();
1455 // Remove whole text
1456 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1457 DevelTextField::SelectWholeText(field);
1458 application.SendNotification();
1459 application.Render();
1461 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1462 application.SendNotification();
1463 application.Render();
1465 // Remove all with backspace
1466 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1467 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1468 application.SendNotification();
1469 application.Render();
1471 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1472 application.SendNotification();
1473 application.Render();
1475 // Remove all with delete
1476 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1477 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1478 application.SendNotification();
1479 application.Render();
1481 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1482 application.SendNotification();
1483 application.Render();
1488 // Positive test for the textChanged signal.
1489 int utcDaliTextFieldTextChangedP(void)
1491 ToolkitTestApplication application;
1492 tet_infoline(" utcDaliTextFieldTextChangedP");
1493 TextField field = TextField::New();
1494 DALI_TEST_CHECK(field);
1496 application.GetScene().Add(field);
1498 // connect to the text changed signal.
1499 ConnectionTracker* testTracker = new ConnectionTracker();
1500 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1501 bool textChangedSignal = false;
1502 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1504 gTextChangedCallBackCalled = false;
1505 field.SetProperty(TextField::Property::TEXT, "ABC");
1506 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1507 DALI_TEST_CHECK(textChangedSignal);
1509 application.SendNotification();
1510 field.SetKeyInputFocus();
1512 gTextChangedCallBackCalled = false;
1513 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1514 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1517 field.SetProperty(TextField::Property::TEXT, "");
1519 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1520 gTextChangedCallBackCalled = false;
1521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1522 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1524 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1525 gTextChangedCallBackCalled = false;
1526 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1527 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1532 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1534 ToolkitTestApplication application;
1535 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1536 TextField field = TextField::New();
1537 DALI_TEST_CHECK(field);
1539 application.GetScene().Add(field);
1541 // connect to the text changed signal.
1542 ConnectionTracker* testTracker = new ConnectionTracker();
1543 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1544 bool textChangedSignal = false;
1545 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1547 // get InputMethodContext
1549 InputMethodContext::EventData imfEvent;
1550 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1552 field.SetKeyInputFocus();
1553 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1556 gTextChangedCallBackCalled = false;
1557 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1558 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1562 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1564 gTextChangedCallBackCalled = false;
1565 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1566 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1567 application.SendNotification();
1568 application.Render();
1569 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1570 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1572 gTextChangedCallBackCalled = false;
1573 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1574 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1578 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1580 gTextChangedCallBackCalled = false;
1581 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1582 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1583 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1585 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1586 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1587 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1589 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1590 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1591 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1593 application.SendNotification();
1594 application.Render();
1595 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1596 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1601 // Negative test for the textChanged signal.
1602 int utcDaliTextFieldTextChangedN(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" utcDaliTextFieldTextChangedN");
1606 TextField field = TextField::New();
1607 DALI_TEST_CHECK(field);
1609 application.GetScene().Add(field);
1611 // connect to the text changed signal.
1612 ConnectionTracker* testTracker = new ConnectionTracker();
1613 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1614 bool textChangedSignal = false;
1615 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1617 gTextChangedCallBackCalled = false;
1618 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1619 application.SendNotification();
1620 application.Render();
1621 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1622 DALI_TEST_CHECK(!textChangedSignal);
1627 // Positive test for Max Characters reached signal.
1628 int utcDaliTextFieldMaxCharactersReachedP(void)
1630 ToolkitTestApplication application;
1631 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1632 TextField field = TextField::New();
1633 DALI_TEST_CHECK(field);
1635 application.GetScene().Add(field);
1637 const int maxNumberOfCharacters = 1;
1638 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1640 field.SetKeyInputFocus();
1642 // connect to the text changed signal.
1643 ConnectionTracker* testTracker = new ConnectionTracker();
1644 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1645 bool maxLengthReachedSignal = false;
1646 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1648 gMaxCharactersCallBackCalled = false;
1650 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1651 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1653 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1654 DALI_TEST_CHECK(maxLengthReachedSignal);
1659 // Negative test for Max Characters reached signal.
1660 int utcDaliTextFieldMaxCharactersReachedN(void)
1662 ToolkitTestApplication application;
1663 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1664 TextField field = TextField::New();
1665 DALI_TEST_CHECK(field);
1667 application.GetScene().Add(field);
1669 const int maxNumberOfCharacters = 3;
1670 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1672 field.SetKeyInputFocus();
1674 // connect to the text changed signal.
1675 ConnectionTracker* testTracker = new ConnectionTracker();
1676 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1677 bool maxLengthReachedSignal = false;
1678 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1680 gMaxCharactersCallBackCalled = false;
1682 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1683 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1685 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1686 DALI_TEST_CHECK(!maxLengthReachedSignal);
1688 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1690 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1691 DALI_TEST_CHECK(!maxLengthReachedSignal);
1696 // Positive test for Input Filtered signal.
1697 int utcDaliTextFieldInputFilteredP(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextFieldInputFilteredP");
1701 TextField field = TextField::New();
1702 DALI_TEST_CHECK(field);
1704 application.GetScene().Add(field);
1706 Property::Map inputFilter;
1708 // Only digit is accepted.
1709 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1711 // Set input filter to TextField.
1712 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1714 field.SetKeyInputFocus();
1716 // connect to the input filtered signal.
1717 ConnectionTracker* testTracker = new ConnectionTracker();
1718 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1719 bool inputFilteredSignal = false;
1720 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1722 gInputFilteredAcceptedCallbackCalled = false;
1724 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1727 DALI_TEST_CHECK(inputFilteredSignal);
1729 // Word is rejected.
1730 inputFilter[InputFilter::Property::ACCEPTED] = "";
1731 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1733 // Set input filter to TextField.
1734 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1736 field.SetKeyInputFocus();
1738 inputFilteredSignal = false;
1739 gInputFilteredRejectedCallbackCalled = false;
1741 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1743 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1744 DALI_TEST_CHECK(inputFilteredSignal);
1749 // Negative test for Input Filtered signal.
1750 int utcDaliTextFieldInputFilteredN(void)
1752 ToolkitTestApplication application;
1753 tet_infoline(" utcDaliTextFieldInputFilteredP");
1754 TextField field = TextField::New();
1755 DALI_TEST_CHECK(field);
1757 application.GetScene().Add(field);
1759 Property::Map inputFilter;
1761 // Only word is accepted.
1762 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1764 // Set input filter to TextField.
1765 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1767 field.SetKeyInputFocus();
1769 // connect to the input filtered signal.
1770 ConnectionTracker* testTracker = new ConnectionTracker();
1771 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1772 bool inputFilteredSignal = false;
1773 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1775 gInputFilteredAcceptedCallbackCalled = false;
1777 // Key a, d should not be filtered.
1778 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1780 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1781 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1783 // Backspace, Delete should not be filtered.
1784 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1785 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1792 DALI_TEST_CHECK(!inputFilteredSignal);
1794 // Digit is rejected.
1795 inputFilter[InputFilter::Property::ACCEPTED] = "";
1796 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1798 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1800 field.SetKeyInputFocus();
1802 inputFilteredSignal = false;
1803 gInputFilteredRejectedCallbackCalled = false;
1805 // Key a, d should not be filtered.
1806 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1807 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1808 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1809 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1811 // Backspace, Delete should not be filtered.
1812 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1813 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1820 DALI_TEST_CHECK(!inputFilteredSignal);
1825 int utcDaliTextFieldInputStyleChanged01(void)
1827 // The text-field emits signals when the input style changes. These changes of style are
1828 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1829 // can't be emitted during the size negotiation as the callbacks may update the UI.
1830 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1831 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1832 ToolkitTestApplication application;
1833 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1837 char* pathNamePtr = get_current_dir_name();
1838 const std::string pathName(pathNamePtr);
1841 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1842 fontClient.SetDpi(93u, 93u);
1844 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1845 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1847 TextField field = TextField::New();
1848 DALI_TEST_CHECK(field);
1850 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1851 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1852 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1854 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1855 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1857 // connect to the text changed signal.
1858 ConnectionTracker* testTracker = new ConnectionTracker();
1859 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1860 bool inputStyleChangedSignal = false;
1861 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1863 application.GetScene().Add(field);
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Executes the idle callbacks added by the text control on the change of input style.
1870 application.RunIdles();
1872 gInputStyleChangedCallbackCalled = false;
1873 gInputStyleMask = TextField::InputStyle::NONE;
1874 inputStyleChangedSignal = false;
1876 // Create a tap event to touch the text field.
1877 TestGenerateTap(application, 18.0f, 25.0f);
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 // Executes the idle callbacks added by the text control on the change of input style.
1884 application.RunIdles();
1886 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1887 if(gInputStyleChangedCallbackCalled)
1889 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1891 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1892 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1894 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1895 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1897 DALI_TEST_CHECK(inputStyleChangedSignal);
1899 gInputStyleChangedCallbackCalled = false;
1900 gInputStyleMask = TextField::InputStyle::NONE;
1901 inputStyleChangedSignal = false;
1903 // Create a tap event to touch the text field.
1904 TestGenerateTap(application, 30.0f, 25.0f);
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Executes the idle callbacks added by the text control on the change of input style.
1911 application.RunIdles();
1913 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1914 DALI_TEST_CHECK(!inputStyleChangedSignal);
1916 gInputStyleChangedCallbackCalled = false;
1917 gInputStyleMask = TextField::InputStyle::NONE;
1918 inputStyleChangedSignal = false;
1920 // Create a tap event to touch the text field.
1921 TestGenerateTap(application, 43.0f, 25.0f);
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Executes the idle callbacks added by the text control on the change of input style.
1928 application.RunIdles();
1930 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1931 if(gInputStyleChangedCallbackCalled)
1933 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
1935 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1936 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1938 DALI_TEST_CHECK(inputStyleChangedSignal);
1940 gInputStyleChangedCallbackCalled = false;
1941 gInputStyleMask = TextField::InputStyle::NONE;
1942 inputStyleChangedSignal = false;
1944 // Create a tap event to touch the text field.
1945 TestGenerateTap(application, 88.0f, 25.0f);
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 // Executes the idle callbacks added by the text control on the change of input style.
1952 application.RunIdles();
1954 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1955 if(gInputStyleChangedCallbackCalled)
1957 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
1959 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1960 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1962 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
1964 Property::Map fontStyleMapSet;
1965 fontStyleMapSet.Insert("weight", "bold");
1967 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1968 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1970 DALI_TEST_CHECK(inputStyleChangedSignal);
1972 gInputStyleChangedCallbackCalled = false;
1973 gInputStyleMask = TextField::InputStyle::NONE;
1974 inputStyleChangedSignal = false;
1976 // Create a tap event to touch the text field.
1977 TestGenerateTap(application, 115.0f, 25.0f);
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Executes the idle callbacks added by the text control on the change of input style.
1984 application.RunIdles();
1986 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1987 DALI_TEST_CHECK(!inputStyleChangedSignal);
1989 gInputStyleChangedCallbackCalled = false;
1990 gInputStyleMask = TextField::InputStyle::NONE;
1991 inputStyleChangedSignal = false;
1993 // Create a tap event to touch the text field.
1994 TestGenerateTap(application, 164.0f, 25.0f);
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Executes the idle callbacks added by the text control on the change of input style.
2001 application.RunIdles();
2003 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2004 if(gInputStyleChangedCallbackCalled)
2006 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2008 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2009 DALI_TEST_CHECK(style.empty());
2011 DALI_TEST_CHECK(inputStyleChangedSignal);
2013 gInputStyleChangedCallbackCalled = false;
2014 gInputStyleMask = TextField::InputStyle::NONE;
2015 inputStyleChangedSignal = false;
2017 // Create a tap event to touch the text field.
2018 TestGenerateTap(application, 191.0f, 25.0f);
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 // Executes the idle callbacks added by the text control on the change of input style.
2025 application.RunIdles();
2027 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2028 DALI_TEST_CHECK(!inputStyleChangedSignal);
2033 int utcDaliTextFieldInputStyleChanged02(void)
2035 // The text-field emits signals when the input style changes. These changes of style are
2036 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2037 // can't be emitted during the size negotiation as the callbacks may update the UI.
2038 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2039 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2040 ToolkitTestApplication application;
2041 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2045 char* pathNamePtr = get_current_dir_name();
2046 const std::string pathName(pathNamePtr);
2049 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2050 fontClient.SetDpi(93u, 93u);
2052 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2053 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2055 TextField field = TextField::New();
2056 DALI_TEST_CHECK(field);
2058 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2059 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2060 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2062 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2063 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>");
2065 // connect to the text changed signal.
2066 ConnectionTracker* testTracker = new ConnectionTracker();
2067 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2068 bool inputStyleChangedSignal = false;
2069 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2071 application.GetScene().Add(field);
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 // Executes the idle callbacks added by the text control on the change of input style.
2078 application.RunIdles();
2080 gInputStyleChangedCallbackCalled = false;
2081 gInputStyleMask = TextField::InputStyle::NONE;
2082 inputStyleChangedSignal = false;
2084 // Create a tap event to touch the text field.
2085 TestGenerateTap(application, 53.0f, 25.0f, 100);
2086 TestGenerateTap(application, 53.0f, 25.0f, 200);
2088 // Render and notify
2089 application.SendNotification();
2090 application.Render();
2092 // Executes the idle callbacks added by the text control on the change of input style.
2093 application.RunIdles();
2095 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2096 if(gInputStyleChangedCallbackCalled)
2098 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2099 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2100 TextField::InputStyle::POINT_SIZE |
2101 TextField::InputStyle::COLOR),
2104 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2105 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2107 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2108 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2110 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2111 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2113 DALI_TEST_CHECK(inputStyleChangedSignal);
2115 gInputStyleChangedCallbackCalled = false;
2116 gInputStyleMask = TextField::InputStyle::NONE;
2117 inputStyleChangedSignal = false;
2119 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2125 // Executes the idle callbacks added by the text control on the change of input style.
2126 application.RunIdles();
2128 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2129 if(gInputStyleChangedCallbackCalled)
2131 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2132 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2135 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2136 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2138 DALI_TEST_CHECK(inputStyleChangedSignal);
2140 gInputStyleChangedCallbackCalled = false;
2141 gInputStyleMask = TextField::InputStyle::NONE;
2142 inputStyleChangedSignal = false;
2144 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2146 // Render and notify
2147 application.SendNotification();
2148 application.Render();
2150 // Executes the idle callbacks added by the text control on the change of input style.
2151 application.RunIdles();
2153 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2154 DALI_TEST_CHECK(!inputStyleChangedSignal);
2156 gInputStyleChangedCallbackCalled = false;
2157 gInputStyleMask = TextField::InputStyle::NONE;
2158 inputStyleChangedSignal = false;
2160 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Executes the idle callbacks added by the text control on the change of input style.
2167 application.RunIdles();
2169 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2170 if(gInputStyleChangedCallbackCalled)
2172 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2173 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2176 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2177 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2179 DALI_TEST_CHECK(inputStyleChangedSignal);
2181 gInputStyleChangedCallbackCalled = false;
2182 gInputStyleMask = TextField::InputStyle::NONE;
2183 inputStyleChangedSignal = false;
2185 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2187 Property::Map fontStyleMapSet;
2188 fontStyleMapSet.Insert("weight", "thin");
2189 fontStyleMapSet.Insert("width", "condensed");
2190 fontStyleMapSet.Insert("slant", "italic");
2192 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2193 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2195 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2196 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2197 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2198 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2199 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2201 // Render and notify
2202 application.SendNotification();
2203 application.Render();
2205 // Executes the idle callbacks added by the text control on the change of input style.
2206 application.RunIdles();
2208 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2209 DALI_TEST_CHECK(!inputStyleChangedSignal);
2211 // Create a tap event to touch the text field.
2212 TestGenerateTap(application, 63.0f, 25.0f, 700);
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // Executes the idle callbacks added by the text control on the change of input style.
2219 application.RunIdles();
2221 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2222 if(gInputStyleChangedCallbackCalled)
2224 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2225 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2226 TextField::InputStyle::POINT_SIZE |
2227 TextField::InputStyle::FONT_STYLE |
2228 TextField::InputStyle::UNDERLINE |
2229 TextField::InputStyle::SHADOW |
2230 TextField::InputStyle::EMBOSS |
2231 TextField::InputStyle::OUTLINE),
2234 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2235 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2237 DALI_TEST_CHECK(inputStyleChangedSignal);
2242 int utcDaliTextFieldEvent01(void)
2244 ToolkitTestApplication application;
2245 tet_infoline(" utcDaliTextFieldEvent01");
2247 // Creates a tap event. After creating a tap event the text field should
2248 // have the focus and add text with key events should be possible.
2250 TextField field = TextField::New();
2251 DALI_TEST_CHECK(field);
2253 application.GetScene().Add(field);
2255 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2256 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2257 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // Avoid a crash when core load gl resources.
2264 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 // Add a key event but as the text field has not the focus it should do nothing.
2271 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2277 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2279 // Create a tap event to touch the text field.
2280 TestGenerateTap(application, 150.0f, 25.0f);
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // Pressing delete key should be fine even if there is no text in TextField.
2287 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 // Now the text field has the focus, so it can handle the key events.
2293 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2294 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2302 // Create a second text field and send key events to it.
2303 TextField field2 = TextField::New();
2305 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2306 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2307 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2308 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2310 application.GetScene().Add(field2);
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 // Create a tap event on the second text field.
2317 TestGenerateTap(application, 150.0f, 125.0f);
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // The second text field has the focus. It should handle the key events.
2324 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2325 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Check the text has been added to the second text field.
2332 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2337 int utcDaliTextFieldEvent02(void)
2339 ToolkitTestApplication application;
2340 tet_infoline(" utcDaliTextFieldEvent02");
2342 // Checks if the right number of actors are created.
2344 TextField field = TextField::New();
2345 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2346 DALI_TEST_CHECK(field);
2347 LoadMarkerImages(application, field);
2349 application.GetScene().Add(field);
2351 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2352 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2353 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2355 // Avoid a crash when core load gl resources.
2356 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Check there are the expected number of children ( stencil ).
2363 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2365 Actor stencil = field.GetChildAt(0u);
2366 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2368 // Create a tap event to touch the text field.
2369 TestGenerateTap(application, 150.0f, 25.0f, 300);
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 Actor layer = field.GetChildAt(2u);
2376 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2377 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2379 // Now the text field has the focus, so it can handle the key events.
2380 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2381 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 // Checks the cursor and the renderer have been created.
2388 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2389 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2391 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2392 DALI_TEST_CHECK(cursor);
2394 // The offscreen root actor has a container with all the actors which contain the text renderers.
2395 Actor container = stencil.GetChildAt(0u);
2396 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2398 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2399 DALI_TEST_CHECK(renderer);
2402 // Move the cursor and check the position changes.
2403 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2404 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2411 DALI_TEST_CHECK(position2.x < position1.x);
2413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2420 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2422 // Move the cursor to the first position.
2423 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2424 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2432 // Send some taps and check the cursor positions.
2434 // Try to tap at the beginning.
2435 TestGenerateTap(application, 1.0f, 25.0f, 900);
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Cursor position should be the same than position1.
2442 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2444 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2446 // Tap away from the start position.
2447 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2455 DALI_TEST_CHECK(position6.x > position5.x);
2457 // Remove all the text.
2458 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2459 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2460 field.SetProperty(TextField::Property::TEXT, "");
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 // Cursor position should be the same than position2.
2467 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2469 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2471 // Should not be a renderer, there is only a clipped cursor.
2472 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2474 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2475 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2476 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2478 application.SendNotification();
2479 application.Render();
2481 // There are renderer and decorator layer
2482 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2487 int utcDaliTextFieldEvent03(void)
2489 ToolkitTestApplication application;
2490 tet_infoline(" utcDaliTextFieldEvent03");
2492 // Checks if the highlight actor is created.
2494 TextField field = TextField::New();
2495 DALI_TEST_CHECK(field);
2497 application.GetScene().Add(field);
2499 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2500 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2501 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2502 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2503 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2505 // Avoid a crash when core load gl resources.
2506 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2507 LoadMarkerImages(application, field);
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Tap first to get the focus.
2514 TestGenerateTap(application, 3.0f, 25.0f);
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // Double tap to select a word.
2521 TestGenerateTap(application, 3.0f, 25.0f);
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2528 Actor stencil = field.GetChildAt(0u);
2530 // The highlight actor is drawn first, so is the first actor in the list
2531 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2532 DALI_TEST_CHECK(highlight);
2534 // The offscreen root actor has a container with all the actors which contain the text renderers.
2535 Actor container = stencil.GetChildAt(1u);
2536 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2538 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2539 DALI_TEST_CHECK(renderer);
2545 int utcDaliTextFieldEvent04(void)
2547 ToolkitTestApplication application;
2548 tet_infoline(" utcDaliTextFieldEvent04");
2550 // Checks if the highlight actor is created.
2552 TextField field = TextField::New();
2553 DALI_TEST_CHECK(field);
2554 application.GetScene().Add(field);
2555 LoadMarkerImages(application, field);
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2561 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2562 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2563 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2564 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2566 // Avoid a crash when core load gl resources.
2567 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Create a tap event to touch the text field.
2573 TestGenerateTap(application, 150.0f, 25.0f);
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Tap first to get the focus.
2579 TestGenerateTap(application, 1.0f, 25.0f);
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Double tap to select a word.
2586 TestGenerateTap(application, 1.0f, 25.0f);
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2593 TestGenerateTap(application, 0.0f, 40.0f);
2597 int utcDaliTextFieldEvent05(void)
2599 ToolkitTestApplication application;
2600 tet_infoline(" utcDaliTextFieldEvent05");
2602 // Checks dragging of cursor/grab handle
2604 TextField field = TextField::New();
2605 DALI_TEST_CHECK(field);
2606 application.GetScene().Add(field);
2607 LoadMarkerImages(application, field);
2608 // Render and notify
2609 application.SendNotification();
2610 application.Render();
2612 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2613 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2614 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2615 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2616 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2618 // Avoid a crash when core load gl resources.
2619 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Create a tap event to touch the text field.
2625 TestGenerateTap(application, 150.0f, 25.0f);
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 // Tap first to get the focus.
2631 TestGenerateTap(application, 1.0f, 25.0f);
2633 // Render and notify
2634 application.SendNotification();
2635 application.Render();
2637 // Double tap to select a word.
2638 TestGenerateTap(application, 1.0f, 25.0f);
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2644 Actor stencil = field.GetChildAt(1u);
2648 int utcDaliTextFieldEvent06(void)
2650 ToolkitTestApplication application;
2651 tet_infoline(" utcDaliTextFieldEvent06");
2653 // Checks Longpress when in edit mode
2655 TextField field = TextField::New();
2656 DALI_TEST_CHECK(field);
2657 application.GetScene().Add(field);
2658 LoadMarkerImages(application, field);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2664 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2665 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2666 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2667 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2669 // Avoid a crash when core load gl resources.
2670 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2675 // Create a tap event to touch the text field.
2676 TestGenerateTap(application, 150.0f, 25.0f);
2677 // Render and notify
2678 application.SendNotification();
2679 application.Render();
2681 // Tap first to get the focus.
2682 TestGenerateTap(application, 1.0f, 25.0f);
2684 // Render and notify
2685 application.SendNotification();
2686 application.Render();
2689 TestGenerateLongPress(application, 1.0f, 25.0f);
2691 // Render and notify
2692 application.SendNotification();
2693 application.Render();
2698 int utcDaliTextFieldEvent07(void)
2700 ToolkitTestApplication application;
2701 tet_infoline(" utcDaliTextFieldEvent07");
2703 // Checks Longpress to start edit mode
2705 TextField field = TextField::New();
2706 DALI_TEST_CHECK(field);
2707 application.GetScene().Add(field);
2708 LoadMarkerImages(application, field);
2709 // Render and notify
2710 application.SendNotification();
2711 application.Render();
2713 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2714 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2715 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2716 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2717 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2718 Property::Map propertyMap;
2719 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2720 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2722 // Avoid a crash when core load gl resources.
2723 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2729 TestGenerateLongPress(application, 1.0f, 25.0f);
2731 // Render and notify
2732 application.SendNotification();
2733 application.Render();
2738 int utcDaliTextFieldEvent08(void)
2740 ToolkitTestApplication application;
2741 tet_infoline(" utcDaliTextFieldEvent08");
2743 Dali::Clipboard clipboard = Clipboard::Get();
2744 clipboard.SetItem("testTextFieldEvent");
2746 // Checks Longpress when only place holder text
2748 TextField field = TextField::New();
2749 DALI_TEST_CHECK(field);
2750 application.GetScene().Add(field);
2751 LoadMarkerImages(application, field);
2752 // Render and notify
2753 application.SendNotification();
2754 application.Render();
2756 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2757 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2758 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2759 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2760 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2762 // Avoid a crash when core load gl resources.
2763 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2769 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2775 Wait(application, 500);
2777 TestEndLongPress(application, 1.0f, 25.0f, 520);
2780 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2782 // Render and notify
2783 application.Render();
2785 Wait(application, 500);
2787 Integration::Scene stage = application.GetScene();
2788 Layer layer = stage.GetRootLayer();
2789 Actor actor = layer.FindChildByName("optionPaste");
2793 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2794 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2795 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2797 Dali::Integration::TouchEvent event;
2798 event = Dali::Integration::TouchEvent();
2799 event.AddPoint(GetPointDownInside(position));
2800 application.ProcessEvent(event);
2802 event = Dali::Integration::TouchEvent();
2803 event.AddPoint(GetPointUpInside(position));
2804 application.ProcessEvent(event);
2806 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2811 int utcDaliTextFieldEvent09(void)
2813 ToolkitTestApplication application;
2814 tet_infoline(" utcDaliTextFieldEvent09");
2816 TextField field = TextField::New();
2817 DALI_TEST_CHECK(field);
2818 application.GetScene().Add(field);
2819 LoadMarkerImages(application, field);
2820 // Render and notify
2821 application.SendNotification();
2822 application.Render();
2824 field.SetProperty(TextField::Property::TEXT, "Hello");
2825 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2826 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2827 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2828 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2830 // Avoid a crash when core load gl resources.
2831 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2833 // Create a tap event to touch the text field.
2834 TestGenerateTap(application, 150.0f, 25.0f);
2835 application.SendNotification();
2836 application.Render();
2839 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2840 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2841 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2842 application.SendNotification();
2843 application.Render();
2845 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2846 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2847 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2848 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2849 application.SendNotification();
2850 application.Render();
2852 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2853 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2854 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2855 for(unsigned int index = 0u; index < 5u; ++index)
2857 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2858 application.SendNotification();
2859 application.Render();
2862 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
2863 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2864 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2865 for(unsigned int index = 0u; index < 5u; ++index)
2867 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2868 application.SendNotification();
2869 application.Render();
2872 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2873 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2874 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2875 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2876 application.SendNotification();
2877 application.Render();
2878 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2879 application.SendNotification();
2880 application.Render();
2882 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2883 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2884 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2885 application.SendNotification();
2886 application.Render();
2888 Property::Map mapGet;
2889 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2890 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2891 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2895 int utcDaliTextFieldStyleWhilstSelected(void)
2897 ToolkitTestApplication application;
2898 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2900 // Change font and styles whilst text is selected whilst word selected
2902 TextField field = TextField::New();
2903 DALI_TEST_CHECK(field);
2904 application.GetScene().Add(field);
2905 LoadMarkerImages(application, field);
2906 // Render and notify
2907 application.SendNotification();
2908 application.Render();
2910 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2911 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2912 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2913 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2914 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2916 // Avoid a crash when core load gl resources.
2917 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 // Create a tap event to touch the text field.
2923 TestGenerateTap(application, 150.0f, 25.0f);
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 // Tap first to get the focus.
2929 TestGenerateTap(application, 1.0f, 25.0f);
2931 // Render and notify
2932 application.SendNotification();
2933 application.Render();
2935 // Double tap to select a word.
2936 TestGenerateTap(application, 1.0f, 25.0f);
2938 // Render and notify
2939 application.SendNotification();
2940 application.Render();
2942 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
2943 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
2945 Property::Map fontStyleMapSet;
2946 Property::Map fontStyleMapGet;
2948 fontStyleMapSet.Insert("weight", "bold");
2949 fontStyleMapSet.Insert("slant", "italic");
2950 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2952 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2953 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2954 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2956 fontStyleMapSet.Clear();
2957 fontStyleMapSet.Insert("width", "expanded");
2958 fontStyleMapSet.Insert("slant", "italic");
2959 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2961 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2962 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2963 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2965 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
2966 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2968 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
2969 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
2971 fontStyleMapSet.Clear();
2972 fontStyleMapSet.Insert("weight", "bold");
2973 fontStyleMapSet.Insert("slant", "italic");
2975 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2977 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2978 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2979 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2981 fontStyleMapSet.Clear();
2982 fontStyleMapSet.Insert("width", "expanded");
2984 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2986 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2987 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2988 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2990 // Press Escape to increase coverage
2991 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2992 application.SendNotification();
2993 application.Render();
2995 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3000 int utcDaliTextFieldEscKeyLoseFocus(void)
3002 ToolkitTestApplication application;
3003 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3005 // Creates a tap event. After creating a tap event the text field should
3006 // have the focus and add text with key events should be possible.
3008 TextField field = TextField::New();
3009 DALI_TEST_CHECK(field);
3011 application.GetScene().Add(field);
3013 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3014 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3015 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3017 // Avoid a crash when core load gl resources.
3018 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3020 // Render and notify
3021 application.SendNotification();
3022 application.Render();
3024 // Add a key event but as the text field has not the focus it should do nothing.
3025 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3026 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3034 // Create a tap event to touch the text field.
3035 TestGenerateTap(application, 150.0f, 25.0f);
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 // Now the text field has the focus, so it can handle the key events.
3042 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3043 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3044 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3045 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3047 // Render and notify
3048 application.SendNotification();
3049 application.Render();
3051 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3053 // Generate a Esc key event. The text field should lose the focus.
3054 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3055 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3057 // Render and notify
3058 application.SendNotification();
3059 application.Render();
3061 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3063 // No more text should be introduced
3064 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3065 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3067 // Render and notify
3068 application.SendNotification();
3069 application.Render();
3071 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3076 int utcDaliTextFieldSomeSpecialKeys(void)
3078 ToolkitTestApplication application;
3079 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3081 // Checks some special keys when the text is selected.
3083 TextField field = TextField::New();
3084 DALI_TEST_CHECK(field);
3085 application.GetScene().Add(field);
3086 LoadMarkerImages(application, field);
3087 // Render and notify
3088 application.SendNotification();
3089 application.Render();
3091 const std::string longText("This is a long text for the size of the text-field.");
3093 field.SetProperty(TextField::Property::TEXT, longText);
3094 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3095 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3096 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3097 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3099 // Avoid a crash when core load gl resources.
3100 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3101 // Render and notify
3102 application.SendNotification();
3103 application.Render();
3105 // Create a tap event to touch the text field.
3106 TestGenerateTap(application, 150.0f, 25.0f);
3108 // Render and notify
3109 application.SendNotification();
3110 application.Render();
3112 // Tap first to get the focus.
3113 TestGenerateTap(application, 1.0f, 25.0f);
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 // Double tap to select a word.
3120 TestGenerateTap(application, 1.0f, 25.0f);
3122 // Render and notify
3123 application.SendNotification();
3124 application.Render();
3126 // Generate a Esc key event. The text field should lose the focus.
3127 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3128 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3130 // Render and notify
3131 application.SendNotification();
3132 application.Render();
3134 // Generate a Esc key event. The text field should lose the focus.
3135 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3136 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3138 // Render and notify
3139 application.SendNotification();
3140 application.Render();
3142 // Generate a Esc key event. The text field should lose the focus.
3143 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3144 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3146 // Render and notify
3147 application.SendNotification();
3148 application.Render();
3150 // The text shouldn't be deleted.
3151 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3156 int utcDaliTextFieldSizeUpdate(void)
3158 ToolkitTestApplication application;
3159 tet_infoline("utcDaliTextFieldSizeUpdate");
3161 // Checks some special keys when the text is selected.
3162 TextField field = TextField::New();
3163 DALI_TEST_CHECK(field);
3164 application.GetScene().Add(field);
3166 float previousHeight = 0.0f;
3167 float currentHeight = 0.0f;
3168 const float fieldWidth = 1920.0f;
3170 // "ㅁ" is bigger then "ኢ"
3171 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3172 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3173 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3175 field.SetProperty(TextField::Property::TEXT, "ኢ");
3176 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3177 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3179 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3180 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3182 application.SendNotification();
3183 application.Render();
3185 previousHeight = field.GetHeightForWidth(fieldWidth);
3186 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3188 // Add another script characters ( glyph height is defferent )
3189 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3190 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3192 application.SendNotification();
3193 application.Render();
3195 currentHeight = field.GetHeightForWidth(fieldWidth);
3196 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3197 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3202 int utcDaliTextFieldExtremlyLargePointSize(void)
3204 ToolkitTestApplication application;
3205 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3207 TextField field = TextField::New();
3209 field.SetProperty(TextField::Property::TEXT, "Text");
3210 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3211 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3212 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3213 application.GetScene().Add(field);
3217 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3218 application.SendNotification();
3219 DALI_TEST_CHECK(field);
3223 tet_result(TET_FAIL);
3228 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3230 ToolkitTestApplication application;
3231 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3232 TextField field = TextField::New();
3233 DALI_TEST_CHECK(field);
3234 application.GetScene().Add(field);
3236 Property::Map fontStyleMapGet;
3238 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3240 Property::Value* weightValue = NULL;
3241 Property::Value* widthValue = NULL;
3242 Property::Value* slantValue = NULL;
3243 weightValue = fontStyleMapGet.Find("weight");
3244 widthValue = fontStyleMapGet.Find("width");
3245 slantValue = fontStyleMapGet.Find("slant");
3246 DALI_TEST_CHECK(!weightValue);
3247 DALI_TEST_CHECK(!widthValue);
3248 DALI_TEST_CHECK(!slantValue);
3253 int UtcDaliTextFieldSettingPlaceholder(void)
3255 ToolkitTestApplication application;
3256 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3258 TextField field = TextField::New();
3259 DALI_TEST_CHECK(field);
3260 application.GetScene().Add(field);
3262 // Check the placeholder property with pixel size
3263 Property::Map placeholderPixelSizeMapSet;
3264 Property::Map placeholderPixelSizeMapGet;
3265 Property::Map placeholderFontstyleMap;
3266 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3267 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3268 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3269 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3270 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3271 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3273 placeholderFontstyleMap.Insert("weight", "bold");
3274 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3275 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3277 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3278 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3279 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3281 // Check the placeholder property with point size
3282 Property::Map placeholderMapSet;
3283 Property::Map placeholderMapGet;
3284 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3285 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3286 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3287 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3288 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3289 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3291 // Check the placeholder font style property
3292 placeholderFontstyleMap.Clear();
3294 placeholderFontstyleMap.Insert("weight", "bold");
3295 placeholderFontstyleMap.Insert("width", "condensed");
3296 placeholderFontstyleMap.Insert("slant", "italic");
3297 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3298 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3300 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3301 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3302 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3304 // Reset font style.
3305 placeholderFontstyleMap.Clear();
3306 placeholderFontstyleMap.Insert("weight", "normal");
3307 placeholderFontstyleMap.Insert("slant", "oblique");
3308 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3309 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3311 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3312 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3313 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3315 placeholderFontstyleMap.Clear();
3316 placeholderFontstyleMap.Insert("slant", "roman");
3317 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3318 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3320 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3322 placeholderFontstyleMap.Clear();
3323 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3325 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3326 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3327 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3328 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3333 int UtcDaliTextFieldPlaceholderCoverage(void)
3335 ToolkitTestApplication application;
3336 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3338 // mPlaceholderFont is created only once, so create a new control for coverage.
3339 TextField fieldForCoverage = TextField::New();
3340 DALI_TEST_CHECK(fieldForCoverage);
3341 application.GetScene().Add(fieldForCoverage);
3343 // for SetPlaceholderFontFamily() coverage.
3344 Property::Map fontFamilyMap;
3345 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3346 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3348 // mPlaceholderFont is created only once, so create a new control for coverage.
3349 fieldForCoverage = TextField::New();
3350 DALI_TEST_CHECK(fieldForCoverage);
3351 application.GetScene().Add(fieldForCoverage);
3353 // for SetPlaceholderTextFontSize coverage.
3354 Property::Map fontSizeMap;
3355 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3356 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3358 // mPlaceholderFont is created only once, so create a new control for coverage.
3359 fieldForCoverage = TextField::New();
3360 DALI_TEST_CHECK(fieldForCoverage);
3361 application.GetScene().Add(fieldForCoverage);
3363 // for SetPlaceholderTextFontWeight coverage.
3364 Property::Map fontStyleWeightMap;
3365 Property::Map fontStyleWeightPropertyMap;
3366 fontStyleWeightPropertyMap.Insert("weight", "bold");
3367 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3368 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3370 // mPlaceholderFont is created only once, so create a new control for coverage.
3371 fieldForCoverage = TextField::New();
3372 DALI_TEST_CHECK(fieldForCoverage);
3373 application.GetScene().Add(fieldForCoverage);
3375 // for SetPlaceholderTextFontWidth coverage.
3376 Property::Map fontStyleWidthMap;
3377 Property::Map fontStyleWidthPropertyMap;
3378 fontStyleWidthPropertyMap.Insert("width", "expanded");
3379 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3380 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3382 // mPlaceholderFont is created only once, so create a new control for coverage.
3383 fieldForCoverage = TextField::New();
3384 DALI_TEST_CHECK(fieldForCoverage);
3385 application.GetScene().Add(fieldForCoverage);
3387 // for SetPlaceholderTextFontSlant coverage.
3388 Property::Map fontStyleSlantMap;
3389 Property::Map fontStyleSlantPropertyMap;
3390 fontStyleSlantPropertyMap.Insert("slant", "italic");
3391 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3392 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3397 int UtcDaliTextFieldSetPaddingProperty(void)
3399 ToolkitTestApplication application;
3400 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3402 TextField field = TextField::New();
3403 DALI_TEST_CHECK(field);
3404 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3405 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3406 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3407 application.GetScene().Add(field);
3409 application.SendNotification();
3410 application.Render();
3412 Vector3 originalSize = field.GetNaturalSize();
3414 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3416 application.SendNotification();
3417 application.Render();
3419 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3421 Vector3 paddingAddedSize = field.GetNaturalSize();
3423 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3425 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3430 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3432 ToolkitTestApplication application;
3433 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3435 TextField field = TextField::New();
3436 DALI_TEST_CHECK(field);
3437 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3438 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3439 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3440 application.GetScene().Add(field);
3442 application.SendNotification();
3443 application.Render();
3445 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3446 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3448 // Check the enable shift selection property
3449 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3450 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3452 application.SendNotification();
3453 application.Render();
3458 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3460 ToolkitTestApplication application;
3461 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3463 TextField field = TextField::New();
3464 DALI_TEST_CHECK(field);
3465 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3466 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3467 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3468 application.GetScene().Add(field);
3470 application.SendNotification();
3471 application.Render();
3473 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3474 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3476 // Check the enable grab handle property
3477 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3478 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3480 application.SendNotification();
3481 application.Render();
3486 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3488 ToolkitTestApplication application;
3489 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3491 TextField field = TextField::New();
3492 DALI_TEST_CHECK(field);
3493 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3494 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3495 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3496 application.GetScene().Add(field);
3498 application.SendNotification();
3499 application.Render();
3501 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3502 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3504 // Check the match system language direction property
3505 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3506 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3508 application.SendNotification();
3509 application.Render();
3514 int utcDaliTextFieldLayoutDirectionCoverage(void)
3516 ToolkitTestApplication application;
3517 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3519 // Creates a tap event. After creating a tap event the text field should
3520 // have the focus and add text with key events should be possible.
3521 TextField field = TextField::New();
3522 DALI_TEST_CHECK(field);
3524 application.GetScene().Add(field);
3526 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3527 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3528 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3530 // Avoid a crash when core load gl resources.
3531 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3533 // Render and notify
3534 application.SendNotification();
3535 application.Render();
3537 // init direction for coverage
3538 // Set horizontal alignment END
3539 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3541 // Create a tap event to touch the text field.
3542 TestGenerateTap(application, 150.0f, 25.0f);
3544 // Render and notify
3545 application.SendNotification();
3546 application.Render();
3548 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3549 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
3550 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);