2 * Copyright (c) 2024 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-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
26 #include <dali-toolkit/devel-api/text/rendering-backend.h>
27 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
28 #include <dali/devel-api/actors/actor-devel.h>
29 #include <dali/devel-api/adaptor-framework/key-devel.h>
30 #include <dali/devel-api/events/pan-gesture-devel.h>
31 #include <dali/devel-api/text-abstraction/font-client.h>
32 #include <dali/integration-api/events/key-event-integ.h>
33 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali/public-api/rendering/renderer.h>
35 #include "test-text-geometry-utils.h"
36 #include "toolkit-clipboard.h"
39 using namespace Toolkit;
41 void dali_textfield_startup(void)
43 test_return_value = TET_UNDEF;
46 void dali_textfield_cleanup(void)
48 test_return_value = TET_PASS;
53 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT = "text";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
57 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
58 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
59 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
60 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
61 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
62 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
63 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
64 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
65 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
66 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
67 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
68 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
71 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
74 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
75 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
76 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
83 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
84 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
85 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
86 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
87 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
88 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
89 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
90 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
92 const char* const PROPERTY_NAME_UNDERLINE = "underline";
93 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
94 const char* const PROPERTY_NAME_SHADOW = "shadow";
95 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
96 const char* const PROPERTY_NAME_EMBOSS = "emboss";
97 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
98 const char* const PROPERTY_NAME_OUTLINE = "outline";
99 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
100 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
101 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
103 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
104 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
105 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
106 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
107 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
116 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
118 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
119 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
121 const float RENDER_FRAME_INTERVAL = 16.66f;
123 const unsigned int DEFAULT_FONT_SIZE = 1152u;
124 const std::string DEFAULT_FONT_DIR("/resources/fonts");
126 const int KEY_RETURN_CODE = 36;
127 const int KEY_A_CODE = 38;
128 const int KEY_D_CODE = 40;
129 const int KEY_SHIFT_MODIFIER = 257;
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
133 static bool gSelectionChangedCallbackCalled;
134 static uint32_t oldSelectionStart;
135 static uint32_t oldSelectionEnd;
136 static bool gSelectionClearedCallbackCalled;
137 static bool gSelectionStartedCallbackCalled;
138 static bool gAnchorClickedCallBackCalled;
139 static bool gAnchorClickedCallBackNotCalled;
140 static bool gTextChangedCallBackCalled;
141 static bool gMaxCharactersCallBackCalled;
142 static bool gInputFilteredAcceptedCallbackCalled;
143 static bool gInputFilteredRejectedCallbackCalled;
144 static bool gInputStyleChangedCallbackCalled;
145 static bool gCursorPositionChangedCallbackCalled;
146 static uint32_t oldCursorPos;
147 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
149 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
151 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
152 Integration::ResourcePointer resource(bitmap);
153 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
156 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
160 LoadBitmapResource(app.GetPlatform(), width, height);
162 Property::Map propertyMap;
163 propertyMap["filename"] = "image.png";
164 propertyMap["width"] = width;
165 propertyMap["height"] = height;
166 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
167 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
168 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png");
173 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png");
177 * Simulate time passed by.
179 * @note this will always process at least 1 frame (1/60 sec)
181 * @param application Test application instance
182 * @param duration Time to pass in milliseconds.
183 * @return The actual time passed in milliseconds
185 static int Wait(ToolkitTestApplication& application, int duration = 0)
189 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
191 application.SendNotification();
192 application.Render(RENDER_FRAME_INTERVAL);
193 time += RENDER_FRAME_INTERVAL;
199 Dali::Integration::Point GetPointDownInside(Vector2& pos)
201 Dali::Integration::Point point;
202 point.SetState(PointState::DOWN);
203 point.SetScreenPosition(pos);
207 Dali::Integration::Point GetPointUpInside(Vector2& pos)
209 Dali::Integration::Point point;
210 point.SetState(PointState::UP);
211 point.SetScreenPosition(pos);
215 struct CallbackFunctor
217 CallbackFunctor(bool* callbackFlag)
218 : mCallbackFlag(callbackFlag)
224 *mCallbackFlag = true;
229 static void TestSelectionClearedCallback(TextField control)
231 tet_infoline(" TestSelectionClearedCallback");
233 gSelectionClearedCallbackCalled = true;
236 static void TestSelectionStartedCallback(TextField control)
238 tet_infoline(" TestSelectionStartedCallback");
240 gSelectionStartedCallbackCalled = true;
243 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
245 tet_infoline(" TestSelectionChangedCallback");
247 gSelectionChangedCallbackCalled = true;
248 oldSelectionStart = oldStart;
249 oldSelectionEnd = oldEnd;
252 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
254 tet_infoline(" TestAnchorClickedCallback");
256 gAnchorClickedCallBackNotCalled = false;
258 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
260 gAnchorClickedCallBackCalled = true;
264 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
266 tet_infoline(" TestCursorPositionChangedCallback");
268 gCursorPositionChangedCallbackCalled = true;
269 oldCursorPos = oldPos;
272 static void TestTextChangedCallback(TextField control)
274 tet_infoline(" TestTextChangedCallback");
276 gTextChangedCallBackCalled = true;
279 static void TestMaxLengthReachedCallback(TextField control)
281 tet_infoline(" TestMaxLengthReachedCallback");
283 gMaxCharactersCallBackCalled = true;
286 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
288 tet_infoline(" TestInputFilteredCallback");
290 if(type == Toolkit::InputFilter::Property::ACCEPTED)
292 gInputFilteredAcceptedCallbackCalled = true;
294 else if(type == Toolkit::InputFilter::Property::REJECTED)
296 gInputFilteredRejectedCallbackCalled = true;
300 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
302 tet_infoline(" TestInputStyleChangedCallback");
304 gInputStyleChangedCallbackCalled = true;
305 gInputStyleMask = mask;
308 // Generate a KeyEvent to send to Core.
309 Integration::KeyEvent GenerateKey(const std::string& keyName,
310 const std::string& logicalKey,
311 const std::string& keyString,
314 unsigned long timeStamp,
315 const Integration::KeyEvent::State& keyState,
316 const std::string& compose = "",
317 const std::string& deviceName = DEFAULT_DEVICE_NAME,
318 const Device::Class::Type& deviceClass = Device::Class::NONE,
319 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
321 return Integration::KeyEvent(keyName,
334 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
336 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
338 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
340 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
342 Property::Value* valueSet = NULL;
343 if(valueGet.first.type == Property::Key::INDEX)
345 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
349 // Get Key is a string so searching Set Map for a string key
350 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
355 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
357 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
360 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
362 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
365 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
367 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
370 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
372 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
375 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
377 Vector2 vector2Get = valueGet.second.Get<Vector2>();
378 Vector2 vector2Set = valueSet->Get<Vector2>();
379 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
382 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
384 Vector4 vector4Get = valueGet.second.Get<Vector4>();
385 Vector4 vector4Set = valueSet->Get<Vector4>();
386 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);
392 if(valueGet.first.type == Property::Key::INDEX)
394 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
398 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
408 // Stores data that is populated in the callback and will be read by the test cases
412 : functorCalled(false),
413 voidFunctorCalled(false),
420 functorCalled = false;
421 voidFunctorCalled = false;
423 receivedGesture.Reset();
429 bool voidFunctorCalled;
430 PanGesture receivedGesture;
434 // Functor that sets the data when called
435 struct GestureReceivedFunctor
437 GestureReceivedFunctor(SignalData& data)
442 void operator()(Actor actor, const PanGesture& pan)
444 signalData.functorCalled = true;
445 signalData.receivedGesture = pan;
446 signalData.pannedActor = actor;
451 signalData.voidFunctorCalled = true;
454 SignalData& signalData;
459 int UtcDaliToolkitTextFieldConstructorP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
464 DALI_TEST_CHECK(!textField);
468 int UtcDaliToolkitTextFieldNewP(void)
470 ToolkitTestApplication application;
471 tet_infoline(" UtcDaliToolkitTextFieldNewP");
472 TextField textField = TextField::New();
473 DALI_TEST_CHECK(textField);
477 int UtcDaliToolkitTextFieldDownCastP(void)
479 ToolkitTestApplication application;
480 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
481 TextField textField1 = TextField::New();
482 BaseHandle object(textField1);
484 TextField textField2 = TextField::DownCast(object);
485 DALI_TEST_CHECK(textField2);
487 TextField textField3 = DownCast<TextField>(object);
488 DALI_TEST_CHECK(textField3);
492 int UtcDaliToolkitTextFieldDownCastN(void)
494 ToolkitTestApplication application;
495 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
496 BaseHandle uninitializedObject;
497 TextField textField1 = TextField::DownCast(uninitializedObject);
498 DALI_TEST_CHECK(!textField1);
500 TextField textField2 = DownCast<TextField>(uninitializedObject);
501 DALI_TEST_CHECK(!textField2);
505 int UtcDaliToolkitTextFieldCopyConstructorP(void)
507 ToolkitTestApplication application;
508 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
509 TextField textField = TextField::New();
510 textField.SetProperty(TextField::Property::TEXT, "Test");
512 TextField copy(textField);
513 DALI_TEST_CHECK(copy);
514 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
518 int UtcDaliTextFieldMoveConstructor(void)
520 ToolkitTestApplication application;
522 TextField textField = TextField::New();
523 textField.SetProperty(TextEditor::Property::TEXT, "Test");
524 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
526 TextField moved = std::move(textField);
527 DALI_TEST_CHECK(moved);
528 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
529 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
530 DALI_TEST_CHECK(!textField);
535 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
539 TextField textField = TextField::New();
540 textField.SetProperty(TextField::Property::TEXT, "Test");
542 TextField copy = textField;
543 DALI_TEST_CHECK(copy);
544 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
548 int UtcDaliTextFieldMoveAssignment(void)
550 ToolkitTestApplication application;
552 TextField textField = TextField::New();
553 textField.SetProperty(TextEditor::Property::TEXT, "Test");
554 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
557 moved = std::move(textField);
558 DALI_TEST_CHECK(moved);
559 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
560 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
561 DALI_TEST_CHECK(!textField);
566 int UtcDaliTextFieldNewP(void)
568 ToolkitTestApplication application;
569 tet_infoline(" UtcDaliToolkitTextFieldNewP");
570 TextField textField = TextField::New();
571 DALI_TEST_CHECK(textField);
575 // Positive test case for a method
576 int UtcDaliTextFieldGetPropertyP(void)
578 ToolkitTestApplication application;
579 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
580 TextField field = TextField::New();
581 DALI_TEST_CHECK(field);
583 // Check Property Indices are correct
584 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
585 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
586 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
597 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
598 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
599 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
600 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
601 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
602 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
603 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
604 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
605 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
606 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
607 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
608 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
609 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
610 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
611 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
612 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
613 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
614 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
615 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
616 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
617 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
618 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
619 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
620 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
621 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
622 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
623 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
624 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
625 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
626 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
627 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
628 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
629 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
630 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
631 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
632 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
633 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
634 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
635 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
636 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
637 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
638 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
639 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
640 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
641 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
642 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
643 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
644 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
645 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
650 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
653 Property::Map imageMap;
654 imageMap[mapKey] = mapValue;
656 field.SetProperty(property, imageMap);
657 Property::Value propValue = field.GetProperty(property);
658 Property::Map* resultMap = propValue.GetMap();
660 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
668 // Positive test case for a method
669 int UtcDaliTextFieldSetPropertyP(void)
671 ToolkitTestApplication application;
672 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
673 TextField field = TextField::New();
674 DALI_TEST_CHECK(field);
675 application.GetScene().Add(field);
677 // Note - we can't check the defaults since the stylesheets are platform-specific
679 // Check the render backend property.
680 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
681 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
683 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
684 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
686 // Check text property.
687 field.SetProperty(TextField::Property::TEXT, "Setting Text");
688 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
690 // Check placeholder text properties.
691 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
692 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
694 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
695 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
697 // Check font properties.
698 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
699 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
701 Property::Map fontStyleMapSet;
702 Property::Map fontStyleMapGet;
703 Property::Value* slantValue = NULL;
705 fontStyleMapSet.Insert("weight", "bold");
706 fontStyleMapSet.Insert("width", "condensed");
707 fontStyleMapSet.Insert("slant", "italic");
708 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
710 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
711 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
712 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
714 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
715 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
717 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
718 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
719 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
721 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
722 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
723 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
726 fontStyleMapSet.Clear();
727 fontStyleMapSet.Insert("weight", "normal");
728 fontStyleMapSet.Insert("slant", "oblique");
729 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
731 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
732 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
733 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
735 fontStyleMapSet.Clear();
736 fontStyleMapSet.Insert("slant", "roman");
737 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
738 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
740 // Replace 'roman' for 'normal'.
741 slantValue = fontStyleMapGet.Find("slant");
742 if(NULL != slantValue)
744 if("normal" == slantValue->Get<std::string>())
746 fontStyleMapGet["slant"] = "roman";
749 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
750 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
752 fontStyleMapSet.Clear();
754 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
755 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
756 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
757 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
759 // Check that the MAX_LENGTH property can be correctly set
760 const int maxNumberOfCharacters = 20;
761 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
762 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
764 // Check exceed policy
765 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
766 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
767 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
768 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
770 // Check that the Alignment properties can be correctly set
771 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
772 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
773 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
774 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
776 // Check text's color property
777 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
778 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
780 // Check placeholder text's color property.
781 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
782 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
784 // Check cursor properties
785 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
786 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
787 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
788 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
790 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
791 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
792 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
793 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
794 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
795 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
796 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
797 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
799 // Check scroll properties.
800 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
801 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
802 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
803 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
805 // Check handle images
806 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
807 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
808 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
809 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
810 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
812 // Check handle images
813 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
814 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
815 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
816 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
817 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
818 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
820 // Check the selection popup style
821 const Vector2 popupMaxSize(200.0f, 300.0f);
822 const Vector2 optionDividerSize(30.0f, 5.0f);
823 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
824 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
826 Property::Map selectionPopupStyle;
827 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
828 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
829 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
830 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
832 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
834 Property::Map selectionPopupStyleGet;
835 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
837 Property::Value* popupValue;
838 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
839 DALI_TEST_CHECK(NULL != popupValue);
842 Vector2 popupMaxSizeGet;
843 popupValue->Get(popupMaxSizeGet);
844 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
847 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
848 DALI_TEST_CHECK(NULL != popupValue);
851 Vector2 optionDividerSizeGet;
852 popupValue->Get(optionDividerSizeGet);
853 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
856 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
857 DALI_TEST_CHECK(NULL != popupValue);
860 Vector4 optionDividerPaddingGet;
861 popupValue->Get(optionDividerPaddingGet);
862 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
865 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
866 DALI_TEST_CHECK(NULL != popupValue);
869 Vector4 labelPaddingGet;
870 popupValue->Get(labelPaddingGet);
871 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
874 // Reset selection popup style
875 selectionPopupStyle.Clear();
876 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
878 // Check the highlight color
879 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
880 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
882 // Decoration bounding box
883 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
884 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
886 // Check the input method setting
887 Property::Map propertyMap;
888 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
889 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
890 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
891 int inputVariation = 1;
892 propertyMap["PANEL_LAYOUT"] = panelLayout;
893 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
894 propertyMap["BUTTON_ACTION"] = buttonAction;
895 propertyMap["VARIATION"] = inputVariation;
896 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
898 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
900 DALI_TEST_CHECK(value.Get(map));
903 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
904 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
907 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
908 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
911 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
912 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
915 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
916 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
918 // Check input color property.
919 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
920 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
922 // Check the enable markup property.
923 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
924 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
925 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
927 // Check input font properties.
928 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
929 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
931 fontStyleMapSet.Clear();
932 fontStyleMapSet.Insert("weight", "bold");
933 fontStyleMapSet.Insert("width", "condensed");
934 fontStyleMapSet.Insert("slant", "italic");
936 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
937 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
938 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
939 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
941 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
942 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
944 // Reset input font style.
945 fontStyleMapSet.Clear();
946 fontStyleMapSet.Insert("weight", "normal");
947 fontStyleMapSet.Insert("slant", "oblique");
949 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
950 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
951 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
952 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
954 fontStyleMapSet.Clear();
955 fontStyleMapSet.Insert("slant", "roman");
957 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
958 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
960 // Replace 'roman' for 'normal'.
961 slantValue = fontStyleMapGet.Find("slant");
962 if(NULL != slantValue)
964 if("normal" == slantValue->Get<std::string>())
966 fontStyleMapGet["slant"] = "roman";
969 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
970 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
972 fontStyleMapSet.Clear();
974 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
975 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
976 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
977 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
979 Property::Map strikethroughMapSet;
980 Property::Map strikethroughMapGet;
982 strikethroughMapSet.Insert("enable", true);
983 strikethroughMapSet.Insert("color", Color::RED);
984 strikethroughMapSet.Insert("height", 2.0f);
986 // Check the strikethrough property
987 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
989 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
990 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
991 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
993 // Check the input strikethrough property
994 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
995 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
997 Property::Map underlineMapSet;
998 Property::Map underlineMapGet;
1000 underlineMapSet.Insert("enable", true);
1001 underlineMapSet.Insert("color", Color::RED);
1002 underlineMapSet.Insert("height", 1);
1003 underlineMapSet.Insert("type", Text::Underline::SOLID);
1004 underlineMapSet.Insert("dashWidth", 2);
1005 underlineMapSet.Insert("dashGap", 1);
1007 // Check the underline property
1008 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1010 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1011 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1012 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1014 // Render and notify
1015 application.SendNotification();
1016 application.Render();
1018 underlineMapSet.Clear();
1019 underlineMapGet.Clear();
1021 underlineMapSet.Insert("enable", true);
1022 underlineMapSet.Insert("color", Color::BLUE);
1023 underlineMapSet.Insert("height", 1);
1024 underlineMapSet.Insert("type", Text::Underline::DASHED);
1025 underlineMapSet.Insert("dashWidth", 4);
1026 underlineMapSet.Insert("dashGap", 2);
1028 // Check the dashed underline property
1029 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1031 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1032 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1033 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1035 // Render and notify
1036 application.SendNotification();
1037 application.Render();
1039 underlineMapSet.Clear();
1040 underlineMapGet.Clear();
1042 underlineMapSet.Insert("enable", true);
1043 underlineMapSet.Insert("color", Color::BLUE);
1044 underlineMapSet.Insert("height", 4);
1045 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
1046 underlineMapSet.Insert("dashWidth", 4);
1047 underlineMapSet.Insert("dashGap", 2);
1049 // Check the dashed underline property
1050 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1052 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1053 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1054 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1056 // Render and notify
1057 application.SendNotification();
1058 application.Render();
1060 underlineMapSet.Clear();
1061 underlineMapGet.Clear();
1063 // Check the input underline property
1064 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1065 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1067 // Check the shadow property
1068 Property::Map shadowMapSet;
1069 Property::Map shadowMapGet;
1071 shadowMapSet.Insert("color", Color::GREEN);
1072 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1073 shadowMapSet.Insert("blurRadius", 3.0f);
1075 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1077 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1078 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1079 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1081 // Check the input shadow property
1082 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1083 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1085 // Check the emboss property
1086 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1087 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1089 // Check the input emboss property
1090 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1091 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1093 // Check the outline property
1095 // Test string type first
1096 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1097 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1098 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1100 // Then test the property map type
1101 Property::Map outlineMapSet;
1102 Property::Map outlineMapGet;
1104 outlineMapSet["color"] = Color::RED;
1105 outlineMapSet["width"] = 2.0f;
1107 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1109 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1110 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1111 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1113 // Check the input outline property
1114 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1115 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1117 // Check the hidden input settings property
1118 Property::Map hiddenMapSet;
1119 Property::Map hiddenMapGet;
1120 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1121 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1122 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1123 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1124 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1126 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1127 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1128 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1130 // Check the pixel size of font
1131 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1132 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1134 // Check the enable selection property
1135 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1136 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1138 // Check the placeholder property with pixel size
1139 Property::Map placeholderPixelSizeMapSet;
1140 Property::Map placeholderPixelSizeMapGet;
1141 Property::Map placeholderFontstyleMap;
1142 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1143 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1144 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1145 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1146 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1147 placeholderPixelSizeMapSet["ellipsis"] = true;
1149 placeholderFontstyleMap.Insert("weight", "bold");
1150 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1151 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1153 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1154 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1156 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1157 Property::Map placeholderConversionMap;
1158 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1159 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1160 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1161 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1162 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1163 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1165 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1167 // Check the placeholder property with point size
1168 Property::Map placeholderMapSet;
1169 Property::Map placeholderMapGet;
1170 placeholderMapSet["text"] = "Setting Placeholder Text";
1171 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1172 placeholderMapSet["color"] = Color::RED;
1173 placeholderMapSet["fontFamily"] = "Arial";
1174 placeholderMapSet["pointSize"] = 12.0f;
1175 placeholderMapSet["ellipsis"] = false;
1177 // Check the placeholder font style property
1178 placeholderFontstyleMap.Clear();
1180 placeholderFontstyleMap.Insert("weight", "bold");
1181 placeholderFontstyleMap.Insert("width", "condensed");
1182 placeholderFontstyleMap.Insert("slant", "italic");
1183 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1184 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1186 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1187 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1189 placeholderConversionMap.Clear();
1190 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1191 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1192 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1193 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1194 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1195 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1197 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1199 // Reset font style.
1200 placeholderFontstyleMap.Clear();
1201 placeholderFontstyleMap.Insert("weight", "normal");
1202 placeholderFontstyleMap.Insert("slant", "oblique");
1203 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1204 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1206 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1207 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1209 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1210 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1212 placeholderFontstyleMap.Clear();
1213 placeholderFontstyleMap.Insert("slant", "roman");
1214 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1215 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1217 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1219 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1221 placeholderFontstyleMap.Clear();
1222 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1223 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1225 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1226 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1227 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1229 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1231 // Check the ellipsis property
1232 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1233 field.SetProperty(TextField::Property::ELLIPSIS, true);
1234 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1236 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1237 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1239 // Test the ENABLE_GRAB_HANDLE_POPUP property
1240 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1241 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1242 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1244 // Check the background property
1245 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1246 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1248 //Check handle color
1249 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1250 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1252 // Check the input filter property
1253 Property::Map inputFilterMapSet;
1254 Property::Map inputFilterMapGet;
1255 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1256 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1258 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1260 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1261 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1264 inputFilterMapSet.Clear();
1265 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1267 application.SendNotification();
1268 application.Render();
1273 // Positive Atlas Text Renderer test
1274 int utcDaliTextFieldAtlasRenderP(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1278 StyleManager styleManager = StyleManager::Get();
1279 styleManager.ApplyDefaultTheme();
1280 TextField field = TextField::New();
1281 DALI_TEST_CHECK(field);
1283 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1285 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1287 application.GetScene().Add(field);
1291 // Render some text with the shared atlas backend
1292 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1293 application.SendNotification();
1294 application.Render();
1298 tet_result(TET_FAIL);
1303 // Positive test for the anchorClicked signal.
1304 int utcDaliTextFieldAnchorClicked01(void)
1306 ToolkitTestApplication application;
1307 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1308 TextField field = TextField::New();
1309 DALI_TEST_CHECK(field);
1311 application.GetScene().Add(field);
1313 // connect to the anchor clicked signal.
1314 ConnectionTracker* testTracker = new ConnectionTracker();
1315 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1316 bool anchorClickedSignal = false;
1317 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1319 gAnchorClickedCallBackCalled = false;
1320 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1321 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1322 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1323 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1324 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1326 application.SendNotification();
1327 application.Render();
1328 field.SetKeyInputFocus();
1330 // Create a tap event to touch the text field.
1331 TestGenerateTap(application, 5.0f, 25.0f);
1332 application.SendNotification();
1333 application.Render();
1335 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1336 DALI_TEST_CHECK(anchorClickedSignal);
1338 gAnchorClickedCallBackNotCalled = true;
1339 // Tap the outside of anchor, callback should not be called.
1340 TestGenerateTap(application, 150.f, 100.f);
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1349 // Positive test for the anchorClicked signal.
1350 int utcDaliTextFieldAnchorClicked02(void)
1352 ToolkitTestApplication application;
1353 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1354 TextField field = TextField::New();
1355 DALI_TEST_CHECK(field);
1357 application.GetScene().Add(field);
1359 // connect to the anchor clicked signal.
1360 ConnectionTracker* testTracker = new ConnectionTracker();
1361 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1362 bool anchorClickedSignal = false;
1363 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1365 gAnchorClickedCallBackCalled = false;
1366 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1367 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1368 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1369 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1370 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1372 application.SendNotification();
1373 application.Render();
1374 field.SetKeyInputFocus();
1376 // Avoid a crash when core load gl resources.
1377 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1379 // Create a tap event to touch the text field.
1380 TestGenerateTap(application, 30.0f, 25.0f, 100);
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1385 DALI_TEST_CHECK(anchorClickedSignal);
1387 // For coverage InsertTextAnchor, RemoveTextAnchor
1388 // first index insert
1389 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1390 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1391 application.SendNotification();
1392 application.Render();
1394 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1395 application.SendNotification();
1396 application.Render();
1398 gAnchorClickedCallBackCalled = false;
1399 // Create a tap event to touch the text field.
1400 TestGenerateTap(application, 30.0f, 25.0f, 700);
1401 application.SendNotification();
1402 field.SetKeyInputFocus();
1404 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1406 // last index insert
1407 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1408 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1409 application.SendNotification();
1410 application.Render();
1412 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1413 application.SendNotification();
1414 application.Render();
1416 gAnchorClickedCallBackCalled = false;
1417 // Create a tap event to touch the text field.
1418 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1419 application.SendNotification();
1420 field.SetKeyInputFocus();
1422 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1425 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1426 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1427 application.SendNotification();
1428 application.Render();
1430 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1431 application.SendNotification();
1432 application.Render();
1434 gAnchorClickedCallBackCalled = false;
1435 // Create a tap event to touch the text field.
1436 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1437 application.SendNotification();
1438 field.SetKeyInputFocus();
1440 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1442 // first index remove
1443 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1444 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1445 application.SendNotification();
1446 application.Render();
1448 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1449 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));
1450 application.SendNotification();
1451 application.Render();
1453 gAnchorClickedCallBackCalled = false;
1454 // Create a tap event to touch the text field.
1455 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1456 application.SendNotification();
1457 field.SetKeyInputFocus();
1459 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1461 // last index remove
1462 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1463 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1464 application.SendNotification();
1465 application.Render();
1467 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1468 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));
1469 application.SendNotification();
1470 application.Render();
1472 gAnchorClickedCallBackCalled = false;
1473 // Create a tap event to touch the text field.
1474 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1475 application.SendNotification();
1476 application.Render();
1478 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1481 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1482 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1483 application.SendNotification();
1484 application.Render();
1486 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1487 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));
1488 application.SendNotification();
1489 application.Render();
1491 gAnchorClickedCallBackCalled = false;
1492 // Create a tap event to touch the text field.
1493 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1494 application.SendNotification();
1495 application.Render();
1497 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1499 // 0 ~ 1 index remove
1500 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1501 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1502 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1503 application.SendNotification();
1504 application.Render();
1506 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1507 application.SendNotification();
1508 application.Render();
1510 gAnchorClickedCallBackCalled = false;
1511 // Create a tap event to touch the text field.
1512 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1513 application.SendNotification();
1514 application.Render();
1516 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1518 // 1 ~ 3 index remove
1519 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1520 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1521 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1522 application.SendNotification();
1523 application.Render();
1525 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1526 application.SendNotification();
1527 application.Render();
1529 gAnchorClickedCallBackCalled = false;
1530 // Create a tap event to touch the text field.
1531 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1532 application.SendNotification();
1533 application.Render();
1535 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1537 // 3 ~ 4 index remove
1538 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1539 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1540 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1541 application.SendNotification();
1542 application.Render();
1544 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1545 application.SendNotification();
1546 application.Render();
1548 gAnchorClickedCallBackCalled = false;
1549 // Create a tap event to touch the text field.
1550 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1556 // Remove front of anchor
1557 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1558 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1559 application.SendNotification();
1560 application.Render();
1562 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1563 application.SendNotification();
1564 application.Render();
1566 // Remove whole text
1567 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1568 DevelTextField::SelectWholeText(field);
1569 application.SendNotification();
1570 application.Render();
1572 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1573 application.SendNotification();
1574 application.Render();
1576 // Remove all with backspace
1577 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1578 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1579 application.SendNotification();
1580 application.Render();
1582 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1583 application.SendNotification();
1584 application.Render();
1586 // Remove all with delete
1587 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1588 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1589 application.SendNotification();
1590 application.Render();
1592 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));
1593 application.SendNotification();
1594 application.Render();
1599 // Positive test for the textChanged signal.
1600 int utcDaliTextFieldTextChangedP(void)
1602 ToolkitTestApplication application;
1603 tet_infoline(" utcDaliTextFieldTextChangedP");
1604 TextField field = TextField::New();
1605 DALI_TEST_CHECK(field);
1607 application.GetScene().Add(field);
1609 // connect to the text changed signal.
1610 ConnectionTracker* testTracker = new ConnectionTracker();
1611 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1612 bool textChangedSignal = false;
1613 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1615 gTextChangedCallBackCalled = false;
1616 field.SetProperty(TextField::Property::TEXT, "ABC");
1617 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1618 DALI_TEST_CHECK(textChangedSignal);
1620 application.SendNotification();
1621 field.SetKeyInputFocus();
1623 gTextChangedCallBackCalled = false;
1624 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1625 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1628 field.SetProperty(TextField::Property::TEXT, "");
1630 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1631 gTextChangedCallBackCalled = false;
1632 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1633 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1635 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1636 gTextChangedCallBackCalled = false;
1637 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1638 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1643 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1645 ToolkitTestApplication application;
1646 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1647 TextField field = TextField::New();
1648 DALI_TEST_CHECK(field);
1650 application.GetScene().Add(field);
1652 // connect to the text changed signal.
1653 ConnectionTracker* testTracker = new ConnectionTracker();
1654 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1655 bool textChangedSignal = false;
1656 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1658 // get InputMethodContext
1660 InputMethodContext::EventData imfEvent;
1661 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1663 field.SetKeyInputFocus();
1664 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1667 gTextChangedCallBackCalled = false;
1668 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1669 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1670 application.SendNotification();
1671 application.Render();
1672 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1673 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1675 gTextChangedCallBackCalled = false;
1676 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1677 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1678 application.SendNotification();
1679 application.Render();
1680 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1681 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1683 gTextChangedCallBackCalled = false;
1684 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1685 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1686 application.SendNotification();
1687 application.Render();
1688 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1689 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1691 gTextChangedCallBackCalled = false;
1692 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1693 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1694 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1696 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1697 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1698 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1700 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1701 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1702 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1707 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1712 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1714 ToolkitTestApplication application;
1715 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1716 TextField field = TextField::New();
1717 DALI_TEST_CHECK(field);
1719 field.SetProperty(TextField::Property::TEXT, "Hello world");
1721 application.GetScene().Add(field);
1723 // connect to the selection changed signal.
1724 ConnectionTracker* testTracker = new ConnectionTracker();
1725 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1726 bool selectionChangedSignal = false;
1727 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1729 // get InputMethodContext
1731 InputMethodContext::EventData imfEvent;
1732 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1734 field.SetKeyInputFocus();
1735 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1738 gSelectionChangedCallbackCalled = false;
1739 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1740 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1741 application.SendNotification();
1742 application.Render();
1743 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1745 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1746 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1751 int utcDaliTextFieldPositionWithInputMethodContext(void)
1753 ToolkitTestApplication application;
1754 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1755 TextField field = TextField::New();
1756 DALI_TEST_CHECK(field);
1758 field.SetProperty(TextField::Property::TEXT, "Hello world");
1760 application.GetScene().Add(field);
1762 // connect to the selection changed signal.
1763 ConnectionTracker* testTracker = new ConnectionTracker();
1764 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1765 bool cursorPositionChangedSignal = false;
1766 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1768 // get InputMethodContext
1770 InputMethodContext::EventData imfEvent;
1771 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1773 field.SetKeyInputFocus();
1774 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1777 gCursorPositionChangedCallbackCalled = false;
1778 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1779 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1780 application.SendNotification();
1781 application.Render();
1782 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1784 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1789 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1791 ToolkitTestApplication application;
1792 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1793 TextField field = TextField::New();
1794 DALI_TEST_CHECK(field);
1796 Property::Map inputFilter;
1797 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1798 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1800 // Set input filter to TextField.
1801 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1803 application.GetScene().Add(field);
1805 // connect to the input filtered signal.
1806 ConnectionTracker* testTracker = new ConnectionTracker();
1807 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1808 bool inputFilteredSignal = false;
1809 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1811 // get InputMethodContext
1813 InputMethodContext::EventData imfEvent;
1814 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1816 field.SetKeyInputFocus();
1817 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1820 gInputFilteredAcceptedCallbackCalled = false;
1821 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1822 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1823 application.SendNotification();
1824 application.Render();
1825 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1826 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1828 inputFilteredSignal = false;
1829 gInputFilteredRejectedCallbackCalled = false;
1830 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1831 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1832 application.SendNotification();
1833 application.Render();
1834 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1835 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1840 // Negative test for the textChanged signal.
1841 int utcDaliTextFieldTextChangedN(void)
1843 ToolkitTestApplication application;
1844 tet_infoline(" utcDaliTextFieldTextChangedN");
1845 TextField field = TextField::New();
1846 DALI_TEST_CHECK(field);
1848 application.GetScene().Add(field);
1850 // connect to the text changed signal.
1851 ConnectionTracker* testTracker = new ConnectionTracker();
1852 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1853 bool textChangedSignal = false;
1854 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1856 gTextChangedCallBackCalled = false;
1857 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1858 application.SendNotification();
1859 application.Render();
1860 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1861 DALI_TEST_CHECK(!textChangedSignal);
1866 // Positive test for Max Characters reached signal.
1867 int utcDaliTextFieldMaxCharactersReachedP(void)
1869 ToolkitTestApplication application;
1870 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1871 TextField field = TextField::New();
1872 DALI_TEST_CHECK(field);
1874 application.GetScene().Add(field);
1876 const int maxNumberOfCharacters = 1;
1877 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1879 field.SetKeyInputFocus();
1881 // connect to the text changed signal.
1882 ConnectionTracker* testTracker = new ConnectionTracker();
1883 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1884 bool maxLengthReachedSignal = false;
1885 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1887 gMaxCharactersCallBackCalled = false;
1889 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1890 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1892 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1893 DALI_TEST_CHECK(maxLengthReachedSignal);
1898 // Negative test for Max Characters reached signal.
1899 int utcDaliTextFieldMaxCharactersReachedN(void)
1901 ToolkitTestApplication application;
1902 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1903 TextField field = TextField::New();
1904 DALI_TEST_CHECK(field);
1906 application.GetScene().Add(field);
1908 const int maxNumberOfCharacters = 3;
1909 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1911 field.SetKeyInputFocus();
1913 // connect to the text changed signal.
1914 ConnectionTracker* testTracker = new ConnectionTracker();
1915 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1916 bool maxLengthReachedSignal = false;
1917 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1919 gMaxCharactersCallBackCalled = false;
1921 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1922 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1924 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1925 DALI_TEST_CHECK(!maxLengthReachedSignal);
1927 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1929 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1930 DALI_TEST_CHECK(!maxLengthReachedSignal);
1935 // Positive test for Input Filtered signal.
1936 int utcDaliTextFieldInputFilteredP(void)
1938 ToolkitTestApplication application;
1939 tet_infoline(" utcDaliTextFieldInputFilteredP");
1940 TextField field = TextField::New();
1941 DALI_TEST_CHECK(field);
1943 application.GetScene().Add(field);
1945 Property::Map inputFilter;
1947 // Only digit is accepted.
1948 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1950 // Set input filter to TextField.
1951 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1953 field.SetKeyInputFocus();
1955 // connect to the input filtered signal.
1956 ConnectionTracker* testTracker = new ConnectionTracker();
1957 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1958 bool inputFilteredSignal = false;
1959 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1961 gInputFilteredAcceptedCallbackCalled = false;
1963 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1965 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1966 DALI_TEST_CHECK(inputFilteredSignal);
1968 // Word is rejected.
1969 inputFilter[InputFilter::Property::ACCEPTED] = "";
1970 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1972 // Set input filter to TextField.
1973 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1975 field.SetKeyInputFocus();
1977 inputFilteredSignal = false;
1978 gInputFilteredRejectedCallbackCalled = false;
1980 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1982 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1983 DALI_TEST_CHECK(inputFilteredSignal);
1988 // Negative test for Input Filtered signal.
1989 int utcDaliTextFieldInputFilteredN(void)
1991 ToolkitTestApplication application;
1992 tet_infoline(" utcDaliTextFieldInputFilteredP");
1993 TextField field = TextField::New();
1994 DALI_TEST_CHECK(field);
1996 application.GetScene().Add(field);
1998 Property::Map inputFilter;
2000 // Only word is accepted.
2001 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2003 // Set input filter to TextField.
2004 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2006 field.SetKeyInputFocus();
2008 // connect to the input filtered signal.
2009 ConnectionTracker* testTracker = new ConnectionTracker();
2010 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2011 bool inputFilteredSignal = false;
2012 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2014 gInputFilteredAcceptedCallbackCalled = false;
2016 // Key a, d should not be filtered.
2017 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2018 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2019 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2020 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2022 // Backspace, Delete should not be filtered.
2023 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2024 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));
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2030 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2031 DALI_TEST_CHECK(!inputFilteredSignal);
2033 // Digit is rejected.
2034 inputFilter[InputFilter::Property::ACCEPTED] = "";
2035 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2037 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2039 field.SetKeyInputFocus();
2041 inputFilteredSignal = false;
2042 gInputFilteredRejectedCallbackCalled = false;
2044 // Key a, d should not be filtered.
2045 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2046 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2047 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2048 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2050 // Backspace, Delete should not be filtered.
2051 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2052 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));
2054 // Render and notify
2055 application.SendNotification();
2056 application.Render();
2058 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2059 DALI_TEST_CHECK(!inputFilteredSignal);
2064 int utcDaliTextFieldInputStyleChanged01(void)
2066 // The text-field emits signals when the input style changes. These changes of style are
2067 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2068 // can't be emitted during the size negotiation as the callbacks may update the UI.
2069 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2070 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2071 ToolkitTestApplication application;
2072 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2076 char* pathNamePtr = get_current_dir_name();
2077 const std::string pathName(pathNamePtr);
2080 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2081 fontClient.SetDpi(93u, 93u);
2083 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2084 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2086 TextField field = TextField::New();
2087 DALI_TEST_CHECK(field);
2089 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2090 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2091 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2093 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2094 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2096 // connect to the text changed signal.
2097 ConnectionTracker* testTracker = new ConnectionTracker();
2098 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2099 bool inputStyleChangedSignal = false;
2100 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2102 application.GetScene().Add(field);
2104 // Render and notify
2105 application.SendNotification();
2106 application.Render();
2108 // Executes the idle callbacks added by the text control on the change of input style.
2109 application.RunIdles();
2111 gInputStyleChangedCallbackCalled = false;
2112 gInputStyleMask = TextField::InputStyle::NONE;
2113 inputStyleChangedSignal = false;
2115 // Create a tap event to touch the text field.
2116 TestGenerateTap(application, 18.0f, 25.0f);
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Executes the idle callbacks added by the text control on the change of input style.
2123 application.RunIdles();
2125 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2126 if(gInputStyleChangedCallbackCalled)
2128 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2130 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2131 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2133 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2134 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2136 DALI_TEST_CHECK(inputStyleChangedSignal);
2138 gInputStyleChangedCallbackCalled = false;
2139 gInputStyleMask = TextField::InputStyle::NONE;
2140 inputStyleChangedSignal = false;
2142 // Create a tap event to touch the text field.
2143 TestGenerateTap(application, 30.0f, 25.0f);
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 // Executes the idle callbacks added by the text control on the change of input style.
2150 application.RunIdles();
2152 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2153 DALI_TEST_CHECK(!inputStyleChangedSignal);
2155 gInputStyleChangedCallbackCalled = false;
2156 gInputStyleMask = TextField::InputStyle::NONE;
2157 inputStyleChangedSignal = false;
2159 // Create a tap event to touch the text field.
2160 TestGenerateTap(application, 43.0f, 25.0f);
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Executes the idle callbacks added by the text control on the change of input style.
2167 application.RunIdles();
2169 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2170 if(gInputStyleChangedCallbackCalled)
2172 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2174 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2175 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2177 DALI_TEST_CHECK(inputStyleChangedSignal);
2179 gInputStyleChangedCallbackCalled = false;
2180 gInputStyleMask = TextField::InputStyle::NONE;
2181 inputStyleChangedSignal = false;
2183 // Create a tap event to touch the text field.
2184 TestGenerateTap(application, 88.0f, 25.0f);
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 // Executes the idle callbacks added by the text control on the change of input style.
2191 application.RunIdles();
2193 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2194 if(gInputStyleChangedCallbackCalled)
2196 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2198 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2199 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2201 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2203 Property::Map fontStyleMapSet;
2204 fontStyleMapSet.Insert("weight", "bold");
2206 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2207 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2209 DALI_TEST_CHECK(inputStyleChangedSignal);
2211 gInputStyleChangedCallbackCalled = false;
2212 gInputStyleMask = TextField::InputStyle::NONE;
2213 inputStyleChangedSignal = false;
2215 // Create a tap event to touch the text field.
2216 TestGenerateTap(application, 115.0f, 25.0f);
2218 // Render and notify
2219 application.SendNotification();
2220 application.Render();
2222 // Executes the idle callbacks added by the text control on the change of input style.
2223 application.RunIdles();
2225 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2226 DALI_TEST_CHECK(!inputStyleChangedSignal);
2228 gInputStyleChangedCallbackCalled = false;
2229 gInputStyleMask = TextField::InputStyle::NONE;
2230 inputStyleChangedSignal = false;
2232 // Create a tap event to touch the text field.
2233 TestGenerateTap(application, 164.0f, 25.0f);
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // Executes the idle callbacks added by the text control on the change of input style.
2240 application.RunIdles();
2242 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2243 if(gInputStyleChangedCallbackCalled)
2245 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2247 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2248 DALI_TEST_CHECK(style.empty());
2250 DALI_TEST_CHECK(inputStyleChangedSignal);
2252 gInputStyleChangedCallbackCalled = false;
2253 gInputStyleMask = TextField::InputStyle::NONE;
2254 inputStyleChangedSignal = false;
2256 // Create a tap event to touch the text field.
2257 TestGenerateTap(application, 191.0f, 25.0f);
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // Executes the idle callbacks added by the text control on the change of input style.
2264 application.RunIdles();
2266 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2267 DALI_TEST_CHECK(!inputStyleChangedSignal);
2272 int utcDaliTextFieldInputStyleChanged02(void)
2274 // The text-field emits signals when the input style changes. These changes of style are
2275 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2276 // can't be emitted during the size negotiation as the callbacks may update the UI.
2277 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2278 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2279 ToolkitTestApplication application;
2280 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2284 char* pathNamePtr = get_current_dir_name();
2285 const std::string pathName(pathNamePtr);
2288 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2289 fontClient.SetDpi(93u, 93u);
2291 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2292 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2294 TextField field = TextField::New();
2295 DALI_TEST_CHECK(field);
2297 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2298 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2299 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2301 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2302 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>");
2304 // connect to the text changed signal.
2305 ConnectionTracker* testTracker = new ConnectionTracker();
2306 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2307 bool inputStyleChangedSignal = false;
2308 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2310 application.GetScene().Add(field);
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 // Executes the idle callbacks added by the text control on the change of input style.
2317 application.RunIdles();
2319 gInputStyleChangedCallbackCalled = false;
2320 gInputStyleMask = TextField::InputStyle::NONE;
2321 inputStyleChangedSignal = false;
2323 // Create a tap event to touch the text field.
2324 TestGenerateTap(application, 53.0f, 25.0f, 100);
2325 TestGenerateTap(application, 53.0f, 25.0f, 200);
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Executes the idle callbacks added by the text control on the change of input style.
2332 application.RunIdles();
2334 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2335 if(gInputStyleChangedCallbackCalled)
2337 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2338 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2339 TextField::InputStyle::POINT_SIZE |
2340 TextField::InputStyle::COLOR),
2343 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2344 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2346 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2347 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2349 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2350 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2352 DALI_TEST_CHECK(inputStyleChangedSignal);
2354 gInputStyleChangedCallbackCalled = false;
2355 gInputStyleMask = TextField::InputStyle::NONE;
2356 inputStyleChangedSignal = false;
2358 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // Executes the idle callbacks added by the text control on the change of input style.
2365 application.RunIdles();
2367 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2368 if(gInputStyleChangedCallbackCalled)
2370 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2371 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2374 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2375 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2377 DALI_TEST_CHECK(inputStyleChangedSignal);
2379 gInputStyleChangedCallbackCalled = false;
2380 gInputStyleMask = TextField::InputStyle::NONE;
2381 inputStyleChangedSignal = false;
2383 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2385 // Render and notify
2386 application.SendNotification();
2387 application.Render();
2389 // Executes the idle callbacks added by the text control on the change of input style.
2390 application.RunIdles();
2392 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2393 DALI_TEST_CHECK(!inputStyleChangedSignal);
2395 gInputStyleChangedCallbackCalled = false;
2396 gInputStyleMask = TextField::InputStyle::NONE;
2397 inputStyleChangedSignal = false;
2399 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2405 // Executes the idle callbacks added by the text control on the change of input style.
2406 application.RunIdles();
2408 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2409 if(gInputStyleChangedCallbackCalled)
2411 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2412 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2415 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2416 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2418 DALI_TEST_CHECK(inputStyleChangedSignal);
2420 gInputStyleChangedCallbackCalled = false;
2421 gInputStyleMask = TextField::InputStyle::NONE;
2422 inputStyleChangedSignal = false;
2424 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2426 Property::Map fontStyleMapSet;
2427 fontStyleMapSet.Insert("weight", "thin");
2428 fontStyleMapSet.Insert("width", "condensed");
2429 fontStyleMapSet.Insert("slant", "italic");
2431 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2432 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2434 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2435 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2436 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2437 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2438 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2440 // Render and notify
2441 application.SendNotification();
2442 application.Render();
2444 // Executes the idle callbacks added by the text control on the change of input style.
2445 application.RunIdles();
2447 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2448 DALI_TEST_CHECK(!inputStyleChangedSignal);
2450 // Create a tap event to touch the text field.
2451 TestGenerateTap(application, 63.0f, 25.0f, 700);
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Executes the idle callbacks added by the text control on the change of input style.
2458 application.RunIdles();
2460 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2461 if(gInputStyleChangedCallbackCalled)
2463 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2464 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2465 TextField::InputStyle::POINT_SIZE |
2466 TextField::InputStyle::FONT_STYLE |
2467 TextField::InputStyle::UNDERLINE |
2468 TextField::InputStyle::SHADOW |
2469 TextField::InputStyle::EMBOSS |
2470 TextField::InputStyle::OUTLINE),
2473 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2474 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2476 DALI_TEST_CHECK(inputStyleChangedSignal);
2481 int utcDaliTextFieldInputStyleChanged03(void)
2483 // Test InputStyleCahnged signal emitted even if AddIdle failed.
2484 ToolkitTestApplication application;
2485 tet_infoline(" utcDaliTextFieldInputStyleChanged03");
2489 char* pathNamePtr = get_current_dir_name();
2490 const std::string pathName(pathNamePtr);
2493 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2494 fontClient.SetDpi(93u, 93u);
2496 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2497 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2499 TextField field = TextField::New();
2500 DALI_TEST_CHECK(field);
2502 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2503 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2504 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2506 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2507 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2509 // connect to the text changed signal.
2510 ConnectionTracker* testTracker = new ConnectionTracker();
2511 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2512 bool inputStyleChangedSignal = false;
2513 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2515 application.GetScene().Add(field);
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Executes the idle callbacks added by the text control on the change of input style.
2522 application.RunIdles();
2524 gInputStyleChangedCallbackCalled = false;
2525 gInputStyleMask = TextField::InputStyle::NONE;
2526 inputStyleChangedSignal = false;
2528 // Create a tap event to touch the text field.
2529 TestGenerateTap(application, 18.0f, 25.0f);
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Executes the idle callbacks added by the text control on the change of input style.
2536 application.RunIdles();
2538 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2539 if(gInputStyleChangedCallbackCalled)
2541 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2543 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2544 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2546 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2547 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2549 DALI_TEST_CHECK(inputStyleChangedSignal);
2551 gInputStyleChangedCallbackCalled = false;
2552 gInputStyleMask = TextField::InputStyle::NONE;
2553 inputStyleChangedSignal = false;
2555 // Create a tap event to touch the text field.
2556 TestGenerateTap(application, 30.0f, 25.0f);
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 // Executes the idle callbacks added by the text control on the change of input style.
2563 application.RunIdles();
2565 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2566 DALI_TEST_CHECK(!inputStyleChangedSignal);
2568 gInputStyleChangedCallbackCalled = false;
2569 gInputStyleMask = TextField::InputStyle::NONE;
2570 inputStyleChangedSignal = false;
2572 // Create a tap event to touch the text field.
2573 TestGenerateTap(application, 43.0f, 25.0f);
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2579 // Executes the idle callbacks added by the text control on the change of input style.
2580 application.RunIdles();
2582 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2583 if(gInputStyleChangedCallbackCalled)
2585 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2587 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2588 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2590 DALI_TEST_CHECK(inputStyleChangedSignal);
2592 gInputStyleChangedCallbackCalled = false;
2593 gInputStyleMask = TextField::InputStyle::NONE;
2594 inputStyleChangedSignal = false;
2596 // Make AddIdle return false.
2597 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2599 // Create a tap event to touch the text field.
2600 TestGenerateTap(application, 88.0f, 25.0f);
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2606 // Execute the idle callbacks.
2607 // And check whether we didn't change of input style.
2608 application.RunIdles();
2610 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2611 DALI_TEST_CHECK(!inputStyleChangedSignal);
2613 gInputStyleChangedCallbackCalled = false;
2614 gInputStyleMask = TextField::InputStyle::NONE;
2615 inputStyleChangedSignal = false;
2617 // Create a tap event to touch the text field.
2618 TestGenerateTap(application, 115.0f, 25.0f);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Execute the idle callbacks.
2625 // And check whether we didn't change of input style.
2626 application.RunIdles();
2628 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2629 DALI_TEST_CHECK(!inputStyleChangedSignal);
2631 gInputStyleChangedCallbackCalled = false;
2632 gInputStyleMask = TextField::InputStyle::NONE;
2633 inputStyleChangedSignal = false;
2635 // Revert AddIdle return true.
2636 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2638 // Create a tap event to touch the text field.
2639 TestGenerateTap(application, 164.0f, 25.0f);
2641 // Render and notify
2642 application.SendNotification();
2643 application.Render();
2645 // Executes the idle callbacks added by the text control on the change of input style.
2646 application.RunIdles();
2648 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2649 if(gInputStyleChangedCallbackCalled)
2651 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2653 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2654 DALI_TEST_CHECK(style.empty());
2656 DALI_TEST_CHECK(inputStyleChangedSignal);
2658 gInputStyleChangedCallbackCalled = false;
2659 gInputStyleMask = TextField::InputStyle::NONE;
2660 inputStyleChangedSignal = false;
2662 // Create a tap event to touch the text field.
2663 TestGenerateTap(application, 191.0f, 25.0f);
2665 // Render and notify
2666 application.SendNotification();
2667 application.Render();
2669 // Executes the idle callbacks added by the text control on the change of input style.
2670 application.RunIdles();
2672 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2673 DALI_TEST_CHECK(!inputStyleChangedSignal);
2678 int utcDaliTextFieldEvent01(void)
2680 ToolkitTestApplication application;
2681 tet_infoline(" utcDaliTextFieldEvent01");
2683 // Creates a tap event. After creating a tap event the text field should
2684 // have the focus and add text with key events should be possible.
2686 TextField field = TextField::New();
2687 DALI_TEST_CHECK(field);
2689 application.GetScene().Add(field);
2691 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2692 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2693 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2695 // Render and notify
2696 application.SendNotification();
2697 application.Render();
2699 // Avoid a crash when core load gl resources.
2700 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2702 // Render and notify
2703 application.SendNotification();
2704 application.Render();
2706 // Add a key event but as the text field has not the focus it should do nothing.
2707 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2709 // Render and notify
2710 application.SendNotification();
2711 application.Render();
2713 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2715 // Create a tap event to touch the text field.
2716 TestGenerateTap(application, 150.0f, 25.0f);
2718 // Render and notify
2719 application.SendNotification();
2720 application.Render();
2722 // Pressing delete key should be fine even if there is no text in TextField.
2723 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));
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2728 // Now the text field has the focus, so it can handle the key events.
2729 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2730 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2732 // Render and notify
2733 application.SendNotification();
2734 application.Render();
2736 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2738 // Create a second text field and send key events to it.
2739 TextField field2 = TextField::New();
2741 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2742 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2743 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2744 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2746 application.GetScene().Add(field2);
2748 // Render and notify
2749 application.SendNotification();
2750 application.Render();
2752 // Create a tap event on the second text field.
2753 TestGenerateTap(application, 150.0f, 125.0f);
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 // The second text field has the focus. It should handle the key events.
2760 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2761 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2763 // Render and notify
2764 application.SendNotification();
2765 application.Render();
2767 // Check the text has been added to the second text field.
2768 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2773 int utcDaliTextFieldEvent02(void)
2775 ToolkitTestApplication application;
2776 tet_infoline(" utcDaliTextFieldEvent02");
2778 // Checks if the right number of actors are created.
2780 TextField field = TextField::New();
2781 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2782 DALI_TEST_CHECK(field);
2783 LoadMarkerImages(application, field);
2785 application.GetScene().Add(field);
2787 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2788 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2789 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2791 // Avoid a crash when core load gl resources.
2792 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 // Check there are the expected number of children ( stencil ).
2799 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2801 Actor stencil = field.GetChildAt(0u);
2802 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2804 // Create a tap event to touch the text field.
2805 TestGenerateTap(application, 150.0f, 25.0f, 300);
2807 // Render and notify
2808 application.SendNotification();
2809 application.Render();
2811 Actor layer = field.GetChildAt(2u);
2812 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2813 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2815 // Now the text field has the focus, so it can handle the key events.
2816 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2817 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 // Checks the cursor and the renderer have been created.
2824 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2825 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2827 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2828 DALI_TEST_CHECK(cursor);
2830 // The offscreen root actor has a container with all the actors which contain the text renderers.
2831 Actor container = stencil.GetChildAt(0u);
2832 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2834 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2835 DALI_TEST_CHECK(renderer);
2838 // Move the cursor and check the position changes.
2839 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2840 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2842 // Render and notify
2843 application.SendNotification();
2844 application.Render();
2846 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2847 DALI_TEST_CHECK(position2.x < position1.x);
2849 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2851 // Render and notify
2852 application.SendNotification();
2853 application.Render();
2855 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2856 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2858 // Move the cursor to the first position.
2859 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2860 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2862 // Render and notify
2863 application.SendNotification();
2864 application.Render();
2866 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2868 // Send some taps and check the cursor positions.
2870 // Try to tap at the beginning.
2871 TestGenerateTap(application, 1.0f, 25.0f, 900);
2873 // Render and notify
2874 application.SendNotification();
2875 application.Render();
2877 // Cursor position should be the same than position1.
2878 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2880 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2882 // Tap away from the start position.
2883 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2885 // Render and notify
2886 application.SendNotification();
2887 application.Render();
2889 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2891 DALI_TEST_CHECK(position6.x > position5.x);
2893 // Remove all the text.
2894 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2895 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2896 field.SetProperty(TextField::Property::TEXT, "");
2898 // Render and notify
2899 application.SendNotification();
2900 application.Render();
2902 // Cursor position should be the same than position2.
2903 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2905 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2907 // Should not be a renderer, there is only a clipped cursor.
2908 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2910 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2911 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2912 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2914 application.SendNotification();
2915 application.Render();
2917 // There are renderer and decorator layer
2918 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2923 int utcDaliTextFieldEvent03(void)
2925 ToolkitTestApplication application;
2926 tet_infoline(" utcDaliTextFieldEvent03");
2928 // Checks if the highlight actor is created.
2930 TextField field = TextField::New();
2931 DALI_TEST_CHECK(field);
2933 application.GetScene().Add(field);
2935 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2936 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2937 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2938 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2939 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2941 // Avoid a crash when core load gl resources.
2942 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2943 LoadMarkerImages(application, field);
2945 // Render and notify
2946 application.SendNotification();
2947 application.Render();
2949 // Tap first to get the focus.
2950 TestGenerateTap(application, 3.0f, 25.0f, 100);
2952 // Render and notify
2953 application.SendNotification();
2954 application.Render();
2956 // Double tap to select a word.
2957 TestGenerateTap(application, 3.0f, 25.0f, 200);
2959 // Render and notify
2960 application.SendNotification();
2961 application.Render();
2963 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2964 Actor stencil = field.GetChildAt(0u);
2966 // The highlight actor is drawn first, so is the first actor in the list
2967 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2968 DALI_TEST_CHECK(highlight);
2970 // The offscreen root actor has a container with all the actors which contain the text renderers.
2971 Actor container = stencil.GetChildAt(1u);
2972 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2974 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2975 DALI_TEST_CHECK(renderer);
2981 int utcDaliTextFieldEvent04(void)
2983 ToolkitTestApplication application;
2984 tet_infoline(" utcDaliTextFieldEvent04");
2986 // Checks if the highlight actor is created.
2988 TextField field = TextField::New();
2989 DALI_TEST_CHECK(field);
2990 application.GetScene().Add(field);
2991 LoadMarkerImages(application, field);
2992 // Render and notify
2993 application.SendNotification();
2994 application.Render();
2996 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2997 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2998 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2999 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3000 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3002 // Avoid a crash when core load gl resources.
3003 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3004 // Render and notify
3005 application.SendNotification();
3006 application.Render();
3008 // Create a tap event to touch the text field.
3009 TestGenerateTap(application, 150.0f, 25.0f);
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 // Tap first to get the focus.
3015 TestGenerateTap(application, 1.0f, 25.0f);
3017 // Render and notify
3018 application.SendNotification();
3019 application.Render();
3021 // Double tap to select a word.
3022 TestGenerateTap(application, 1.0f, 25.0f);
3024 // Render and notify
3025 application.SendNotification();
3026 application.Render();
3029 TestGenerateTap(application, 0.0f, 40.0f);
3031 field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
3032 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3037 int utcDaliTextFieldEvent05(void)
3039 ToolkitTestApplication application;
3040 tet_infoline(" utcDaliTextFieldEvent05");
3042 // Checks dragging of cursor/grab handle
3044 TextField field = TextField::New();
3045 DALI_TEST_CHECK(field);
3046 application.GetScene().Add(field);
3047 LoadMarkerImages(application, field);
3048 // Render and notify
3049 application.SendNotification();
3050 application.Render();
3052 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3053 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3054 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3055 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3056 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3058 // Avoid a crash when core load gl resources.
3059 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3060 // Render and notify
3061 application.SendNotification();
3062 application.Render();
3064 // Create a tap event to touch the text field.
3065 TestGenerateTap(application, 150.0f, 25.0f);
3066 // Render and notify
3067 application.SendNotification();
3068 application.Render();
3070 // Tap first to get the focus.
3071 TestGenerateTap(application, 1.0f, 25.0f);
3073 // Render and notify
3074 application.SendNotification();
3075 application.Render();
3077 // Double tap to select a word.
3078 TestGenerateTap(application, 1.0f, 25.0f);
3080 // Render and notify
3081 application.SendNotification();
3082 application.Render();
3084 Actor stencil = field.GetChildAt(1u);
3088 int utcDaliTextFieldEvent06(void)
3090 ToolkitTestApplication application;
3091 tet_infoline(" utcDaliTextFieldEvent06");
3093 // Checks Longpress when in edit mode
3095 TextField field = TextField::New();
3096 DALI_TEST_CHECK(field);
3097 application.GetScene().Add(field);
3098 LoadMarkerImages(application, field);
3099 // Render and notify
3100 application.SendNotification();
3101 application.Render();
3103 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3104 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3105 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3106 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3107 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3109 // Avoid a crash when core load gl resources.
3110 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3111 // Render and notify
3112 application.SendNotification();
3113 application.Render();
3115 // Create a tap event to touch the text field.
3116 TestGenerateTap(application, 150.0f, 25.0f);
3117 // Render and notify
3118 application.SendNotification();
3119 application.Render();
3121 // Tap first to get the focus.
3122 TestGenerateTap(application, 1.0f, 25.0f);
3124 // Render and notify
3125 application.SendNotification();
3126 application.Render();
3129 TestGenerateLongPress(application, 1.0f, 25.0f);
3131 // Render and notify
3132 application.SendNotification();
3133 application.Render();
3138 int utcDaliTextFieldEvent07(void)
3140 ToolkitTestApplication application;
3141 tet_infoline(" utcDaliTextFieldEvent07");
3143 // Checks Longpress to start edit mode
3145 TextField field = TextField::New();
3146 DALI_TEST_CHECK(field);
3147 application.GetScene().Add(field);
3148 LoadMarkerImages(application, field);
3149 // Render and notify
3150 application.SendNotification();
3151 application.Render();
3153 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3154 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3155 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3156 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3157 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3158 Property::Map propertyMap;
3159 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3160 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3162 // Avoid a crash when core load gl resources.
3163 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3164 // Render and notify
3165 application.SendNotification();
3166 application.Render();
3169 TestGenerateLongPress(application, 1.0f, 25.0f);
3171 // Render and notify
3172 application.SendNotification();
3173 application.Render();
3178 int utcDaliTextFieldEvent08(void)
3180 ToolkitTestApplication application;
3181 tet_infoline(" utcDaliTextFieldEvent08");
3183 Dali::Clipboard clipboard = Clipboard::Get();
3184 Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3185 clipboard.SetData(data);
3187 // Checks Longpress when only place holder text
3189 TextField field = TextField::New();
3190 DALI_TEST_CHECK(field);
3191 application.GetScene().Add(field);
3192 LoadMarkerImages(application, field);
3193 // Render and notify
3194 application.SendNotification();
3195 application.Render();
3197 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3198 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3199 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3200 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3201 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3203 // Avoid a crash when core load gl resources.
3204 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3205 // Render and notify
3206 application.SendNotification();
3207 application.Render();
3210 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3212 // Render and notify
3213 application.SendNotification();
3214 application.Render();
3216 Wait(application, 500);
3218 TestEndLongPress(application, 1.0f, 25.0f, 520);
3221 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3223 // Render and notify
3224 application.Render();
3226 Wait(application, 500);
3228 Integration::Scene stage = application.GetScene();
3229 Layer layer = stage.GetRootLayer();
3230 Actor actor = layer.FindChildByName("optionPaste");
3234 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3235 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3236 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3238 Dali::Integration::TouchEvent event;
3239 event = Dali::Integration::TouchEvent();
3240 event.AddPoint(GetPointDownInside(position));
3241 application.ProcessEvent(event);
3243 event = Dali::Integration::TouchEvent();
3244 event.AddPoint(GetPointUpInside(position));
3245 application.ProcessEvent(event);
3247 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3252 int utcDaliTextFieldEvent09(void)
3254 ToolkitTestApplication application;
3255 tet_infoline(" utcDaliTextFieldEvent09");
3257 TextField field = TextField::New();
3258 DALI_TEST_CHECK(field);
3259 application.GetScene().Add(field);
3260 LoadMarkerImages(application, field);
3261 // Render and notify
3262 application.SendNotification();
3263 application.Render();
3265 field.SetProperty(TextField::Property::TEXT, "Hello");
3266 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3267 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3268 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3269 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3270 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3272 // Avoid a crash when core load gl resources.
3273 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3275 // Create a tap event to touch the text field.
3276 TestGenerateTap(application, 150.0f, 25.0f);
3277 application.SendNotification();
3278 application.Render();
3281 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3282 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3283 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3284 application.SendNotification();
3285 application.Render();
3286 for(unsigned int index = 0u; index < 6u; ++index)
3288 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3289 application.SendNotification();
3290 application.Render();
3293 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3294 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3295 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3296 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3297 application.SendNotification();
3298 application.Render();
3300 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3301 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3302 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3303 for(unsigned int index = 0u; index < 5u; ++index)
3305 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3306 application.SendNotification();
3307 application.Render();
3310 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3311 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3312 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3313 for(unsigned int index = 0u; index < 5u; ++index)
3315 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3316 application.SendNotification();
3317 application.Render();
3320 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3321 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3322 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3323 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3324 application.SendNotification();
3325 application.Render();
3326 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3327 application.SendNotification();
3328 application.Render();
3330 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3331 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3332 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3333 application.SendNotification();
3334 application.Render();
3336 Property::Map mapGet;
3337 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3338 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3339 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3343 int utcDaliTextFieldStyleWhilstSelected(void)
3345 ToolkitTestApplication application;
3346 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3348 // Change font and styles whilst text is selected whilst word selected
3350 TextField field = TextField::New();
3351 DALI_TEST_CHECK(field);
3352 application.GetScene().Add(field);
3353 LoadMarkerImages(application, field);
3354 // Render and notify
3355 application.SendNotification();
3356 application.Render();
3358 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3359 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3360 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3361 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3362 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3364 // Avoid a crash when core load gl resources.
3365 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3366 // Render and notify
3367 application.SendNotification();
3368 application.Render();
3370 // Create a tap event to touch the text field.
3371 TestGenerateTap(application, 150.0f, 25.0f);
3372 // Render and notify
3373 application.SendNotification();
3374 application.Render();
3376 // Tap first to get the focus.
3377 TestGenerateTap(application, 1.0f, 25.0f);
3379 // Render and notify
3380 application.SendNotification();
3381 application.Render();
3383 // Double tap to select a word.
3384 TestGenerateTap(application, 1.0f, 25.0f);
3386 // Render and notify
3387 application.SendNotification();
3388 application.Render();
3390 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3391 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3393 Property::Map fontStyleMapSet;
3394 Property::Map fontStyleMapGet;
3396 fontStyleMapSet.Insert("weight", "bold");
3397 fontStyleMapSet.Insert("slant", "italic");
3398 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3400 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3401 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3402 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3404 fontStyleMapSet.Clear();
3405 fontStyleMapSet.Insert("width", "expanded");
3406 fontStyleMapSet.Insert("slant", "italic");
3407 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3409 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3410 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3411 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3413 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3414 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3416 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3417 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3419 fontStyleMapSet.Clear();
3420 fontStyleMapSet.Insert("weight", "bold");
3421 fontStyleMapSet.Insert("slant", "italic");
3423 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3425 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3426 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3427 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3429 fontStyleMapSet.Clear();
3430 fontStyleMapSet.Insert("width", "expanded");
3432 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3434 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3435 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3436 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3438 // Press Escape to increase coverage
3439 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3440 application.SendNotification();
3441 application.Render();
3443 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3448 int utcDaliTextFieldEscKeyLoseFocus(void)
3450 ToolkitTestApplication application;
3451 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3453 // Creates a tap event. After creating a tap event the text field should
3454 // have the focus and add text with key events should be possible.
3456 TextField field = TextField::New();
3457 DALI_TEST_CHECK(field);
3459 application.GetScene().Add(field);
3461 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3462 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3463 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3465 // Avoid a crash when core load gl resources.
3466 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3468 // Render and notify
3469 application.SendNotification();
3470 application.Render();
3472 // Add a key event but as the text field has not the focus it should do nothing.
3473 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3474 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3476 // Render and notify
3477 application.SendNotification();
3478 application.Render();
3480 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3482 // Create a tap event to touch the text field.
3483 TestGenerateTap(application, 150.0f, 25.0f);
3485 // Render and notify
3486 application.SendNotification();
3487 application.Render();
3489 // Now the text field has the focus, so it can handle the key events.
3490 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3491 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3492 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3493 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3495 // Render and notify
3496 application.SendNotification();
3497 application.Render();
3499 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3501 // Generate a Esc key event. The text field should lose the focus.
3502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3505 // Render and notify
3506 application.SendNotification();
3507 application.Render();
3509 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3511 // No more text should be introduced
3512 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3513 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3515 // Render and notify
3516 application.SendNotification();
3517 application.Render();
3519 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3524 int utcDaliTextFieldSomeSpecialKeys(void)
3526 ToolkitTestApplication application;
3527 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3529 // Checks some special keys when the text is selected.
3531 TextField field = TextField::New();
3532 DALI_TEST_CHECK(field);
3533 application.GetScene().Add(field);
3534 LoadMarkerImages(application, field);
3535 // Render and notify
3536 application.SendNotification();
3537 application.Render();
3539 const std::string longText("This is a long text for the size of the text-field.");
3541 field.SetProperty(TextField::Property::TEXT, longText);
3542 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3543 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3544 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3545 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3547 // Avoid a crash when core load gl resources.
3548 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3549 // Render and notify
3550 application.SendNotification();
3551 application.Render();
3553 // Create a tap event to touch the text field.
3554 TestGenerateTap(application, 150.0f, 25.0f);
3556 // Render and notify
3557 application.SendNotification();
3558 application.Render();
3560 // Tap first to get the focus.
3561 TestGenerateTap(application, 1.0f, 25.0f);
3563 // Render and notify
3564 application.SendNotification();
3565 application.Render();
3567 // Double tap to select a word.
3568 TestGenerateTap(application, 1.0f, 25.0f);
3570 // Render and notify
3571 application.SendNotification();
3572 application.Render();
3574 // Generate a Esc key event. The text field should lose the focus.
3575 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3576 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3578 // Render and notify
3579 application.SendNotification();
3580 application.Render();
3582 // Generate a Esc key event. The text field should lose the focus.
3583 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3584 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3586 // Render and notify
3587 application.SendNotification();
3588 application.Render();
3590 // Generate a Esc key event. The text field should lose the focus.
3591 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3592 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3594 // Render and notify
3595 application.SendNotification();
3596 application.Render();
3598 // Generate a Back key event. Nothing happens to the text field.
3599 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3600 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3602 // Render and notify
3603 application.SendNotification();
3604 application.Render();
3606 // The text shouldn't be deleted.
3607 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3612 int utcDaliTextFieldSizeUpdate(void)
3614 ToolkitTestApplication application;
3615 tet_infoline("utcDaliTextFieldSizeUpdate");
3617 // Checks some special keys when the text is selected.
3618 TextField field = TextField::New();
3619 DALI_TEST_CHECK(field);
3620 application.GetScene().Add(field);
3622 float previousHeight = 0.0f;
3623 float currentHeight = 0.0f;
3624 const float fieldWidth = 1920.0f;
3626 // "ㅁ" is bigger then "ኢ"
3627 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3628 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3629 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3631 field.SetProperty(TextField::Property::TEXT, "ኢ");
3632 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3633 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3635 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3636 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3638 application.SendNotification();
3639 application.Render();
3641 previousHeight = field.GetHeightForWidth(fieldWidth);
3642 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3644 // Add another script characters ( glyph height is defferent )
3645 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3646 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3648 application.SendNotification();
3649 application.Render();
3651 currentHeight = field.GetHeightForWidth(fieldWidth);
3652 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3653 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3658 int utcDaliTextFieldExtremlyLargePointSize(void)
3660 ToolkitTestApplication application;
3661 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3663 TextField field = TextField::New();
3665 field.SetProperty(TextField::Property::TEXT, "Text");
3666 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3667 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3668 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3669 application.GetScene().Add(field);
3673 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3674 application.SendNotification();
3675 DALI_TEST_CHECK(field);
3679 tet_result(TET_FAIL);
3684 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3686 ToolkitTestApplication application;
3687 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3688 TextField field = TextField::New();
3689 DALI_TEST_CHECK(field);
3690 application.GetScene().Add(field);
3692 Property::Map fontStyleMapGet;
3694 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3696 Property::Value* weightValue = NULL;
3697 Property::Value* widthValue = NULL;
3698 Property::Value* slantValue = NULL;
3699 weightValue = fontStyleMapGet.Find("weight");
3700 widthValue = fontStyleMapGet.Find("width");
3701 slantValue = fontStyleMapGet.Find("slant");
3702 DALI_TEST_CHECK(!weightValue);
3703 DALI_TEST_CHECK(!widthValue);
3704 DALI_TEST_CHECK(!slantValue);
3709 int UtcDaliTextFieldSettingPlaceholder(void)
3711 ToolkitTestApplication application;
3712 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3714 TextField field = TextField::New();
3715 DALI_TEST_CHECK(field);
3716 application.GetScene().Add(field);
3718 // Check the placeholder property with pixel size
3719 Property::Map placeholderPixelSizeMapSet;
3720 Property::Map placeholderPixelSizeMapGet;
3721 Property::Map placeholderFontstyleMap;
3722 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3723 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3724 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3725 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3726 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3727 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3729 placeholderFontstyleMap.Insert("weight", "bold");
3730 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3731 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3733 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3734 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3735 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3737 // Check the placeholder property with point size
3738 Property::Map placeholderMapSet;
3739 Property::Map placeholderMapGet;
3740 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3741 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3742 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3743 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3744 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3745 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3747 // Check the placeholder font style property
3748 placeholderFontstyleMap.Clear();
3750 placeholderFontstyleMap.Insert("weight", "bold");
3751 placeholderFontstyleMap.Insert("width", "condensed");
3752 placeholderFontstyleMap.Insert("slant", "italic");
3753 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3754 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3756 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3757 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3758 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3760 // Reset font style.
3761 placeholderFontstyleMap.Clear();
3762 placeholderFontstyleMap.Insert("weight", "normal");
3763 placeholderFontstyleMap.Insert("slant", "oblique");
3764 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3765 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3767 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3768 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3769 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3771 placeholderFontstyleMap.Clear();
3772 placeholderFontstyleMap.Insert("slant", "roman");
3773 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3774 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3776 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3778 placeholderFontstyleMap.Clear();
3779 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3781 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3782 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3783 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3784 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3789 int UtcDaliTextFieldPlaceholderCoverage(void)
3791 ToolkitTestApplication application;
3792 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3794 // mPlaceholderFont is created only once, so create a new control for coverage.
3795 TextField fieldForCoverage = TextField::New();
3796 DALI_TEST_CHECK(fieldForCoverage);
3797 application.GetScene().Add(fieldForCoverage);
3799 // for SetPlaceholderFontFamily() coverage.
3800 Property::Map fontFamilyMap;
3801 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3802 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3804 // mPlaceholderFont is created only once, so create a new control for coverage.
3805 fieldForCoverage = TextField::New();
3806 DALI_TEST_CHECK(fieldForCoverage);
3807 application.GetScene().Add(fieldForCoverage);
3809 // for SetPlaceholderTextFontSize coverage.
3810 Property::Map fontSizeMap;
3811 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3812 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3814 // mPlaceholderFont is created only once, so create a new control for coverage.
3815 fieldForCoverage = TextField::New();
3816 DALI_TEST_CHECK(fieldForCoverage);
3817 application.GetScene().Add(fieldForCoverage);
3819 // for SetPlaceholderTextFontWeight coverage.
3820 Property::Map fontStyleWeightMap;
3821 Property::Map fontStyleWeightPropertyMap;
3822 fontStyleWeightPropertyMap.Insert("weight", "bold");
3823 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3824 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3826 // mPlaceholderFont is created only once, so create a new control for coverage.
3827 fieldForCoverage = TextField::New();
3828 DALI_TEST_CHECK(fieldForCoverage);
3829 application.GetScene().Add(fieldForCoverage);
3831 // for SetPlaceholderTextFontWidth coverage.
3832 Property::Map fontStyleWidthMap;
3833 Property::Map fontStyleWidthPropertyMap;
3834 fontStyleWidthPropertyMap.Insert("width", "expanded");
3835 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3836 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3838 // mPlaceholderFont is created only once, so create a new control for coverage.
3839 fieldForCoverage = TextField::New();
3840 DALI_TEST_CHECK(fieldForCoverage);
3841 application.GetScene().Add(fieldForCoverage);
3843 // for SetPlaceholderTextFontSlant coverage.
3844 Property::Map fontStyleSlantMap;
3845 Property::Map fontStyleSlantPropertyMap;
3846 fontStyleSlantPropertyMap.Insert("slant", "italic");
3847 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3848 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3853 int UtcDaliTextFieldSetPaddingProperty(void)
3855 ToolkitTestApplication application;
3856 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3858 TextField field = TextField::New();
3859 DALI_TEST_CHECK(field);
3860 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3861 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3862 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3863 application.GetScene().Add(field);
3865 application.SendNotification();
3866 application.Render();
3868 Vector3 originalSize = field.GetNaturalSize();
3870 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3872 application.SendNotification();
3873 application.Render();
3875 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3877 Vector3 paddingAddedSize = field.GetNaturalSize();
3879 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3881 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3886 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3888 ToolkitTestApplication application;
3889 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3891 TextField field = TextField::New();
3892 DALI_TEST_CHECK(field);
3893 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3894 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3895 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3896 application.GetScene().Add(field);
3898 application.SendNotification();
3899 application.Render();
3901 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3902 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3904 // Check the enable shift selection property
3905 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3906 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3908 application.SendNotification();
3909 application.Render();
3914 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3916 ToolkitTestApplication application;
3917 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3919 TextField field = TextField::New();
3920 DALI_TEST_CHECK(field);
3921 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3922 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3923 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3924 application.GetScene().Add(field);
3926 application.SendNotification();
3927 application.Render();
3929 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3930 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3932 // Check the enable grab handle property
3933 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3934 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3936 application.SendNotification();
3937 application.Render();
3942 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3944 ToolkitTestApplication application;
3945 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3947 TextField field = TextField::New();
3948 DALI_TEST_CHECK(field);
3949 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3950 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3951 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3952 application.GetScene().Add(field);
3954 application.SendNotification();
3955 application.Render();
3957 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3958 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3960 // Check the match system language direction property
3961 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3962 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3964 application.SendNotification();
3965 application.Render();
3970 int utcDaliTextFieldLayoutDirectionCoverage(void)
3972 ToolkitTestApplication application;
3973 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3975 // Creates a tap event. After creating a tap event the text field should
3976 // have the focus and add text with key events should be possible.
3977 TextField field = TextField::New();
3978 DALI_TEST_CHECK(field);
3980 application.GetScene().Add(field);
3982 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3983 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3984 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3986 // Avoid a crash when core load gl resources.
3987 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3989 // Render and notify
3990 application.SendNotification();
3991 application.Render();
3993 // init direction for coverage
3994 // Set horizontal alignment END
3995 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3997 // Create a tap event to touch the text field.
3998 TestGenerateTap(application, 150.0f, 25.0f);
4000 // Render and notify
4001 application.SendNotification();
4002 application.Render();
4004 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4005 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4006 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4008 // Set horizontal alignment BEGIN
4009 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4011 // Create a tap event to touch the text field.
4012 TestGenerateTap(application, 150.0f, 25.0f);
4014 // Render and notify
4015 application.SendNotification();
4016 application.Render();
4018 // Set horizontal alignment CENTER
4019 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4021 // Create a tap event to touch the text field.
4022 TestGenerateTap(application, 150.0f, 25.0f);
4024 // Render and notify
4025 application.SendNotification();
4026 application.Render();
4028 // Set horizontal alignment END
4029 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4031 // Create a tap event to touch the text field.
4032 TestGenerateTap(application, 150.0f, 25.0f);
4034 // Render and notify
4035 application.SendNotification();
4036 application.Render();
4038 // Generate a Esc key event. The text field should lose the focus.
4039 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4040 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4042 // Render and notify
4043 application.SendNotification();
4044 application.Render();
4046 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4051 int UtcDaliTextFieldGetInputMethodContext(void)
4053 ToolkitTestApplication application;
4054 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4056 TextField field = TextField::New();
4057 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4062 int UtcDaliTextFieldSelectWholeText(void)
4064 ToolkitTestApplication application;
4065 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4067 TextField textField = TextField::New();
4069 application.GetScene().Add(textField);
4071 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4072 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4073 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4075 // Avoid a crash when core load gl resources.
4076 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4078 application.SendNotification();
4079 application.Render();
4081 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4083 DevelTextField::SelectWholeText(textField);
4085 application.SendNotification();
4086 application.Render();
4088 // Nothing should have been selected. The number of children is still 1
4089 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4091 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4093 application.SendNotification();
4094 application.Render();
4096 DevelTextField::SelectWholeText(textField);
4098 application.SendNotification();
4099 application.Render();
4101 // Even if resize, selection should remain.
4102 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4104 application.SendNotification();
4105 application.Render();
4107 // Should be 2 children, the stencil and the layer
4108 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4110 // The offscreen root actor should have two actors: the renderer and the highlight actor.
4111 Actor stencil = textField.GetChildAt(0u);
4113 // The highlight actor is drawn first, so is the first actor in the list
4114 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4115 DALI_TEST_CHECK(highlight);
4120 int UtcDaliTextFieldSelectText(void)
4122 ToolkitTestApplication application;
4123 tet_infoline(" UtcDaliTextFieldSelectText ");
4125 TextField textField = TextField::New();
4127 application.GetScene().Add(textField);
4129 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4130 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4131 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4133 // Avoid a crash when core load gl resources.
4134 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4136 application.SendNotification();
4137 application.Render();
4139 DevelTextField::SelectText(textField, 0, 5);
4141 application.SendNotification();
4142 application.Render();
4144 // Nothing is selected
4145 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4146 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4148 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4150 application.SendNotification();
4151 application.Render();
4153 // Hello is selected
4154 DevelTextField::SelectText(textField, 0, 5);
4156 application.SendNotification();
4157 application.Render();
4159 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4160 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4162 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4163 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4165 // world is selected
4166 DevelTextField::SelectText(textField, 6, 11);
4168 application.SendNotification();
4169 application.Render();
4171 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4172 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4174 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4175 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4180 int UtcDaliTextFieldSelectNone(void)
4182 ToolkitTestApplication application;
4183 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4185 TextField textField = TextField::New();
4187 application.GetScene().Add(textField);
4189 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4190 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4191 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4193 // Avoid a crash when core load gl resources.
4194 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4196 application.SendNotification();
4197 application.Render();
4199 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4201 application.SendNotification();
4202 application.Render();
4204 // Nothing is selected
4205 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4206 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4208 DevelTextField::SelectWholeText(textField);
4210 application.SendNotification();
4211 application.Render();
4213 // whole text is selected
4214 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4215 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4217 DevelTextField::SelectNone(textField);
4219 application.SendNotification();
4220 application.Render();
4222 // Nothing is selected
4223 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4224 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4229 int UtcDaliTextFieldSelectRange(void)
4231 ToolkitTestApplication application;
4232 tet_infoline(" UtcDaliTextFieldSelectRange ");
4234 TextField textField = TextField::New();
4236 application.GetScene().Add(textField);
4238 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4239 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4240 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4242 // Avoid a crash when core load gl resources.
4243 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4245 application.SendNotification();
4246 application.Render();
4248 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4250 application.SendNotification();
4251 application.Render();
4253 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4254 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4256 // Hello is selected
4257 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4258 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4260 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4261 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4263 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4264 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4266 // world is selected
4267 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4268 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4270 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4271 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4276 int UtcDaliTextFieldEnableEditing(void)
4278 ToolkitTestApplication application;
4279 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4281 TextField textField = TextField::New();
4283 application.GetScene().Add(textField);
4285 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4286 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4287 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4289 // Avoid a crash when core load gl resources.
4290 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4292 application.SendNotification();
4293 application.Render();
4295 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4296 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4298 textField.SetKeyInputFocus();
4299 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4300 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4302 // Render and notify
4303 application.SendNotification();
4304 application.Render();
4306 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4307 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4309 textField.SetKeyInputFocus();
4310 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4311 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4313 // Render and notify
4314 application.SendNotification();
4315 application.Render();
4317 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4318 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4320 // Check the user interaction enabled and for coverage
4321 DevelTextField::SelectWholeText(textField);
4323 // Render and notify
4324 application.SendNotification();
4325 application.Render();
4327 textField.SetKeyInputFocus();
4328 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4329 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4331 // Render and notify
4332 application.SendNotification();
4333 application.Render();
4335 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4336 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4341 int UtcDaliToolkitTextFieldFontSizeScale(void)
4343 ToolkitTestApplication application;
4344 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4346 TextField textField = TextField::New();
4347 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4348 textField.SetProperty(TextField::Property::TEXT, "Test");
4349 Vector3 nonScaledSize = textField.GetNaturalSize();
4351 TextField textFieldScaled = TextField::New();
4352 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4353 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4354 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4355 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4357 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4359 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4360 textField.SetProperty(TextField::Property::TEXT, "Test");
4361 nonScaledSize = textField.GetNaturalSize();
4363 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4364 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4365 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4366 scaledSize = textFieldScaled.GetNaturalSize();
4368 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4373 int UtcDaliTextFieldPrimaryCursorPosition(void)
4375 ToolkitTestApplication application;
4376 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4378 TextField textField = TextField::New();
4380 application.GetScene().Add(textField);
4382 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4383 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4384 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4385 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4387 // Avoid a crash when core load gl resources.
4388 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4390 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4391 application.SendNotification();
4392 application.Render();
4393 textField.SetKeyInputFocus();
4395 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4397 // Render and notify
4398 application.SendNotification();
4399 application.Render();
4401 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4402 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4407 // test max length when set after setting long text
4408 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4410 ToolkitTestApplication application;
4411 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4412 TextField field = TextField::New();
4413 DALI_TEST_CHECK(field);
4415 application.GetScene().Add(field);
4417 field.SetProperty(TextField::Property::TEXT, "123456789");
4419 const int maxNumberOfCharacters = 3;
4420 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4422 field.SetKeyInputFocus();
4424 // connect to the text max lengh reached signal.
4425 ConnectionTracker* testTracker = new ConnectionTracker();
4426 bool maxLengthReachedSignal = false;
4427 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4429 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4430 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4432 DALI_TEST_CHECK(maxLengthReachedSignal);
4434 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4439 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4441 ToolkitTestApplication application;
4442 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4444 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4445 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4446 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4448 // Create a text field
4449 TextField textField = TextField::New();
4451 //Set size to avoid automatic eliding
4452 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4453 //Set very large font-size using point-size
4454 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4455 //Specify font-family
4456 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4457 //Set text to check if appear or not
4458 textField.SetProperty(TextField::Property::TEXT, "A");
4460 application.GetScene().Add(textField);
4462 application.SendNotification();
4463 application.Render();
4464 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4465 Vector3 naturalSize = textField.GetNaturalSize();
4467 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4468 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4473 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4475 ToolkitTestApplication application;
4476 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4478 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4479 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4480 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4482 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4483 // Create a text editor
4484 TextField textField = TextField::New();
4486 //Set size to avoid automatic eliding
4487 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4488 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4489 textField.SetProperty(TextField::Property::TEXT, "A");
4491 const int numberOfCases = 6;
4492 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4494 for(int index = 0; index < numberOfCases; index++)
4496 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4497 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4498 application.GetScene().Add(textField);
4499 application.SendNotification();
4500 application.Render();
4501 naturalSize = textField.GetNaturalSize();
4502 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4503 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4509 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4511 ToolkitTestApplication application;
4512 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4513 TextField textField = TextField::New();
4515 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4516 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4518 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4519 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4520 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4522 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4523 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4524 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4526 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4527 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4528 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4530 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4531 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4532 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4534 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4535 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4536 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4538 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4539 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4540 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4542 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4543 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4544 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4546 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4547 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4548 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4550 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4551 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4552 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4554 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4555 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4556 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4558 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4559 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4560 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4562 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4563 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4564 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4569 int UtcDaliTextFieldCopyText(void)
4571 ToolkitTestApplication application;
4572 tet_infoline(" UtcDaliTextFieldCopyText ");
4574 TextField textField = TextField::New();
4576 std::string selectedText = "";
4577 std::string copiedText = "";
4579 application.GetScene().Add(textField);
4581 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4582 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4583 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4585 // Avoid a crash when core load gl resources.
4586 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4588 application.SendNotification();
4589 application.Render();
4591 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4593 application.SendNotification();
4594 application.Render();
4596 // Hello is selected
4597 DevelTextField::SelectText(textField, 0, 5);
4599 application.SendNotification();
4600 application.Render();
4602 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4603 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4605 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4606 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4609 copiedText = DevelTextField::CopyText(textField);
4610 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4612 // world is selected
4613 DevelTextField::SelectText(textField, 6, 11);
4615 application.SendNotification();
4616 application.Render();
4618 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4619 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4621 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4622 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4625 copiedText = DevelTextField::CopyText(textField);
4626 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4628 // "lo wo" is selected
4629 DevelTextField::SelectText(textField, 3, 8);
4631 application.SendNotification();
4632 application.Render();
4634 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4635 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4637 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4638 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4640 // "lo wo" is copied
4641 copiedText = DevelTextField::CopyText(textField);
4642 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4647 int UtcDaliTextFieldCutText(void)
4649 ToolkitTestApplication application;
4650 tet_infoline(" UtcDaliTextFieldCutText ");
4652 TextField textField = TextField::New();
4654 std::string selectedText = "";
4656 application.GetScene().Add(textField);
4658 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4659 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4660 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4662 // Avoid a crash when core load gl resources.
4663 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4665 application.SendNotification();
4666 application.Render();
4668 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4670 application.SendNotification();
4671 application.Render();
4673 // Hello is selected
4674 DevelTextField::SelectText(textField, 0, 5);
4676 application.SendNotification();
4677 application.Render();
4679 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4680 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4682 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4683 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4686 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4688 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4691 DevelTextField::SelectText(textField, 0, 2);
4693 application.SendNotification();
4694 application.Render();
4696 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4697 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4699 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4700 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4703 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4705 application.SendNotification();
4706 application.Render();
4708 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4710 // Test Cut from the middle
4713 DevelTextField::SelectText(textField, 1, 3);
4715 application.SendNotification();
4716 application.Render();
4718 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4719 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4721 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4722 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4725 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4727 application.SendNotification();
4728 application.Render();
4730 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4732 // Test Cut from the end
4735 DevelTextField::SelectText(textField, 1, 2);
4737 application.SendNotification();
4738 application.Render();
4740 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4741 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4743 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4744 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4747 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4749 application.SendNotification();
4750 application.Render();
4752 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4757 int UtcDaliTextFieldPasteText(void)
4759 ToolkitTestApplication application;
4760 tet_infoline(" UtcDaliTextFieldPasteText ");
4762 TextField textField = TextField::New();
4764 application.GetScene().Add(textField);
4766 std::string cutText = "";
4767 std::string copiedText = "";
4769 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4770 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4771 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4773 // Avoid a crash when core load gl resources.
4774 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4776 application.SendNotification();
4777 application.Render();
4779 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4781 application.SendNotification();
4782 application.Render();
4784 // Tap on the text editor
4785 TestGenerateTap(application, 3.0f, 25.0f);
4787 // Render and notify
4788 application.SendNotification();
4789 application.Render();
4791 // Select some text in the right of the current cursor position
4792 DevelTextField::SelectText(textField, 0, 3);
4794 // Render and notify
4795 application.SendNotification();
4796 application.Render();
4798 // Cut the selected text
4799 cutText = DevelTextField::CutText(textField);
4801 // Render and notify
4802 application.SendNotification();
4803 application.Render();
4805 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4806 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4808 DevelTextField::SelectText(textField, 0, 3);
4810 // Render and notify
4811 application.SendNotification();
4812 application.Render();
4814 // Copy the selected text
4815 copiedText = DevelTextField::CopyText(textField);
4817 // Render and notify
4818 application.SendNotification();
4819 application.Render();
4821 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4822 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4824 // Move the cursor to the end of the line
4825 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4826 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4827 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4828 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4829 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4830 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4831 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4832 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4834 // Render and notify
4835 application.SendNotification();
4836 application.Render();
4838 // Paste the selected text at the current cursor position
4839 DevelTextField::PasteText(textField);
4841 // Render and notify
4842 application.SendNotification();
4843 application.Render();
4845 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4850 int utcDaliTextFieldCursorPositionChangedSignal(void)
4852 ToolkitTestApplication application;
4853 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4855 TextField field = TextField::New();
4856 DALI_TEST_CHECK(field);
4858 application.GetScene().Add(field);
4860 // connect to the selection changed signal.
4861 ConnectionTracker* testTracker = new ConnectionTracker();
4862 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4863 bool cursorPositionChangedSignal = false;
4864 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4866 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4867 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4868 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4869 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4870 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4872 // Avoid a crash when core load gl resources.
4873 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4875 // Render and notify
4876 application.SendNotification();
4877 application.Render();
4879 field.SetKeyInputFocus();
4881 // Tap on the text field
4882 TestGenerateTap(application, 3.0f, 25.0f);
4884 // Render and notify
4885 application.SendNotification();
4886 application.Render();
4888 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4889 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4891 gCursorPositionChangedCallbackCalled = false;
4894 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4896 // Render and notify
4897 application.SendNotification();
4898 application.Render();
4900 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4901 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4903 gCursorPositionChangedCallbackCalled = false;
4906 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4908 // Render and notify
4909 application.SendNotification();
4910 application.Render();
4912 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4913 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4915 gCursorPositionChangedCallbackCalled = false;
4917 //delete one character
4918 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4920 // Render and notify
4921 application.SendNotification();
4922 application.Render();
4924 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4925 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4927 gCursorPositionChangedCallbackCalled = false;
4929 field.SetProperty(TextField::Property::TEXT, "Hello");
4931 // Render and notify
4932 application.SendNotification();
4933 application.Render();
4935 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4936 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4938 gCursorPositionChangedCallbackCalled = false;
4940 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4942 // Render and notify
4943 application.SendNotification();
4944 application.Render();
4946 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4947 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4952 int utcDaliTextFieldGeometryEllipsisStart(void)
4954 ToolkitTestApplication application;
4955 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4957 TextField field = TextField::New();
4958 DALI_TEST_CHECK(field);
4960 application.GetScene().Add(field);
4962 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4963 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4964 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4965 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4966 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4967 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4968 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4969 field.SetProperty(TextField::Property::TEXT, "Hello World");
4971 // Avoid a crash when core load gl resources.
4972 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4974 // Render and notify
4975 application.SendNotification();
4976 application.Render();
4978 unsigned int expectedCount = 1;
4979 unsigned int startIndex = 0;
4980 unsigned int endIndex = 10;
4982 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4983 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4985 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4986 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4988 Vector<Vector2> expectedSizes;
4989 Vector<Vector2> expectedPositions;
4991 expectedPositions.PushBack(Vector2(14, 0));
4992 expectedSizes.PushBack(Vector2(107, 25));
4994 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4999 int utcDaliTextFieldGeometryEllipsisEnd(void)
5001 ToolkitTestApplication application;
5002 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
5004 TextField field = TextField::New();
5005 DALI_TEST_CHECK(field);
5007 application.GetScene().Add(field);
5009 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5010 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5011 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5012 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5013 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5014 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5015 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5016 field.SetProperty(TextField::Property::TEXT, "Hello World");
5018 // Avoid a crash when core load gl resources.
5019 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5021 // Render and notify
5022 application.SendNotification();
5023 application.Render();
5025 unsigned int expectedCount = 1;
5026 unsigned int startIndex = 0;
5027 unsigned int endIndex = 10;
5029 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5030 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5032 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5033 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5035 Vector<Vector2> expectedSizes;
5036 Vector<Vector2> expectedPositions;
5038 expectedPositions.PushBack(Vector2(-2, 0));
5039 expectedSizes.PushBack(Vector2(123, 25));
5041 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5046 int utcDaliTextFieldGeometryRTL(void)
5048 ToolkitTestApplication application;
5049 tet_infoline(" utcDaliTextFieldGeometryRTL");
5051 TextField field = TextField::New();
5052 DALI_TEST_CHECK(field);
5054 application.GetScene().Add(field);
5056 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5057 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5058 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5059 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5060 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5061 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5063 // Avoid a crash when core load gl resources.
5064 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5066 // Render and notify
5067 application.SendNotification();
5068 application.Render();
5070 unsigned int expectedCount = 1;
5071 unsigned int startIndex = 1;
5072 unsigned int endIndex = 7;
5074 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5075 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5077 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5078 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5080 Vector<Vector2> expectedSizes;
5081 Vector<Vector2> expectedPositions;
5083 expectedPositions.PushBack(Vector2(38, 0));
5084 expectedSizes.PushBack(Vector2(75, 25));
5086 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5091 int utcDaliTextFieldGeometryGlyphMiddle(void)
5093 ToolkitTestApplication application;
5094 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5096 TextField field = TextField::New();
5097 DALI_TEST_CHECK(field);
5099 application.GetScene().Add(field);
5101 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5102 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5103 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5104 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5105 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5106 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5108 // Avoid a crash when core load gl resources.
5109 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5111 // Render and notify
5112 application.SendNotification();
5113 application.Render();
5115 unsigned int expectedCount = 1;
5116 unsigned int startIndex = 1;
5117 unsigned int endIndex = 13;
5119 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5120 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5122 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5123 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5125 Vector<Vector2> expectedSizes;
5126 Vector<Vector2> expectedPositions;
5128 expectedPositions.PushBack(Vector2(6, 0));
5129 expectedSizes.PushBack(Vector2(125, 25));
5131 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5136 int utcDaliTextFieldGeometryNullPtr(void)
5138 ToolkitTestApplication application;
5139 tet_infoline("utcDaliTextFieldGeometryNullPtr");
5141 TextField field = TextField::New();
5142 DALI_TEST_CHECK(field);
5144 application.GetScene().Add(field);
5146 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5147 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5148 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5149 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5150 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5151 field.SetProperty(TextField::Property::TEXT, "");
5153 // Avoid a crash when core load gl resources.
5154 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5156 unsigned int expectedCount = 0;
5157 unsigned int startIndex = 0;
5158 unsigned int endIndex = 0;
5160 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5161 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5163 // Render and notify
5164 application.SendNotification();
5165 application.Render();
5167 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5168 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5173 int utcDaliTextFieldSelectionClearedSignal(void)
5175 ToolkitTestApplication application;
5176 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5178 TextField field = TextField::New();
5179 DALI_TEST_CHECK(field);
5181 application.GetScene().Add(field);
5183 // connect to the selection changed signal.
5184 ConnectionTracker* testTracker = new ConnectionTracker();
5185 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5186 bool selectionClearedSignal = false;
5187 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5189 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5190 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5191 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5192 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5193 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5195 // Avoid a crash when core load gl resources.
5196 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5198 // Render and notify
5199 application.SendNotification();
5200 application.Render();
5202 // Tap on the text editor
5203 TestGenerateTap(application, 3.0f, 25.0f);
5205 // Render and notify
5206 application.SendNotification();
5207 application.Render();
5209 // Move to second line of the text & Select some text in the right of the current cursor position
5210 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5211 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5214 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5216 // Render and notify
5217 application.SendNotification();
5218 application.Render();
5220 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5222 // Render and notify
5223 application.SendNotification();
5224 application.Render();
5226 // Tap on the text editor
5227 TestGenerateTap(application, 3.0f, 25.0f);
5229 // Render and notify
5230 application.SendNotification();
5231 application.Render();
5233 gSelectionClearedCallbackCalled = false;
5235 // Move to second line of the text & select.
5236 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5237 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5240 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5242 // Render and notify
5243 application.SendNotification();
5244 application.Render();
5246 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5248 gSelectionClearedCallbackCalled = false;
5250 // Render and notify
5251 application.SendNotification();
5252 application.Render();
5254 // Move to second line of the text & select.
5255 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5256 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5258 // replace D with selected text
5259 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5261 // Render and notify
5262 application.SendNotification();
5263 application.Render();
5265 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5267 gSelectionClearedCallbackCalled = false;
5269 // Render and notify
5270 application.SendNotification();
5271 application.Render();
5273 DevelTextField::SelectText(field, 1, 3);
5275 // Render and notify
5276 application.SendNotification();
5277 application.Render();
5279 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5281 // Render and notify
5282 application.SendNotification();
5283 application.Render();
5285 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5287 gSelectionClearedCallbackCalled = false;
5289 DevelTextField::SelectText(field, 1, 3);
5291 // Render and notify
5292 application.SendNotification();
5293 application.Render();
5296 DevelTextField::SelectNone(field);
5298 // Render and notify
5299 application.SendNotification();
5300 application.Render();
5302 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5307 int utcDaliTextFieldSelectionStartedSignal(void)
5309 ToolkitTestApplication application;
5310 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5312 TextField field = TextField::New();
5313 DALI_TEST_CHECK(field);
5315 application.GetScene().Add(field);
5317 // connect to the selection changed signal.
5318 ConnectionTracker* testTracker = new ConnectionTracker();
5319 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5320 bool selectionStartedSignal = false;
5321 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5323 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5324 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5325 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5326 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5327 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5329 // Avoid a crash when core load gl resources.
5330 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5332 // Render and notify
5333 application.SendNotification();
5334 application.Render();
5336 // Tap on the text field
5337 TestGenerateTap(application, 3.0f, 25.0f);
5339 // Render and notify
5340 application.SendNotification();
5341 application.Render();
5343 // Move to second line of the text & Select some text in the right of the current cursor position
5344 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5345 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5347 // Render and notify
5348 application.SendNotification();
5349 application.Render();
5351 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5354 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5356 // Render and notify
5357 application.SendNotification();
5358 application.Render();
5360 gSelectionStartedCallbackCalled = false;
5362 DevelTextField::SelectText(field, 1, 3);
5364 // Render and notify
5365 application.SendNotification();
5366 application.Render();
5368 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5373 int utcDaliTextFieldSelectionChangedSignal(void)
5375 ToolkitTestApplication application;
5376 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5378 TextField field = TextField::New();
5379 DALI_TEST_CHECK(field);
5381 application.GetScene().Add(field);
5383 // connect to the selection changed signal.
5384 ConnectionTracker* testTracker = new ConnectionTracker();
5385 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5386 bool selectionChangedSignal = false;
5387 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5389 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5390 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5391 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5392 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5393 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5395 // Avoid a crash when core load gl resources.
5396 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5398 // Render and notify
5399 application.SendNotification();
5400 application.Render();
5402 // Tap on the text field
5403 TestGenerateTap(application, 3.0f, 25.0f);
5405 // Render and notify
5406 application.SendNotification();
5407 application.Render();
5409 // Select some text in the right of the current cursor position
5410 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5411 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5413 // Render and notify
5414 application.SendNotification();
5415 application.Render();
5417 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5418 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5420 gSelectionChangedCallbackCalled = false;
5422 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5424 // Render and notify
5425 application.SendNotification();
5426 application.Render();
5428 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5429 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5430 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5432 gSelectionChangedCallbackCalled = false;
5434 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5436 // Render and notify
5437 application.SendNotification();
5438 application.Render();
5440 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5441 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5442 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5444 gSelectionChangedCallbackCalled = false;
5445 field.SetKeyInputFocus();
5447 // Render and notify
5448 application.SendNotification();
5449 application.Render();
5451 DevelTextField::SelectText(field, 0, 5);
5453 application.SendNotification();
5454 application.Render();
5456 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5457 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5459 gSelectionChangedCallbackCalled = false;
5461 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5463 // Render and notify
5464 application.SendNotification();
5465 application.Render();
5467 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5468 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5469 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5471 gSelectionChangedCallbackCalled = false;
5474 DevelTextField::SelectWholeText(field);
5476 // Render and notify
5477 application.SendNotification();
5478 application.Render();
5480 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5481 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5483 gSelectionChangedCallbackCalled = false;
5486 DevelTextField::SelectNone(field);
5488 // Render and notify
5489 application.SendNotification();
5490 application.Render();
5492 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5493 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5494 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5499 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5501 ToolkitTestApplication application;
5502 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5504 TextField textField = TextField::New();
5505 textField.SetProperty(TextField::Property::TEXT, "Test");
5506 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5507 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5508 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5510 application.GetScene().Add(textField);
5511 application.SendNotification();
5512 application.Render();
5514 Property::Map strikethroughMapSet;
5515 Property::Map strikethroughMapGet;
5517 strikethroughMapSet.Insert("enable", true);
5518 strikethroughMapSet.Insert("color", Color::RED);
5519 strikethroughMapSet.Insert("height", 2.0f);
5521 // Check the strikethrough property
5522 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5523 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5524 textField.SetProperty(TextField::Property::TEXT, "Test1");
5525 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5526 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5528 // Render and notify
5529 application.SendNotification();
5530 application.Render();
5532 strikethroughMapSet.Clear();
5533 strikethroughMapGet.Clear();
5538 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5540 ToolkitTestApplication application;
5541 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5543 TextField textField = TextField::New();
5544 textField.SetProperty(TextField::Property::TEXT, "Test");
5545 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5546 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5547 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5549 application.GetScene().Add(textField);
5550 application.SendNotification();
5551 application.Render();
5553 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5555 // Check the strikethrough property
5556 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5557 textField.SetProperty(TextField::Property::TEXT, "Test1");
5558 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5560 // Render and notify
5561 application.SendNotification();
5562 application.Render();
5567 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5569 ToolkitTestApplication application;
5570 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5571 TextField field = TextField::New();
5572 field.SetProperty(TextField::Property::TEXT, "Test");
5573 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5574 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5575 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5577 application.GetScene().Add(field);
5578 application.SendNotification();
5579 application.Render();
5581 Property::Map underlineMapSet;
5582 Property::Map underlineMapGet;
5584 underlineMapSet.Insert("enable", true);
5585 underlineMapSet.Insert("color", Color::RED);
5586 underlineMapSet.Insert("height", 1);
5587 underlineMapSet.Insert("type", Text::Underline::SOLID);
5588 underlineMapSet.Insert("dashWidth", 2);
5589 underlineMapSet.Insert("dashGap", 1);
5591 // Check the underline property
5592 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5594 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5595 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5596 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5598 // Render and notify
5599 application.SendNotification();
5600 application.Render();
5602 underlineMapSet.Clear();
5603 underlineMapGet.Clear();
5605 underlineMapSet.Insert("enable", true);
5606 underlineMapSet.Insert("color", Color::BLUE);
5607 underlineMapSet.Insert("height", 1);
5608 underlineMapSet.Insert("type", Text::Underline::DASHED);
5609 underlineMapSet.Insert("dashWidth", 4);
5610 underlineMapSet.Insert("dashGap", 2);
5612 // Check the dashed underline property
5613 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5615 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5616 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5617 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5619 // Render and notify
5620 application.SendNotification();
5621 application.Render();
5623 underlineMapSet.Clear();
5624 underlineMapGet.Clear();
5626 underlineMapSet.Insert("enable", true);
5627 underlineMapSet.Insert("color", Color::BLUE);
5628 underlineMapSet.Insert("height", 1);
5629 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5630 underlineMapSet.Insert("dashWidth", 4);
5631 underlineMapSet.Insert("dashGap", 2);
5633 // Check the dashed underline property
5634 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5636 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5637 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5638 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5640 // Render and notify
5641 application.SendNotification();
5642 application.Render();
5644 underlineMapSet.Clear();
5645 underlineMapGet.Clear();
5650 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5652 ToolkitTestApplication application;
5653 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5655 TextField field1 = TextField::New();
5656 field1.SetProperty(TextField::Property::TEXT, "Test");
5657 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5658 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5659 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5661 Property::Map underlineMapSet1;
5662 Property::Map underlineMapGet1;
5664 underlineMapSet1.Insert("enable", true);
5665 underlineMapSet1.Insert("color", Color::RED);
5666 underlineMapSet1.Insert("height", 1);
5667 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5668 underlineMapSet1.Insert("dashWidth", 2);
5669 underlineMapSet1.Insert("dashGap", 1);
5671 // Check the underline property
5672 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5674 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5675 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5676 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5678 application.GetScene().Add(field1);
5679 application.SendNotification();
5680 application.Render();
5682 TextField field2 = TextField::New();
5683 field2.SetProperty(TextField::Property::TEXT, "Test");
5684 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5685 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5686 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5688 Property::Map underlineMapSet2;
5689 Property::Map underlineMapGet2;
5691 underlineMapSet2.Insert("enable", true);
5692 underlineMapSet2.Insert("color", Color::BLUE);
5693 underlineMapSet2.Insert("height", 1);
5694 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5695 underlineMapSet2.Insert("dashWidth", 4);
5696 underlineMapSet2.Insert("dashGap", 2);
5698 // Check the dashed underline property
5699 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5701 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5702 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5703 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5705 application.GetScene().Add(field2);
5706 application.SendNotification();
5707 application.Render();
5709 TextField field3 = TextField::New();
5710 field3.SetProperty(TextField::Property::TEXT, "Test");
5711 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5712 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5713 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5715 Property::Map underlineMapSet3;
5716 Property::Map underlineMapGet3;
5718 underlineMapSet3.Insert("enable", true);
5719 underlineMapSet3.Insert("color", Color::BLUE);
5720 underlineMapSet3.Insert("height", 1);
5721 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5722 underlineMapSet3.Insert("dashWidth", 4);
5723 underlineMapSet3.Insert("dashGap", 2);
5725 // Check the dashed underline property
5726 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5728 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5729 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5730 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5732 application.GetScene().Add(field3);
5734 application.SendNotification();
5735 application.Render();
5740 int UtcDaliTextFieldCharacterSpacing(void)
5742 ToolkitTestApplication application;
5743 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5745 TextField textField = TextField::New();
5747 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5749 application.GetScene().Add(textField);
5750 application.SendNotification();
5751 application.Render();
5753 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5754 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5755 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5757 application.SendNotification();
5758 application.Render();
5763 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5765 ToolkitTestApplication application;
5766 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5768 TextField field1 = TextField::New();
5769 field1.SetProperty(TextField::Property::TEXT, "Test1");
5770 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5771 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5772 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5774 Property::Map underlineMapSet1;
5775 Property::Map underlineMapGet1;
5777 underlineMapSet1.Insert("enable", true);
5778 underlineMapSet1.Insert("color", Color::RED);
5779 underlineMapSet1.Insert("height", 1);
5780 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5781 underlineMapSet1.Insert("dashWidth", 2);
5782 underlineMapSet1.Insert("dashGap", 1);
5784 // Check the underline property
5785 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5786 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5788 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5789 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5790 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5792 application.GetScene().Add(field1);
5793 application.SendNotification();
5794 application.Render();
5799 int UtcDaliToolkitTextfieldParagraphTag(void)
5801 ToolkitTestApplication application;
5802 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5803 TextField fieldNewlineSeparator = TextField::New();
5804 TextField fieldParagraphTag = TextField::New();
5805 DALI_TEST_CHECK(fieldNewlineSeparator);
5806 DALI_TEST_CHECK(fieldParagraphTag);
5808 application.GetScene().Add(fieldNewlineSeparator);
5809 application.GetScene().Add(fieldParagraphTag);
5811 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5812 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5813 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5814 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5815 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5816 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5818 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5819 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5820 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5821 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5822 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5824 application.SendNotification();
5825 application.Render();
5827 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5828 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5830 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5832 application.SendNotification();
5833 application.Render();
5838 //Handle Emoji clustering for cursor handling
5839 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5841 ToolkitTestApplication application;
5842 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5843 TextField textField = TextField::New();
5844 DALI_TEST_CHECK(textField);
5846 application.GetScene().Add(textField);
5848 // Avoid a crash when core load gl resources.
5849 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5851 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5852 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5854 // Render and notify
5855 application.SendNotification();
5856 application.Render();
5859 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5860 application.SendNotification();
5861 application.Render();
5863 // Set focus and remove Emoji
5864 textField.SetKeyInputFocus();
5865 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5867 //Check the changed text and cursor position
5868 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5869 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5871 // Render and notify
5872 application.SendNotification();
5873 application.Render();
5878 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5880 ToolkitTestApplication application;
5881 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5882 TextField textField = TextField::New();
5883 DALI_TEST_CHECK(textField);
5885 application.GetScene().Add(textField);
5887 // Avoid a crash when core load gl resources.
5888 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5890 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5891 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5893 // Render and notify
5894 application.SendNotification();
5895 application.Render();
5898 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5899 application.SendNotification();
5900 application.Render();
5902 // Set focus and remove Emoji
5903 textField.SetKeyInputFocus();
5904 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5906 //Check the changed text and cursor position
5907 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5908 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5910 // Render and notify
5911 application.SendNotification();
5912 application.Render();
5917 int utcDaliTextFieldPanGesturePropagation(void)
5919 ToolkitTestApplication application;
5920 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5922 Actor actor = Actor::New();
5923 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5924 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5925 application.GetScene().Add(actor);
5927 TextField field = TextField::New();
5928 DALI_TEST_CHECK(field);
5930 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5931 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5933 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5934 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5935 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5939 // Render and notify
5940 application.SendNotification();
5941 application.Render();
5944 GestureReceivedFunctor functor(data);
5946 PanGestureDetector detector = PanGestureDetector::New();
5947 detector.Attach(actor);
5948 detector.DetectedSignal().Connect(&application, functor);
5950 // Tap first to get the focus.
5951 TestGenerateTap(application, 3.0f, 25.0f, 100);
5953 // Render and notify
5954 application.SendNotification();
5955 application.Render();
5957 // Pan the text field
5958 uint32_t time = 100;
5959 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5960 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5961 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5962 application.SendNotification();
5963 application.Render();
5965 // The text scrolls because there is text that is scrolling.
5966 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5969 // Set the size large enough to prevent scrolling.
5970 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5972 // Render and notify
5973 application.SendNotification();
5974 application.Render();
5977 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5978 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5979 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5981 // Because scrolling is not possible, the pan gesture is propagated.
5982 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
5988 int utcDaliTextFieldGetTextBoundingRectangle(void)
5990 ToolkitTestApplication application;
5991 tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
5993 TextField field = TextField::New();
5994 DALI_TEST_CHECK(field);
5996 application.GetScene().Add(field);
5998 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5999 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6000 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6001 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6002 field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6004 // Avoid a crash when core load gl resources.
6005 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6007 // Render and notify
6008 application.SendNotification();
6009 application.Render();
6011 unsigned int startIndex = 0;
6012 unsigned int endIndex = 15;
6014 Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6015 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6017 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6022 int utcDaliTextFieldDecoratorColor(void)
6024 ToolkitTestApplication application;
6025 tet_infoline(" utcDaliTextFieldDecoratorColor");
6026 TextField textField = TextField::New();
6027 DALI_TEST_CHECK(textField);
6028 LoadMarkerImages(application, textField);
6029 application.GetScene().Add(textField);
6031 // Render and notify
6032 application.SendNotification();
6033 application.Render();
6035 textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6036 textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6037 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6038 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6039 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6041 // Avoid a crash when core load gl resources.
6042 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6044 application.SendNotification();
6045 application.Render();
6047 textField.SetKeyInputFocus();
6049 application.SendNotification();
6050 application.Render();
6052 // Create a tap event to touch the text field.
6053 TestGenerateTap(application, 1.0f, 25.0f, 100);
6055 // Render and notify
6056 application.SendNotification();
6057 application.Render();
6059 // Double tap to select a word.
6060 TestGenerateTap(application, 1.0f, 25.0f, 200);
6062 application.SendNotification();
6063 application.Render();
6065 // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6066 // Check some properties for coverage.
6067 textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6068 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6070 textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6071 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6073 textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6074 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6076 textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6077 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6079 textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6080 DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6082 application.SendNotification();
6083 application.Render();