2 * Copyright (c) 2021 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 gAnchorClickedCallBackCalled;
135 static bool gAnchorClickedCallBackNotCalled;
136 static bool gTextChangedCallBackCalled;
137 static bool gMaxCharactersCallBackCalled;
138 static bool gInputFilteredAcceptedCallbackCalled;
139 static bool gInputFilteredRejectedCallbackCalled;
140 static bool gInputStyleChangedCallbackCalled;
141 static bool gCursorPositionChangedCallbackCalled;
142 static uint32_t oldCursorPos;
143 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
145 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
147 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
148 Integration::ResourcePointer resource(bitmap);
149 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
152 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
156 LoadBitmapResource(app.GetPlatform(), width, height);
158 Property::Map propertyMap;
159 propertyMap["filename"] = "image.png";
160 propertyMap["width"] = width;
161 propertyMap["height"] = height;
162 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
163 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
164 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
165 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap);
173 * Simulate time passed by.
175 * @note this will always process at least 1 frame (1/60 sec)
177 * @param application Test application instance
178 * @param duration Time to pass in milliseconds.
179 * @return The actual time passed in milliseconds
181 static int Wait(ToolkitTestApplication& application, int duration = 0)
185 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
187 application.SendNotification();
188 application.Render(RENDER_FRAME_INTERVAL);
189 time += RENDER_FRAME_INTERVAL;
195 Dali::Integration::Point GetPointDownInside(Vector2& pos)
197 Dali::Integration::Point point;
198 point.SetState(PointState::DOWN);
199 point.SetScreenPosition(pos);
203 Dali::Integration::Point GetPointUpInside(Vector2& pos)
205 Dali::Integration::Point point;
206 point.SetState(PointState::UP);
207 point.SetScreenPosition(pos);
211 struct CallbackFunctor
213 CallbackFunctor(bool* callbackFlag)
214 : mCallbackFlag(callbackFlag)
220 *mCallbackFlag = true;
225 static void TestSelectionClearedCallback(TextField control)
227 tet_infoline(" TestSelectionClearedCallback");
229 gSelectionClearedCallbackCalled = true;
232 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
234 tet_infoline(" TestSelectionChangedCallback");
236 gSelectionChangedCallbackCalled = true;
237 oldSelectionStart = oldStart;
238 oldSelectionEnd = oldEnd;
241 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
243 tet_infoline(" TestAnchorClickedCallback");
245 gAnchorClickedCallBackNotCalled = false;
247 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
249 gAnchorClickedCallBackCalled = true;
253 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
255 tet_infoline(" TestCursorPositionChangedCallback");
257 gCursorPositionChangedCallbackCalled = true;
258 oldCursorPos = oldPos;
261 static void TestTextChangedCallback(TextField control)
263 tet_infoline(" TestTextChangedCallback");
265 gTextChangedCallBackCalled = true;
268 static void TestMaxLengthReachedCallback(TextField control)
270 tet_infoline(" TestMaxLengthReachedCallback");
272 gMaxCharactersCallBackCalled = true;
275 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
277 tet_infoline(" TestInputFilteredCallback");
279 if(type == Toolkit::InputFilter::Property::ACCEPTED)
281 gInputFilteredAcceptedCallbackCalled = true;
283 else if(type == Toolkit::InputFilter::Property::REJECTED)
285 gInputFilteredRejectedCallbackCalled = true;
289 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
291 tet_infoline(" TestInputStyleChangedCallback");
293 gInputStyleChangedCallbackCalled = true;
294 gInputStyleMask = mask;
297 // Generate a KeyEvent to send to Core.
298 Integration::KeyEvent GenerateKey(const std::string& keyName,
299 const std::string& logicalKey,
300 const std::string& keyString,
303 unsigned long timeStamp,
304 const Integration::KeyEvent::State& keyState,
305 const std::string& compose = "",
306 const std::string& deviceName = DEFAULT_DEVICE_NAME,
307 const Device::Class::Type& deviceClass = Device::Class::NONE,
308 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
310 return Integration::KeyEvent(keyName,
323 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
325 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
327 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
329 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
331 Property::Value* valueSet = NULL;
332 if(valueGet.first.type == Property::Key::INDEX)
334 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
338 // Get Key is a string so searching Set Map for a string key
339 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
344 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
346 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
349 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
351 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
354 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
356 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
359 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
361 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
364 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
366 Vector2 vector2Get = valueGet.second.Get<Vector2>();
367 Vector2 vector2Set = valueSet->Get<Vector2>();
368 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
371 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
373 Vector4 vector4Get = valueGet.second.Get<Vector4>();
374 Vector4 vector4Set = valueSet->Get<Vector4>();
375 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);
381 if(valueGet.first.type == Property::Key::INDEX)
383 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
387 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
399 int UtcDaliToolkitTextFieldConstructorP(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
404 DALI_TEST_CHECK(!textField);
408 int UtcDaliToolkitTextFieldNewP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldNewP");
412 TextField textField = TextField::New();
413 DALI_TEST_CHECK(textField);
417 int UtcDaliToolkitTextFieldDownCastP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
421 TextField textField1 = TextField::New();
422 BaseHandle object(textField1);
424 TextField textField2 = TextField::DownCast(object);
425 DALI_TEST_CHECK(textField2);
427 TextField textField3 = DownCast<TextField>(object);
428 DALI_TEST_CHECK(textField3);
432 int UtcDaliToolkitTextFieldDownCastN(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
436 BaseHandle uninitializedObject;
437 TextField textField1 = TextField::DownCast(uninitializedObject);
438 DALI_TEST_CHECK(!textField1);
440 TextField textField2 = DownCast<TextField>(uninitializedObject);
441 DALI_TEST_CHECK(!textField2);
445 int UtcDaliToolkitTextFieldCopyConstructorP(void)
447 ToolkitTestApplication application;
448 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
449 TextField textField = TextField::New();
450 textField.SetProperty(TextField::Property::TEXT, "Test");
452 TextField copy(textField);
453 DALI_TEST_CHECK(copy);
454 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
458 int UtcDaliTextFieldMoveConstructor(void)
460 ToolkitTestApplication application;
462 TextField textField = TextField::New();
463 textField.SetProperty(TextEditor::Property::TEXT, "Test");
464 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
466 TextField moved = std::move(textField);
467 DALI_TEST_CHECK(moved);
468 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
469 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
470 DALI_TEST_CHECK(!textField);
475 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
477 ToolkitTestApplication application;
478 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
479 TextField textField = TextField::New();
480 textField.SetProperty(TextField::Property::TEXT, "Test");
482 TextField copy = textField;
483 DALI_TEST_CHECK(copy);
484 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
488 int UtcDaliTextFieldMoveAssignment(void)
490 ToolkitTestApplication application;
492 TextField textField = TextField::New();
493 textField.SetProperty(TextEditor::Property::TEXT, "Test");
494 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
497 moved = std::move(textField);
498 DALI_TEST_CHECK(moved);
499 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
500 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
501 DALI_TEST_CHECK(!textField);
506 int UtcDaliTextFieldNewP(void)
508 ToolkitTestApplication application;
509 tet_infoline(" UtcDaliToolkitTextFieldNewP");
510 TextField textField = TextField::New();
511 DALI_TEST_CHECK(textField);
515 // Positive test case for a method
516 int UtcDaliTextFieldGetPropertyP(void)
518 ToolkitTestApplication application;
519 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
520 TextField field = TextField::New();
521 DALI_TEST_CHECK(field);
523 // Check Property Indices are correct
524 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
525 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
526 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
527 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
528 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
529 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
530 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
531 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
532 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
533 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
534 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
535 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
536 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
537 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
538 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
539 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
540 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
541 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
542 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
543 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
544 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
545 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
546 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
547 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
548 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
549 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
550 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
551 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
552 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
553 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
554 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
555 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
556 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
557 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
558 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
559 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
560 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
561 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
562 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
563 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
564 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
565 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
566 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
567 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
568 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
569 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
570 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
571 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
572 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
573 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
574 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
575 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
576 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
577 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
578 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
579 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
580 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
581 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
582 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
583 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
589 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
592 Property::Map imageMap;
593 imageMap[mapKey] = mapValue;
595 field.SetProperty(property, imageMap);
596 Property::Value propValue = field.GetProperty(property);
597 Property::Map* resultMap = propValue.GetMap();
599 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
607 // Positive test case for a method
608 int UtcDaliTextFieldSetPropertyP(void)
610 ToolkitTestApplication application;
611 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
612 TextField field = TextField::New();
613 DALI_TEST_CHECK(field);
614 application.GetScene().Add(field);
616 // Note - we can't check the defaults since the stylesheets are platform-specific
618 // Check the render backend property.
619 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
620 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
622 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
623 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
625 // Check text property.
626 field.SetProperty(TextField::Property::TEXT, "Setting Text");
627 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
629 // Check placeholder text properties.
630 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
631 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
633 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
634 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
636 // Check font properties.
637 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
638 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
640 Property::Map fontStyleMapSet;
641 Property::Map fontStyleMapGet;
642 Property::Value* slantValue = NULL;
644 fontStyleMapSet.Insert("weight", "bold");
645 fontStyleMapSet.Insert("width", "condensed");
646 fontStyleMapSet.Insert("slant", "italic");
647 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
649 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
650 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
651 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
653 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
654 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
656 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
657 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
658 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
660 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
661 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
662 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
665 fontStyleMapSet.Clear();
666 fontStyleMapSet.Insert("weight", "normal");
667 fontStyleMapSet.Insert("slant", "oblique");
668 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
670 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
671 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
672 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
674 fontStyleMapSet.Clear();
675 fontStyleMapSet.Insert("slant", "roman");
676 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
677 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
679 // Replace 'roman' for 'normal'.
680 slantValue = fontStyleMapGet.Find("slant");
681 if(NULL != slantValue)
683 if("normal" == slantValue->Get<std::string>())
685 fontStyleMapGet["slant"] = "roman";
688 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
689 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
691 fontStyleMapSet.Clear();
693 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
694 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
695 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
696 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
698 // Check that the MAX_LENGTH property can be correctly set
699 const int maxNumberOfCharacters = 20;
700 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
701 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
703 // Check exceed policy
704 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
705 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
706 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
707 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
709 // Check that the Alignment properties can be correctly set
710 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
711 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
712 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
713 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
715 // Check text's color property
716 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
717 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
719 // Check placeholder text's color property.
720 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
721 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
723 // Check cursor properties
724 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
725 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
726 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
727 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
729 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
730 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
731 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
732 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
733 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
734 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
735 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
736 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
738 // Check scroll properties.
739 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
740 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
741 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
742 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
744 // Check handle images
745 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
746 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
747 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
748 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
749 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
751 // Check handle images
752 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
753 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
754 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
755 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
756 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
757 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
759 // Check the highlight color
760 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
761 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
763 // Decoration bounding box
764 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
765 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
767 // Check the input method setting
768 Property::Map propertyMap;
769 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
770 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
771 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
772 int inputVariation = 1;
773 propertyMap["PANEL_LAYOUT"] = panelLayout;
774 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
775 propertyMap["BUTTON_ACTION"] = buttonAction;
776 propertyMap["VARIATION"] = inputVariation;
777 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
779 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
781 DALI_TEST_CHECK(value.Get(map));
784 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
785 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
788 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
789 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
792 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
793 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
796 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
797 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
799 // Check input color property.
800 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
801 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
803 // Check the enable markup property.
804 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
805 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
806 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
808 // Check input font properties.
809 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
810 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
812 fontStyleMapSet.Clear();
813 fontStyleMapSet.Insert("weight", "bold");
814 fontStyleMapSet.Insert("width", "condensed");
815 fontStyleMapSet.Insert("slant", "italic");
817 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
818 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
819 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
820 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
822 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
823 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
825 // Reset input font style.
826 fontStyleMapSet.Clear();
827 fontStyleMapSet.Insert("weight", "normal");
828 fontStyleMapSet.Insert("slant", "oblique");
830 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
831 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
832 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
833 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
835 fontStyleMapSet.Clear();
836 fontStyleMapSet.Insert("slant", "roman");
838 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
839 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
841 // Replace 'roman' for 'normal'.
842 slantValue = fontStyleMapGet.Find("slant");
843 if(NULL != slantValue)
845 if("normal" == slantValue->Get<std::string>())
847 fontStyleMapGet["slant"] = "roman";
850 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
851 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
853 fontStyleMapSet.Clear();
855 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
856 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
857 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
858 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
860 Property::Map strikethroughMapSet;
861 Property::Map strikethroughMapGet;
863 strikethroughMapSet.Insert("enable", true);
864 strikethroughMapSet.Insert("color", Color::RED);
865 strikethroughMapSet.Insert("height", 2.0f);
867 // Check the strikethrough property
868 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
870 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
871 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
872 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
874 // Check the input strikethrough property
875 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
876 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
878 Property::Map underlineMapSet;
879 Property::Map underlineMapGet;
881 underlineMapSet.Insert("enable", true);
882 underlineMapSet.Insert("color", Color::RED);
883 underlineMapSet.Insert("height", 1);
884 underlineMapSet.Insert("type", Text::Underline::SOLID);
885 underlineMapSet.Insert("dashWidth", 2);
886 underlineMapSet.Insert("dashGap", 1);
888 // Check the underline property
889 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
891 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
892 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
893 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
896 application.SendNotification();
897 application.Render();
899 underlineMapSet.Clear();
900 underlineMapGet.Clear();
902 underlineMapSet.Insert("enable", true);
903 underlineMapSet.Insert("color", Color::BLUE);
904 underlineMapSet.Insert("height", 1);
905 underlineMapSet.Insert("type", Text::Underline::DASHED);
906 underlineMapSet.Insert("dashWidth", 4);
907 underlineMapSet.Insert("dashGap", 2);
909 // Check the dashed underline property
910 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
912 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
913 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
914 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
917 application.SendNotification();
918 application.Render();
920 underlineMapSet.Clear();
921 underlineMapGet.Clear();
923 underlineMapSet.Insert("enable", true);
924 underlineMapSet.Insert("color", Color::BLUE);
925 underlineMapSet.Insert("height", 4);
926 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
927 underlineMapSet.Insert("dashWidth", 4);
928 underlineMapSet.Insert("dashGap", 2);
930 // Check the dashed underline property
931 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
933 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
934 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
935 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
938 application.SendNotification();
939 application.Render();
941 underlineMapSet.Clear();
942 underlineMapGet.Clear();
944 // Check the input underline property
945 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
946 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
948 // Check the shadow property
949 Property::Map shadowMapSet;
950 Property::Map shadowMapGet;
952 shadowMapSet.Insert("color", Color::GREEN);
953 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
954 shadowMapSet.Insert("blurRadius", 3.0f);
956 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
958 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
959 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
960 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
962 // Check the input shadow property
963 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
964 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
966 // Check the emboss property
967 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
968 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
970 // Check the input emboss property
971 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
972 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
974 // Check the outline property
976 // Test string type first
977 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
978 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
979 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
981 // Then test the property map type
982 Property::Map outlineMapSet;
983 Property::Map outlineMapGet;
985 outlineMapSet["color"] = Color::RED;
986 outlineMapSet["width"] = 2.0f;
988 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
990 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
991 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
992 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
994 // Check the input outline property
995 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
996 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
998 // Check the hidden input settings property
999 Property::Map hiddenMapSet;
1000 Property::Map hiddenMapGet;
1001 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1002 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1003 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1004 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1005 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1007 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1008 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1009 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1011 // Check the pixel size of font
1012 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1013 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1015 // Check the enable selection property
1016 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1017 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1019 // Check the placeholder property with pixel size
1020 Property::Map placeholderPixelSizeMapSet;
1021 Property::Map placeholderPixelSizeMapGet;
1022 Property::Map placeholderFontstyleMap;
1023 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1024 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1025 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1026 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1027 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1028 placeholderPixelSizeMapSet["ellipsis"] = true;
1030 placeholderFontstyleMap.Insert("weight", "bold");
1031 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1032 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1034 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1035 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1037 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1038 Property::Map placeholderConversionMap;
1039 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1040 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1041 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1042 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1043 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1044 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1046 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1048 // Check the placeholder property with point size
1049 Property::Map placeholderMapSet;
1050 Property::Map placeholderMapGet;
1051 placeholderMapSet["text"] = "Setting Placeholder Text";
1052 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1053 placeholderMapSet["color"] = Color::RED;
1054 placeholderMapSet["fontFamily"] = "Arial";
1055 placeholderMapSet["pointSize"] = 12.0f;
1056 placeholderMapSet["ellipsis"] = false;
1058 // Check the placeholder font style property
1059 placeholderFontstyleMap.Clear();
1061 placeholderFontstyleMap.Insert("weight", "bold");
1062 placeholderFontstyleMap.Insert("width", "condensed");
1063 placeholderFontstyleMap.Insert("slant", "italic");
1064 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1065 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1067 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1068 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1070 placeholderConversionMap.Clear();
1071 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1072 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1073 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1074 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1075 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1076 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1078 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1080 // Reset font style.
1081 placeholderFontstyleMap.Clear();
1082 placeholderFontstyleMap.Insert("weight", "normal");
1083 placeholderFontstyleMap.Insert("slant", "oblique");
1084 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1085 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1087 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1088 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1090 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1091 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1093 placeholderFontstyleMap.Clear();
1094 placeholderFontstyleMap.Insert("slant", "roman");
1095 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1096 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1098 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1100 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1102 placeholderFontstyleMap.Clear();
1103 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1104 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1106 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1107 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1108 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1110 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1112 // Check the ellipsis property
1113 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1114 field.SetProperty(TextField::Property::ELLIPSIS, true);
1115 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1117 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1118 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1120 // Test the ENABLE_GRAB_HANDLE_POPUP property
1121 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1122 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1123 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1125 // Check the background property
1126 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1127 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1129 //Check handle color
1130 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1131 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1133 // Check the input filter property
1134 Property::Map inputFilterMapSet;
1135 Property::Map inputFilterMapGet;
1136 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1137 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1139 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1141 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1142 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1145 inputFilterMapSet.Clear();
1146 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1148 application.SendNotification();
1149 application.Render();
1154 // Positive Atlas Text Renderer test
1155 int utcDaliTextFieldAtlasRenderP(void)
1157 ToolkitTestApplication application;
1158 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1159 StyleManager styleManager = StyleManager::Get();
1160 styleManager.ApplyDefaultTheme();
1161 TextField field = TextField::New();
1162 DALI_TEST_CHECK(field);
1164 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1166 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1168 application.GetScene().Add(field);
1172 // Render some text with the shared atlas backend
1173 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1174 application.SendNotification();
1175 application.Render();
1179 tet_result(TET_FAIL);
1184 // Positive test for the anchorClicked signal.
1185 int utcDaliTextFieldAnchorClicked01(void)
1187 ToolkitTestApplication application;
1188 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1189 TextField field = TextField::New();
1190 DALI_TEST_CHECK(field);
1192 application.GetScene().Add(field);
1194 // connect to the anchor clicked signal.
1195 ConnectionTracker* testTracker = new ConnectionTracker();
1196 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1197 bool anchorClickedSignal = false;
1198 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1200 gAnchorClickedCallBackCalled = false;
1201 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1202 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1203 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1204 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1205 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1207 application.SendNotification();
1208 application.Render();
1209 field.SetKeyInputFocus();
1211 // Create a tap event to touch the text field.
1212 TestGenerateTap(application, 5.0f, 25.0f);
1213 application.SendNotification();
1214 application.Render();
1216 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1217 DALI_TEST_CHECK(anchorClickedSignal);
1219 gAnchorClickedCallBackNotCalled = true;
1220 // Tap the outside of anchor, callback should not be called.
1221 TestGenerateTap(application, 150.f, 100.f);
1222 application.SendNotification();
1223 application.Render();
1225 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1230 // Positive test for the anchorClicked signal.
1231 int utcDaliTextFieldAnchorClicked02(void)
1233 ToolkitTestApplication application;
1234 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1235 TextField field = TextField::New();
1236 DALI_TEST_CHECK(field);
1238 application.GetScene().Add(field);
1240 // connect to the anchor clicked signal.
1241 ConnectionTracker* testTracker = new ConnectionTracker();
1242 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1243 bool anchorClickedSignal = false;
1244 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1246 gAnchorClickedCallBackCalled = false;
1247 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1248 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1249 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1250 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1251 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1253 application.SendNotification();
1254 application.Render();
1255 field.SetKeyInputFocus();
1257 // Avoid a crash when core load gl resources.
1258 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1260 // Create a tap event to touch the text field.
1261 TestGenerateTap(application, 30.0f, 25.0f, 100);
1262 application.SendNotification();
1263 application.Render();
1265 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1266 DALI_TEST_CHECK(anchorClickedSignal);
1268 // For coverage InsertTextAnchor, RemoveTextAnchor
1269 // first index insert
1270 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1271 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1272 application.SendNotification();
1273 application.Render();
1275 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1276 application.SendNotification();
1277 application.Render();
1279 gAnchorClickedCallBackCalled = false;
1280 // Create a tap event to touch the text field.
1281 TestGenerateTap(application, 30.0f, 25.0f, 700);
1282 application.SendNotification();
1283 field.SetKeyInputFocus();
1285 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1287 // last index insert
1288 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1289 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1290 application.SendNotification();
1291 application.Render();
1293 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1294 application.SendNotification();
1295 application.Render();
1297 gAnchorClickedCallBackCalled = false;
1298 // Create a tap event to touch the text field.
1299 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1300 application.SendNotification();
1301 field.SetKeyInputFocus();
1303 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1306 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1307 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1308 application.SendNotification();
1309 application.Render();
1311 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1312 application.SendNotification();
1313 application.Render();
1315 gAnchorClickedCallBackCalled = false;
1316 // Create a tap event to touch the text field.
1317 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1318 application.SendNotification();
1319 field.SetKeyInputFocus();
1321 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1323 // first index remove
1324 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1325 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1326 application.SendNotification();
1327 application.Render();
1329 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1330 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));
1331 application.SendNotification();
1332 application.Render();
1334 gAnchorClickedCallBackCalled = false;
1335 // Create a tap event to touch the text field.
1336 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1337 application.SendNotification();
1338 field.SetKeyInputFocus();
1340 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1342 // last index remove
1343 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1344 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1345 application.SendNotification();
1346 application.Render();
1348 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1349 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));
1350 application.SendNotification();
1351 application.Render();
1353 gAnchorClickedCallBackCalled = false;
1354 // Create a tap event to touch the text field.
1355 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1356 application.SendNotification();
1357 application.Render();
1359 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1362 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1363 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1364 application.SendNotification();
1365 application.Render();
1367 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1368 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));
1369 application.SendNotification();
1370 application.Render();
1372 gAnchorClickedCallBackCalled = false;
1373 // Create a tap event to touch the text field.
1374 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1375 application.SendNotification();
1376 application.Render();
1378 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1380 // 0 ~ 1 index remove
1381 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1382 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1383 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1384 application.SendNotification();
1385 application.Render();
1387 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1388 application.SendNotification();
1389 application.Render();
1391 gAnchorClickedCallBackCalled = false;
1392 // Create a tap event to touch the text field.
1393 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1394 application.SendNotification();
1395 application.Render();
1397 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1399 // 1 ~ 3 index remove
1400 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1401 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1402 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1403 application.SendNotification();
1404 application.Render();
1406 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1407 application.SendNotification();
1408 application.Render();
1410 gAnchorClickedCallBackCalled = false;
1411 // Create a tap event to touch the text field.
1412 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1413 application.SendNotification();
1414 application.Render();
1416 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1418 // 3 ~ 4 index remove
1419 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1420 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1421 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1422 application.SendNotification();
1423 application.Render();
1425 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1426 application.SendNotification();
1427 application.Render();
1429 gAnchorClickedCallBackCalled = false;
1430 // Create a tap event to touch the text field.
1431 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1437 // Remove front of anchor
1438 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1439 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1440 application.SendNotification();
1441 application.Render();
1443 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1444 application.SendNotification();
1445 application.Render();
1447 // Remove whole text
1448 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1449 DevelTextField::SelectWholeText(field);
1450 application.SendNotification();
1451 application.Render();
1453 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1454 application.SendNotification();
1455 application.Render();
1457 // Remove all with backspace
1458 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1459 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1460 application.SendNotification();
1461 application.Render();
1463 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1464 application.SendNotification();
1465 application.Render();
1467 // Remove all with delete
1468 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1469 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1470 application.SendNotification();
1471 application.Render();
1473 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));
1474 application.SendNotification();
1475 application.Render();
1480 // Positive test for the textChanged signal.
1481 int utcDaliTextFieldTextChangedP(void)
1483 ToolkitTestApplication application;
1484 tet_infoline(" utcDaliTextFieldTextChangedP");
1485 TextField field = TextField::New();
1486 DALI_TEST_CHECK(field);
1488 application.GetScene().Add(field);
1490 // connect to the text changed signal.
1491 ConnectionTracker* testTracker = new ConnectionTracker();
1492 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1493 bool textChangedSignal = false;
1494 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1496 gTextChangedCallBackCalled = false;
1497 field.SetProperty(TextField::Property::TEXT, "ABC");
1498 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1499 DALI_TEST_CHECK(textChangedSignal);
1501 application.SendNotification();
1502 field.SetKeyInputFocus();
1504 gTextChangedCallBackCalled = false;
1505 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1506 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1509 field.SetProperty(TextField::Property::TEXT, "");
1511 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1512 gTextChangedCallBackCalled = false;
1513 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1514 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1516 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1517 gTextChangedCallBackCalled = false;
1518 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1519 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1524 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1526 ToolkitTestApplication application;
1527 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1528 TextField field = TextField::New();
1529 DALI_TEST_CHECK(field);
1531 application.GetScene().Add(field);
1533 // connect to the text changed signal.
1534 ConnectionTracker* testTracker = new ConnectionTracker();
1535 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1536 bool textChangedSignal = false;
1537 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1539 // get InputMethodContext
1541 InputMethodContext::EventData imfEvent;
1542 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1544 field.SetKeyInputFocus();
1545 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1548 gTextChangedCallBackCalled = false;
1549 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1550 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1551 application.SendNotification();
1552 application.Render();
1553 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1554 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
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 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1577 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1578 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1579 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1581 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1582 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1583 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1585 application.SendNotification();
1586 application.Render();
1587 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1588 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1593 // Negative test for the textChanged signal.
1594 int utcDaliTextFieldTextChangedN(void)
1596 ToolkitTestApplication application;
1597 tet_infoline(" utcDaliTextFieldTextChangedN");
1598 TextField field = TextField::New();
1599 DALI_TEST_CHECK(field);
1601 application.GetScene().Add(field);
1603 // connect to the text changed signal.
1604 ConnectionTracker* testTracker = new ConnectionTracker();
1605 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1606 bool textChangedSignal = false;
1607 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1609 gTextChangedCallBackCalled = false;
1610 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1611 application.SendNotification();
1612 application.Render();
1613 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1614 DALI_TEST_CHECK(!textChangedSignal);
1619 // Positive test for Max Characters reached signal.
1620 int utcDaliTextFieldMaxCharactersReachedP(void)
1622 ToolkitTestApplication application;
1623 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1624 TextField field = TextField::New();
1625 DALI_TEST_CHECK(field);
1627 application.GetScene().Add(field);
1629 const int maxNumberOfCharacters = 1;
1630 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1632 field.SetKeyInputFocus();
1634 // connect to the text changed signal.
1635 ConnectionTracker* testTracker = new ConnectionTracker();
1636 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1637 bool maxLengthReachedSignal = false;
1638 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1640 gMaxCharactersCallBackCalled = false;
1642 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1643 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1645 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1646 DALI_TEST_CHECK(maxLengthReachedSignal);
1651 // Negative test for Max Characters reached signal.
1652 int utcDaliTextFieldMaxCharactersReachedN(void)
1654 ToolkitTestApplication application;
1655 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1656 TextField field = TextField::New();
1657 DALI_TEST_CHECK(field);
1659 application.GetScene().Add(field);
1661 const int maxNumberOfCharacters = 3;
1662 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1664 field.SetKeyInputFocus();
1666 // connect to the text changed signal.
1667 ConnectionTracker* testTracker = new ConnectionTracker();
1668 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1669 bool maxLengthReachedSignal = false;
1670 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1672 gMaxCharactersCallBackCalled = false;
1674 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1675 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1677 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1678 DALI_TEST_CHECK(!maxLengthReachedSignal);
1680 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1682 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1683 DALI_TEST_CHECK(!maxLengthReachedSignal);
1688 // Positive test for Input Filtered signal.
1689 int utcDaliTextFieldInputFilteredP(void)
1691 ToolkitTestApplication application;
1692 tet_infoline(" utcDaliTextFieldInputFilteredP");
1693 TextField field = TextField::New();
1694 DALI_TEST_CHECK(field);
1696 application.GetScene().Add(field);
1698 Property::Map inputFilter;
1700 // Only digit is accepted.
1701 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1703 // Set input filter to TextField.
1704 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1706 field.SetKeyInputFocus();
1708 // connect to the input filtered signal.
1709 ConnectionTracker* testTracker = new ConnectionTracker();
1710 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1711 bool inputFilteredSignal = false;
1712 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1714 gInputFilteredAcceptedCallbackCalled = false;
1716 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1718 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1719 DALI_TEST_CHECK(inputFilteredSignal);
1721 // Word is rejected.
1722 inputFilter[InputFilter::Property::ACCEPTED] = "";
1723 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1725 // Set input filter to TextField.
1726 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1728 field.SetKeyInputFocus();
1730 inputFilteredSignal = false;
1731 gInputFilteredRejectedCallbackCalled = false;
1733 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1735 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1736 DALI_TEST_CHECK(inputFilteredSignal);
1741 // Negative test for Input Filtered signal.
1742 int utcDaliTextFieldInputFilteredN(void)
1744 ToolkitTestApplication application;
1745 tet_infoline(" utcDaliTextFieldInputFilteredP");
1746 TextField field = TextField::New();
1747 DALI_TEST_CHECK(field);
1749 application.GetScene().Add(field);
1751 Property::Map inputFilter;
1753 // Only word is accepted.
1754 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1756 // Set input filter to TextField.
1757 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1759 field.SetKeyInputFocus();
1761 // connect to the input filtered signal.
1762 ConnectionTracker* testTracker = new ConnectionTracker();
1763 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1764 bool inputFilteredSignal = false;
1765 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1767 gInputFilteredAcceptedCallbackCalled = false;
1769 // Key a, d should not be filtered.
1770 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1771 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1772 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1773 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1775 // Backspace, Delete should not be filtered.
1776 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1777 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));
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1784 DALI_TEST_CHECK(!inputFilteredSignal);
1786 // Digit is rejected.
1787 inputFilter[InputFilter::Property::ACCEPTED] = "";
1788 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1790 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1792 field.SetKeyInputFocus();
1794 inputFilteredSignal = false;
1795 gInputFilteredRejectedCallbackCalled = false;
1797 // Key a, d should not be filtered.
1798 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1799 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1800 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1801 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1803 // Backspace, Delete should not be filtered.
1804 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1805 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));
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1812 DALI_TEST_CHECK(!inputFilteredSignal);
1817 int utcDaliTextFieldInputStyleChanged01(void)
1819 // The text-field emits signals when the input style changes. These changes of style are
1820 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1821 // can't be emitted during the size negotiation as the callbacks may update the UI.
1822 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1823 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1824 ToolkitTestApplication application;
1825 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1829 char* pathNamePtr = get_current_dir_name();
1830 const std::string pathName(pathNamePtr);
1833 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1834 fontClient.SetDpi(93u, 93u);
1836 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
1837 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
1839 TextField field = TextField::New();
1840 DALI_TEST_CHECK(field);
1842 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
1843 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1844 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1846 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1847 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
1849 // connect to the text changed signal.
1850 ConnectionTracker* testTracker = new ConnectionTracker();
1851 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
1852 bool inputStyleChangedSignal = false;
1853 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
1855 application.GetScene().Add(field);
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 // Executes the idle callbacks added by the text control on the change of input style.
1862 application.RunIdles();
1864 gInputStyleChangedCallbackCalled = false;
1865 gInputStyleMask = TextField::InputStyle::NONE;
1866 inputStyleChangedSignal = false;
1868 // Create a tap event to touch the text field.
1869 TestGenerateTap(application, 18.0f, 25.0f);
1871 // Render and notify
1872 application.SendNotification();
1873 application.Render();
1875 // Executes the idle callbacks added by the text control on the change of input style.
1876 application.RunIdles();
1878 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1879 if(gInputStyleChangedCallbackCalled)
1881 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
1883 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
1884 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
1886 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
1887 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1889 DALI_TEST_CHECK(inputStyleChangedSignal);
1891 gInputStyleChangedCallbackCalled = false;
1892 gInputStyleMask = TextField::InputStyle::NONE;
1893 inputStyleChangedSignal = false;
1895 // Create a tap event to touch the text field.
1896 TestGenerateTap(application, 30.0f, 25.0f);
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Executes the idle callbacks added by the text control on the change of input style.
1903 application.RunIdles();
1905 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1906 DALI_TEST_CHECK(!inputStyleChangedSignal);
1908 gInputStyleChangedCallbackCalled = false;
1909 gInputStyleMask = TextField::InputStyle::NONE;
1910 inputStyleChangedSignal = false;
1912 // Create a tap event to touch the text field.
1913 TestGenerateTap(application, 43.0f, 25.0f);
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 // Executes the idle callbacks added by the text control on the change of input style.
1920 application.RunIdles();
1922 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1923 if(gInputStyleChangedCallbackCalled)
1925 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
1927 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1928 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
1930 DALI_TEST_CHECK(inputStyleChangedSignal);
1932 gInputStyleChangedCallbackCalled = false;
1933 gInputStyleMask = TextField::InputStyle::NONE;
1934 inputStyleChangedSignal = false;
1936 // Create a tap event to touch the text field.
1937 TestGenerateTap(application, 88.0f, 25.0f);
1939 // Render and notify
1940 application.SendNotification();
1941 application.Render();
1943 // Executes the idle callbacks added by the text control on the change of input style.
1944 application.RunIdles();
1946 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1947 if(gInputStyleChangedCallbackCalled)
1949 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
1951 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
1952 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
1954 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
1956 Property::Map fontStyleMapSet;
1957 fontStyleMapSet.Insert("weight", "bold");
1959 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
1960 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
1962 DALI_TEST_CHECK(inputStyleChangedSignal);
1964 gInputStyleChangedCallbackCalled = false;
1965 gInputStyleMask = TextField::InputStyle::NONE;
1966 inputStyleChangedSignal = false;
1968 // Create a tap event to touch the text field.
1969 TestGenerateTap(application, 115.0f, 25.0f);
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 // Executes the idle callbacks added by the text control on the change of input style.
1976 application.RunIdles();
1978 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
1979 DALI_TEST_CHECK(!inputStyleChangedSignal);
1981 gInputStyleChangedCallbackCalled = false;
1982 gInputStyleMask = TextField::InputStyle::NONE;
1983 inputStyleChangedSignal = false;
1985 // Create a tap event to touch the text field.
1986 TestGenerateTap(application, 164.0f, 25.0f);
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 // Executes the idle callbacks added by the text control on the change of input style.
1993 application.RunIdles();
1995 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
1996 if(gInputStyleChangedCallbackCalled)
1998 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2000 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2001 DALI_TEST_CHECK(style.empty());
2003 DALI_TEST_CHECK(inputStyleChangedSignal);
2005 gInputStyleChangedCallbackCalled = false;
2006 gInputStyleMask = TextField::InputStyle::NONE;
2007 inputStyleChangedSignal = false;
2009 // Create a tap event to touch the text field.
2010 TestGenerateTap(application, 191.0f, 25.0f);
2012 // Render and notify
2013 application.SendNotification();
2014 application.Render();
2016 // Executes the idle callbacks added by the text control on the change of input style.
2017 application.RunIdles();
2019 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2020 DALI_TEST_CHECK(!inputStyleChangedSignal);
2025 int utcDaliTextFieldInputStyleChanged02(void)
2027 // The text-field emits signals when the input style changes. These changes of style are
2028 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2029 // can't be emitted during the size negotiation as the callbacks may update the UI.
2030 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2031 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2032 ToolkitTestApplication application;
2033 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2037 char* pathNamePtr = get_current_dir_name();
2038 const std::string pathName(pathNamePtr);
2041 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2042 fontClient.SetDpi(93u, 93u);
2044 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2045 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2047 TextField field = TextField::New();
2048 DALI_TEST_CHECK(field);
2050 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2051 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2052 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2054 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2055 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>");
2057 // connect to the text changed signal.
2058 ConnectionTracker* testTracker = new ConnectionTracker();
2059 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2060 bool inputStyleChangedSignal = false;
2061 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2063 application.GetScene().Add(field);
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 // Executes the idle callbacks added by the text control on the change of input style.
2070 application.RunIdles();
2072 gInputStyleChangedCallbackCalled = false;
2073 gInputStyleMask = TextField::InputStyle::NONE;
2074 inputStyleChangedSignal = false;
2076 // Create a tap event to touch the text field.
2077 TestGenerateTap(application, 53.0f, 25.0f, 100);
2078 TestGenerateTap(application, 53.0f, 25.0f, 200);
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // Executes the idle callbacks added by the text control on the change of input style.
2085 application.RunIdles();
2087 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2088 if(gInputStyleChangedCallbackCalled)
2090 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2091 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2092 TextField::InputStyle::POINT_SIZE |
2093 TextField::InputStyle::COLOR),
2096 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2097 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2099 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2100 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2102 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2103 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2105 DALI_TEST_CHECK(inputStyleChangedSignal);
2107 gInputStyleChangedCallbackCalled = false;
2108 gInputStyleMask = TextField::InputStyle::NONE;
2109 inputStyleChangedSignal = false;
2111 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 // Executes the idle callbacks added by the text control on the change of input style.
2118 application.RunIdles();
2120 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2121 if(gInputStyleChangedCallbackCalled)
2123 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2124 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2127 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2128 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2130 DALI_TEST_CHECK(inputStyleChangedSignal);
2132 gInputStyleChangedCallbackCalled = false;
2133 gInputStyleMask = TextField::InputStyle::NONE;
2134 inputStyleChangedSignal = false;
2136 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 // Executes the idle callbacks added by the text control on the change of input style.
2143 application.RunIdles();
2145 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2146 DALI_TEST_CHECK(!inputStyleChangedSignal);
2148 gInputStyleChangedCallbackCalled = false;
2149 gInputStyleMask = TextField::InputStyle::NONE;
2150 inputStyleChangedSignal = false;
2152 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2158 // Executes the idle callbacks added by the text control on the change of input style.
2159 application.RunIdles();
2161 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2162 if(gInputStyleChangedCallbackCalled)
2164 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2165 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2168 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2169 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2171 DALI_TEST_CHECK(inputStyleChangedSignal);
2173 gInputStyleChangedCallbackCalled = false;
2174 gInputStyleMask = TextField::InputStyle::NONE;
2175 inputStyleChangedSignal = false;
2177 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2179 Property::Map fontStyleMapSet;
2180 fontStyleMapSet.Insert("weight", "thin");
2181 fontStyleMapSet.Insert("width", "condensed");
2182 fontStyleMapSet.Insert("slant", "italic");
2184 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2185 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2187 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2188 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2189 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2190 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2191 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2197 // Executes the idle callbacks added by the text control on the change of input style.
2198 application.RunIdles();
2200 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2201 DALI_TEST_CHECK(!inputStyleChangedSignal);
2203 // Create a tap event to touch the text field.
2204 TestGenerateTap(application, 63.0f, 25.0f, 700);
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Executes the idle callbacks added by the text control on the change of input style.
2211 application.RunIdles();
2213 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2214 if(gInputStyleChangedCallbackCalled)
2216 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2217 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2218 TextField::InputStyle::POINT_SIZE |
2219 TextField::InputStyle::FONT_STYLE |
2220 TextField::InputStyle::UNDERLINE |
2221 TextField::InputStyle::SHADOW |
2222 TextField::InputStyle::EMBOSS |
2223 TextField::InputStyle::OUTLINE),
2226 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2227 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2229 DALI_TEST_CHECK(inputStyleChangedSignal);
2234 int utcDaliTextFieldEvent01(void)
2236 ToolkitTestApplication application;
2237 tet_infoline(" utcDaliTextFieldEvent01");
2239 // Creates a tap event. After creating a tap event the text field should
2240 // have the focus and add text with key events should be possible.
2242 TextField field = TextField::New();
2243 DALI_TEST_CHECK(field);
2245 application.GetScene().Add(field);
2247 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2248 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2249 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // Avoid a crash when core load gl resources.
2256 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 // Add a key event but as the text field has not the focus it should do nothing.
2263 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2269 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2271 // Create a tap event to touch the text field.
2272 TestGenerateTap(application, 150.0f, 25.0f);
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 // Pressing delete key should be fine even if there is no text in TextField.
2279 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));
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2284 // Now the text field has the focus, so it can handle the key events.
2285 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2286 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2294 // Create a second text field and send key events to it.
2295 TextField field2 = TextField::New();
2297 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2298 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2299 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2300 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2302 application.GetScene().Add(field2);
2304 // Render and notify
2305 application.SendNotification();
2306 application.Render();
2308 // Create a tap event on the second text field.
2309 TestGenerateTap(application, 150.0f, 125.0f);
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // The second text field has the focus. It should handle the key events.
2316 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2317 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // Check the text has been added to the second text field.
2324 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2329 int utcDaliTextFieldEvent02(void)
2331 ToolkitTestApplication application;
2332 tet_infoline(" utcDaliTextFieldEvent02");
2334 // Checks if the right number of actors are created.
2336 TextField field = TextField::New();
2337 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2338 DALI_TEST_CHECK(field);
2339 LoadMarkerImages(application, field);
2341 application.GetScene().Add(field);
2343 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2344 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2345 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2347 // Avoid a crash when core load gl resources.
2348 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 // Check there are the expected number of children ( stencil ).
2355 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2357 Actor stencil = field.GetChildAt(0u);
2358 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2360 // Create a tap event to touch the text field.
2361 TestGenerateTap(application, 150.0f, 25.0f, 300);
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 Actor layer = field.GetChildAt(1u);
2368 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2369 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2371 // Now the text field has the focus, so it can handle the key events.
2372 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2373 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2375 // Render and notify
2376 application.SendNotification();
2377 application.Render();
2379 // Checks the cursor and the renderer have been created.
2380 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2381 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION); // The renderer
2383 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2384 DALI_TEST_CHECK(cursor);
2386 // The offscreen root actor has a container with all the actors which contain the text renderers.
2387 Actor container = stencil.GetChildAt(0u);
2388 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2390 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2391 DALI_TEST_CHECK(renderer);
2394 // Move the cursor and check the position changes.
2395 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2396 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2403 DALI_TEST_CHECK(position2.x < position1.x);
2405 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2412 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2414 // Move the cursor to the first position.
2415 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2416 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2424 // Send some taps and check the cursor positions.
2426 // Try to tap at the beginning.
2427 TestGenerateTap(application, 1.0f, 25.0f, 900);
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 // Cursor position should be the same than position1.
2434 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2436 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2438 // Tap away from the start position.
2439 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2447 DALI_TEST_CHECK(position6.x > position5.x);
2449 // Remove all the text.
2450 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2451 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2452 field.SetProperty(TextField::Property::TEXT, "");
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2458 // Cursor position should be the same than position2.
2459 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2461 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2463 // Should not be a renderer.
2464 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2466 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2467 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2468 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2470 application.SendNotification();
2471 application.Render();
2473 // There are renderer and decorator layer
2474 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2479 int utcDaliTextFieldEvent03(void)
2481 ToolkitTestApplication application;
2482 tet_infoline(" utcDaliTextFieldEvent03");
2484 // Checks if the highlight actor is created.
2486 TextField field = TextField::New();
2487 DALI_TEST_CHECK(field);
2489 application.GetScene().Add(field);
2491 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2492 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2493 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2494 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2495 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2497 // Avoid a crash when core load gl resources.
2498 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2499 LoadMarkerImages(application, field);
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Tap first to get the focus.
2506 TestGenerateTap(application, 3.0f, 25.0f);
2508 // Render and notify
2509 application.SendNotification();
2510 application.Render();
2512 // Double tap to select a word.
2513 TestGenerateTap(application, 3.0f, 25.0f);
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2520 Actor stencil = field.GetChildAt(0u);
2522 // The highlight actor is drawn first, so is the first actor in the list
2523 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2524 DALI_TEST_CHECK(highlight);
2526 // The offscreen root actor has a container with all the actors which contain the text renderers.
2527 Actor container = stencil.GetChildAt(1u);
2528 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2530 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2531 DALI_TEST_CHECK(renderer);
2537 int utcDaliTextFieldEvent04(void)
2539 ToolkitTestApplication application;
2540 tet_infoline(" utcDaliTextFieldEvent04");
2542 // Checks if the highlight actor is created.
2544 TextField field = TextField::New();
2545 DALI_TEST_CHECK(field);
2546 application.GetScene().Add(field);
2547 LoadMarkerImages(application, field);
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2553 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2554 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2555 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2556 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2558 // Avoid a crash when core load gl resources.
2559 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2560 // Render and notify
2561 application.SendNotification();
2562 application.Render();
2564 // Create a tap event to touch the text field.
2565 TestGenerateTap(application, 150.0f, 25.0f);
2566 // Render and notify
2567 application.SendNotification();
2568 application.Render();
2570 // Tap first to get the focus.
2571 TestGenerateTap(application, 1.0f, 25.0f);
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 // Double tap to select a word.
2578 TestGenerateTap(application, 1.0f, 25.0f);
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2585 TestGenerateTap(application, 0.0f, 40.0f);
2589 int utcDaliTextFieldEvent05(void)
2591 ToolkitTestApplication application;
2592 tet_infoline(" utcDaliTextFieldEvent05");
2594 // Checks dragging of cursor/grab handle
2596 TextField field = TextField::New();
2597 DALI_TEST_CHECK(field);
2598 application.GetScene().Add(field);
2599 LoadMarkerImages(application, field);
2600 // Render and notify
2601 application.SendNotification();
2602 application.Render();
2604 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2605 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2606 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2607 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2608 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2610 // Avoid a crash when core load gl resources.
2611 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2616 // Create a tap event to touch the text field.
2617 TestGenerateTap(application, 150.0f, 25.0f);
2618 // Render and notify
2619 application.SendNotification();
2620 application.Render();
2622 // Tap first to get the focus.
2623 TestGenerateTap(application, 1.0f, 25.0f);
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2629 // Double tap to select a word.
2630 TestGenerateTap(application, 1.0f, 25.0f);
2632 // Render and notify
2633 application.SendNotification();
2634 application.Render();
2636 Actor stencil = field.GetChildAt(1u);
2640 int utcDaliTextFieldEvent06(void)
2642 ToolkitTestApplication application;
2643 tet_infoline(" utcDaliTextFieldEvent06");
2645 // Checks Longpress when in edit mode
2647 TextField field = TextField::New();
2648 DALI_TEST_CHECK(field);
2649 application.GetScene().Add(field);
2650 LoadMarkerImages(application, field);
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2655 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2656 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2657 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2658 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2659 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2661 // Avoid a crash when core load gl resources.
2662 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 // Create a tap event to touch the text field.
2668 TestGenerateTap(application, 150.0f, 25.0f);
2669 // Render and notify
2670 application.SendNotification();
2671 application.Render();
2673 // Tap first to get the focus.
2674 TestGenerateTap(application, 1.0f, 25.0f);
2676 // Render and notify
2677 application.SendNotification();
2678 application.Render();
2681 TestGenerateLongPress(application, 1.0f, 25.0f);
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2690 int utcDaliTextFieldEvent07(void)
2692 ToolkitTestApplication application;
2693 tet_infoline(" utcDaliTextFieldEvent07");
2695 // Checks Longpress to start edit mode
2697 TextField field = TextField::New();
2698 DALI_TEST_CHECK(field);
2699 application.GetScene().Add(field);
2700 LoadMarkerImages(application, field);
2701 // Render and notify
2702 application.SendNotification();
2703 application.Render();
2705 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
2706 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2707 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2708 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2709 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2710 Property::Map propertyMap;
2711 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2712 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
2714 // Avoid a crash when core load gl resources.
2715 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2716 // Render and notify
2717 application.SendNotification();
2718 application.Render();
2721 TestGenerateLongPress(application, 1.0f, 25.0f);
2723 // Render and notify
2724 application.SendNotification();
2725 application.Render();
2730 int utcDaliTextFieldEvent08(void)
2732 ToolkitTestApplication application;
2733 tet_infoline(" utcDaliTextFieldEvent08");
2735 Dali::Clipboard clipboard = Clipboard::Get();
2736 clipboard.SetItem("testTextFieldEvent");
2738 // Checks Longpress when only place holder text
2740 TextField field = TextField::New();
2741 DALI_TEST_CHECK(field);
2742 application.GetScene().Add(field);
2743 LoadMarkerImages(application, field);
2744 // Render and notify
2745 application.SendNotification();
2746 application.Render();
2748 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
2749 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2750 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2751 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2752 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2754 // Avoid a crash when core load gl resources.
2755 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2756 // Render and notify
2757 application.SendNotification();
2758 application.Render();
2761 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
2763 // Render and notify
2764 application.SendNotification();
2765 application.Render();
2767 Wait(application, 500);
2769 TestEndLongPress(application, 1.0f, 25.0f, 520);
2772 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
2774 // Render and notify
2775 application.Render();
2777 Wait(application, 500);
2779 Integration::Scene stage = application.GetScene();
2780 Layer layer = stage.GetRootLayer();
2781 Actor actor = layer.FindChildByName("optionPaste");
2785 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
2786 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2787 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2789 Dali::Integration::TouchEvent event;
2790 event = Dali::Integration::TouchEvent();
2791 event.AddPoint(GetPointDownInside(position));
2792 application.ProcessEvent(event);
2794 event = Dali::Integration::TouchEvent();
2795 event.AddPoint(GetPointUpInside(position));
2796 application.ProcessEvent(event);
2798 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
2803 int utcDaliTextFieldEvent09(void)
2805 ToolkitTestApplication application;
2806 tet_infoline(" utcDaliTextFieldEvent09");
2808 TextField field = TextField::New();
2809 DALI_TEST_CHECK(field);
2810 application.GetScene().Add(field);
2811 LoadMarkerImages(application, field);
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2816 field.SetProperty(TextField::Property::TEXT, "Hello");
2817 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2818 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2819 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2820 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2822 // Avoid a crash when core load gl resources.
2823 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2825 // Create a tap event to touch the text field.
2826 TestGenerateTap(application, 150.0f, 25.0f);
2827 application.SendNotification();
2828 application.Render();
2831 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
2832 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2833 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2834 application.SendNotification();
2835 application.Render();
2837 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
2838 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
2839 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2840 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2841 application.SendNotification();
2842 application.Render();
2844 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
2845 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2846 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2847 for(unsigned int index = 0u; index < 5u; ++index)
2849 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2850 application.SendNotification();
2851 application.Render();
2854 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
2855 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
2856 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2857 for(unsigned int index = 0u; index < 5u; ++index)
2859 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2860 application.SendNotification();
2861 application.Render();
2864 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2865 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
2866 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2867 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2868 application.SendNotification();
2869 application.Render();
2870 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2871 application.SendNotification();
2872 application.Render();
2874 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
2875 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
2876 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2877 application.SendNotification();
2878 application.Render();
2880 Property::Map mapGet;
2881 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
2882 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
2883 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
2887 int utcDaliTextFieldStyleWhilstSelected(void)
2889 ToolkitTestApplication application;
2890 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2892 // Change font and styles whilst text is selected whilst word selected
2894 TextField field = TextField::New();
2895 DALI_TEST_CHECK(field);
2896 application.GetScene().Add(field);
2897 LoadMarkerImages(application, field);
2898 // Render and notify
2899 application.SendNotification();
2900 application.Render();
2902 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2903 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2904 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2905 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2906 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2908 // Avoid a crash when core load gl resources.
2909 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2910 // Render and notify
2911 application.SendNotification();
2912 application.Render();
2914 // Create a tap event to touch the text field.
2915 TestGenerateTap(application, 150.0f, 25.0f);
2916 // Render and notify
2917 application.SendNotification();
2918 application.Render();
2920 // Tap first to get the focus.
2921 TestGenerateTap(application, 1.0f, 25.0f);
2923 // Render and notify
2924 application.SendNotification();
2925 application.Render();
2927 // Double tap to select a word.
2928 TestGenerateTap(application, 1.0f, 25.0f);
2930 // Render and notify
2931 application.SendNotification();
2932 application.Render();
2934 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
2935 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
2937 Property::Map fontStyleMapSet;
2938 Property::Map fontStyleMapGet;
2940 fontStyleMapSet.Insert("weight", "bold");
2941 fontStyleMapSet.Insert("slant", "italic");
2942 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2944 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2945 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2946 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2948 fontStyleMapSet.Clear();
2949 fontStyleMapSet.Insert("width", "expanded");
2950 fontStyleMapSet.Insert("slant", "italic");
2951 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2953 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
2954 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2955 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2957 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
2958 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2960 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
2961 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
2963 fontStyleMapSet.Clear();
2964 fontStyleMapSet.Insert("weight", "bold");
2965 fontStyleMapSet.Insert("slant", "italic");
2967 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2969 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2970 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2971 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2973 fontStyleMapSet.Clear();
2974 fontStyleMapSet.Insert("width", "expanded");
2976 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
2978 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
2979 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2980 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2982 // Press Escape to increase coverage
2983 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2984 application.SendNotification();
2985 application.Render();
2987 DALI_TEST_CHECK(!field.HasKeyInputFocus());
2992 int utcDaliTextFieldEscKeyLoseFocus(void)
2994 ToolkitTestApplication application;
2995 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2997 // Creates a tap event. After creating a tap event the text field should
2998 // have the focus and add text with key events should be possible.
3000 TextField field = TextField::New();
3001 DALI_TEST_CHECK(field);
3003 application.GetScene().Add(field);
3005 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3006 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3007 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3009 // Avoid a crash when core load gl resources.
3010 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 // Add a key event but as the text field has not the focus it should do nothing.
3017 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3018 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3020 // Render and notify
3021 application.SendNotification();
3022 application.Render();
3024 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3026 // Create a tap event to touch the text field.
3027 TestGenerateTap(application, 150.0f, 25.0f);
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 // Now the text field has the focus, so it can handle the key events.
3034 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3035 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3036 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3037 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3039 // Render and notify
3040 application.SendNotification();
3041 application.Render();
3043 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3045 // Generate a Esc key event. The text field should lose the focus.
3046 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3047 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3049 // Render and notify
3050 application.SendNotification();
3051 application.Render();
3053 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3055 // No more text should be introduced
3056 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3057 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3059 // Render and notify
3060 application.SendNotification();
3061 application.Render();
3063 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3068 int utcDaliTextFieldSomeSpecialKeys(void)
3070 ToolkitTestApplication application;
3071 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");